/* Shared chrome for all FiAI pages: palette, nav bar, page head, controls. */

:root {
  color-scheme: light;
  --page:      #f9f9f7;
  --surface-1: #fcfcfb;
  --ink-1:     #0b0b0b;
  --ink-2:     #52514e;
  --muted:     #898781;
  --hairline:  #e1e0d9;
  --ring:      rgba(11,11,11,0.10);
  --loss:      #d03b3b;
  --gain:      #006300;
  /* categorical slots, fixed order (validated reference palette) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --fold: #898781;  /* neutral for spaces beyond the 8 slots */
  /* slate band: the "world state" strip on Today/Economy pages */
  --band:      #dfe6f0;
  --band-edge: #c3cede;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:      #0d0d0d;
    --surface-1: #1a1a19;
    --ink-1:     #ffffff;
    --ink-2:     #c3c2b7;
    --muted:     #898781;
    --hairline:  #2c2c2a;
    --ring:      rgba(255,255,255,0.10);
    --loss:      #e66767;
    --gain:      #0ca30c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --band:      #1c2534;
    --band-edge: #35415a;
    }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:      #0d0d0d;
  --surface-1: #1a1a19;
  --ink-1:     #ffffff;
  --ink-2:     #c3c2b7;
  --muted:     #898781;
  --hairline:  #2c2c2a;
  --ring:      rgba(255,255,255,0.10);
  --loss:      #e66767;
  --gain:      #0ca30c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --band:      #1c2534;
  --band-edge: #35415a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink-1);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column;
}

/* ---- App nav: dark bar, navigation only (matches the todo app's header).
   Deliberately dark in both themes; the active tab is marked by brightness,
   not hue. Page actions live with the content, not in the nav bar. */
.appnav {
  --nav-bg: #0c0d10;
  --nav-text: #ffffff;
  --nav-dim: #b7bcc6;
  --nav-pill: rgba(255, 255, 255, 0.13);
  --nav-edge: rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; gap: 26px;
  padding: 13px 22px;
  position: sticky; top: 0; z-index: 10;
  background: var(--nav-bg); color: var(--nav-text);
  border-bottom: 1px solid var(--nav-edge);
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
}
.appnav h1 {
  font-size: 17px; margin: 0; font-weight: 700;
  letter-spacing: 0.02em; flex: none; white-space: nowrap;
  color: var(--nav-text);
}
.tabs { display: flex; gap: 6px; }
.tabs .tab {
  border: none; padding: 6px 13px; border-radius: 7px;
  font: inherit; font-size: 13px;
  color: var(--nav-dim); background: transparent;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
  transition: color 0.12s, background 0.12s;
}
.tabs .tab:hover { color: var(--nav-text); }
.tabs .tab.active {
  background: var(--nav-pill);
  color: var(--nav-text);
  font-weight: 600;
}

.pagehead {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px 8px;
}
.pagehead h2 { font-size: 20px; margin: 0; font-weight: 700; }
.pagehead .asof { color: var(--muted); font-size: 12px; }
.pagehead .spacer { flex: 1; }
.stat { color: var(--ink-2); font-size: 12px; }
.stat b { color: var(--ink-1); }

.controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 0 16px 10px;
}
.controls label { font-size: 12px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
select, button.ctl {
  font: inherit; font-size: 13px;
  color: var(--ink-1); background: var(--surface-1);
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 4px 8px; cursor: pointer;
}
button.ctl:hover, select:hover { border-color: var(--muted); }
button.ctl[aria-pressed="true"] { border-color: var(--ink-2); font-weight: 600; }

#tooltip {
  position: fixed; z-index: 10; pointer-events: none; display: none;
  max-width: 300px; padding: 10px 12px;
  background: var(--surface-1); color: var(--ink-1);
  border: 1px solid var(--hairline); border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  font-size: 12px;
}
#tooltip h3 { margin: 0 0 2px; font-size: 13px; }
#tooltip .sub { color: var(--muted); margin-bottom: 6px; }
#tooltip table { border-collapse: collapse; }
#tooltip td { padding: 1px 0; font-variant-numeric: tabular-nums; }
#tooltip td:first-child { color: var(--ink-2); padding-right: 14px; }
#tooltip .desc { margin-top: 6px; color: var(--ink-2); font-style: italic; }

footer {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 6px 16px 12px; font-size: 11px; color: var(--muted);
}

.chip { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }

/* ---- Slate band: full-width strip of small boxes under the nav.
   Its palette is deliberately its own (cool blue-grey) so it separates from
   the page in both themes. Collapsible; state is the page's to persist. */
.band {
  display: flex; align-items: stretch;
  padding: 6px 16px;
  background: var(--band); border-bottom: 1px solid var(--band-edge);
}
.band .bx {
  flex: 0 1 185px; min-width: 0;
  padding: 2px 16px 3px;
}
.band .bx + .bx { border-left: 1px solid var(--band-edge); }
.band .bl {
  font-size: 8.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
}
.band .tr {
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
  font-size: 10.5px; line-height: 1.45; min-width: 0;
  text-decoration: none; color: inherit;
}
.band a.tr:hover .n { opacity: 1; }
.band .tr .n {
  opacity: .72; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.band .tr .v { font-weight: 700; flex: none; }
.band .fold {
  margin-left: auto;
  flex: none; border: none; cursor: pointer; font: inherit;
  width: 20px; height: 20px; border-radius: 5px; align-self: center;
  display: flex; align-items: center; justify-content: center; font-size: 9px;
  background: transparent; color: var(--muted);
}
.band .fold:hover { color: var(--ink-1); }
.band.closed .bx { display: none; }
.band.closed { padding: 3px 16px; }
.gain { color: var(--gain); } .loss { color: var(--loss); }
