/* Neutral application chrome. Calendar meaning and colors are in calendar.css. */
#summaryContent { display: grid; gap: 14px; }
#summaryContent .summary-section { border: 1px solid var(--border); border-radius: 8px; padding: 16px; min-width: 0; }
#summaryContent h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
#summaryContent h5 { margin: 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
#summaryContent .summary-order-name { margin-bottom: 14px; }
#summaryContent h6 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
#summaryContent p { margin: 0; }
.summary-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px 24px; margin: 0; }
.summary-field { min-width: 0; }
.summary-field dt { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.summary-field dd { margin: 0; overflow-wrap: anywhere; }
.summary-item { padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); }
.summary-item + .summary-item { margin-top: 12px; }
.summary-item-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.summary-quantity { flex-shrink: 0; font-weight: 600; font-size: 13px; }
.summary-subsection { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.summary-decoration { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 4px 0; font-size: 13px; }
.summary-decoration strong { font-weight: 500; }
.summary-file { overflow-wrap: anywhere; font-size: 13px; padding: 4px 0; }
.summary-muted { color: var(--muted); font-size: 13px; }
.summary-comment { white-space: pre-wrap; overflow-wrap: anywhere; }
.summary-stage { display: grid; grid-template-columns: minmax(100px,1fr) minmax(0,2fr); gap: 8px 16px; padding: 10px 0; }
.summary-stage + .summary-stage { border-top: 1px solid var(--border); }
.summary-stage:first-child { padding-top: 0; }
.summary-stage:last-child { padding-bottom: 0; }
.summary-stage strong { font-weight: 500; overflow-wrap: anywhere; }
.summary-stage span { font-size: 13px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media(max-width:540px) {
  #summaryContent .summary-section { padding: 12px; }
  .summary-fields { gap: 12px; }
  .summary-stage { grid-template-columns: minmax(0,1fr); gap: 4px; }
  .summary-item-heading { flex-wrap: wrap; gap: 4px; }
}
.missing-file-notice { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.missing-file-notice > p { flex: 1; min-width: 0; overflow-wrap: anywhere; margin: 0; }
.missing-file-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.notice-close { width: 36px; padding: 0 !important; font-size: 22px !important; }
@media(max-width:640px) { .missing-file-notice { flex-wrap: wrap; gap: 12px; } .missing-file-notice > p { flex-basis: 100%; } .missing-file-actions { width: 100%; justify-content: flex-end; } }
.history-panel { margin: 20px 0; scroll-margin-top: 16px; }
.history-panel > summary { cursor: pointer; font-weight: 600; }
.history-note { margin: 14px 0; color: var(--muted); line-height: 1.6; }
.history-meta { color: var(--muted); font-size: 12px; }
.history-list { margin-top: 12px; max-height: 560px; overflow-y: auto; padding-right: 14px; scrollbar-gutter: stable; }
.history-entry { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 16px 0; border-top: 1px solid var(--border); }
.history-entry-text { min-width: 0; overflow-wrap: anywhere; }
.history-entry-text p { margin: 6px 0 0; }
.history-entry > .btn { flex-shrink: 0; }
.restore-panel { margin: 20px auto; max-width: 960px; }
.restore-scopes { margin: 16px 0; }
.restore-change { border-top: 1px solid var(--border); padding: 16px 0; }
.restore-change h3 { font-size: 15px; margin-bottom: 10px; }
.restore-values { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.restore-values > div { padding: 12px; background: var(--surface-muted); border-radius: 6px; }
.restore-values p { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; }
@media(max-width:640px) { .history-entry { flex-wrap: wrap; } .restore-values { grid-template-columns: minmax(0,1fr); } }
:root {
  color-scheme: light;
  --page: #f2f2f2;
  --surface: #ffffff;
  --surface-muted: #f5f5f5;
  --field: #ffffff;
  --hover: #e9e9e9;
  --text: #242424;
  --muted: #606060;
  --border: #cdcdcd;
  --border-strong: #858585;
  --accent: #333333;
  --primary: #303030;
  --primary-text: #fafafa;
  --danger: #b42318;
  --success: #25713c;
}
html.dark-theme, body.dark-theme {
  color-scheme: dark;
  --page: #0a0a0a;
  --surface: #161616;
  --surface-muted: #1e1e1e;
  --field: #111111;
  --hover: #2c2c2c;
  --text: #e6e6e6;
  --muted: #ababab;
  --border: #414141;
  --border-strong: #858585;
  --accent: #d0d0d0;
  --primary: #d6d6d6;
  --primary-text: #171717;
  --danger: #ffaaa3;
  --success: #9dd6aa;
}
body { background: var(--page); color: var(--text); }
button, input, select, textarea { font-family: inherit; }
a { color: var(--text); }
.header, .footer { background: var(--surface); color: var(--muted); }
.header { border-bottom: 1px solid var(--border); }
.footer { border-top: 1px solid var(--border); }
.logo, .nav-link:hover { color: var(--text); }
.nav-link { color: var(--muted); }
.form-container, .card-box, .table-container, .stat-card,
.modal-content, .confirm-modal-content, .day-order-card {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}
.form-block-card, .position-card, .position-detail-card, .info-block,
.stage-item-row, .stage-info-item, .sample-duration-box, .checkbox-grid,
.mass-shift-box, .emb-row, .draft-files-banner, .draft-file-badge {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
}
.form-group label, .field-title, .size-table, .order-total-bar,
.stat-card-value, .start-date-display, .stage-dates-text,
.draft-file-link, .mass-shift-box strong { color: var(--text); }
.stat-card-title, .stage-info-dates, .stage-duration-text, .stage-dates-display,
.mass-shift-help, .file-upload-hint, .file-icon, .info-row > span,
.modal-close, .btn-close-custom { color: var(--muted); }
.file-upload-hint { font-size: 12px !important; }
.btn, .btn-action-sm, .tab-btn, .btn-file-upload {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  min-height: 36px;
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 20px;
  box-shadow: none;
  transition: background-color .15s, border-color .15s;
}
.btn:hover, .btn-action-sm:hover, .tab-btn:hover, .btn-file-upload:hover {
  background: var(--hover);
  border-color: var(--border-strong) !important;
  color: var(--text);
}
.btn-primary, .tab-btn.active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary) !important;
}
.btn-primary:hover, .tab-btn.active:hover { background: var(--primary); color: var(--primary-text); border-color: var(--border-strong) !important; }
.btn-danger, .btn-danger:hover, .draft-file-del-btn:hover { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger) !important; }
.tab-count { color: inherit; background: transparent; }
.btn:disabled, .btn-action-sm:disabled, .btn-file-upload:disabled {
  background: var(--surface-muted); color: var(--muted); border-color: var(--border) !important;
  opacity: .65; cursor: not-allowed;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]), select, textarea {
  background: var(--field); color: var(--text); border-color: var(--border);
  caret-color: var(--text); font-size: 14px;
}
select { color-scheme: light; }
html.dark-theme select { color-scheme: dark; }
select option { background-color: var(--field); color: var(--text); }
select option:checked, select option:hover { background-color: var(--primary); color: var(--primary-text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--border-strong); }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.stage-item-row input[readonly] { background: transparent; }
.field-input-error { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger); }
.field-error-text { color: var(--danger); }
.size-table th, .orders-table th { background: var(--surface-muted); color: var(--text); border-color: var(--border); }
.size-table td, .orders-table td { border-color: var(--border); }
.size-table input { background: var(--field); }
.size-table .pos-total-cell { color: var(--text); background: var(--surface-muted); }
.size-table th:last-child { color: var(--text); }
.stepper-btn { background: var(--hover); color: var(--text); }
.stepper-btn:hover { background: var(--primary); color: var(--primary-text); }
.order-row:hover { background: var(--hover); }
.orders-table th a { color: inherit; }
.stage-dropdown-menu { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 8px 24px #0003; }
.stage-dropdown-item { color: var(--text); }
.stage-dropdown-item:hover { background: var(--hover); }
.stage-dropdown-divider, .load-track { background: var(--border); }
.load-bar { background: var(--accent); }
.draft-file-badge:hover { background: var(--hover); border-color: var(--border-strong); }
.draft-file-tag { background: var(--surface); color: var(--muted); border-color: var(--border); }
.draft-file-del-btn, .btn-close-custom { background: transparent; color: var(--muted); }
.draft-file-link:hover { color: var(--text); }
.modal-overlay, .confirm-modal-overlay { background: #000b; backdrop-filter: none; }
.modal-content, .confirm-modal-content { border: 1px solid var(--border); box-shadow: 0 16px 48px #0005; }
.modal-close:hover { color: var(--text); }
.alert, .form-error { background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: none; }
.alert-error, .form-error { color: var(--danger); border-left: 3px solid var(--danger); }
.alert-success { color: var(--success); border-left: 3px solid var(--success); }
.form-status { color: var(--muted); }
.move-control-bar { background: var(--surface); color: var(--text); border-color: var(--border); }
.stage-detail-row, .pos-files-section { border-color: var(--border); }
.stage-detail-row { border-left-color: var(--border-strong); }
.dark-theme input[type=date]::-webkit-calendar-picker-indicator { filter: none; }
/* Two 22px quarter-day buttons plus the existing 2px gap must fit inside each day. */
.day-cell-picker .q-grid { height: 46px; }
@media (max-width: 640px) {
  .info-block, .position-detail-card { min-width: 0; }
  .info-row { gap: 12px; flex-wrap: wrap; }
  .info-row strong { overflow-wrap: anywhere; }
  .confirm-modal-buttons { flex-wrap: wrap; }
  #summaryModal .modal-content > div:last-child { flex-wrap: wrap; }
  #summaryModal .modal-content > div:last-child .btn { flex: 1; min-width: 140px; }
}

/* Position decorations and compact production stages. */
.embellishments-panel { margin-bottom: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); }
.embellishments-panel > div:first-child { flex-wrap: wrap; justify-content: flex-start; margin-bottom: 0 !important; }
.embellishments-panel > div:first-child .btn { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.embellishments-panel:has(.emb-row) > div:first-child { margin-bottom: 8px !important; }
#sortable-stages .stage-item-row { display: grid; grid-template-columns: 18px minmax(130px,1fr) 142px 76px auto 36px; gap: 4px 8px; padding: 8px 10px; align-items: center; min-height: 0; overflow: visible; }
#sortable-stages .stage-item-row > span:first-child { grid-column: 1; grid-row: 1; }
#sortable-stages .stage-item-row > input[readonly] { grid-column: 2; grid-row: 1; min-width: 0 !important; padding: 4px 0; }
#sortable-stages .duration-select { grid-column: 3; grid-row: 1; box-sizing: border-box; width: 142px !important; min-width: 142px; max-width: 142px; }
#sortable-stages .custom-duration { grid-column: 4; grid-row: 1; }
#sortable-stages .btn-outline { grid-column: 5; grid-row: 1; }
#sortable-stages .btn-danger { grid-column: 6; grid-row: 1; margin: 0 !important; padding: 0; width: 36px; }
#sortable-stages .stage-dates-display { grid-column: 2 / -1; grid-row: 2; margin: 0 !important; font-size: 12px !important; font-weight: 400 !important; color: var(--muted) !important; }
@media(max-width:640px) {
  #sortable-stages .stage-item-row { grid-template-columns: 18px minmax(0,1fr) auto 36px; }
  #sortable-stages .stage-item-row > input[readonly] { grid-column: 2 / 4; }
  #sortable-stages .btn-danger { grid-column: 4; }
  #sortable-stages .duration-select { grid-column: 2; grid-row: 3; width: 100% !important; }
  #sortable-stages .custom-duration { grid-column: 3; grid-row: 3; }
  #sortable-stages .btn-outline { grid-column: 2 / -1; grid-row: 4; }
  .embellishments-panel .emb-row { flex-wrap: wrap; padding: 8px; }
  .embellishments-panel .emb-row select:first-child { flex-basis: 100% !important; }
}

/* Attachment tiles: the same geometry for local files and saved uploads. */
.pos-files-list { display: flex; flex-wrap: wrap; gap: 12px; }
.attachment-card { position: relative; display: flex; flex-direction: column; width: 136px; min-width: 0; padding: 8px; gap: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); text-decoration: none; box-sizing: border-box; }
.attachment-open { display: flex; flex-direction: column; gap: 8px; min-width: 0; text-decoration: none; color: var(--text); }
.attachment-thumbnail, .attachment-placeholder { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 4px; background: var(--field); }
.attachment-placeholder { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.attachment-card .draft-file-link { display: block; font-size: 12px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.attachment-card .draft-file-tag { font-size: 11px; color: var(--muted); }
.attachment-remove { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 20px; }
.attachment-remove:hover { background: var(--hover); }
.attachment-open:focus-visible, .attachment-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.attachment-dialog { margin: auto; padding: 48px 16px 16px; max-width: 92vw; max-height: 92vh; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.attachment-dialog::backdrop { background: #000c; }
.attachment-dialog > img { display: block; max-width: 85vw; max-height: 72vh; object-fit: contain; margin: auto; }
.attachment-dialog > p { overflow-wrap: anywhere; margin: 12px 0 0; font-size: 13px; }
.attachment-dialog .attachment-close { position: absolute; right: 10px; top: 8px; width: 32px; min-height: 32px; padding: 0; font-size: 22px; }

.orders-more { position: relative; margin-left: auto; }
.orders-more > summary { cursor: pointer; list-style: none; }
.orders-more > summary::-webkit-details-marker { display: none; }
.orders-more-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; display: flex; flex-direction: column; gap: 6px; min-width: 190px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px #0003; }
.orders-more-menu .tab-btn { display: flex; justify-content: space-between; }
.history-entry { align-items: flex-start; }
.history-entry-text { flex: 1; }
.history-change-details { margin-top: 10px; }
.history-change-details > summary { cursor: pointer; font-size: 13px; }
.history-change { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.history-change > strong { display: block; font-size: 13px; margin-bottom: 8px; }
.history-change small { color: var(--muted); }
.history-change p { font-size: 13px; }

/* Compact notices stay away from the header and can be dismissed individually. */
#globalNotificationBar { top: 76px !important; left: auto !important; right: 20px !important; bottom: auto !important; transform: none !important; width: min(360px,calc(100vw - 32px)) !important; max-width: none !important; padding: 0 !important; display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
#globalNotificationBar .alert { display: flex; align-items: flex-start; gap: 12px; flex-shrink: 0; background: var(--surface) !important; box-shadow: 0 4px 16px #0003 !important; }
.notification-message { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.5; }
.notification-close { flex-shrink: 0; width: 28px; height: 28px; padding: 0; margin: -3px -6px -3px 0; display: grid; place-items: center; background: transparent; color: var(--muted); border: 0; border-radius: 4px; font-size: 22px; cursor: pointer; }
.notification-close:hover { background: var(--hover); color: var(--text); }
.notification-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media(max-width:540px) { #globalNotificationBar { right: 12px !important; top: 72px !important; bottom: auto !important; width: calc(100vw - 24px) !important; max-height: 35vh; } }

.position-pricing { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 12px 0; font-size: 13px; }
.unit-price-field { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text); min-width: 0; margin: 0; }
.unit-price-field input { box-sizing: border-box; width: 132px; height: 38px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--field); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.unit-price-field input:hover { border-color: var(--border-strong); }
.unit-price-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.embellishments-panel .unit-price-field input { width: 110px; }
.embellishments-panel .emb-row { margin-bottom: 0 !important; }

.embellishments-panel .emb-row { flex-wrap: wrap; }
.pricing-total { margin-top: 20px; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); display: flex; flex-wrap: wrap; gap: 12px 24px; }
.pricing-grand-total { margin-left: auto; font-size: 18px; }
#legacy-price-note { flex-basis: 100%; color: var(--muted); font-size: 13px; }

.embellishments-panel .emb-qty-input { width: 80px; }
.embellishments-panel .unit-price-field { flex-wrap: nowrap; }

/* Keep grouping at the section and position level. */
.order-form-shell { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; }
#block-positions { border: 0; padding: 0; background: transparent; }
.passport-row { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.passport-row > .form-group { min-width: 0 !important; margin: 0; }
.passport-row input:not([type=hidden]), .passport-row select { width: 100%; box-sizing: border-box; min-height: 40px; }
.embellishments-panel { border: 0; border-radius: 0; padding: 0; background: transparent; }
.embellishments-panel .emb-row { border: 0 !important; padding: 0 !important; background: transparent !important; }
.position-subtotal { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 16px; font-size: 14px; color: var(--text); }
.position-subtotal strong { margin-left: 6px; font-variant-numeric: tabular-nums; }
.position-subtotal-grand { margin-left: auto; font-size: 16px; }
.item-costs { margin: 16px 0; color: var(--text); font-size: 14px; }
.item-cost-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.item-cost-row > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.item-cost-row > strong { white-space: nowrap; font-size: 16px; font-variant-numeric: tabular-nums; }
.summary-attachments { display: flex; gap: 8px; flex-wrap: wrap; }
#summaryContent .summary-section:has(.summary-item) { border: 0; padding: 0; }
@media(max-width:640px) { .passport-row { grid-template-columns: 1fr; gap: 14px; } .position-subtotal-grand { margin-left: 0; width: 100%; } }

/* Order editor: one surface per logical section, quiet controls. */
html body .order-form-shell { border: none !important; outline: none !important; box-shadow: none !important; background: transparent !important; }
html body #block-positions { border: none !important; outline: none !important; background: transparent !important; padding: 0 !important; box-shadow: none !important; }
.order-form-shell .form-block-card, .order-form-shell .position-card { border: 1px solid var(--border) !important; box-shadow: none !important; }
.order-form-shell .position-card { margin-bottom: 18px; padding: 20px; }
.position-heading { display:flex; align-items:center; gap:12px; margin-bottom:18px; padding-bottom:14px; border-bottom:1px solid var(--border); }
.position-toggle { display:flex; flex:1; flex-wrap:wrap; align-items:center; text-align:left; gap:8px 16px; min-width:0; border:0; background:transparent; color:var(--text); font:inherit; cursor:pointer; padding:4px 0; }
.pos-header-title { font-size:16px; font-weight:650; overflow-wrap:anywhere; }
.position-overview { font-size:13px; color:var(--muted); }
.position-toggle-label { margin-left:auto; color:var(--muted); font-size:12px; }
.position-heading .pos-delete-btn { font-size:12px; min-height:32px; padding:5px 9px; }
.position-card.is-collapsed > :not(.position-heading) { display:none !important; }
.position-card.is-collapsed .position-heading { margin:0; padding:0; border:0; }
.product-price-group { display:grid; gap:6px; }
.order-form-shell .field-title { font-size:13px; font-weight:500; }
.order-form-shell .size-table { border:0; border-collapse:separate; border-spacing:4px 0; }
.order-form-shell .size-table th, .order-form-shell .size-table td { border:0 !important; background:transparent !important; padding:4px 0; }
.order-form-shell .size-table th { font-size:12px; font-weight:500; color:var(--muted); }
.order-form-shell .size-table .pos-total-cell { font-weight:650; }
.size-table th.pos-total-cell, .size-table td.pos-total-cell { box-sizing:border-box; width:92px; min-width:92px; max-width:92px; border-left:2px solid var(--border-strong) !important; background:var(--surface-muted) !important; font-weight:700 !important; white-space:nowrap; }
.order-checkout { position:sticky; bottom:12px; z-index:30; margin-top:24px; padding:14px 18px; background:var(--surface); border:1px solid var(--border); border-radius:8px; box-shadow:0 4px 16px #0002; }
.order-checkout .pricing-total { margin:0; padding:0 0 12px; border:0; background:transparent; align-items:center; gap:8px 20px; font-size:13px; }
.order-checkout .form-actions { margin-top:0 !important; align-items:center; flex-wrap:wrap; }
.order-checkout .form-actions .btn-primary { margin-left:auto; order:2; }
.order-checkout .pricing-grand-total { font-size:19px; color:var(--text); }
.checkout-quantity { color:var(--muted); }
.order-form-shell { padding-bottom:16px !important; }
@media(max-width:640px){
 .order-form-shell .position-card { padding:14px; }
 .position-heading { gap:8px; align-items:flex-start; }
 .position-toggle-label { margin-left:0; }
 .order-checkout { bottom:0; padding:12px; }
 .order-checkout .pricing-total > div:nth-child(-n+2) { display:none; }
 .order-checkout .form-actions { gap:8px !important; }
 .order-checkout .form-actions .btn { font-size:12px; padding:8px; }
}

.order-section-heading { margin:0 0 15px; font-size:16px; font-weight:600; }
.order-form-shell .position-pricing { justify-content:flex-end; }
html body .order-form-shell .size-table th:last-child,
html body .order-form-shell .size-table td:last-child { border:0 !important; outline:0 !important; box-shadow:none !important; background:transparent !important; }
html body .order-form-shell .size-table th.pos-total-cell,
html body .order-form-shell .size-table td.pos-total-cell { border-left:2px solid var(--border-strong) !important; background:var(--surface-muted) !important; font-weight:700 !important; }
html body .order-form-shell .embellishments-panel { border:0 !important; outline:0 !important; box-shadow:none !important; background:transparent !important; }
.order-form-shell .position-subtotal-grand { display:flex; align-items:baseline; gap:16px; padding:10px 0; }
.order-form-shell .position-subtotal-grand strong { font-size:20px; }

/* Order form proportions and typography. */
.order-form-shell { max-width:900px; margin:0 auto; width:100%; box-sizing:border-box; }
.order-copy-note { margin:0 0 16px; padding:10px 12px; border:1px solid var(--border); border-radius:7px; background:var(--surface-muted); color:var(--muted); font-size:13px; }
.order-form-shell .form-block-card { padding:20px; margin-bottom:24px; }
.order-form-shell #block-positions { padding:0 !important; }
.order-form-shell .position-heading { margin-bottom:16px; padding-bottom:12px; }
.order-form-shell .position-overview, .order-form-shell .position-toggle-label { font-size:13px; }
.order-form-shell .field-title, .order-form-shell .file-upload-hint { font-size:13px; line-height:1.45; }
.order-form-shell .position-pricing { margin:10px 0 16px; }
.order-form-shell .pos-files-section { margin-top:16px; padding-top:14px; border-top:1px solid var(--border); }
.order-form-shell .position-subtotal { margin-top:16px; padding-top:12px; gap:10px 20px; }
.order-form-shell .position-subtotal-grand { padding:4px 0; }
.order-form-shell .embellishments-panel > div:first-child { gap:12px !important; }
.order-form-shell .embellishments-panel .emb-row { gap:8px !important; }
@media(max-width:640px){ .order-form-shell .form-block-card { padding:14px; } }

/* Use the browser's anchored select picker where supported. The native Windows
   popup otherwise opens over the select control and can cover nearby fields. */
@supports (appearance: base-select) {
  .order-form-shell select,
  .order-form-shell select::picker(select) { appearance: base-select; }
  .order-form-shell select {
    position: relative;
    display: block;
    min-width: 0;
    padding-right: 32px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .order-form-shell select::picker(select) {
    box-sizing: border-box;
    width: anchor-size(width);
    min-width: anchor-size(width);
    max-width: calc(100vw - 24px);
    max-height: 280px;
    overflow-x: hidden;
    overflow-y: auto;
    margin-block: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 10px 26px rgba(0,0,0,.28);
  }
  .order-form-shell select option {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    margin: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 0;
    background: transparent;
  }
  .order-form-shell select option:checked,
  .order-form-shell select option:hover,
  .order-form-shell select option:focus {
    background: var(--hover);
    color: var(--text);
  }
  .order-form-shell select::picker-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
  }
  .order-form-shell select option::checkmark { flex: 0 0 12px; margin: 0; }
}

.order-form-shell .position-subtotal-quantity { display:flex; align-items:baseline; gap:16px; padding:4px 0; font-size:16px; }
.order-form-shell .position-subtotal-quantity strong { font-size:20px; }

.trash-action-cell { text-align:right; white-space:nowrap; }
.trash-action-cell .btn { min-height:34px; }
@media(max-width:760px){ .trash-action-cell { white-space:normal; min-width:120px; } .trash-action-cell .btn { white-space:normal; } }

/* Match quantity to the other position summary metrics. */
.order-form-shell .position-subtotal { align-items:baseline; }
.order-form-shell .position-subtotal-quantity { display:inline-flex; align-items:baseline; gap:8px; padding:4px 0; font-size:14px; color:var(--text); }
.order-form-shell .position-subtotal-quantity strong { margin:0; font-size:16px; font-weight:650; font-variant-numeric:tabular-nums; }

.order-checkout .pricing-total > div:not(.pricing-grand-total), .order-checkout .pricing-total > div:not(.pricing-grand-total) strong { color:var(--muted); }

.order-form-shell .position-subtotal-grand { gap:8px; }
.order-form-shell .position-subtotal-grand strong { margin-left:0; }

.production-duration-total { display:flex; align-items:baseline; gap:8px; color:var(--muted); font-size:13px; }
.production-duration-total strong { color:var(--text); font-size:14px; font-variant-numeric:tabular-nums; }
#batch-ui > .production-duration-total { justify-content:flex-end; margin-top:12px; }
#sample-ui .production-duration-total { margin-top:10px; }
@media(max-width:640px){ #batch-ui > .production-duration-total { justify-content:flex-start; } }


.order-comment-card { margin-bottom:20px; }
.order-comment-card h3 { margin:0 0 8px; font-size:16px; }
.order-comment-card p { margin:0; color:var(--text); white-space:pre-wrap; overflow-wrap:anywhere; }
.position-price-summary { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-top:12px; }
.position-price-details { color:var(--muted); font-size:12px; }
.position-price-details summary { display:inline-flex; align-items:center; gap:6px; padding:0; border:0; background:none; color:var(--muted); cursor:pointer; text-decoration:none; list-style:none; }
.position-price-details summary::-webkit-details-marker { display:none; }
.position-price-details summary::before { content:'▸'; font-size:11px; line-height:1; }
.position-price-details[open] { flex-basis:100%; }
.position-price-details[open] summary::before { content:'▾'; }
.position-price-details summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.position-price-details .item-costs-scroll { overflow-x:auto; margin-top:8px; }
.position-price-details .item-costs { width:100%; margin:0; border-collapse:collapse; font-size:13px; }
.position-price-details .item-costs th, .position-price-details .item-costs td { padding:6px 12px 6px 0; border-bottom:1px solid var(--border); text-align:left; white-space:nowrap; }
.position-price-details .item-costs th { width:1%; padding-right:16px; font-weight:700; }
.position-price-details .item-costs td:nth-child(2) { color:var(--text); }
.position-price-details .item-costs .item-cost-amount { width:1%; padding-right:0; text-align:right; font-weight:700; font-variant-numeric:tabular-nums; }
.position-price-total { display:flex; align-items:baseline; gap:12px; margin-left:auto; white-space:nowrap; color:var(--muted); font-size:13px; }
.position-price-total strong { color:var(--text); font-size:18px; font-variant-numeric:tabular-nums; }

.order-detail-overview { display:grid; grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr); gap:16px; align-items:stretch; }
.order-detail-facts, .order-progress-card { min-width:0; margin:0; }
.order-detail-facts .info-row { gap:16px; }
.order-detail-facts .info-row strong { text-align:right; overflow-wrap:anywhere; }
.order-progress-list { list-style:none; position:relative; display:grid; gap:2px; margin:0; padding:0 0 0 2px; }
.order-progress-step { min-height:40px; position:relative; display:grid; grid-template-columns:14px minmax(0,1fr); align-items:center; column-gap:9px; color:var(--muted); font-size:13px; }
.order-progress-step:not(:last-child)::after { content:''; position:absolute; left:6px; top:21px; bottom:-10px; width:1px; background:var(--border); }
.order-progress-dot { z-index:1; width:12px; height:12px; border:2px solid var(--border); border-radius:50%; background:var(--surface); }
.order-progress-content { display:grid; justify-items:start; gap:3px; min-width:0; }
.order-progress-label { min-width:0; }
.order-progress-time { display:inline-flex; align-items:center; gap:5px; color:var(--muted); font-size:12px; line-height:1.35; white-space:nowrap; font-variant-numeric:tabular-nums; }
.order-progress-time::before { content:"—"; width:auto; height:auto; border-radius:0; background:none; opacity:.8; font-weight:600; }
.order-progress-step.is-active { color:var(--text); font-weight:700; }
.order-progress-step.is-active .order-progress-dot { background:var(--text); border-color:var(--text); box-shadow:0 0 0 3px color-mix(in srgb,var(--text) 12%,transparent); }
.order-progress-step.is-active .order-progress-time { color:var(--muted); font-weight:500; }
.order-progress-step.is-complete { color:color-mix(in srgb,var(--text) 62%,var(--muted)); }
.order-progress-step.is-complete .order-progress-dot { border-color:color-mix(in srgb,var(--text) 48%,var(--muted)); background:color-mix(in srgb,var(--text) 48%,var(--muted)); }
@media(max-width:760px) { .order-detail-overview { grid-template-columns:minmax(0,1fr); } }

.order-status-cell { min-width:170px; }
.stage-status-select { box-sizing:border-box; width:100%; min-width:0; min-height:34px; padding:6px 25px 6px 8px; border:1px solid var(--border); border-radius:7px; color:var(--text); background-color:var(--field); font:inherit; font-size:13px; cursor:pointer; }
.stage-status-select:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.stage-status-select:disabled { opacity:.65; cursor:wait; }
.stage-status-select option { background:var(--surface); color:var(--text); }
.dark-theme .stage-bg-ожидание-материалов { background-color:#3a3a3a!important; color:#e5e5e5!important; }
html:not(.dark-theme) .stage-bg-ожидание-материалов { background-color:#e5e7eb!important; color:#374151!important; }

.orders-list-table { table-layout:fixed; min-width:1155px; }
.orders-list-table th, .orders-list-table td { white-space:nowrap; }
.orders-list-table th:nth-child(1), .orders-list-table td:nth-child(1) { width:62px; }
.orders-list-table th:nth-child(2), .orders-list-table td:nth-child(2) { width:130px; }
.orders-list-table th:nth-child(3), .orders-list-table td:nth-child(3) { width:240px; }
.orders-list-table th:nth-child(4), .orders-list-table td:nth-child(4) { width:135px; }
.orders-list-table th:nth-child(5), .orders-list-table td:nth-child(5) { width:205px; }
.orders-list-table th:nth-child(6), .orders-list-table td:nth-child(6) { width:170px; }
.orders-list-table th:nth-child(7), .orders-list-table td:nth-child(7) { width:130px; }
.orders-list-table th:nth-child(8), .orders-list-table td:nth-child(8) { width:82px; }
.orders-list-table .order-name-cell, .orders-list-table .order-client-cell { overflow:hidden; text-overflow:ellipsis; }
.orders-list-table .order-type-badge { display:inline-block; max-width:none; white-space:nowrap !important; }
@media(max-width:640px){ .orders-list-table { min-width:1150px; } }

.orders-list-table .order-row > td { white-space:nowrap !important; }
.orders-trash-table { width:100%; min-width:1000px; table-layout:fixed; }
.orders-trash-table th:nth-child(1), .orders-trash-table td:nth-child(1) { width:5%; }
.orders-trash-table th:nth-child(2), .orders-trash-table td:nth-child(2) { width:13%; }
.orders-trash-table th:nth-child(3), .orders-trash-table td:nth-child(3) { width:21%; }
.orders-trash-table th:nth-child(4), .orders-trash-table td:nth-child(4) { width:13%; }
.orders-trash-table th:nth-child(5), .orders-trash-table td:nth-child(5) { width:14%; }
.orders-trash-table th:nth-child(6), .orders-trash-table td:nth-child(6) { width:10%; }
.orders-trash-table th:nth-child(7), .orders-trash-table td:nth-child(7) { width:8%; }
.orders-trash-table th:nth-child(8), .orders-trash-table td:nth-child(8) { width:16%; }
.orders-trash-table th:nth-child(8), .orders-trash-table .trash-action-cell { padding-inline:7px; text-align:center; }
.orders-trash-table .trash-action-cell form { display:flex; justify-content:center; }
.orders-trash-table .trash-action-cell .btn { width:100%; max-width:148px; padding-inline:7px; font-size:12px; white-space:nowrap; }

/* High contrast stage-status chips, independent from calendar cell rules. */
html:not(.dark-theme) .stage-status-select[class*="status-stage-"] { color:#172033 !important; font-weight:600; }
html:not(.dark-theme) .status-stage-раскрой { background-color:#a3c4f3 !important; }
html:not(.dark-theme) .status-stage-пошив { background-color:#f1c0e8 !important; }
html:not(.dark-theme) .status-stage-dtf { background-color:#cfbaf0 !important; }
html:not(.dark-theme) .status-stage-шелкография { background-color:#fde4cf !important; }
html:not(.dark-theme) .status-stage-вышивка { background-color:#90dbf4 !important; }
html:not(.dark-theme) .status-stage-вто-и-упаковка { background-color:#fbd48e !important; }
html:not(.dark-theme) .status-stage-отгрузка { background-color:#b9fbc0 !important; }
html:not(.dark-theme) .status-stage-ожидание-материалов { background-color:#e5e7eb !important; color:#374151 !important; }
html.dark-theme .stage-status-select[class*="status-stage-"] { color:#f8fafc !important; font-weight:600; }
html.dark-theme .status-stage-раскрой { background-color:#075985 !important; }
html.dark-theme .status-stage-пошив { background-color:#9d174d !important; }
html.dark-theme .status-stage-dtf { background-color:#6b21a8 !important; }
html.dark-theme .status-stage-шелкография { background-color:#9a3412 !important; }
html.dark-theme .status-stage-вышивка { background-color:#0f766e !important; }
html.dark-theme .status-stage-вто-и-упаковка { background-color:#854d0e !important; }
html.dark-theme .status-stage-отгрузка { background-color:#166534 !important; }
html.dark-theme .status-stage-ожидание-материалов { background-color:#3f3f46 !important; color:#f4f4f5 !important; }

.order-progress-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; }
.order-progress-heading h4 { margin:0; color:var(--text); }
.order-progress-select { max-width:58%; min-width:150px; min-height:34px; padding:5px 9px; border:1px solid var(--border); border-radius:8px; background:var(--field); color:var(--text); font:inherit; font-size:12px; cursor:pointer; }
.order-progress-select:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.order-progress-select:disabled { opacity:.65; cursor:wait; }
.order-progress-time::before { content:none; }
.order-status-badge { display:inline-flex; align-items:center; justify-content:center; padding:3px 10px; border:1px solid; border-radius:6px; font-size:11px; line-height:1.2; font-weight:600; white-space:nowrap; }
.order-status-badge.is-created { color:#9dc7ff; border-color:#355d91; background:#1c304d; }
.order-status-badge.is-waiting { color:#ffe19a; border-color:#806120; background:#483919; }
.order-status-badge.is-working { color:#a8ebbb; border-color:#326a43; background:#1d3827; }
.order-status-badge.is-shipped { color:#d1d5db; border-color:#62676e; background:#3b3e43; }
.order-modal-actions { display:flex; align-items:center; justify-content:flex-start; flex-wrap:wrap; gap:8px; margin-top:20px; }
.order-modal-actions > .btn, .order-modal-actions form .btn { flex:0 0 auto; min-height:36px; padding:7px 12px; line-height:1.2; white-space:nowrap; }
.order-modal-actions form { display:flex; margin:0; }
.orders-toolbar { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-bottom:15px; }
.orders-tabs, .orders-tools { display:flex; align-items:center; gap:6px; min-width:0; }
.orders-tabs { flex-wrap:wrap; }
.orders-tabs .orders-more { margin-left:0; }
.orders-tools { flex:1; justify-content:flex-end; gap:8px; }
.orders-search { display:flex; align-items:center; gap:8px; flex:0 1 420px; min-width:260px; }
.orders-search input[type=search] { appearance:none; box-sizing:border-box; flex:1; width:100%; min-width:0; height:36px; padding:7px 12px; font:inherit; font-size:13px; border:1px solid var(--border); border-radius:7px; background:var(--field); color:var(--text); }
.orders-search input[type=search]::placeholder { color:var(--muted); }
.orders-search input[type=search]:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
#orders-search-message { color:var(--muted); font-size:13px; }
#orders-search-message:empty { display:none; }
.orders-search .btn { min-height:36px; white-space:nowrap; }
.orders-filter { position:relative; flex:none; }
.orders-filter-trigger { display:inline-flex; align-items:center; min-height:36px; box-sizing:border-box; padding:7px 12px; font-size:13px; }
.orders-filter > summary { list-style:none; cursor:pointer; white-space:nowrap; }
.orders-filter > summary::-webkit-details-marker { display:none; }
.orders-filter > summary.has-date::after { content:''; display:inline-block; width:6px; height:6px; margin-left:7px; border-radius:50%; background:var(--accent); vertical-align:middle; }
.orders-period-control { display:flex; align-items:center; flex:none; }
.orders-period-control.has-date { border:1px solid var(--border); border-radius:6px; background:var(--surface); }
.orders-period-control.has-date .orders-filter-trigger { border:0 !important; background:transparent; padding-right:5px; font-variant-numeric:tabular-nums; }
.orders-period-clear { display:grid; place-items:center; width:30px; height:34px; margin-right:2px; border-radius:5px; color:var(--muted); font-size:20px; text-decoration:none; }
.orders-period-clear:hover { background:var(--hover); color:var(--text); }
.orders-filter-menu { position:absolute; z-index:30; top:calc(100% + 8px); right:0; display:grid; gap:12px; width:340px; max-width:calc(100vw - 32px); padding:16px; box-sizing:border-box; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:0 14px 32px rgba(0,0,0,.28); color:var(--text); font-size:13px; }
.range-selection { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:8px; }
.range-boundary { display:grid; gap:5px; padding:9px 8px; border:1px solid var(--border); border-radius:7px; background:var(--field); color:var(--text); font:inherit; text-align:left; cursor:pointer; }
.range-boundary span { font-size:11px; color:var(--muted); }
.range-boundary strong { font-size:12px; font-weight:500; }
.range-boundary.is-selecting { border-color:var(--text); }
.range-month-nav { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.range-month-nav .btn { width:32px; min-height:32px; padding:0; font-size:22px; }
.range-month-title { text-transform:capitalize; font-size:14px; }
.range-weekdays, .range-days { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); text-align:center; }
.range-weekdays { color:var(--muted); font-size:11px; }
.range-days { row-gap:4px; }
.range-day { height:36px; padding:0; border:0; border-radius:6px; font:inherit; background:transparent; color:var(--text); cursor:pointer; }
.range-day:hover { background:var(--hover); }
.range-day.in-range { background:var(--surface-muted); border-radius:0; }
.range-day[aria-current=date] { text-decoration:underline; text-underline-offset:5px; }
.range-day.range-start, .range-day.range-end { background:var(--text); color:var(--surface); border-radius:6px; font-weight:700; }
.range-day:focus-visible, .range-boundary:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
.range-hint { margin:0; min-height:18px; font-size:12px; color:var(--muted); }
.orders-filter-actions button:disabled { opacity:.45; cursor:default; }
.orders-filter-title { font-weight:700; }
.orders-filter-menu label { display:grid; grid-template-columns:24px minmax(0,1fr); align-items:center; gap:7px; color:var(--muted); }
.orders-filter-menu input[type=date] { box-sizing:border-box; width:100%; min-height:36px; padding:5px 8px; border:1px solid var(--border); border-radius:7px; background:var(--field); color:var(--text); color-scheme:dark; font:inherit; }
html:not(.dark-theme) .orders-filter-menu input[type=date] { color-scheme:light; }
.orders-filter-actions { display:flex; gap:7px; }
.orders-filter-actions .btn { flex:1; text-align:center; }
@media(max-width:960px) { .orders-tools { flex-basis:100%; } .orders-search { flex:1; max-width:520px; } }
@media(max-width:600px) { .orders-search { min-width:0; } .orders-filter-menu { right:auto; left:0; } }
html:not(.dark-theme) .order-status-badge.is-created { color:#1e40af; border-color:#60a5fa; background:#bfdbfe; }
html:not(.dark-theme) .order-status-badge.is-waiting { color:#78350f; border-color:#f59e0b; background:#fde68a; }
html:not(.dark-theme) .order-status-badge.is-working { color:#14532d; border-color:#4ade80; background:#bbf7d0; }
html:not(.dark-theme) .order-status-badge.is-shipped { color:#374151; border-color:#9ca3af; background:#d1d5db; }

/* Client directory */
.clients-page { max-width: 1200px; margin: 0 auto; }
.clients-page h1 { margin: 0; font-size: 24px; line-height: 1.3; }
.clients-page-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.clients-page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.clients-search-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.clients-search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
#clients-search { box-sizing: border-box; width: min(420px,100%); min-height: 38px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--field); color: var(--text); font: inherit; }
#clients-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.clients-table-container { border: 1px solid var(--border); }
.clients-table th:nth-child(4), .clients-table td:nth-child(4) { text-align: center; }
.clients-table th:last-child, .clients-table td:last-child { text-align: right; }
.client-row { cursor: pointer; }
.client-row:hover { background: var(--hover); }
.client-name-link { color: var(--text); font-weight: 650; text-decoration: none; }
.client-name-link:hover { text-decoration: underline; }
.clients-empty-row td { padding: 30px; color: var(--muted); text-align: center !important; }
.client-detail-page > h1 { margin: 0 0 18px; overflow-wrap: anywhere; }
.client-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.client-stat { display: grid; gap: 8px; padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.client-stat span { color: var(--muted); font-size: 13px; }
.client-stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.client-details-card, .client-orders-card { margin-bottom: 20px; }
.client-details-card h2, .client-orders-card h2 { margin: 0 0 18px; font-size: 17px; }
.client-details-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 24px; margin: 0; }
.client-details-grid > div { min-width: 0; }
.client-details-grid dt { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.client-details-grid dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.client-details-wide { grid-column: 1 / -1; }
.client-legal-block { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.client-legal-block h3 { margin: 0 0 10px; font-size: 14px; }
.client-legal-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; padding: 9px 0; border-top: 1px solid var(--border); }
.client-legal-row strong { font-weight: 600; }
.client-legal-row > span { color: var(--muted); font-size: 13px; }
.client-primary-mark { margin-left: auto; }
.client-muted { margin: 0; color: var(--muted); }
.clients-orders-table { min-width: 680px; }
.clients-orders-table td:nth-child(4), .clients-orders-table td:nth-child(5) { white-space: nowrap; }
.client-modal { box-sizing: border-box; width: min(620px,calc(100vw - 24px)); max-height: min(90vh,800px); margin: auto; padding: 22px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 18px 50px #0007; }
.client-modal::backdrop { background: #0009; }
.client-modal-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.client-modal-heading h2 { margin: 0; font-size: 19px; }
.client-modal-close { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; }
.client-modal-description { margin: 8px 0 18px; color: var(--muted); font-size: 13px; }
.client-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.client-field { display: grid; gap: 5px; min-width: 0; font-size: 13px; font-weight: 600; }
.client-field-wide { grid-column: 1 / -1; }
.client-field input, .client-field textarea { box-sizing: border-box; width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--field); color: var(--text); font: inherit; font-weight: 400; }
.client-field textarea { resize: vertical; }
.client-legal-entities { display: grid; gap: 8px; }
.client-legal-entities .client-legal-row { display: grid; grid-template-columns: minmax(0,1fr) 150px 32px; align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.client-legal-entities .client-legal-row label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 12px; }
.client-legal-entities .client-legal-primary::before { content: 'Основное'; grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.client-legal-remove { height: 38px; border: 1px solid var(--border); border-radius: 7px; background: var(--field); color: var(--muted); font-size: 21px; cursor: pointer; }
.client-legal-remove[hidden] { visibility: hidden; }
.client-text-action { justify-self: start; padding: 3px 0; border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.client-text-action:hover { text-decoration: underline; }
.client-form-error { color: var(--danger); font-size: 13px; }
.client-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@media(max-width:640px) { .client-stats, .client-details-grid, .client-form-grid { grid-template-columns: 1fr; } .client-details-wide, .client-field-wide { grid-column: auto; } .client-modal { padding: 16px; } .client-legal-entities .client-legal-row { grid-template-columns: minmax(0,1fr) 32px; } .client-legal-entities .client-legal-row label:first-of-type { grid-column: 1 / -1; } }
.passport-client-row { grid-template-columns: minmax(160px,1fr) minmax(260px,3fr); }
.client-picker { position: relative; }
.client-picker #client-search { width: 100%; }
.client-options { position: absolute; z-index: 60; top: calc(100% + 5px); left: 0; right: 0; max-height: 250px; overflow-y: auto; padding: 5px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 28px #0004; }
.client-options[hidden] { display: none; }
.client-option { display: block; box-sizing: border-box; width: 100%; min-height: 36px; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.client-option:hover, .client-option:focus-visible { background: var(--hover); }
.client-option-add { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0; font-weight: 600; }
.client-options-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
@media(max-width:640px) { .passport-client-row { grid-template-columns: 1fr; } }
.order-client-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.order-client-link:hover { text-decoration-color: currentColor; }
@media(max-width:520px) { .order-progress-heading { align-items:flex-start; flex-direction:column; } .order-progress-select { max-width:100%; width:100%; } }

/* Stronger badge fills in the light theme. */
html:not(.dark-theme) .order-type-badge.order-type-batch {
  background-color:#bfdbfe !important;
  color:#1e40af !important;
  border-color:#60a5fa !important;
}
html:not(.dark-theme) .order-type-badge.order-type-sample {
  background-color:#d1d5db !important;
  color:#374151 !important;
  border-color:#9ca3af !important;
}
