/* Shared appearance controls; app styles retain their original light fallbacks. */
:root { color-scheme: light; }
.appearance-slot { flex: 0 0 auto; }
.theme-control { position: relative; font: 600 12px/1.4 var(--font-geist-sans, Arial), sans-serif; color: var(--theme-ink, #193b42); }
.theme-control > summary { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 11px; border: 1px solid var(--theme-line, #cbd8ce); border-radius: 7px; background: var(--theme-surface, #fff); cursor: pointer; list-style: none; white-space: nowrap; }
.theme-control > summary::-webkit-details-marker { display: none; }
.theme-control > summary:hover, .theme-control[open] > summary { background: var(--theme-subtle, #edf3ed); }
.theme-control > summary svg { display: block; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.theme-control > summary svg path { fill: currentColor; stroke: none; }
.theme-chevron { color: var(--theme-muted, #667a70); font-size: 15px; }
.theme-control[open] .theme-chevron { transform: rotate(180deg); }
.theme-control .theme-options { position: absolute; z-index: 100; top: calc(100% + 8px); right: 0; width: 218px; margin: 0; padding: 10px; border: 1px solid var(--theme-line, #d7e1d8); border-radius: 10px; background: var(--theme-surface, #fff); box-shadow: 0 12px 36px #0003; }
.theme-options legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.theme-control .theme-options label { display: grid; grid-template-columns: 16px 1fr; column-gap: 10px; row-gap: 2px; align-items: center; margin: 0; padding: 10px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; line-height: 1.4; }
.theme-options label:hover, .theme-options label:has(input:checked) { background: var(--theme-subtle, #edf3ed); }
.theme-control .theme-options input { grid-row: 1 / 3; display: block; width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0; accent-color: var(--theme-green, #28765f); }
.theme-options small { grid-column: 2; color: var(--theme-muted, #667a70); font-size: 11px; font-weight: 400; }
.theme-control summary:focus-visible, .theme-control input:focus-visible { outline: 3px solid var(--theme-green, #28765f); outline-offset: 3px; }
.login-shell { position: relative; padding-top: 82px; }
.auth-appearance { position: absolute; top: 22px; right: 24px; z-index: 10; }
.connect-appearance { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.quantglide-page .header-inner { gap: 18px; }

/* Dark tokens exist only on screen, so printed reports keep the light palette. */
@media screen {
  html[data-theme="dark"] {
    color-scheme: dark;
    --theme-paper: #101a19;
    --theme-surface: #192825;
    --theme-subtle: #22362f;
    --theme-ink: #dfeae5;
    --theme-heading: #e3efea;
    --theme-muted: #a8bdb4;
    --theme-line: #3a5148;
    --theme-green: #7ed5ad;
    --theme-red: #f1a29c;
    --theme-amber: #e2c080;
    --theme-link: #a2d4e3;
    --theme-success-surface: #203c30;
    --theme-danger-surface: #422c2b;
    --theme-warning-surface: #403822;
    --theme-info-surface: #243c47;
    --chart-primary: #9cc6db;
    --chart-green: #73c4a2;
    --chart-sage: #8faca0;
    --chart-lime: #bfd6a2;
    --chart-gold: #d9bc7e;
    --chart-slate: #81979c;
    --chart-red: #e59885;
    --chart-track: #2c4037;
    --chart-grid: #334b41;
    --chart-muted: #a8bdb4;
    --chart-connector: #6f8c7b;
    background: var(--theme-paper);
  }
  html[data-theme="dark"] .login-shell { background: radial-gradient(ellipse at 80% 5%, #23433866, transparent 55%), #101a19; }
  html[data-theme="dark"] .login-card { border-color: var(--theme-line); }
  html[data-theme="dark"] :is(.primary-btn, .login-submit) { background: #29594e; color: #f2faf6; }
  html[data-theme="dark"] :is(.primary-btn, .login-submit):hover { background: #356e60; }
  html[data-theme="dark"] :is(.sidebar, .foundation-ui .sidebar) { background: #122521; }
  html[data-theme="dark"] :is(.foundation-hero, .foundation-ui .holdings-total, .quantglide-page .hero) { border: 1px solid #3a5650; }
  html[data-theme="dark"] .quantglide-page :is(.forecast-management-bar, .management-dot) { background: var(--chart-primary); }
  html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #8ea79d; opacity: 1; }
  html[data-theme="dark"] :is(input[type="checkbox"], input[type="radio"]) { accent-color: var(--theme-green); }
  html[data-theme="dark"] .quantglide-connect { background: var(--theme-paper); }
  html[data-theme="dark"] ::selection { background: #486953; color: #fff; }
}
@media (max-width: 900px) {
  .topbar-actions .theme-options { left: 0; right: auto; }
  .quantglide-page .header-inner { flex-wrap: wrap; padding-top: 18px; padding-bottom: 18px; gap: 12px; }
  .quantglide-page .header-inner nav { order: 4; width: 100%; justify-content: space-between; }
  .quantglide-page .header-inner nav a { padding: 5px 0; }
  .quantglide-page .header-inner nav a::after { bottom: 0; }
  .quantglide-page .header-inner .brand { margin-right: auto; }
}
@media (max-width: 520px) {
  .auth-appearance { top: 18px; right: 18px; }
  .quantglide-page .header-inner > .theme-control { margin-left: auto; }
  .quantglide-page .export-button { padding: 10px; }
  .quantglide-page .export-button span { display: none; }
  .theme-control > summary { padding-inline: 9px; }
}
@media print { .appearance-slot, .theme-control, .connect-appearance { display: none !important; } }
