/* Magnify Finance — brand theme (green/black from magnifyequity.com)
   Chart pair green #4E864F / blue #176cae validated for CVD + contrast in both
   modes (dataviz six-checks validator, 2026-08). */
:root {
  color-scheme: light;
  --page: #f6f8f6;
  --surface: #fcfdfc;
  --ink: #0e120f;
  --ink-2: #4c544d;
  --muted: #83887f;
  --grid: #e2e6e1;
  --baseline: #c2c8c0;
  --border: rgba(14, 18, 15, 0.10);
  --s1: #4E864F;  /* magnify green */
  --s2: #176cae;  /* magnify blue */
  --s3: #eda100;  /* gold */
  --s4: #e87ba4;  /* magenta */
  --s5: #4a3aa7;  /* violet */
  --seq-250: #a8c8a8;
  --seq-450: #4E864F;
  --good: #0ca30c;
  --good-text: #1c7c1c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --wash: rgba(78, 134, 79, 0.09);
  --shadow: 0 1px 2px rgba(14,18,15,.05), 0 4px 16px rgba(14,18,15,.06);
  --radius: 10px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0a0c0b;
  --surface: #131614;
  --ink: #f4f6f3;
  --ink-2: #b9c1b8;
  --muted: #848b82;
  --grid: #242923;
  --baseline: #333a32;
  --border: rgba(244, 246, 243, 0.10);
  --s1: #63A664;
  --s2: #3B8CC9;
  --s3: #c98500;
  --s4: #d55181;
  --s5: #9085e9;
  --seq-250: #2f4a30;
  --seq-450: #63A664;
  --good-text: #35b435;
  --wash: rgba(99, 166, 100, 0.12);
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 16px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0a0c0b;
    --surface: #131614;
    --ink: #f4f6f3;
    --ink-2: #b9c1b8;
    --muted: #848b82;
    --grid: #242923;
    --baseline: #333a32;
    --border: rgba(244, 246, 243, 0.10);
    --s1: #63A664;
    --s2: #3B8CC9;
    --s3: #c98500;
    --s4: #d55181;
    --s5: #9085e9;
    --seq-250: #2f4a30;
    --seq-450: #63A664;
    --good-text: #35b435;
    --wash: rgba(99, 166, 100, 0.12);
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 4px 16px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex: none; padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
}
.brand { padding: 4px 10px 14px; }
.brand img { width: 100%; max-width: 170px; height: auto; display: block; }
.brand .logo-dark { display: none; }
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
.brand small { display: block; font-weight: 600; color: var(--muted); font-size: 10.5px; margin-top: 6px; letter-spacing: .14em; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: var(--ink-2); border: 0; background: none; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--wash); }
.nav-item.active { background: var(--wash); color: var(--ink); font-weight: 600; }
.nav-item .badge {
  margin-left: auto; background: var(--critical); color: #fff;
  font-size: 11px; font-weight: 600; border-radius: 99px; padding: 0 7px; line-height: 18px;
}
.nav-sep { margin: 10px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sidebar .spacer { flex: 1; }
#agent-nav { display: contents; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 12.5px; }
.topbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px;
  animation: card-in .28s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}

/* insight callout strip */
.insights { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 0; }
.insight {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--s1); border-radius: 8px;
  padding: 9px 13px; font-size: 12.5px; color: var(--ink-2);
  box-shadow: var(--shadow); flex: 1; min-width: 230px;
}
.insight b { color: var(--ink); }
.insight.up { border-left-color: var(--good); }
.insight.down { border-left-color: var(--serious); }
.insight .ico { font-size: 15px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.tile.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.tile.clickable:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(14,18,15,.08), 0 8px 22px rgba(14,18,15,.1); border-color: var(--s1); }
.tile .label { font-size: 12px; color: var(--ink-2); }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 3px; letter-spacing: -.01em; }
.tile .value.hero { font-size: 34px; }
.tile .delta { font-size: 12px; margin-top: 3px; color: var(--muted); }
.tile .delta.up { color: var(--good-text); }
.tile .delta.down { color: var(--critical); }
.tile svg { display: block; margin-top: 6px; }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; font-size: 13px;
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--s1); border-color: var(--s1); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.ghost { border-color: transparent; }
.btn.danger { color: var(--critical); }

input[type=text], input[type=search], input[type=number], input[type=date], input[type=password], select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--s1); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; padding: 8px 10px;
  border-bottom: 1px solid var(--baseline); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data tr:hover td { background: var(--wash); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--critical); }
.pos { color: var(--good-text); }
.scroll-x { overflow-x: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 1px 8px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip.ok { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.chip.warn { color: var(--serious); }
.chip.bad { color: var(--critical); }
.conf-low { color: var(--serious); }
.conf-none { color: var(--critical); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters > * { flex: none; }
.filters input[type=search] { width: 230px; }

.pill-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pill-toggle button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--ink-2); font-size: 12.5px; }
.pill-toggle button.active { background: var(--wash); color: var(--ink); font-weight: 600; }

/* chart bits */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin: 4px 0 2px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.tooltip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 8px 11px; font-size: 12.5px; display: none; max-width: 320px;
}
.tooltip .t-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 16px; }
.tooltip .t-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* P&L table */
.pnl-table td, .pnl-table th { padding: 6px 10px; }
.pnl-table .sect td { font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; color: var(--muted); padding-top: 16px; border-bottom: 0; }
.pnl-table .totalrow td { font-weight: 700; border-top: 1px solid var(--baseline); }
.pnl-table .expand { cursor: pointer; }
.pnl-table .expand .arrow { display: inline-block; width: 14px; color: var(--muted); transition: transform .12s; }
.pnl-table .expand.open .arrow { transform: rotate(90deg); }
.pnl-table .subrow td:first-child { padding-left: 34px; color: var(--ink-2); }
.pnl-table .netrow td { font-weight: 750; font-size: 14.5px; border-top: 2px solid var(--ink); }

/* drawer */
.drawer-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 94vw); z-index: 41;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 20px 22px; overflow-y: auto; display: none;
}
.drawer h3 { margin: 0 0 4px; font-size: 15px; }
.drawer .row { margin: 12px 0; }
.drawer label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.drawer input, .drawer select, .drawer textarea { width: 100%; }

.bulkbar {
  position: sticky; bottom: 12px; display: none; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--s1); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 14px; margin-top: 10px; z-index: 10;
}

/* login */
#login-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: var(--page);
}
.login-card { width: 340px; text-align: center; }
.login-card h2 { margin: 4px 0 2px; }
.login-card .err { color: var(--critical); font-size: 12.5px; min-height: 17px; margin-top: 8px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.mt { margin-top: 14px; }
.hidden { display: none !important; }
a { color: var(--s1); text-decoration: none; }
a:hover { text-decoration: underline; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page); border-radius: 8px; padding: 9px 16px;
  font-size: 13px; z-index: 90; opacity: 0; transition: opacity .18s;
}
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .spacer, .brand small { display: none; }
  .nav-item { width: auto; }
}

/* ===================== elevation pass — clean & branded ===================== */

/* Signature look: the sidebar is always black with the white logo and green
   accents, in both themes — the content area keeps its light/dark choice. */
.sidebar {
  background: #0b0d0c;
  border-right: 1px solid rgba(255,255,255,.08);
}
.sidebar .logo-light { display: none !important; }
.sidebar .logo-dark { display: block !important; }
.sidebar .brand small { color: #6f7a6f; letter-spacing: .18em; }
.sidebar .nav-item { color: #b9c1b8; }
.sidebar .nav-item:hover { background: rgba(99,166,100,.12); color: #f4f6f3; }
.sidebar .nav-item.active {
  background: linear-gradient(90deg, rgba(99,166,100,.22), rgba(99,166,100,.08));
  color: #fff; font-weight: 600;
  box-shadow: inset 2px 0 0 #63A664;
}
.sidebar .nav-sep { color: #5d665d; }

/* typography rhythm */
.topbar h1 { font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.tile .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 650; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.tile .label::before {
  content: ""; width: 3px; height: 10px; border-radius: 2px;
  background: var(--s1); flex: none; opacity: .8;
}
.tile .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.tile .value.hero { font-size: 38px; }

/* cards & tiles */
.card { border-radius: 12px; }
.card.tile { background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 94%, var(--s1))); }
.card > b { font-size: 13.5px; letter-spacing: -.01em; }

/* buttons & controls */
.btn { border-radius: 9px; transition: background .12s, transform .08s; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #579458, #4E864F);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(14,18,15,.25);
}
.pill-toggle { border-radius: 9px; }
.pill-toggle button.active { background: var(--wash); color: var(--s1); font-weight: 650; }
input:focus, select:focus, textarea:focus {
  border-color: var(--s1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--s1) 18%, transparent);
}

/* tables */
table.data th { font-size: 11px; padding: 9px 12px; }
table.data td { padding: 8px 12px; }
table.data tr:hover td { background: color-mix(in srgb, var(--s1) 6%, transparent); }

/* drawer */
.drawer { border-radius: 14px 0 0 14px; }
.drawer-back { backdrop-filter: blur(2px); }

/* chips */
.chip { border-radius: 7px; padding: 2px 8px; }
.chip.ok { background: color-mix(in srgb, var(--good) 10%, transparent); }
.chip.warn { background: color-mix(in srgb, var(--serious) 10%, transparent); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--baseline) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--baseline); border-radius: 5px; }
*::-webkit-scrollbar-track { background: transparent; }

/* login moment: black brand backdrop */
#login-overlay { background: #0b0d0c; }
#login-overlay .login-card { background: #131614; border-color: rgba(255,255,255,.09); }
#login-overlay .login-card, #login-overlay .muted { color: #b9c1b8; }
#login-overlay .logo-light { display: none !important; }
#login-overlay .logo-dark { display: block !important; }
#login-overlay input { background: #0e100f; border-color: rgba(255,255,255,.12); color: #f4f6f3; }

/* ===== Dynamix Pro wordmark — same construction as the Optix Pro logo:
   DYNAM + [magnifier-i cropped from the Magnify master wordmark] + X + PRO.
   Crop ratios from the Optix component: left 71.47%, width 8.53%,
   top 22.49%, height 50.41%; i is 1.094x cap-height; Space Grotesk 700. ===== */
.dxlogo {
  display: inline-flex; align-items: baseline; line-height: 1;
  font-family: 'Space Grotesk', 'Futura', 'Avenir Next', system-ui, sans-serif;
  white-space: nowrap;
}
.dx-t {
  font-size: var(--cap); font-weight: 700; letter-spacing: -0.02em;
  line-height: 1; color: #0f172a;
}
.dx-i {
  display: inline-block; align-self: center;
  width: calc(var(--cap) * 0.529); height: calc(var(--cap) * 0.769);
  margin-left: calc(var(--cap) * 0.045); margin-right: calc(var(--cap) * -0.01);
  transform: translateY(calc(var(--cap) * 0.01));
  background-image: url('/logo-full.png?v=18');
  background-size: calc(var(--cap) * 6.202) calc(var(--cap) * 1.526);
  background-position: calc(var(--cap) * -4.433) calc(var(--cap) * -0.343);
  background-repeat: no-repeat;
}
.dx-pro {
  font-size: calc(var(--cap) * 0.66); font-weight: 700; letter-spacing: 0.10em;
  line-height: 1; color: #1f6f3e;
  margin-left: calc(var(--cap) * 0.18);
  transform: translateY(calc(var(--cap) * -0.05));
}
.dxlogo-white .dx-t { color: #ffffff; }
.dxlogo-white .dx-pro { color: rgba(255,255,255,0.7); }
.dxlogo-white .dx-i { background-image: url('/logo-full-white.png?v=18'); }
.brand .dxlogo { padding: 2px 0 0 2px; }

/* single-file wordmark image */
.brand .wordmark-img { width: 100%; max-width: 178px; height: auto; display: block; padding: 2px 0 0 2px; }
#login-overlay .wordmark-img { width: 250px; margin: 0 auto 6px; display: block; }

/* settings submenu */
.nav-item.sub { padding-left: 28px; font-size: 12.5px; }
#settings-menu { display: contents; }
#settings-menu.hidden { display: none; }

/* agent-restricted mode: no sidebar, clean single-page scorecard */
body.agent-mode .sidebar { display: none; }
body.agent-mode .main { padding: 22px 4vw 60px; }
body.agent-mode .agent-mode-logo { filter: none !important; }
