/* Navigation has its own palette: changing the workspace never recolors it. */
:root { color-scheme: dark; }
.sidebar, .login-story {
  --text: #eef5f6;
  --muted: #a4bfc9;
  --accent: #7bd3d8;
  --line: #315361;
  color: var(--text);
  color-scheme: dark;
}
.sidebar-bottom > .appearance-controls {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}
.appearance-controls .sidebar-theme { margin: 0; }
.mode-switch {
  position: relative;
  width: 46px;
  height: 26px;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid #577b8d;
  border-radius: 20px;
  background: #16384d;
  overflow: hidden;
  transition: background .3s, border-color .3s;
}
.mode-thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dcecf2;
  color: #20465b;
  z-index: 1;
  transition: transform .4s cubic-bezier(.22,1,.36,1), background .3s;
}
.mode-thumb svg {
  position: absolute;
  inset: 2px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity .25s, transform .4s;
}
.mode-sun { opacity: 0; transform: rotate(-90deg) scale(.5); }
.mode-stars { position: absolute; right: 5px; top: 2px; color: #aacbd7; font-size: 12px; transition: opacity .2s; }
.mode-switch[aria-checked="true"] { background: #49778a; border-color: #81b7c5; }
.mode-switch[aria-checked="true"] .mode-thumb { transform: translateX(20px); background: #fff0cb; color: #885c14; }
.mode-switch[aria-checked="true"] .mode-sun { opacity: 1; transform: rotate(0) scale(1); }
.mode-switch[aria-checked="true"] .mode-moon { opacity: 0; transform: rotate(90deg) scale(.5); }
.mode-switch[aria-checked="true"] .mode-stars { opacity: 0; }
.mode-switch:hover { border-color: #b3e8ec; }

/* Screen-only overrides leave production printouts and certificates untouched. */
@media screen {
  /* Elastic scrolling exposes the root canvas, not the workspace gradient. */
  html { background: var(--sidebar-bg); }
  body { background-color: var(--bg); }
  :root[data-color-mode="light"] {
    color-scheme: light;
    --bg: #edf3f5;
    --page-background: linear-gradient(155deg, #f7fafb 0%, #f2f6f7 46%, var(--bg) 100%);
    --text: #143348;
    --muted: #566f7c;
    --accent: #247e8c;
    --line: #d5e2e7;
  }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) .panel {
    background: #fff;
    border-color: var(--line);
    box-shadow: 0 2px 6px #14334803;
  }
  [data-color-mode="light"] .app-shell :is(.breadcrumb, .demo-banner, .demo-explanation, .demo-badge, .metric small, .tabs a, .search-form button, .product-cell small, .stacked small, .amount > span, .row-link, .table-note, .attention-item small, .privacy-note small, .page-footer, .status-filters > span, .status-filters a, .clear-filter, .optional, .remove-material) { color: var(--muted); }
  [data-color-mode="light"] .app-shell :is(.breadcrumb strong, .info-rule strong, .confirm-production) { color: var(--text); }
  [data-color-mode="light"] .app-shell :is(.preview-tag, .demo-badge, .search-form, .metrics, .attention-panel, .info-panel) { border-color: var(--line); }
  [data-color-mode="light"] .app-shell .avatar { background: #e0eff1; border-color: #b9d6dc; }
  [data-color-mode="light"] .app-shell .account-popover { background: #fff; box-shadow: 0 10px 30px #14334818; }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) .button { background: #fff; border-color: #adc6cf; }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) .button:hover { background: #e8f2f4; border-color: var(--accent); }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) .button.primary { background: #247e8c; color: #fff; border-color: #247e8c; }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) .button.primary:hover { background: #1c6673; }
  [data-color-mode="light"] .app-shell .metrics { background: #fff; border: 1px solid var(--line); border-radius: 4px; }
  [data-color-mode="light"] .app-shell .metric:first-child { padding-left: 25px; }
  [data-color-mode="light"] .app-shell .metric:last-child { padding-right: 25px; }
  [data-color-mode="light"] .app-shell .metric-value { font-weight: 550; }
  [data-color-mode="light"] .app-shell .data-table th { background: #f5f8f9; color: #566f7c; border-color: var(--line); }
  [data-color-mode="light"] .app-shell .data-table td { border-color: var(--line); }
  [data-color-mode="light"] .app-shell .data-table tbody tr:hover { background: #f1f7f8; }
  [data-color-mode="light"] .app-shell .product-icon { background: #f0f7f8; border-color: #c8dfe4; color: #247e8c; }
  [data-color-mode="light"] .app-shell :is(.normal, .positive, .type-label.receipt) { color: #26725d; }
  [data-color-mode="light"] .app-shell :is(.low, .warm, .metric-link, .count-bubble) { color: #826016; }
  [data-color-mode="light"] .app-shell .empty { color: #a05020; }
  [data-color-mode="light"] .app-shell .negative { color: #b23e4f; }
  [data-color-mode="light"] .app-shell .type-label.dispatch { color: #45658a; }
  [data-color-mode="light"] .app-shell .count-bubble { border-color: #dacaa6; }
  [data-color-mode="light"] .app-shell :is(.privacy-note, .notice, .customer-preview) { background: #eaf3f5; border-color: #b8d4dc; }
  [data-color-mode="light"] .app-shell .tabs a.selected { color: var(--accent); }
  [data-color-mode="light"] .app-shell .status-filters a.selected { background: #e6f1f3; border-color: #b7d5dc; color: var(--accent); }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) :is(.field label, .history-filters label) { color: #294b5c; }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) :is(.field input, .field select, .field textarea, .history-filters input, .history-filters select) { background: #fff; border-color: #adc6cf; color: var(--text); }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) :is(.field input, .search-form input)::placeholder { color: #657e8a; }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) :is(.field-errors, .form-errors, .errorlist) { color: #a93243; }
  [data-color-mode="light"] :is(.app-shell, .login-form-area) .form-errors { background: #fff0f1; border-color: #d9a9b0; }
  [data-color-mode="light"] .app-shell .has-error :is(input, select, textarea) { border-color: #b23e4f; }
  [data-color-mode="light"] .app-shell .message { background: #e9f5ef; border-color: #aacdbc; color: #266852; }
  [data-color-mode="light"] .app-shell .production-alert { background: #eaf3f5; border-color: #b8d4dc; color: #345c6a; }
  [data-color-mode="light"] .app-shell .production-alert.error { background: #fff0f1; border-color: #d9a9b0; color: #a93243; }
  [data-color-mode="light"] .app-shell .production-alert.success { background: #e9f5ef; border-color: #aacdbc; color: #266852; }
  [data-color-mode="light"] .login-form-area { background: var(--page-background); }
}
@media screen and (max-width:760px) {
  [data-color-mode="light"] .app-shell .metrics .metric { padding: 20px !important; }
}
@media (prefers-reduced-motion:reduce) {
  .mode-switch, .mode-thumb, .mode-thumb svg, .mode-stars { transition: none; }
}
