/* Header appearance switch. The icon represents the current theme. */
.header-tools{display:flex;align-items:center;gap:14px;min-width:0}
.theme-options{display:inline-flex;flex:none;gap:2px;padding:3px;border:1px solid #d7e0e9;border-radius:24px;background:#edf1f5}
.theme-options button{display:inline-flex;justify-content:center;align-items:center;gap:5px;min-height:32px;padding:4px 9px;border:1px solid transparent;border-radius:20px;background:transparent;color:#42556b;font:inherit;font-size:12px;white-space:nowrap;cursor:pointer;touch-action:manipulation}
.theme-options svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.theme-options button:hover{background:#dce7f1}
.theme-options button[aria-pressed="true"]{border-color:#145aad;background:#1666bd;color:white;font-weight:600}
.theme-options button:focus-visible{outline:2px solid #147ad9;outline-offset:1px}
.issued-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
@media(max-width:900px){.theme-options button:not([aria-pressed="true"]) span{display:none}.theme-options button{min-width:34px}}
@media(max-width:420px){.theme-options button span{display:none}}
@media(max-width:650px){.header-tools{gap:10px;margin-left:auto}.header-tools .mini-profile{margin-left:0;max-width:170px}}
@media(max-width:380px){.header-tools .profile-name{max-width:90px}.topbar{padding-left:14px;padding-right:14px;gap:10px}}

/* Screen-only palette: printed work orders always keep their light layout. */
@media screen {
  :root[data-theme="dark"]{color-scheme:dark;background:#10161f;color:#e5edf5;--blue:#69b2ff;--muted:#a1b0bf;--line:#303c4c;--navy:#e5edf5}
  [data-theme="dark"] body{background:#10161f}
  [data-theme="dark"] .surface{background:#19222e;box-shadow:0 8px 32px #0002}
  [data-theme="dark"] .content{background:#131c27}
  [data-theme="dark"] :is(.panel,.stat,.mobile-card,.login-card,dialog,.profile-popover,.role-rule,.permission-sticky,.permissions-matrix th,.picker-person,.picker-footer,.role-save){background:#1b2634;color:#e5edf5;border-color:var(--line)}
  [data-theme="dark"] :is(th,.footer-actions,.scope-options,.picker-nav,.permissions-matrix .permission-group td){background:#202d3d;color:#b9c7d6}
  [data-theme="dark"] :is(td,.permissions-matrix td,.permissions-matrix th,.profile-popover dl>div,.role-rule-body,.picker-layout,.picker-nav,.picker-search){border-color:var(--line)}
  [data-theme="dark"] :is(input,select,textarea,.worker-select,.draft input,.draft select,.form input,.form select,.form textarea,.assign,.worker-name-form input,.role-rule textarea){background:#131d29;color:#e5edf5;border-color:#41516a}
  [data-theme="dark"] :is(input,textarea)::placeholder{color:#8c9db0}
  [data-theme="dark"] .picker-search input{background:transparent}
  [data-theme="dark"] :is(.button,.row-actions button,.add-button,.role-plus){background:#243246;color:#cedcf0;border-color:#43536b}
  [data-theme="dark"] .button.primary{background:#2586e9;border-color:#2586e9;color:#fff}
  [data-theme="dark"] :is(.ghost,.profile-trigger,.staff-name-button,.permission-role-name,.mobile-product,.timing-detail .work-timer strong){color:#d7e5f3}
  [data-theme="dark"] .ghost{background:transparent;border-color:transparent}
  [data-theme="dark"] :is(.nav button,.subtitle,.form label,.form small,.empty,.work-timer small,.op-cell small,.profile-period,.profile-popover>small,.role-label,.permissions-note,.role-department-tags,.inline-summary,.role-editor-section small,.picker-head p,.picker-person small,.picker-explanation,.picker-empty,.picker-footer span,.footnote .credit,.grant-cell small,.timing-detail>small,.mobile-label){color:#a5b5c6}
  [data-theme="dark"] .nav .active{color:#81c1ff}
  [data-theme="dark"] :is(a,.scope-value,.inline-scope>summary){color:#8fc8ff}
  [data-theme="dark"] :is(.badge,.staff-code){background:#2b3746;color:#b9c7d6}
  [data-theme="dark"] :is(.badge.ready,.stat-icon.green){background:#193e35;color:#80ddbb}
  [data-theme="dark"] :is(.stat-icon.amber,.warning){background:#413723;color:#edca7f;border-color:#685735}
  [data-theme="dark"] :is(.badge.error,.form input[aria-invalid="true"]){background:#422a33;color:#ffb2b8;border-color:#b85c67}
  [data-theme="dark"] :is(.danger,.row-actions .delete-order,.pin-warning){color:#ff9da8}
  [data-theme="dark"] :is(.stat-icon,.op-symbol,.avatar,.role-person,.role-avatar,.person-avatar,.profile-avatar){background:#283d55;color:#a9d3ff}
  [data-theme="dark"] :is(.portal-admin-note,.demo-banner,.selection-tag,.recipient-chip){background:#20394c;color:#b6d8f3;border-color:#35526b}
  [data-theme="dark"] .portal-admin-note p{color:#b3c8d9}
  [data-theme="dark"] :is(.picker-person:hover,.picker-person.selected,.picker-nav button.active,.action-name:hover,.grant-cell:hover){background:#2a415a;color:#b9ddff}
  [data-theme="dark"] :is(.permission-value.allowed,.grant-cell.allowed strong){color:#83dabb}
  [data-theme="dark"] :is(.permission-value.denied,.grant-cell.denied){color:#9fadc0}
  [data-theme="dark"] .qr-view>img{background:white;padding:12px;border-radius:10px}
  [data-theme="dark"] .brand img{filter:brightness(1.8)}

  [data-theme="dark"] dialog::backdrop{background:#050c17a6}
}
@media screen {
  [data-theme="dark"] .theme-options{background:#233042;border-color:#46586c}
  [data-theme="dark"] .theme-options button{color:#c4d2e2}
  [data-theme="dark"] .theme-options button:hover{background:#374a61}
  [data-theme="dark"] .theme-options button[aria-pressed="true"]{background:#91c6ff;color:#10263f;border-color:#b4d9ff}
}
@media print{:root{color-scheme:light!important;background:white!important;color:#142538!important}.theme-options{display:none!important}}
[data-theme="dark"] :is(.badge.partial){background:#47381a;color:#f2c76b}
[data-theme="dark"] .partial-button{background:#47381a;color:#f2c76b;border-color:#6b5421}
[data-theme="dark"] .partial-time{color:#f2c76b}

@media screen {
  [data-theme="dark"] :is(.staff-card,.staff-menu-list){background:#1b2634;color:#e5edf5;border-color:var(--line)}
  [data-theme="dark"] .staff-card.selected{border-color:#69b2ff;box-shadow:0 0 0 1px #69b2ff}
  [data-theme="dark"] .staff-card.off{background:#161f2b}
  [data-theme="dark"] .staff-card.off .staff-card-name,[data-theme="dark"] .staff-card-meta{color:#a5b5c6}
  [data-theme="dark"] .staff-card .pin-cell{background:#131d29}
  [data-theme="dark"] .staff-avatar{background:#283d55;color:#a9d3ff}
  [data-theme="dark"] :is(.staff-chip,.staff-chips select){background:#243246;color:#cedcf0;border-color:#43536b}
  [data-theme="dark"] #staff-search{background:#243246;color:#cedcf0;border-color:#43536b}
  [data-theme="dark"] .staff-chip.on{background:#20394c;color:#b9ddff;border-color:#69b2ff}
  [data-theme="dark"] .staff-menu-list button{color:#e5edf5}
  [data-theme="dark"] .staff-menu-list button:hover{background:#2a415a}
  [data-theme="dark"] .staff-menu-list button.staff-danger,[data-theme="dark"] .staff-form-error{color:#ff9da8}
  [data-theme="dark"] .staff-card .staff-menu>summary{background:transparent;color:#d7e5f3}
  [data-theme="dark"] .staff-bar{background:#0d2238;border:1px solid #35526b}
  [data-theme="dark"] .staff-bar .button:not(.primary){background:transparent;color:#fff}
}

@media screen {
  [data-theme="dark"] :is(.staff-card .pin-cell .button,.staff-card .staff-menu>summary,.staff-chip,.staff-chips select,.staff-actions .button:not(.primary)){border-color:#4d6280;box-shadow:0 1px 4px #0008}
  [data-theme="dark"] #staff-search{border-color:#4d6280;box-shadow:0 1px 4px #0008}
  [data-theme="dark"] .staff-card .staff-menu>summary{background:#243246}
  [data-theme="dark"] .staff-chip.on{border-color:#69b2ff}
}

@media screen {
  [data-theme="dark"] .permissions-panel .permissions-matrix thead th,[data-theme="dark"] .permissions-panel .permissions-matrix tbody th.permission-sticky{background:#1b2634;color:#e5edf5;border-color:var(--line)}
  [data-theme="dark"] .permissions-panel .permissions-matrix td{border-color:var(--line)}
  [data-theme="dark"] .permissions-panel .permissions-matrix .permission-group th{background:#202d3d;border-color:var(--line)}
  [data-theme="dark"] .permission-group button{color:#c4d2e2}
  [data-theme="dark"] .permissions-panel .role-head-top .permission-role-name{color:#e5edf5}
  [data-theme="dark"] .scope-chip{background:#243246;color:#cedcf0;border-color:#4d6280;box-shadow:0 1px 4px #0008}
  [data-theme="dark"] .rswitch i{background:#4a5a70}
  [data-theme="dark"] .rswitch input:checked+i{background:#2586e9}
  [data-theme="dark"] .roles-actions input[type=search]{background:#243246;color:#cedcf0;border-color:#4d6280}
  [data-theme="dark"] .roles-actions .button:not(.primary),[data-theme="dark"] .permissions-panel .role-head-top .button{border-color:#4d6280;box-shadow:0 1px 4px #0008}
  [data-theme="dark"] .role-cell .autosave-state,[data-theme="dark"] .roles-autosave{color:#83dabb}
}

@media screen {
  [data-theme="dark"] :is(.order-card,.issued-bar){background:#1b2634;color:#e5edf5;border-color:var(--line)}
  [data-theme="dark"] .order-chip{background:#243246;color:#cedcf0;border-color:#4d6280;box-shadow:0 1px 4px #0008}
  [data-theme="dark"] .order-chip.on{background:#20394c;color:#b9ddff;border-color:#69b2ff}
  [data-theme="dark"] .chip-not_ready .chip-icon{color:#a5b5c6}[data-theme="dark"] .chip-partial .chip-icon{color:#f2c76b}[data-theme="dark"] .chip-ready .chip-icon{color:#80ddbb}[data-theme="dark"] .chip-error .chip-icon{color:#ff9da8}
  [data-theme="dark"] .oc-time{color:#fff}
  [data-theme="dark"] :is(.oc-note,.oc-title small,.order-filters p,[data-order-ready],.master-panel p){color:#a5b5c6}
  [data-theme="dark"] .oc-assign select.assign{background-color:#131d29;color:#e5edf5;border-color:#41516a}
  [data-theme="dark"] .oc-assign select.assign.unassigned{color:#8fc8ff}
  [data-theme="dark"] .oc-top .staff-menu>summary{background:transparent;border-color:transparent;color:#d7e5f3}
  [data-theme="dark"] .issued-bar .button:not(.primary),[data-theme="dark"] .orders-upload .button,[data-theme="dark"] .orders-empty .button:not(.primary){background:#243246;color:#cedcf0;border-color:#4d6280}
  [data-theme="dark"] .issued-bar .delete-all-button{color:#ff9da8;border-color:#7a3d45}
  [data-theme="dark"] .oc-qr,[data-theme="dark"] .orders-heading .staff-actions .button:not(.primary){border-color:#4d6280;box-shadow:0 1px 4px #0008}
}
@media screen{[data-theme="dark"] .issued-bar .button.delete-all-button:not(.primary){color:#ff9da8;border-color:#7a3d45}}
@media screen{[data-theme="dark"] .order-total{background:#1b2634;border-color:var(--line);color:#a5b5c6}[data-theme="dark"] .order-total strong{color:#fff}}
@media screen {
  [data-theme="dark"] .topbar .nav{background:#233042;border-color:#46586c}
  [data-theme="dark"] .topbar .nav button{color:#c4d2e2}
  [data-theme="dark"] .topbar .nav button:hover{background:#374a61}
  [data-theme="dark"] .topbar .nav button.active{background:#91c6ff;color:#10263f;border-color:#b4d9ff}
}
@media print{.topbar .nav{display:none}}
