/* Shared semantic palette for the console and fund manager. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d12; --panel: #131720; --panel-solid: #131720;
  --ink: #f3f4f6; --muted: #94a0b3; --line: #252b36;
  --cyan: #60a5fa; --cyan-soft: #16253b; --pink: #f87171; --pink-soft: #301c23;
  --green: #4ade80; --red: #f87171; --amber: #fbbf24; --violet: #a78bfa;
  --text-secondary: #c5cedb; --label: #a8b3c4; --hint: #758196;
  --input-border: #343c4a; --input-bg: #0e121a; --focus-ring: #1e3a5f;
  --surface-nav: #10141c; --surface-inset: #10151e;
  --surface-hover: #1c2330; --nav-hover: #1a2230;
  --active-bg: #192d49; --active-ink: #79b5ff; --active-subtle: #19263a;
  --menu-bg: #171c26; --menu-hover: #222b3a;
  --violet-border: #45355e; --violet-ink: #c4b5fd;
  --icon-muted: #9ba9bb; --body-soft: #b5c0cf; --hover-border: #64748b;
  --danger-border: #65313b; --danger-bg: #301c23; --danger-ink: #fca5a5;
  --danger-hover: #49242d; --danger-strong: #fecaca;
  --warning-border: #5b4829; --warning-bg: #2b2418; --warning-ink: #fcd34d;
  --warning-hover: #3c301c; --warning-strong: #fde68a;
  --success-border: #23553a; --success-bg: #142d22; --success-ink: #bbf7d0;
  --success-hover: #1c422f; --running-bg: #123322;
  --meter-bg: #2a3240; --table-head: #181e29; --badge-bg: #1b2330;
  --notice-bg: #201f19; --notice-ink: #d1ba88;
  --code-bg: #0d1118; --code-ink: #bdc9da;
  --auth-tint: #11213a66; --auth-shadow: 0 16px 56px #0003;
  --card: var(--panel); --brand: var(--cyan); --brand-soft: var(--active-bg);
  --ok: var(--green); --ok-soft: var(--running-bg);
  --warn: var(--amber); --warn-soft: var(--warning-bg); --danger: var(--red);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb; --panel: #ffffff; --panel-solid: #ffffff;
  --ink: #182230; --muted: #596b80; --line: #e1e7ef;
  --cyan: #2563eb; --cyan-soft: #eff6ff; --pink: #dc2626; --pink-soft: #fef2f2;
  --green: #15803d; --red: #dc2626; --amber: #a16207; --violet: #7c3aed;
  --text-secondary: #425369; --label: #475569; --hint: #64748b;
  --input-border: #cbd5e1; --input-bg: #ffffff; --focus-ring: #dbeafe;
  --surface-nav: #ffffff; --surface-inset: #f8fafc;
  --surface-hover: #f0f4f9; --nav-hover: #f0f4f9;
  --active-bg: #e8f0ff; --active-ink: #1d4ed8; --active-subtle: #edf4ff;
  --menu-bg: #ffffff; --menu-hover: #f0f4f9;
  --violet-border: #ddd6fe; --violet-ink: #6d28d9;
  --icon-muted: #64748b; --body-soft: #475569; --hover-border: #94a3b8;
  --danger-border: #fecaca; --danger-bg: #fef2f2; --danger-ink: #b91c1c;
  --danger-hover: #fee2e2; --danger-strong: #991b1b;
  --warning-border: #f4d58d; --warning-bg: #fffbeb; --warning-ink: #92400e;
  --warning-hover: #fef3c7; --warning-strong: #78350f;
  --success-border: #bbf7d0; --success-bg: #f0fdf4; --success-ink: #166534;
  --success-hover: #dcfce7; --running-bg: #dcfce7;
  --meter-bg: #e2e8f0; --table-head: #f3f6fa; --badge-bg: #f1f5f9;
  --notice-bg: #fffbeb; --notice-ink: #855314;
  --code-bg: #f4f7fb; --code-ink: #334155;
  --auth-tint: #dbeafe88; --auth-shadow: 0 16px 56px #1e3a5f0a;
}
.theme-toggle {
  display: inline-flex; width: auto; min-height: 38px; align-items: center;
  justify-content: center; gap: 8px; margin: 0; padding: 8px 12px;
  border: 1px solid var(--input-border); border-radius: 7px;
  background: var(--panel); color: var(--text-secondary);
  font: 500 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  cursor: pointer; touch-action: manipulation; box-shadow: none; transition: none;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--ink); border-color: var(--hover-border); }
.theme-toggle:focus-visible, [data-set-theme]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-moon { display: none; }
[data-theme="light"] .theme-sun { display: none; }
[data-theme="light"] .theme-moon { display: inline-flex; }
.auth-theme-switch { position: fixed; top: 24px; right: 28px; z-index: 10; }
.theme-settings { margin-bottom: 16px; }
.theme-settings-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.theme-settings .panel-intro { margin: 7px 0 0; }
.theme-options { display: flex; gap: 10px; flex-shrink: 0; }
button.theme-option { display: flex; min-width: 110px; align-items: center; gap: 9px; justify-content: center; border: 1px solid var(--input-border); background: var(--panel); color: var(--text-secondary); padding: 11px 14px; }
button.theme-option:hover { background: var(--surface-hover); border-color: var(--hover-border); color: var(--ink); }
button.theme-option[aria-pressed="true"] { border-color: var(--cyan); background: var(--cyan-soft); color: var(--cyan); }
.theme-swatch { display: inline-block; width: 22px; height: 17px; border-radius: 4px; border: 1px solid #94a3b8; }
.theme-swatch-dark { background: linear-gradient(90deg, #252b36 30%, #131720 30%); }
.theme-swatch-light { background: linear-gradient(90deg, #e1e7ef 30%, #fff 30%); }
/* Legacy page styles and inline headings also participate in the light palette. */
[data-theme="light"] .security-card h2 { color: var(--ink) !important; }
[data-theme="light"] .site-note strong { color: var(--ink); }
[data-theme="light"] .log-controls a { color: var(--muted); }
[data-theme="light"] .trade-table tr, [data-theme="light"] .scenario-table tr { border-color: var(--line); background: var(--surface-inset); }
[data-theme="light"] input[type="file"]::file-selector-button { border-color: var(--input-border); border-radius: 5px; background: var(--cyan-soft); color: var(--cyan); }
[data-theme="light"] .toggle-row { color: var(--text-secondary); }
[data-theme="light"] .source-tabs input:checked + label { background: var(--active-bg); color: var(--active-ink); }
[data-theme="light"] .badge:not(.ok):not(.warn):not(.info), [data-theme="light"] .site-badge { color: var(--label); }
[data-theme="light"] .site-badge.custom { color: #6d28d9; border-color: #ddd6fe; }
@media (max-width: 720px) {
  .auth-theme-switch { top: 14px; right: 16px; min-width: 38px; padding: 8px; }
  .auth-theme-switch [data-theme-label] { display: none; }
  .theme-settings-head { flex-direction: column; align-items: stretch; gap: 16px; }
  .theme-options { width: 100%; }
  button.theme-option { flex: 1; }
}
