/* Foregrounds stay independent of the workshop's fixed status/header colours. */
:root {
  color-scheme: light;
  --on-brand: #f9fbfa;
  --on-status: #102522;
  --brand-text: #163b36;
  --ready-text: #106348;
  --bending-text: #704001;
  --cutting-text: #17475e;
  --metalwork-text: #235573;
  --unresolved-text: #51465f;
  --danger-text: #b93636;
  --signal-text: #ad3c17;
  --muted: #52635f;
  --action: #bc4219;
  --action-hover: #9b3513;
  --on-action: #fff;
  --focus: #bc4219;
}

.theme-toggle,
.account-box .theme-toggle,
.admin-actions .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #78928a;
  border-radius: 7px;
  color: #f9fbfa;
  background: #23443d;
  font: 650 12px/1.2 var(--body);
  text-decoration: none;
  white-space: nowrap;
}
.theme-toggle:hover, .account-box .theme-toggle:hover { color: #fff; background: #31574e; }
.theme-toggle [data-theme-icon] { width: 17px; font: 20px/1 var(--body); }
.theme-toggle [data-theme-label] { display: none; }
.station-box .account-box { display: grid; grid-template-columns: minmax(0, 1fr) 32px; column-gap: 8px; }
.account-box > strong { grid-row: 1; grid-column: 1; }
.account-box > span { grid-row: 2; grid-column: 1; }
.account-box .theme-toggle { grid-row: 1 / 3; grid-column: 2; align-self: center; }
.admin-actions > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-form-wrap > .theme-toggle { margin: 0 0 24px auto; display: flex; }

.scan-input-wrap button, .primary-button, .export-button {
  color: var(--on-action);
  background: var(--action);
}
.scan-input-wrap button:hover, .primary-button:hover, .export-button:hover { background: var(--action-hover); }
.scan-input-wrap input::placeholder, .pallet-search input::placeholder { color: var(--muted); }
.stack-form small, .parts-editor-labels, .spec-record-lines-label, .journal-time-cell small { color: var(--muted); }
.auth-identity .brand small { color: #bdd0cb; }
.inspection-mark { color: #ffb08a; }
.operation-modes button[data-operation="bending"][aria-pressed="true"] { background: #805016; }
.spec-component-switch button b { color: inherit; }
::placeholder { color: var(--muted); opacity: 1; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.topbar :focus-visible, .auth-identity :focus-visible { outline-color: #ffb58f; }

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111c20;
  --paper-deep: #23343a;
  --white: #1b2b30;
  --ink: #ecf3f1;
  --muted: #b3c5c4;
  --line: #607b7e;
  --brand-text: #a1e5ce;
  --ready-text: #9ce1bb;
  --bending-text: #ffd098;
  --cutting-text: #a9d9f2;
  --metalwork-text: #b4dcf6;
  --unresolved-text: #ded0f0;
  --danger-text: #ffb5af;
  --signal-text: #ffb08a;
  --ready-soft: #203e35;
  --bending-soft: #423323;
  --cutting-soft: #213b49;
  --metalwork-soft: #243e52;
  --unresolved-soft: #372f44;
  --signal-soft: #472e27;
  --action: #f28b5c;
  --action-hover: #ffa57f;
  --on-action: #18231f;
  --focus: #ffb58f;
  --shadow: 0 18px 44px rgba(0,0,0,.28);
  scrollbar-color: #78928e #17252a;
}

html[data-theme="dark"] body {
  background: linear-gradient(90deg, rgba(179,197,196,.025) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(rgba(179,197,196,.025) 1px, transparent 1px) 0 0 / 42px 42px, var(--paper);
}
html[data-theme="dark"] .topbar { background: #142724; border-bottom-color: var(--line); }
html[data-theme="dark"] .auth-page { background: var(--paper); }
html[data-theme="dark"] :is(.panel, .pallet-search, .stats-strip, .pallet-grid.pallet-search-empty) {
  background: var(--white);
  border-color: var(--line);
}
html[data-theme="dark"] :is(.nav-tab.active, .workspace-switch a[aria-current="page"]) {
  background: #375d52;
  color: #fff;
  box-shadow: inset 0 0 0 1px #91b8a9;
}
html[data-theme="dark"] :is(.spec-component-switch button[aria-pressed="true"], .admin-sections a[aria-current="page"], .journal-scope button.active) {
  background: #315d4e;
  border-color: #91b8a9;
  color: #fff;
}
html[data-theme="dark"] .operation-modes button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #bdd5cd; }
html[data-theme="dark"] .scan-input-wrap { border-color: var(--line); }
html[data-theme="dark"] .scan-input-wrap:focus-within { border-color: var(--focus); }
html[data-theme="dark"] .nav-tab .counter { color: inherit; background: transparent; }
html[data-theme="dark"] :is(.secondary-button:hover, .edit-spec-button:hover, .bending-pallet-tile:hover, .add-part-button, .turning-location-preview:hover) { border-color: var(--brand-text); }
html[data-theme="dark"] :is(.spec-record-chevron::after) { border-color: var(--brand-text); }

/* Opaque surfaces avoid pale panels and washed-out table rows. */
html[data-theme="dark"] :is(.part-preview-editor, .part-preview-editor.has-preview, .part-pdf-editor, .journal-pagination) { background: var(--paper-deep); border-color: var(--line); }
html[data-theme="dark"] :is(.part-preview-editor.pending, .part-pdf-editor.pending, .part-pdf-editor.drag-over) { background: var(--signal-soft); }
html[data-theme="dark"] :is(.turning-drawing-preview, .specification-image-preview, .journal-preview-tooltip, .pallet-parts li .part-hover-preview, .pallet-parts li .part-hover-preview::after) { background: var(--white); border-color: var(--line); }
html[data-theme="dark"] :is(.spec-record-details) { background: none; }
html[data-theme="dark"] :is(.spec-record-lines li, .journal-table td, .unresolved-actions) { border-color: var(--line); }
html[data-theme="dark"] .journal-table tbody tr:hover td { background: var(--paper-deep); }
html[data-theme="dark"] .journal-row-deleted td code { color: var(--muted); }
html[data-theme="dark"] :is(.pallet-card-body .unresolved-eyebrow, .unresolved-meta, .unresolved-actions > span) { color: var(--unresolved-text); }
html[data-theme="dark"] .pallet-stage-alert { color: var(--cutting-text); }
html[data-theme="dark"] .cutting-table .bending-cell { background: var(--bending-soft); }
html[data-theme="dark"] .cutting-table .cutting-stage-cell { background: var(--cutting-soft); }
html[data-theme="dark"] .info-note { background: var(--bending-soft); }
html[data-theme="dark"] .plan-status.PAUSED { color: var(--bending-text); background: var(--bending-soft); }
html[data-theme="dark"] .user-card[data-role="ADMIN"] .role-stamp { color: var(--signal-text); }
html[data-theme="dark"] .user-card[data-role="TECHNOLOGIST"] .role-stamp { color: var(--cutting-text); background: var(--cutting-soft); }
html[data-theme="dark"] :is(.release-button, .pallet-part-remove, .remove-part-button, .delete-spec-button, .turning-message.error, .turning-shortage, .journal-record-status.deleted) {
  background: #452b30;
  border-color: #b37e7b;
}
html[data-theme="dark"] :is(.release-button, .pallet-part-remove, .remove-part-button, .delete-spec-button):hover { background: #872e35; color: #fff; }
html[data-theme="dark"] .toast { background: #294e44; border: 1px solid var(--line); }
html[data-theme="dark"] .toast.error { background: #872e35; }
html[data-theme="dark"] input[type="checkbox"] { accent-color: #c17b25; }
html[data-theme="dark"] input::file-selector-button { color: var(--ink); background: var(--paper-deep); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; }

/* Status cards use fixed dark fills and light text in both themes. */
.assignment-card:is(.success, .error, .unresolved) :is(.assignment-state, .pallet-label, .assignment-details p:not(.product-code), .assignment-footer, .recognition-note) { color: #fff; }
html[data-theme="dark"] .pallet-card-top { box-shadow: inset 0 0 0 1px rgba(220,240,232,.3); }
html[data-theme="dark"] .dot { border-color: #9eb7b2; }
html[data-theme="dark"] .pallet-card-top .pallet-dates dt { opacity: 1; }

/* Technical originals are never inverted. Keep black lines on a white sheet. */
:is(.turning-location-preview, .turning-spec-thumb, .turning-drawing-preview-image, .turning-drawing-stage, .part-preview-thumb, .spec-line-preview, .journal-part-preview, .part-hover-preview-visual, .pallet-parts li .part-hover-preview-visual, .specification-image-preview .part-hover-preview-visual) {
  color-scheme: light;
  background: #fff;
  color: #536561;
}
.part-preview-stage, .journal-preview-tooltip-visual {
  color-scheme: light;
  color: #102522;
  background: linear-gradient(90deg, rgba(22,59,54,.045) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(22,59,54,.045) 1px, transparent 1px) 0 0 / 24px 24px, #f4f7f6;
}
.part-preview-stage .part-preview-unavailable, .part-preview-stage .part-preview-unavailable strong { color: #536561; }
.part-preview-stage::after { color: #536561; }
.part-preview-stage .part-preview-unavailable::before { color: #ad3c17; }
:is(.part-preview-thumb, .spec-line-preview, .part-hover-preview-visual) i { color: #536561; }

@media (max-width: 700px) {
  .station-box .account-box { max-width: 180px; }
}
