@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light;
  --bg: #e9edf0;
  --panel: #ffffff;
  --panel-2: #f3f6f8;
  --line: #d5dce2;
  --ink: #15202a;
  --ink-2: #3a4752;
  --muted: #5b6a75;
  --accent: #8c6a12;
  --accent-soft: #f1e6c8;
  --good: #0a7d24;
  --bad: #c2312f;
  --warn: #9a6400;
  --track: #dfe5ea;
  --grid: #e6ebef;
  --shadow: 0 1px 0 rgba(21, 32, 42, 0.04);
  --pad: 20px;
  --gap: 16px;
  --radius-lg: 14px;
  --radius-sm: 8px;
}
:root[data-accent="teal"] { --accent: #0b7a6e; --accent-soft: #cdebe6; }
:root[data-accent="blue"] { --accent: #2370cd; --accent-soft: #d6e6fa; }
:root[data-accent="violet"] { --accent: #6a4ce2; --accent-soft: #e3ddfb; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #18222c;
    --panel: #1f2b37;
    --panel-2: #243240;
    --line: #2f3e4c;
    --ink: #e8edf1;
    --ink-2: #c3ccd3;
    --muted: #8f9eab;
    --accent: #d6ae4b;
    --accent-soft: #3a3523;
    --good: #3ccb6a;
    --bad: #f07071;
    --warn: #fbb315;
    --track: #2a3846;
    --grid: #283643;
    --shadow: none;
  }
  :root:not([data-theme="light"])[data-accent="teal"] { --accent: #2fc1ad; --accent-soft: #1d3a3a; }
  :root:not([data-theme="light"])[data-accent="blue"] { --accent: #5aa2f0; --accent-soft: #1f3550; }
  :root:not([data-theme="light"])[data-accent="violet"] { --accent: #a796f2; --accent-soft: #2e2a4f; }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #18222c;
  --panel: #1f2b37;
  --panel-2: #243240;
  --line: #2f3e4c;
  --ink: #e8edf1;
  --ink-2: #c3ccd3;
  --muted: #8f9eab;
  --accent: #d6ae4b;
  --accent-soft: #3a3523;
  --good: #3ccb6a;
  --bad: #f07071;
  --warn: #fbb315;
  --track: #2a3846;
  --grid: #283643;
  --shadow: none;
}
:root[data-theme="dark"][data-accent="teal"] { --accent: #2fc1ad; --accent-soft: #1d3a3a; }
:root[data-theme="dark"][data-accent="blue"] { --accent: #5aa2f0; --accent-soft: #1f3550; }
:root[data-theme="dark"][data-accent="violet"] { --accent: #a796f2; --accent-soft: #2e2a4f; }
:root[data-density="compact"] { --pad: 14px; --gap: 10px; }

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "lnum" 1;
  min-height: 100vh;
  padding: 0 max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.num { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------------- header */
.top {
  max-width: 1240px; margin: 0 auto; padding: 18px 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 17px; white-space: nowrap; }
.mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.mark.big { width: 44px; height: 44px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { border-color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 700; border: 1px solid var(--line); background: var(--panel); white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--good); }
.pill.warn::before { background: var(--warn); }
.pill.stop::before { background: var(--bad); border-radius: 2px; }
.link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.link i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.link.on i { background: var(--good); animation: beat 2.4s ease-in-out infinite; }
.link.off i { background: var(--warn); }
@keyframes beat { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (max-width: 560px) { .link span { display: none; } .brand h1 { font-size: 15px; } }

/* ---------------------------------------------------------------- grid & cards */
.grid {
  max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap);
}
.card {
  grid-column: span 12; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--pad); min-width: 0; box-shadow: var(--shadow);
}
@media (min-width: 900px) {
  .card.w-half { grid-column: span 6; }
  .card.w-third { grid-column: span 4; }
  .card.w-two { grid-column: span 8; }
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; }
.card-head .aside { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); margin: 6px 0 2px; }

/* ---------------------------------------------------------------- hero: the runway */
.hero { padding-top: calc(var(--pad) + 4px); }
.hero-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 32px; }
.total { font-size: clamp(44px, 9vw, 76px); font-weight: 800; line-height: 0.95; letter-spacing: -0.035em; }
.total-cap { font-size: 14px; color: var(--muted); margin-top: 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.fact b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.fact span { font-size: 13px; color: var(--muted); }

.runway { margin-top: 26px; }
.runway-track { position: relative; height: 46px; }
.zone {
  position: absolute; top: 12px; height: 14px; background: var(--track);
  border-left: 2px solid var(--panel);
}
.zone:first-child { border-radius: 7px 0 0 7px; border-left: 0; }
.zone:last-child { border-radius: 0 7px 7px 0; }
.zone.now { background: var(--accent-soft); }
.zone-label {
  position: absolute; top: 30px; font-size: 11.5px; color: var(--muted); transform: translateX(-50%); white-space: nowrap;
}
.zone.now + .zone-label, .zone-label.now { color: var(--ink); font-weight: 700; }
.pause-line { position: absolute; top: 4px; bottom: 14px; left: 0; width: 3px; background: var(--bad); border-radius: 2px; }
.zero-line { position: absolute; top: 6px; height: 26px; width: 1px; background: var(--muted); }
.marker {
  position: absolute; top: 3px; width: 32px; height: 32px; margin-left: -16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent);
  transition: left 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) { .marker { transition: none; } .link.on i { animation: none; } }
.runway-legend { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.runway-legend b { color: var(--ink); font-weight: 700; }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; min-height: 240px; }
.chart .u-legend { display: none; }
.u-axis { color: var(--muted); }
.tip {
  position: fixed; z-index: 30; pointer-events: none; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--panel); font-size: 13px; line-height: 1.4; max-width: 240px;
}
.tip b { font-weight: 700; }

/* ---------------------------------------------------------------- lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: 12px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; padding-top: 2px; }
.row-main { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row-main b { font-weight: 700; }
.row-sub { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.bar { height: 4px; background: var(--track); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.side { font-weight: 700; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.on { background: var(--accent-soft); color: var(--ink); border-color: transparent; }

/* ---------------------------------------------------------------- stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.tile { background: var(--panel); padding: 12px 14px; }
.tile b { display: block; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.tile span { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { padding-right: 0; padding-left: 10px; }
td.c-cost, th:nth-child(5) { padding-right: 24px; }
.losses { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.losses b { color: var(--ink); }
.pips { display: inline-flex; gap: 6px; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pip.used { background: var(--bad); border-color: var(--bad); }
.more { margin-top: 12px; }
.text-btn { background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 700; cursor: pointer; }
.text-btn:hover { text-decoration: underline; }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0; }
  table.stack td.c-time, table.stack td.c-px, table.stack td.c-n { font-size: 13px; color: var(--muted); }
  table.stack td.c-cost { display: none; }
}

/* ---------------------------------------------------------------- per-market bars */
.mbars { display: grid; gap: 10px; }
.mbar { display: grid; grid-template-columns: 92px 1fr 70px; align-items: center; gap: 10px; font-size: 14px; }
.mbar-track { position: relative; height: 10px; background: var(--track); border-radius: 5px; }
.mbar-track .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.mbar-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.mbar-track i.up { background: var(--good); left: 50%; }
.mbar-track i.down { background: var(--bad); right: 50%; }

/* ---------------------------------------------------------------- alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line); margin-top: 14px; font-size: 14px; }
.alert.bad { border-color: var(--bad); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }

.foot { max-width: 1240px; margin: 20px auto 0; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- drawer */
.drawer { position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 20, 0.45); display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-panel {
  width: min(380px, 100%); height: 100%; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line);
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer-head h2 { font-size: 17px; }
fieldset { border: 0; margin: 16px 0 0; padding: 0; }
legend { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; padding: 0; }
.seg > div { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px;
}
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.swatches button { display: inline-flex; align-items: center; gap: 8px; }
.swatches i { width: 14px; height: 14px; border-radius: 50%; }
.card-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.card-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel); }
.card-list li:first-child { border-top: 0; }
.card-list li.dragging { opacity: 0.5; }
.card-list label { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.card-list input { width: 18px; height: 18px; accent-color: var(--accent); }
.card-list .mini { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 3px 7px; font-size: 12px; cursor: pointer; min-width: 30px; }
.grip { cursor: grab; color: var(--muted); padding: 0 2px; user-select: none; }
.drawer-foot { display: flex; justify-content: space-between; margin-top: 18px; }
.drawer-foot form { margin: 0; }

/* ---------------------------------------------------------------- sign-in */
body.login { display: grid; place-items: center; padding-top: 0; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 32px 28px; display: grid; justify-items: center; gap: 10px; text-align: center; margin: 40px 0;
}
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0; }
.google {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 12px; padding: 11px 20px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); text-decoration: none; font-weight: 700;
}
.google:hover { border-color: var(--muted); }
.google svg { width: 20px; height: 20px; }
.err { color: var(--bad); font-size: 14px; }
.login-card.prose { text-align: left; justify-items: start; width: min(560px, 100%); }
