/* ============================================================================
   FundWatch — "Holdings Overlap Terminal" theme
   Matches the FundWatch.html mockup: ink-navy instrument panel, teal accent,
   IBM Plex (Mono data / Sans labels / Sans Condensed wordmark), blue weight-heat
   cells, per-row overlap heat bar. Restyle only — no markup logic.
   ========================================================================== */

/* ---- Self-hosted IBM Plex ---- */
@font-face { font-family:'IBM Plex Mono'; font-style:normal; font-weight:400; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-mono-400.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Mono'; font-style:normal; font-weight:500; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-mono-500.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Mono'; font-style:normal; font-weight:600; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-mono-600.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Mono'; font-style:italic; font-weight:400; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-mono-400-italic.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans'; font-style:normal; font-weight:400; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-sans-400.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans'; font-style:normal; font-weight:500; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-sans-500.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans'; font-style:normal; font-weight:600; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-sans-600.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans Condensed'; font-style:normal; font-weight:700; font-display:swap;
  src:url('/static/fonts/ibm-plex/plex-sans-cond-700.woff2') format('woff2'); }

/* ---- Design tokens (from the mockup) ---- */
:root {
  --bg-0:#070b12; --bg-1:#0b111b; --bg-2:#101826; --bg-3:#15202f;
  --line:#1b2636; --line2:#243246;
  --fg:#e2e9f2; --fg-dim:#92a2b8; --fg-faint:#566a80;
  --up:#43d98c; --down:#ff6573; --stale:#f2b14e; --accent:#37dccb;
  --heat:77,141,255;                 /* weight-heat blue (also used in matrix.py cellStyle) */
  --mono:'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans:'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --cond:'IBM Plex Sans Condensed', 'IBM Plex Sans', sans-serif;
}

/* ============================ Base ====================================== */
html, body {
  background-color: var(--bg-0);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
body {
  background-image:
    radial-gradient(1100px 460px at 82% -16%, rgba(55,220,203,.05), transparent 64%),
    radial-gradient(900px 460px at -5% -10%, rgba(77,141,255,.045), transparent 60%);
  background-attachment: fixed;
}
.q-layout, .q-page-container, .q-page, .nicegui-content { background: transparent !important; }
.nicegui-content { padding: 0 !important; gap: 0 !important; }

::-webkit-scrollbar { width:10px; height:10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background:#1d2940; border:2px solid var(--bg-0); border-radius:0; }
::-webkit-scrollbar-thumb:hover { background:#2b3a58; }
:focus-visible { outline:2px solid var(--accent) !important; outline-offset:1px; border-radius:3px; }

/* Bootstrap .row/.col collide with Quasar's same-named flex grid (NiceGUI uses it);
   Bootstrap's `.row > * {width:100%}` stacks flex children. Neutralize its grid;
   Bootstrap is kept only for utilities. Component widths defined later still win. */
.row { margin: 0; }
.row > * { width: auto; max-width: none; padding-left: 0; padding-right: 0; }
.container, .container-fluid { width: auto; max-width: none; margin: 0; padding: 0; }

/* ============================ Command bar =============================== */
.cmd-bar.q-header, .q-header.cmd-bar {
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 18px; row-gap: 8px;
  background: var(--bg-2) !important;
  border-bottom: 1px solid var(--line2);
  box-shadow: 0 1px 0 rgba(55,220,203,.06), 0 10px 26px -18px #000;
  padding: 10px 18px; min-height: 0;
}

.brand { line-height: 1; }
.brand-name { font-family: var(--cond); font-weight: 700; font-size: 19px; letter-spacing: .12em; color: var(--fg); }
.brand-name .wm-accent { color: var(--accent); }
.brand-sub { font-family: var(--sans); font-size: 9px; letter-spacing: .30em; color: var(--fg-faint);
  text-transform: uppercase; margin-top: 4px; }

.cmd-cluster { gap: 16px; }
.tlm { line-height: 1.25; }
.tlm-label { font-family: var(--sans); font-size: 9px; letter-spacing: .24em; color: var(--fg-faint); text-transform: uppercase; }
.tlm-value { font-family: var(--mono); font-size: 12.5px; color: var(--fg); font-weight: 500; font-variant-numeric: tabular-nums; }

/* status pill — render_tick drives is-live / is-paused / is-stale / is-starting */
.status-pill.q-badge {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; font-weight: 600;
  padding: 5px 11px 5px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
}
.status-pill.q-badge::before { content:''; width:6px; height:6px; border-radius:50%; background: currentColor; opacity:.85; }
.status-pill.is-live     { background: var(--accent); color:#06201c; box-shadow: 0 0 14px rgba(55,220,203,.4); }
.status-pill.is-paused   { background: var(--stale);  color:#241803; box-shadow: 0 0 14px rgba(242,177,78,.3); }
.status-pill.is-stale    { background: var(--down);   color:#2b0c11; box-shadow: 0 0 14px rgba(255,101,115,.35); }
.status-pill.is-starting { background: var(--bg-3);   color: var(--fg-dim); }

/* sweep interval control: SWEEP [n] SEC */
.sweep-ctl { display: flex; align-items: center; gap: 6px; }
.sweep-lab { font-family: var(--sans); font-size: 9px; letter-spacing: .2em; color: var(--fg-faint); text-transform: uppercase; }

/* ============================ Buttons ================================== */
.q-btn.cmd-btn {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 600;
  color: var(--fg-dim); background: var(--bg-2); border: 1px solid var(--line2); border-radius: 6px;
  min-height: 32px; padding: 0 12px;
}
.q-btn.cmd-btn .q-icon { font-size: 13px; }
.q-btn.cmd-btn:hover { color: var(--accent); border-color: rgba(55,220,203,.5); background: rgba(55,220,203,.07); }
.q-btn.cmd-btn-accent { background: var(--accent); color:#06201c; border-color: var(--accent); font-weight: 700; }
.q-btn.cmd-btn-accent:hover { background:#5fe8da; color:#06201c; box-shadow: 0 0 14px rgba(55,220,203,.4); }

/* ============================ Fields =================================== */
.cmd-field .q-field__control, .cmd-num .q-field__control {
  min-height: 32px; height: 32px; background: var(--bg-1); border: 1px solid var(--line2);
  border-radius: 6px; padding: 0 10px;
}
.cmd-field .q-field__control::before, .cmd-field .q-field__control::after,
.cmd-num .q-field__control::before, .cmd-num .q-field__control::after { display: none !important; }
.cmd-field .q-field__native, .cmd-num .q-field__native,
.cmd-field input, .cmd-num input { color: var(--fg) !important; font-family: var(--mono); font-size: 13px; }
.cmd-field .q-field__native::placeholder { color: var(--fg-faint); }
.cmd-field.q-field--focused .q-field__control, .cmd-num.q-field--focused .q-field__control {
  border-color: rgba(55,220,203,.6); box-shadow: 0 0 0 2px rgba(55,220,203,.12);
}
.cmd-field { width: 300px; } .cmd-num { width: 62px; }

/* ============================ Control strip ============================ */
.control-strip {
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 8px;
  padding: 11px 18px; border-bottom: 1px solid var(--line); background: var(--bg-1); width: 100%;
}
.strip-label { font-family: var(--sans); font-size: 9px; letter-spacing: .22em; color: var(--fg-faint); text-transform: uppercase; }

.fund-box { gap: 6px; }
.fund-box .q-chip.fund-chip {
  background: var(--bg-2); border: 1px solid var(--line2); color: var(--fg); border-radius: 6px;
  height: 26px; margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .03em;
}
.fund-box .q-chip.fund-chip-error { background: rgba(255,101,115,.08); border-color: rgba(255,101,115,.5); color: var(--down); }
.fund-box .q-chip .q-chip__icon--remove { color: var(--fg-faint); opacity: .7; font-size: 16px; }
.fund-box .q-chip .q-chip__icon--remove:hover { color: var(--down); opacity: 1; }

/* ============================ Legend strip ============================= */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px; row-gap: 4px;
  padding: 7px 18px; border-bottom: 1px solid var(--line); background: var(--bg-1);
  font-family: var(--sans); font-size: 10px; letter-spacing: .04em; color: var(--fg-faint); text-transform: uppercase;
}
.legend .lg-grp { display: inline-flex; align-items: center; gap: 7px; }
.legend b { color: var(--fg-dim); font-weight: 600; letter-spacing: .14em; }
.lg-up { color: var(--up); } .lg-down { color: var(--down); }
.lg-stale { color: var(--stale); font-style: italic; } .lg-live { color: var(--accent); }
.lg-heat { width: 34px; height: 9px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(77,141,255,.06), rgba(77,141,255,.5)); }

/* ============================ Matrix (AG Grid v33) ===================== */
.matrix-wrap { padding: 14px 18px 0; width: 100%; }
.matrix-grid {
  width: 100%; height: calc(100vh - 246px); min-height: 300px;
  border: 1px solid var(--line); border-radius: 7px; overflow: hidden;
  box-shadow: 0 20px 54px -30px #000;
  --ag-background-color: var(--bg-1);
  --ag-foreground-color: var(--fg);
  --ag-border-color: var(--line);
  --ag-row-border-color: var(--line);
  --ag-header-background-color: var(--bg-2);
  --ag-header-foreground-color: var(--fg-dim);
  --ag-header-column-border: none;
  --ag-row-hover-color: var(--bg-3);
  --ag-odd-row-background-color: rgba(255,255,255,.012);
  --ag-accent-color: var(--accent);
  --ag-selected-row-background-color: rgba(55,220,203,.10);
  --ag-font-family: var(--mono);
  --ag-font-size: 12.5px;
  --ag-header-height: 38px;
  --ag-row-height: 34px;
  --ag-cell-horizontal-padding: 14px;
  --ag-wrapper-border-radius: 7px;
  --ag-border-radius: 0;
}
.matrix-grid .ag-header-cell-text {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 600; color: var(--fg-dim);
}
.matrix-grid .ag-header-cell.col-error .ag-header-cell-text { color: var(--down); }
.matrix-grid .ag-cell { font-variant-numeric: tabular-nums; }
.matrix-grid .ag-pinned-left-header,
.matrix-grid .ag-pinned-left-cols-container {
  background: rgba(0,0,0,.16); border-right: 1px solid var(--line2); box-shadow: 8px 0 16px -10px rgba(0,0,0,.7);
}
/* price cues — colour only; the ▲/▼ glyph is part of the cell text (matrix.py) */
.matrix-grid .ag-cell.price-up    { color: var(--up) !important; }
.matrix-grid .ag-cell.price-down  { color: var(--down) !important; }
.matrix-grid .ag-cell.price-stale { color: var(--stale) !important; font-style: italic; }

/* ============================ Footer status bar ======================= */
.status-foot.q-footer, .q-footer.status-foot {
  display: flex; align-items: center; justify-content: space-between; column-gap: 12px; row-gap: 4px; flex-wrap: wrap;
  padding: 7px 18px; background: var(--bg-2) !important; border-top: 1px solid var(--line);
  font-family: var(--sans); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-faint);
}
.foot-grp { display: inline-flex; align-items: center; gap: 9px; }
.foot-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.foot-dot.paused { background: var(--stale); box-shadow: 0 0 8px var(--stale); }
.foot-dot.stale  { background: var(--down);  box-shadow: 0 0 8px var(--down); }
.foot-num { font-family: var(--mono); color: var(--fg-dim); letter-spacing: .06em; }
.foot-strong { color: var(--fg-dim); }

/* ============================ Responsive ============================== */
@media (max-width: 820px) {
  .cmd-bar.q-header { padding: 9px 12px; column-gap: 12px; }
  .brand-name { font-size: 17px; }
  .cmd-cluster { gap: 10px 12px; flex-wrap: wrap !important; width: 100%; margin-left: 0; }
  .cmd-field { width: 100%; }
  .control-strip, .legend { padding: 9px 12px; }
  .matrix-wrap { padding: 10px 8px 0; }
  .matrix-grid { height: calc(100vh - 320px); border-radius: 5px; }
  .legend { font-size: 9px; column-gap: 12px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
