/* After the light theme. Semantic tokens also style dynamically rendered records.
   Only the root preference selects this palette; the default light theme is intact.
   Do not invert the page, logos or product imagery. Product thumbnails keep
   their own white backplates to match their original catalogue photographs. */
html[data-theme="dark"] {
  color-scheme: dark;
  --paper:#161719; --surface:#202225; --ink:#f3f1ed; --muted:#b6b6b6;
  --line:#414348; --forest:#ffad77; --leaf:#ffc295; --tint:#3d302a;
  --focus:#ffc79f; --accent:#ffad77; --on-accent:#24160e;
  --bg:var(--paper); --bg2:#1b1c1f; --card:var(--surface); --card2:#2b2d31;
  --panel:var(--surface); --border:var(--line); --text:var(--ink);
  --orange:var(--accent); --orange2:#ffbd92; --green:#94dfbd; --red:#ffacb4; --yellow:#f7d582;
  --control-line:#75777d; --control-hover:#323438; --rail:#1b1c1e; --warm-line:#75513c;
  --ws-amber-bg:#382e19; --ws-amber-line:#826c36;
  --ws-red-bg:#3a252b; --ws-red-line:#86545e;
  --ws-success-bg:#20332c; --ws-success-line:#446858;
  --ws-blue:#adcef0; --ws-blue-bg:#232e3b; --ws-blue-line:#516b82;
  background:var(--paper); color:var(--ink);
}
html[data-theme="dark"] ::selection { color:var(--on-accent); background:var(--leaf); }
html[data-theme="dark"] a:hover { color:#ffd8ba; }
html[data-theme="dark"] :is(input:not([type=checkbox]):not([type=radio]),select,textarea) { background:var(--bg2); border-color:var(--control-line); color:var(--ink); }
html[data-theme="dark"] :is(input,textarea)::placeholder { color:#aaa9aa; opacity:1; }
html[data-theme="dark"] input[type=date] { color-scheme:dark; }
html[data-theme="dark"] input[type=file]::file-selector-button { background:var(--card2); color:var(--ink); border-color:var(--control-line); }
html[data-theme="dark"] :is(input,select,textarea):focus { border-color:var(--focus); }
html[data-theme="dark"] :is(button,.button) { border-color:var(--control-line); }
html[data-theme="dark"] :is(button:not(:disabled),.button):hover { color:var(--ink); background:var(--control-hover); border-color:#a1a1a5; }
html[data-theme="dark"] :is(button,.button).primary { color:var(--on-accent); background:var(--accent); border-color:var(--accent); }
html[data-theme="dark"] :is(button:not(:disabled),.button).primary:hover { color:var(--on-accent); background:#ffbe94; border-color:#ffbe94; }
html[data-theme="dark"] .table-sort,html[data-theme="dark"] .table-sort:hover { background:transparent; color:inherit; }
html[data-theme="dark"] :is(dialog,.modal .card) { border-color:var(--line); box-shadow:0 20px 70px #08090b80; }
html[data-theme="dark"] dialog::backdrop,html[data-theme="dark"] .modal { background:rgb(8 9 12/.69); }
html[data-theme="dark"] #siteLock { background:radial-gradient(ellipse at 18% 24%,#352923,transparent 60%),var(--paper); }
html[data-theme="dark"] .tab .form { background:var(--surface); }
html[data-theme="dark"] :is(th,.stat,.handled-card) { background:var(--card2); }
html[data-theme="dark"] th { color:#d5d5d4; }
html[data-theme="dark"] tr:hover td { background:var(--control-hover); }
html[data-theme="dark"] .stat.hl { background:var(--tint); border-color:var(--warm-line); }
html[data-theme="dark"] .label-chip { background:var(--surface); color:var(--ink); border-color:color-mix(in srgb,var(--lc) 65%,var(--line)); }
html[data-theme="dark"] .label-chip:is(:hover,.on) { background:color-mix(in srgb,var(--lc) 24%,var(--surface)); }

/* Mail-inspired navigation: quiet rail, warm active indicator and crisp brand mark. */
html[data-theme="dark"] #sidebar { background:var(--rail); color:var(--ink); box-shadow:inset -1px 0 var(--line); }
html[data-theme="dark"] .logo { background:var(--accent); color:var(--on-accent); }
html[data-theme="dark"] :is(.brand small,.ws-nav-heading span,#collapseBtn) { color:var(--muted); }
html[data-theme="dark"] #sidebar nav { scrollbar-color:#66666b transparent; }
html[data-theme="dark"] #sidebar :is(nav,.sidefoot) button { color:#d8d7d6; }
html[data-theme="dark"] #sidebar :is(nav,.sidefoot) button:hover { color:var(--ink); background:var(--control-hover); }
html[data-theme="dark"] #sidebar nav button.active { color:#ffd7ba; background:#413029; box-shadow:inset 3px 0 var(--accent); }
html[data-theme="dark"] #sidebar .tools-subnav { border-color:#685449; }
html[data-theme="dark"] .ws-nav-heading #navView { color:#e6d3c4; border-color:#79675a; }
html[data-theme="dark"] .ws-nav-heading #navView:hover { background:var(--tint); }
html[data-theme="dark"] #menuRestore { color:var(--on-accent); background:var(--accent); border-color:var(--accent); }
html[data-theme="dark"] #menuRestore:not(:disabled):hover { color:var(--on-accent); background:#ffbe94; }
html[data-theme="dark"] .badge { color:var(--on-accent); background:var(--accent); }

/* Overview, command search, filters, and current-record context. */
html[data-theme="dark"] :is(.ws-eyebrow,.ws-guide-kicker,.flow-eyebrow) { color:var(--orange2); }
html[data-theme="dark"] :is(.ws-kpi-arr,.ws-breadcrumb .ui-icon) { color:var(--muted); }
html[data-theme="dark"] :is(.ws-kpis button,.ws-queue-row,.ws-result,#overviewAccounts):not(:disabled):hover { background:var(--control-hover); }
html[data-theme="dark"] .ws-kpis button:not(:disabled):hover { border-color:var(--warm-line); }
html[data-theme="dark"] .ws-segment button[aria-pressed=true] { color:#ffd8ba; background:var(--tint); border-color:var(--warm-line); }
html[data-theme="dark"] :is(.ws-empty-mark,.ws-kpi-icon) { border-color:var(--warm-line); }
html[data-theme="dark"] .ws-queue-row+.ws-queue-row { border-color:var(--line); }
html[data-theme="dark"] #overviewQueue { scrollbar-color:#626267 transparent; }
html[data-theme="dark"] .ws-guide { background:linear-gradient(142deg,#392e28,#2d2826); border-color:#604a3d; }
html[data-theme="dark"] .ws-guide p { color:#d6c8bd; }
html[data-theme="dark"] .ws-guide li { border-color:#624d3e; }
html[data-theme="dark"] .ws-guide li::before { color:#e2b798; }
html[data-theme="dark"] .ws-guide li button,html[data-theme="dark"] .ws-guide li button:hover { color:#ffd2ae; background:transparent; }
html[data-theme="dark"] #overviewConnections.needs-attention { color:var(--yellow); }
html[data-theme="dark"] .ws-status { background:var(--ws-amber-bg); color:var(--yellow); border-color:var(--ws-amber-line); }
html[data-theme="dark"] .ws-focus { background:var(--tint); color:#ffe1cc; border-color:var(--warm-line); }
html[data-theme="dark"] #workspaceSearchDialog { box-shadow:0 24px 85px #07080aab; }
html[data-theme="dark"] #workspaceSearchDialog::backdrop { background:rgb(7 8 10/.7); }
html[data-theme="dark"] .ws-search-field { background:var(--bg2); border-color:var(--control-line); color:var(--muted); }
html[data-theme="dark"] .ws-search-field input { background:transparent; }

/* Keep authorization, customer urgency, warning and completion distinct from
   the orange navigation accent; the existing labels/icons retain their meaning. */
html[data-theme="dark"] .ticket-sync-health { color:var(--green); background:var(--ws-success-bg); border-color:var(--ws-success-line); }
html[data-theme="dark"] :is(.ticket-sync-health.problem,.account-warning,.ctype.claim,.order-state-cancelled,.order-state-return,.tag.bad) {
  color:var(--red); background:var(--ws-red-bg); border-color:var(--ws-red-line);
}
html[data-theme="dark"] .ticket-sync-health .sync-account { border-color:var(--line); }
html[data-theme="dark"] .ticket-sync-health .sync-account .bad { color:var(--red); }
html[data-theme="dark"] .ticket-sync-health .muted { color:var(--muted); }
html[data-theme="dark"] .tag { background:var(--bg2); }
html[data-theme="dark"] .tag.ok { color:var(--green); background:var(--ws-success-bg); border-color:var(--ws-success-line); }
html[data-theme="dark"] :is(.purchase-duplicate-notice.has-duplicates,.inbox-attention-summary,.thread-attention,.tag.warn) {
  color:var(--yellow); background:var(--ws-amber-bg); border-color:var(--ws-amber-line);
}
html[data-theme="dark"] :is(.inbox-attention-summary,.thread-attention) span:last-child { color:#e9d5a7; }
html[data-theme="dark"] .thread-item:hover { background:var(--card2); }
html[data-theme="dark"] .thread-item.selected { background:var(--tint); border-left-color:var(--accent); }
html[data-theme="dark"] .thread-item.needs-reply { background:#30291b; border-left-color:var(--yellow); }
html[data-theme="dark"] .thread-item.needs-reply:is(:hover,.selected) { background:#41341e; border-left-color:var(--yellow); }
html[data-theme="dark"] .thread-new { background:#6a323e; color:#ffe2e5; }
html[data-theme="dark"] :is(.thread-reply,.customer-message-label) { color:#281e0c; background:#edcb7c; }
html[data-theme="dark"] .msgs { background:var(--paper); }
html[data-theme="dark"] .msg.in { background:var(--card2); border-color:var(--line); }
html[data-theme="dark"] .msg.in.customer-latest { color:var(--ink); background:#373025; border-color:#9e854d; }
html[data-theme="dark"] .msg.out { color:#f1e1d7; background:#3c302c; border-color:#674f41; }
html[data-theme="dark"] :is(.replybox,.thread-head,.order-sections>.order-section,.order-products .oitem) { background:var(--surface); }
html[data-theme="dark"] .copy-inline:not(:disabled):hover { color:#ffd6ba; background:var(--tint); }
html[data-theme="dark"] :is(.message-product,.copy-phone,.order-set-summary,.ctype.dispute) { color:var(--ws-blue); background:var(--ws-blue-bg); border-color:var(--ws-blue-line); }
html[data-theme="dark"] .older-orders-separator { color:#d2b7e7; }
html[data-theme="dark"] .older-orders-separator::before,html[data-theme="dark"] .older-orders-separator::after { border-color:#735d86; }
html[data-theme="dark"] :is(.processing-helper,.pickup,.recipient-details) { background:#302a27; border-color:var(--warm-line); }
html[data-theme="dark"] :is(.ocard.order-alert,.purchase-order-alert>td,tr.warn-bad td) { background:var(--ws-red-bg); border-color:var(--ws-red-line); }
html[data-theme="dark"] .ocard.order-processed:not(.order-alert) { background:var(--ws-success-bg); border-color:var(--ws-success-line); }
html[data-theme="dark"] tr.warn-ok td { background:var(--ws-amber-bg); }
html[data-theme="dark"] :is(.allegro-price-line,.allegro-price-summary) { color:var(--green); background:var(--ws-success-bg); border-color:var(--ws-success-line); }
html[data-theme="dark"] :is(.allegro-price-line b,.allegro-price-summary>b) { color:#b7f0d2; }
html[data-theme="dark"] .qty-2 { color:var(--ws-blue); background:var(--ws-blue-bg); }
html[data-theme="dark"] .qty-3 { color:#9de3d8; background:#203834; }
html[data-theme="dark"] .qty-4 { color:var(--yellow); background:var(--ws-amber-bg); }
html[data-theme="dark"] .qty-5 { color:#e1bfef; background:#382c3f; }
html[data-theme="dark"] .qty-6plus { color:var(--red); background:var(--ws-red-bg); }
html[data-theme="dark"] #tab-repricing .rp-switch { background:#6a6c72; }
html[data-theme="dark"] #tab-repricing .rp-switch.on { background:#cd8050; }
html[data-theme="dark"] #tab-repricing .rp-switch.on i { background:#281b13; }
html[data-theme="dark"] #tab-repricing [data-dirty] { color:var(--yellow); }
