/* Screen-only dialog chrome. Keep form grids, saved colors and document contents intact. */
body dialog:is([class],[id]) {
  --popup-space:24px;
  border:1px solid var(--modern-line);
  border-radius:18px;
  box-shadow:0 28px 90px #0f172a38,0 4px 16px #0f172a18;
}
body dialog:is([class],[id])::backdrop {background:rgba(15,23,42,.44);backdrop-filter:blur(5px);}
body dialog:is([class],[id]) > header,
body dialog:is([class],[id]) > form > header,
body dialog:is([class],[id]) > .file-preview-window > header,
#modalForm > header {
  padding:20px var(--popup-space);
  align-items:center;
  gap:16px;
  background:var(--modern-soft);
  border:0;
  border-bottom:1px solid var(--modern-line);
  border-radius:17px 17px 0 0;
  box-shadow:inset 0 3px 0 color-mix(in srgb,var(--brand) 65%,transparent);
}
body dialog:is([class],[id]) > header h2,
body dialog:is([class],[id]) > form > header h2,
body dialog:is([class],[id]) > .file-preview-window > header h2,
#modalTitle {margin:0;line-height:1.3;font-size:1.22rem;font-weight:650;letter-spacing:-.025em;overflow-wrap:anywhere;}
body dialog:is([class],[id]) > footer,
body dialog:is([class],[id]) > form > footer,
#modalForm > footer {
  padding:16px var(--popup-space);
  gap:10px;
  background:var(--modern-soft);
  border:0;
  border-top:1px solid var(--modern-line);
  border-radius:0 0 17px 17px;
}
/* Only action controls grow: embedded editors and customer date fields keep their dimensions. */
body dialog:is([class],[id]) > header button,
body dialog:is([class],[id]) > form > header button,
body dialog:is([class],[id]) > footer button,
body dialog:is([class],[id]) > form > footer button,
#modalForm > :is(header,footer) button,
#filePreviewDialog .file-preview-actions button,
#outputDialog .output-options button {
  min-height:38px!important;padding:8px 14px!important;line-height:1.35;
  border-radius:8px;
}
body dialog:is([class],[id]) .app-close-x,
#modalForm > header .app-close-x {
  flex:0 0 36px;width:36px;height:36px;min-height:36px!important;
  padding:0!important;display:inline-grid;place-items:center;line-height:1;
  border-radius:9px;font-size:1.4rem;
}
/* Existing list actions become spacious, easy-to-scan action rows. */
body dialog:is([class],[id]).list-action-dialog {width:min(540px,calc(100vw - 24px));}
body dialog:is([class],[id]).list-action-dialog .list-action-description {
  padding:18px var(--popup-space) 0;font-size:.94rem;line-height:1.6;
}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons {padding:20px var(--popup-space) 24px;gap:10px;}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons button {
  display:flex;align-items:center;gap:14px;min-height:48px!important;
  padding:12px 16px!important;border-radius:10px;text-align:left;
  line-height:1.4;font-weight:600;white-space:normal;overflow-wrap:anywhere;
  box-shadow:0 2px 5px #0f172a09;
}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons button::after {
  content:'';width:7px;height:7px;border-top:2px solid currentColor;
  border-right:2px solid currentColor;transform:rotate(45deg);
  margin-left:auto;flex:0 0 7px;opacity:.6;
}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons button:disabled::after {opacity:.25;}
/* Dialogs with existing outer padding retain it around the editor body. */
body dialog:is([class],[id]):is(.bonus-editor,.circular-dialog) > header {margin:-20px -20px 20px;}
body dialog:is([class],[id]):is(.bonus-editor,.circular-dialog) > footer {margin:20px -20px -20px;}
#appQuestion form {color:var(--input-text);border-radius:17px;}
#appQuestion .app-question-icon {border-radius:12px;width:44px;height:44px;flex-basis:44px;}
#appQuestion > form > p {padding:24px;line-height:1.65;}
#outputDialog .output-options {gap:12px;padding-inline:24px;}
body dialog:is([class],[id]) .list-action-buttons button:focus-visible {outline-offset:-4px;}
@media(max-width:600px) {
  body dialog:is([class],[id]) {--popup-space:16px;border-radius:12px;}
  body dialog:is([class],[id]) > header,body dialog:is([class],[id]) > form > header,#modalForm > header,
  body dialog:is([class],[id]) > .file-preview-window > header {padding-block:16px;border-radius:11px 11px 0 0;}
  body dialog:is([class],[id]) > footer,body dialog:is([class],[id]) > form > footer,#modalForm > footer {flex-wrap:wrap;border-radius:0 0 11px 11px;}
  body dialog:is([class],[id]).list-action-dialog .list-action-buttons {padding-block:16px;}
}
@media(prefers-reduced-motion:reduce) {body dialog:is([class],[id])::backdrop {backdrop-filter:none;}}

/* Keep action buttons side by side, including on narrow screens. */
body dialog:is([class],[id]) > footer,
body dialog:is([class],[id]) > form > footer,
body dialog:is([class],[id]) .list-action-buttons,
body dialog:is([class],[id]) .row-actions,
#modalForm > footer,
#filePreviewDialog .file-preview-actions,
#outputDialog .output-options {
  display:flex;flex-direction:row;flex-wrap:nowrap;gap:10px;
  max-width:100%;min-width:0;overflow-x:auto;
  justify-content:flex-start;scroll-padding-inline:16px;
}
body dialog:is([class],[id]) > footer > button,
body dialog:is([class],[id]) > form > footer > button,
body dialog:is([class],[id]) .list-action-buttons > button,
body dialog:is([class],[id]) .row-actions > button,
#modalForm > footer > button,
#filePreviewDialog .file-preview-actions > button,
#outputDialog .output-options > button {
  flex:0 0 auto;width:auto;white-space:nowrap;
}
body dialog:is([class],[id]).list-action-dialog {width:min(850px,calc(100vw - 24px));}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons {display:flex;}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons button {
  width:auto;flex:0 0 auto;white-space:nowrap;text-align:center;min-height:40px!important;
}
body dialog:is([class],[id]).list-action-dialog .list-action-buttons button::after {display:none;}

/* Compact popup controls, including dialogs nested in the workspace. */
body :is(dialog,#modal,#outputDialog,#appQuestion,#filePreviewDialog) button {
  min-height:28px!important;padding-block:3px!important;line-height:1.2;
}
body :is(dialog,#modal,#outputDialog,#appQuestion,#filePreviewDialog) .app-close-x {
  flex-basis:28px;width:28px;height:28px;min-height:28px!important;padding:0!important;font-size:1.2rem;
}

/* List picker uses the browser's top layer instead of the scrolling footer. */
#modalForm .customer-list-options[popover] {
  position:fixed;inset:auto;margin:0;box-sizing:border-box;min-width:0;
  max-width:calc(100vw - 24px);color:var(--input-text);
}
#modalForm .customer-list-options[popover]:not(:popover-open) {display:none;}
#modalForm .customer-list-options[popover]:popover-open {display:grid;}
@supports not selector(:popover-open) {
  #modalForm > footer:has(.customer-list-menu[open]) {overflow:visible;z-index:30;}
}

/* Width is measured from each dialog's visible action rows. */
body dialog[data-fit-actions] {
  box-sizing:border-box;
  width:var(--popup-fit-width)!important;
  max-width:calc(100vw - 24px)!important;
}

/* Customer master data: same compact action controls as the other popups.
   The form marker prevents these rules from reaching document editors. */

#modal:has(#modalBody input[name="customerNumber"]) .customer-list-menu summary {
  box-sizing:border-box;min-height:28px;padding:3px 11px;line-height:1.2;
  font-family:var(--app-button-font-family,"Segoe UI",Arial,sans-serif);
  font-size:var(--app-button-font-size,15px);
  font-weight:var(--app-button-font-weight,700);
}

/* Aligned labels and controls for waiting-list and assigned-student records. */
body dialog.waitlist-record-dialog .waitlist-edit-fields > label:not(.inline-check) {
  display:grid;grid-template-columns:minmax(120px,34%) minmax(0,1fr);
  align-items:center;gap:10px 16px;min-width:0;
}
body dialog.waitlist-record-dialog .waitlist-field-caption {grid-column:1;grid-row:1;overflow-wrap:anywhere;}
body dialog.waitlist-record-dialog .waitlist-edit-fields > label:not(.inline-check) > :is(input,select,textarea,.segmented-date) {
  grid-column:2;grid-row:1;width:100%;min-width:0;max-width:100%;box-sizing:border-box;
}
body dialog.waitlist-record-dialog .waitlist-edit-fields > label.inline-check {
  display:flex;align-items:center;gap:8px;font-weight:inherit;
}
body dialog.waitlist-record-dialog .waitlist-edit-fields > label.inline-check > input[type="checkbox"] {
  width:16px;min-width:16px;flex:0 0 16px;margin:0;
}
body dialog.waitlist-record-dialog .waitlist-assignment-divider {width:100%;box-sizing:border-box;}
@media(max-width:420px) {
  body dialog.waitlist-record-dialog .waitlist-edit-fields {padding:12px;}
  body dialog.waitlist-record-dialog .waitlist-edit-fields > label:not(.inline-check) {grid-template-columns:minmax(90px,36%) minmax(0,1fr);column-gap:10px;}
}

/* One shared control size for customer records and every popup.
   Explicit height also overrides older fixed-height button rules. */
:root body :is(dialog,#modal,#outputDialog,#appQuestion,#filePreviewDialog) button:not(.app-close-x) {
  box-sizing:border-box;
  height:max(28px,calc(var(--app-button-font-size,15px) + 10px))!important;
  min-height:max(28px,calc(var(--app-button-font-size,15px) + 10px))!important;
  max-height:none!important;
  padding:3px 14px!important;
  font-family:var(--app-button-font-family,"Segoe UI",Arial,sans-serif)!important;
  font-size:var(--app-button-font-size,15px)!important;
  font-weight:var(--app-button-font-weight,700)!important;
  font-style:normal;line-height:1.2;border-radius:8px;
}

/* Vehicle data uses the same aligned label/control layout as customer data. */
#vehicleDataSheetForm .vehicle-sheet-fields {display:grid;grid-template-columns:minmax(0,1fr);gap:12px;}
#vehicleDataSheetForm .vehicle-sheet-fields > label {
  display:grid;grid-template-columns:minmax(130px,26%) minmax(0,1fr);
  align-items:center;gap:8px 16px;min-width:0;margin:0;
}
#vehicleDataSheetForm .vehicle-sheet-caption {grid-column:1;grid-row:1;overflow-wrap:anywhere;}
#vehicleDataSheetForm .vehicle-sheet-fields > label > :is(input,.segmented-date) {
  grid-column:2;grid-row:1;width:100%;min-width:0;max-width:100%;box-sizing:border-box;
}
@media(max-width:480px) {
  #vehicleDataSheetForm .vehicle-sheet-fields > label {grid-template-columns:minmax(95px,34%) minmax(0,1fr);column-gap:10px;}
}

/* Report editing: one aligned field per row, including date and checkbox. */
body dialog.reported-hours-dialog .annual-allocation-fields {
  display:grid;grid-template-columns:minmax(0,1fr);gap:12px;
}
body dialog.reported-hours-dialog .annual-allocation-fields > label {
  display:grid;grid-template-columns:minmax(130px,35%) minmax(0,1fr);
  align-items:center;gap:8px 16px;min-width:0;margin:0;
}
body dialog.reported-hours-dialog .report-field-caption {grid-column:1;grid-row:1;overflow-wrap:anywhere;}
body dialog.reported-hours-dialog .annual-allocation-fields > label > :is(input,select,.segmented-date) {
  grid-column:2;grid-row:1;width:100%;min-width:0;max-width:100%;box-sizing:border-box;
}
body dialog.reported-hours-dialog .annual-allocation-fields > label > input[type="checkbox"] {
  width:16px;min-width:16px;justify-self:start;margin:0;
}
@media(max-width:420px) {
  body dialog.reported-hours-dialog .annual-allocation-fields > label {grid-template-columns:minmax(100px,36%) minmax(0,1fr);column-gap:10px;}
}

/* Jahresplaner: einheitliche Feldzeilen einschließlich Datum und Checkboxen. */
body #modal .annual-exam-details-grid {display:grid;grid-template-columns:minmax(0,1fr);gap:12px;}
body #modal .annual-exam-details-grid > label {
  display:grid;grid-template-columns:minmax(160px,26%) minmax(0,1fr);
  align-items:center;gap:8px 16px;min-width:0;margin:0;grid-column:1 / -1;
}
body #modal .annual-exam-details-grid .annual-data-caption {grid-column:1;grid-row:1;overflow-wrap:anywhere;}
body #modal .annual-exam-details-grid > label > :is(input,select,textarea,.segmented-date) {
  grid-column:2;grid-row:1;width:100%;min-width:0;max-width:100%;box-sizing:border-box;margin:0;
}
body #modal .annual-exam-details-grid > label > input[type="checkbox"] {width:16px;min-width:16px;justify-self:start;}
@media(max-width:480px) {
  body #modal .annual-exam-details-grid > label {grid-template-columns:minmax(110px,36%) minmax(0,1fr);column-gap:10px;}
}

/* Delete isolated on the left, all remaining actions reversed from the right. */
body dialog [data-popup-action-order]:not([hidden]) {
  display:flex!important;flex-direction:row-reverse!important;flex-wrap:nowrap!important;
  justify-content:flex-start!important;align-items:center;gap:12px!important;
}
body dialog [data-popup-action-order] > * {
  order:0!important;margin-left:0!important;margin-right:0!important;flex-grow:0!important;
}
body dialog [data-popup-action-order] > [data-popup-delete] {
  order:1!important;margin-right:auto!important;margin-left:24px!important;
}

/* Close controls must never become miniature scroll containers. */
:root body button.app-close-x,
:root body button.app-close-x:hover,
:root body button.app-close-x:focus,
:root body button.app-close-x:active {
  display:inline-flex!important;align-items:center!important;justify-content:center!important;
  box-sizing:border-box!important;flex:0 0 28px!important;
  width:28px!important;min-width:28px!important;max-width:28px!important;
  height:28px!important;min-height:28px!important;max-height:28px!important;
  padding:0!important;line-height:1!important;white-space:nowrap!important;
  overflow:hidden!important;scrollbar-width:none!important;scrollbar-gutter:auto!important;
}
:root body button.app-close-x::-webkit-scrollbar {display:none!important;width:0!important;height:0!important;}

/* Respect dashboard visibility even with the shared close-button layout. */
:root body button.app-close-x[hidden],
:root body button.app-close-x[hidden]:is(:hover,:focus,:active),
:root body #minimizeMenuPage[hidden] {
  display:none!important;
}

/* Discount controls form three full-width columns, not nested label/control grids. */
body #modal .contract-discount-row {
 display:grid!important;grid-template-columns:minmax(100px,.6fr) minmax(160px,1fr) minmax(180px,1.3fr)!important;
 gap:12px;align-items:end;
}
body #modal .contract-discount-row > label {
 display:flex!important;flex-direction:column!important;align-items:stretch!important;
 justify-content:flex-end;gap:6px;min-width:0;width:auto;margin:0;
}
body #modal .contract-discount-row > label > :is(input,select) {
 box-sizing:border-box;width:100%!important;min-width:0!important;max-width:100%!important;margin:0;
}
@media(max-width:600px) {
 body #modal .contract-discount-row {grid-template-columns:minmax(0,1fr)!important;}
}
/* Popup action buttons are stacked, with the saved DOM order. */
body dialog [data-popup-action-order]:not([hidden]) {
 flex-direction:column!important;align-items:stretch!important;gap:8px!important;
}
body dialog [data-popup-action-order] > button,
body dialog [data-popup-action-order] > [data-popup-delete] {
 order:0!important;margin:0!important;width:100%!important;max-width:100%!important;flex:0 0 auto!important;
}
body dialog [data-popup-action-order] > :is(.info-footer-spacer) { display:none; }
body dialog button.popup-sortable { user-select:none;touch-action:none;cursor:grab; }
body dialog button.popup-button-dragging { cursor:grabbing;outline:3px solid var(--brand);outline-offset:2px;opacity:.7; }
body button.shared-button-sortable { user-select:none;touch-action:none;cursor:grab; }
body button.shared-button-sortable.popup-button-dragging { cursor:grabbing;outline:3px solid var(--brand);outline-offset:2px;opacity:.7; }
body [data-shared-button-order] > button { order:0!important; }
:root body dialog button[data-popup-top-close] { display:none!important; }
body dialog .popup-close-actions { padding:14px 20px; }
body dialog button[data-popup-bottom-close] { min-width:100px; }
.print-settings-dialog { width:min(420px,calc(100vw - 24px));padding:0; }
.print-settings-dialog header,.print-settings-dialog footer,.print-settings-fields { padding:16px 20px; }
.print-settings-dialog h2 { margin:0; }
.print-settings-fields { display:grid;gap:16px;caret-color:transparent;user-select:none; }
.print-settings-fields label { display:flex;gap:10px;align-items:center;cursor:pointer; }
.print-settings-fields fieldset { display:grid;gap:12px;border:1px solid var(--line);border-radius:8px;padding:14px; }
.print-settings-fields input { flex:0 0 auto; }
/* Movable controls retain the standard arrow cursor, including while dragging. */
:root body button.shared-button-sortable,
:root body button.shared-button-sortable:hover,
:root body button.shared-button-sortable:active,
:root body button.popup-sortable,
:root body button.popup-button-dragging,
:root body .tile-sortable,
:root body .tile-sortable:hover,
:root body .tile-sortable:active,
:root body .tile-sortable.tile-dragging { cursor:default!important; }

:root body dialog button[data-popup-duplicate-close] { display:none!important; }
