/* Slate — production tokens, light + dark */
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f5f4ef;
  --ink: #14161a;
  --ink-2: #4a4d54;
  --ink-3: #767982;
  --ink-4: #b3b5bb;
  --rule: #e6e4dd;
  --rule-2: #d6d3ca;
  --accent: #1f3d6e;
  --accent-soft: #e8edf5;
  --pos: #1d6b3a;
  --pos-soft: #e6f1ea;
  --neg: #a23a1f;
  --neg-soft: #f5e6e0;
  --warn: #8a6512;
  --warn-soft: #f5ecd6;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(20,22,26,0.04), 0 0 0 1px rgba(20,22,26,0.04);
  --shadow-md: 0 4px 14px rgba(20,22,26,0.06), 0 0 0 1px rgba(20,22,26,0.05);

  --font-ui: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", "Inter Tight", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0e0f12;
  --surface: #16181c;
  --surface-2: #1d1f24;
  --ink: #ececec;
  --ink-2: #b8bac0;
  --ink-3: #8a8d95;
  --ink-4: #565962;
  --rule: #272930;
  --rule-2: #353841;
  --accent: #7aa2dc;
  --accent-soft: #1a2638;
  --pos: #6ec38a;
  --pos-soft: #1a2a20;
  --neg: #d28774;
  --neg-soft: #2a1c18;
  --warn: #d8b46a;
  --warn-soft: #2a2316;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" on; }
.num { font-family: var(--font-mono); font-feature-settings: "tnum" on; letter-spacing: -0.01em; }
.serif { font-family: var(--font-display); letter-spacing: -0.015em; text-wrap: balance; }
h2.serif { line-height: 1.15; margin-bottom: 6px; }
h3.serif { line-height: 1.2; }

.label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}

.divider { height: 1px; background: var(--rule); border: 0; margin: 0; }
.divider.dashed { background: transparent; border-top: 1px dashed var(--rule-2); height: 0; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 7px; border: 1px solid var(--rule-2); border-radius: var(--r-sm);
  color: var(--ink-2); background: var(--surface);
}
.tag.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.tag.pos { background: var(--pos-soft); color: var(--pos); border-color: var(--pos); }
.tag.neg { background: var(--neg-soft); color: var(--neg); border-color: var(--neg); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 8px 14px; border: 1px solid var(--rule-2); background: var(--surface);
  color: var(--ink); border-radius: var(--r-md); cursor: pointer;
  font-size: 13px; transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.92; background: var(--ink); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent:hover { opacity: 0.92; background: var(--accent); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { border-color: var(--rule-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.icon { padding: 7px; }

.input {
  border: 1px solid var(--rule-2); background: var(--surface);
  border-radius: var(--r-md); padding: 8px 10px; font: inherit; color: var(--ink);
  outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ink { background: var(--ink); }
.dot.accent { background: var(--accent); }
.dot.pos { background: var(--pos); }
.dot.neg { background: var(--neg); }
.dot.warn { background: var(--warn); }
.dot.gray { background: var(--ink-4); }

/* avatar */
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--rule-2); background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--ink-2);
}

/* topbar / shell */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--rule);
  background: var(--surface);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand .mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  letter-spacing: -0.04em;
}
[data-theme="dark"] .brand .mark { background: var(--ink); color: var(--bg); }
.brand .name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.brand .sub { font-size: 11px; color: var(--ink-3); }

.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section .h { padding: 6px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: var(--r-md); color: var(--ink-2); cursor: pointer;
  font-size: 13.5px; white-space: nowrap;
}
.nav-item > span:nth-child(2) { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); font-weight: 500; box-shadow: inset 2px 0 0 var(--accent); }
.nav-item .ic { width: 16px; height: 16px; flex: 0 0 auto; opacity: 0.85; }
.nav-item .badge {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px;
  background: var(--neg-soft); color: var(--neg); padding: 1px 6px; border-radius: 99px;
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; border-bottom: 1px solid var(--rule);
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; min-width: 0; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .last { color: var(--ink); font-weight: 500; }
.crumbs > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Topbar brand — visible on mobile (sidebar is hidden behind hamburger), hidden on desktop */
.topbar-brand {
  display: none;
  align-items: center; gap: 9px;
  cursor: pointer;
  padding: 6px 8px; border-radius: var(--r-md);
  user-select: none;
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.topbar-brand:hover { background: var(--surface-2); }
.topbar-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar-brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  letter-spacing: -0.04em; flex: 0 0 auto;
}
.topbar-brand-name {
  font-family: var(--font-display);
  font-weight: 600; font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: var(--r-md); padding: 6px 10px; color: var(--ink-3);
  font-size: 13px;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.search:hover { background: var(--surface); border-color: var(--rule-2); }
.search:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; background: transparent; color: var(--ink); outline: none; flex: 1; font: inherit; min-width: 0; }

/* page */
.page { padding: 28px 36px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--rule); padding-bottom: 20px; margin-bottom: 28px;
}
.page-header h1 {
  font-family: var(--font-display); font-weight: 600; font-size: 44px;
  margin: 6px 0 0; letter-spacing: -0.025em; line-height: 1.05; text-wrap: balance;
}
.page-header .meta { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; color: var(--ink-3); font-size: 12px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.kpi { padding: 22px 24px; border-left: 1px solid var(--rule); display: flex; flex-direction: column; gap: 6px; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi .v { font-family: var(--font-mono); font-feature-settings: "tnum" on; font-size: 32px; letter-spacing: -0.02em; line-height: 1.05; }
.kpi .v.xl { font-size: 56px; }
.kpi .v.lg { font-size: 38px; }
.kpi .delta { font-family: var(--font-mono); font-size: 12px; }
.kpi .delta.up { color: var(--pos); }
.kpi .delta.dn { color: var(--neg); }

/* table */
.table-wrap { overflow: auto; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 500; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky; top: 0;
}
.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-feature-settings: "tnum" on; }
.tbl td.flag { background: var(--warn-soft); }
.tbl tr.flagged td { background: color-mix(in oklch, var(--warn-soft) 70%, var(--surface)); }

/* helpers */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.stack { display: flex; flex-direction: column; }
.stack-2 > * + * { margin-top: 8px; }
.stack-3 > * + * { margin-top: 14px; }
.spacer { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; } .mt-40 { margin-top: 40px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-2 { color: var(--ink-2); }
.text-3 { color: var(--ink-3); }

.section { padding: 28px 0; border-top: 1px solid var(--rule); }
.section:first-child { border-top: 0; padding-top: 0; }
.section h2 { font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.015em; margin: 0 0 14px; }
.section .sub { color: var(--ink-3); margin-top: -8px; margin-bottom: 16px; font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.grid-3-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 24px; }

/* sparkline cells and bars */
.bar-track { height: 6px; background: var(--rule); border-radius: 99px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--ink); }
.bar-fill.accent { background: var(--accent); }
.bar-fill.pos { background: var(--pos); }
.bar-fill.neg { background: var(--neg); }
.bar-track.with-target { overflow: visible; }
.bar-track .target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-3); }

/* insight cards */
.insight {
  border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface);
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.insight:hover { border-color: var(--ink-3); box-shadow: var(--shadow-md); }
.insight .num-impact { font-family: var(--font-mono); font-size: 22px; }
.insight.priority-high { border-top: 3px solid var(--neg); }
.insight.priority-med { border-top: 3px solid var(--warn); }
.insight.priority-low { border-top: 3px solid var(--ink-3); }

/* upload zone */
.dropzone {
  border: 1.5px dashed var(--rule-2); border-radius: var(--r-lg);
  padding: 60px 24px; text-align: center; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  transition: border-color .12s, background .12s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* progress */
.progress {
  height: 6px; background: var(--rule); border-radius: 99px; overflow: hidden;
}
.progress > div { height: 100%; background: var(--accent); transition: width .4s ease; }

/* hover row in tbl */
.kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  border: 1px solid var(--rule-2); border-bottom-width: 1.5px;
  padding: 1px 5px; border-radius: 3px; color: var(--ink-3);
  background: var(--surface);
}

/* segment control */
.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r-md); padding: 2px; background: var(--surface); gap: 2px; }
.seg button {
  background: transparent; border: 0; padding: 5px 11px;
  font-size: 12px; color: var(--ink-2); border-radius: 4px; cursor: pointer;
  white-space: nowrap;
}
.seg button.active { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg button.active { background: var(--rule-2); }

/* scrollbars hidden inside scroll wrappers */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* small svg ic */
.ic { display: inline-block; vertical-align: middle; }

/* footer / sticky action */
.action-bar {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--rule); padding: 14px 28px;
  display: flex; gap: 12px; align-items: center; justify-content: flex-end; z-index: 4;
}

/* mini chip rows */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* bond/lots subtable */
.subtle-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.subtle-tbl td { padding: 8px 0; border-bottom: 1px dashed var(--rule); }
.subtle-tbl td.num { text-align: right; font-family: var(--font-mono); }

/* drill-down hero */
.holding-hero {
  display: grid; grid-template-columns: auto 1fr auto; gap: 28px;
  padding: 24px 0 28px; border-bottom: 1px solid var(--rule);
}
.holding-mark {
  width: 64px; height: 64px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--rule);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 22px; font-weight: 600;
}

/* anomaly margin (subtle, no handwriting) */
.margin-note {
  border-left: 2px solid var(--accent);
  padding: 6px 0 6px 14px;
  background: linear-gradient(to right, var(--accent-soft) 0, transparent 60%);
}

/* page transition */
.page { animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* entity filter */
.filter-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 28px;
  background: var(--surface-2); border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}
.filter-bar .label { margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--rule-2); background: var(--surface);
  color: var(--ink-2); font-size: 12px;
  transition: all .12s;
}
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .x { opacity: 0.5; }
.chip .ck { color: var(--pos); }
.chip.on .ck { color: var(--bg); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 24px; flex-wrap: wrap; }
.tabs button {
  background: transparent; border: 0; padding: 10px 16px; cursor: pointer;
  color: var(--ink-3); font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }

/* fit score ring */
.fit-ring { position: relative; width: 56px; height: 56px; }
.fit-ring svg { transform: rotate(-90deg); }
.fit-ring .fit-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 14px; font-weight: 600;
}

/* deal card */
.deal-card {
  border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 22px; background: var(--surface);
  display: grid; grid-template-columns: 1fr auto; gap: 18px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.deal-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow-md); }

/* RFQ table — make the best column glow */
.rfq-tbl tbody tr.best td { background: color-mix(in oklch, var(--pos-soft) 65%, var(--surface)); }
.rfq-tbl td .winner { display:inline-flex; align-items:center; gap:4px; font-size:10.5px; color: var(--pos); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; margin-left:6px; }
.rfq-tbl tr.pending td { color: var(--ink-3); font-style: italic; }

/* sparkbar for coupons */
.sparkbar {
  position: relative; height: 22px; background: var(--rule); border-radius: 4px; overflow: hidden;
}
.sparkbar > div { position: absolute; top:0; bottom:0; background: var(--ink); }
.sparkbar.win > div { background: var(--pos); }

/* thesis tag */
.thesis-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 99px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--accent-soft);
  font-size: 11.5px; cursor: pointer;
}
/* print-ish faint pattern for hashed empty boxes */
.hash {
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, var(--rule) 6px 7px);
  border: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
}

/* entity filter */
.filter-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 28px;
  background: var(--surface-2); border-bottom: 1px solid var(--rule);
  font-size: 12.5px; flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--rule-2); background: var(--surface);
  color: var(--ink-2); font-size: 12px; transition: all .12s;
}
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* fit ring */
.fit-ring { position: relative; width: 56px; height: 56px; flex: 0 0 auto; }
.fit-ring svg { transform: rotate(-90deg); }
.fit-ring .fit-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 14px; font-weight: 600;
}

/* deal card */
.deal-card {
  border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: 22px; background: var(--surface);
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.deal-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow-md); }

/* RFQ */
.rfq-tbl tbody tr.best td { background: color-mix(in oklch, var(--pos-soft) 65%, var(--surface)); }
.rfq-tbl tr.pending td { color: var(--ink-3); font-style: italic; }
.winner-tag { display:inline-flex; align-items:center; gap:4px; font-size:10px; color: var(--pos); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; margin-left:6px; }
.sparkbar { position: relative; height: 18px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.sparkbar > div { position: absolute; top:0; bottom:0; background: var(--ink); }
.sparkbar.win > div { background: var(--pos); }

/* thesis tag */
.thesis-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 99px;
  border: 1px solid var(--rule-2); color: var(--ink-2); background: var(--surface);
  font-size: 11.5px; cursor: pointer; transition: all .12s;
}
.thesis-tag:hover { border-color: var(--ink-3); }
.thesis-tag.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ================================================================
 * Mobile + tablet responsive styles
 * Mobile drawer sidebar (hidden by default), single-column grids,
 * tightened spacing, larger touch targets, horizontal-scroll tabs.
 * ================================================================ */

/* Hidden by default — only visible on mobile. */
.sidebar-backdrop { display: none; }
.mobile-menu-btn  { display: none; }
.sidebar-close-btn { display: none; }
.sidebar-top-row { display: contents; }

/* Tablet: tighter sidebar, smaller h1, simpler grids. */
@media (max-width: 1024px) {
  .app { grid-template-columns: 200px 1fr; }
  .page { padding: 24px 24px 60px; }
  .page-header h1 { font-size: 36px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-3-2 { grid-template-columns: 1fr; }
  .holding-hero { grid-template-columns: auto 1fr; }
  .holding-hero > :last-child { grid-column: 1 / -1; text-align: left !important; }
  .topbar { padding: 12px 20px; }
  .action-bar { padding: 14px 20px; }
}

/* Phone: drawer sidebar + everything single-column. */
@media (max-width: 768px) {
  /* App layout: sidebar becomes slide-in drawer over content. */
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh;
    width: 280px; max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 100;
    box-shadow: 0 0 24px rgba(0,0,0,0.18);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-top-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 0 4px 0 0;
  }
  .sidebar-close-btn { display: inline-flex; }
  .mobile-menu-btn { display: inline-flex; flex: 0 0 auto; }

  /* Topbar mobile layout: [≡] [S Slate · Briefing]                 [☾]
     Brand wordmark and section share the same display font + size + baseline,
     separated by a centered middle dot — reads as a single typographic line. */
  .topbar { padding: 10px 12px; gap: 6px; }
  .topbar-brand { display: inline-flex; flex: 0 0 auto; padding-right: 4px; }
  .topbar .crumbs {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.2;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--ink-2);
    align-self: center;
    display: inline-flex;
    align-items: baseline;     /* baseline-align the dot and the section text */
    gap: 0;
  }
  .topbar .crumbs::before {
    content: '·';
    color: var(--ink-4);
    margin-right: 8px;
    font-weight: 400;
    flex: 0 0 auto;
  }
  .topbar .crumbs span:not(.last):not(.sep) { display: none; }
  .topbar .crumbs .sep { display: none; }
  .topbar .crumbs .last {
    color: var(--ink-2);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-search { display: none !important; }
  .topbar-download-btn { display: none !important; }
  .topbar-avatar { display: none !important; }

  /* Page chrome */
  .page { padding: 16px 14px 100px; }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 18px;
  }
  .page-header h1 { font-size: 26px; line-height: 1.12; margin-top: 4px; }
  .page-header .meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
    width: 100%;
  }
  .page-header .meta > * { text-align: left !important; }

  /* KPIs: 2 columns on small screens */
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi {
    padding: 14px 12px;
    border-left: 1px solid var(--rule);
  }
  /* Override the desktop "first child has no left border / left padding". */
  .kpi:first-child { padding-left: 12px; }
  .kpi:nth-child(odd) { border-left: 0; padding-left: 12px; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .kpi .v { font-size: 22px; }
  .kpi .v.lg { font-size: 26px; }
  .kpi .v.xl { font-size: 32px; }
  .kpi .label { font-size: 9.5px; }

  /* Sections + headings */
  .section { padding: 20px 0; }
  .section h2 { font-size: 20px; }
  .section .sub { font-size: 12px; }

  /* Grids — collapse to single column */
  .grid-2 { grid-template-columns: 1fr; gap: 14px; }
  .grid-3 { grid-template-columns: 1fr; gap: 14px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-1-2, .grid-2-1, .grid-3-2 { grid-template-columns: 1fr; gap: 14px; }

  /* Holding detail hero */
  .holding-hero {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px 0 20px;
  }
  .holding-mark { width: 48px; height: 48px; font-size: 18px; }
  .holding-hero > :last-child { text-align: left !important; }

  /* Tabs: horizontal scroll instead of wrap (cleaner than two-row wrap on mobile) */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 10px 12px; font-size: 13px; flex: 0 0 auto; }

  /* Filter bar */
  .filter-bar {
    padding: 8px 14px;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar > * { flex: 0 0 auto; }

  /* Action bar */
  .action-bar {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .action-bar .btn { font-size: 12px; padding: 9px 12px; min-height: 38px; }

  /* Tables: smaller padding, smaller text. Horizontal scroll already on .table-wrap. */
  .tbl thead th, .tbl tbody td { padding: 10px 10px; }
  .tbl, .tbl thead th, .tbl tbody td { font-size: 12px; }

  /* Buttons: larger touch targets */
  .btn { min-height: 38px; padding: 9px 14px; }
  .btn.sm { min-height: 32px; padding: 7px 11px; }
  .btn.icon { min-height: 36px; }

  /* Sidebar nav: larger touch targets in drawer */
  .nav-item { padding: 12px 10px; font-size: 14px; }
  .nav-item .badge { font-size: 10.5px; padding: 2px 7px; }

  /* Drop zone */
  .dropzone { padding: 36px 16px; }
  .dropzone .serif { font-size: 22px; }

  /* Segmented controls — let them scroll horizontally instead of overflowing */
  .seg {
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
  }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: 0 0 auto; padding: 7px 11px; }

  /* Brand */
  .brand .name { font-size: 16px; }

  /* Insights */
  .insight { padding: 16px; }

  /* Charts — let them shrink height a bit on mobile via the parent card padding */
  .card svg { height: auto; }

  /* Page-header meta inside Briefing-style layouts */
  .page-header .meta .num { font-size: 18px !important; }

  /* deal-card and similar grid templates */
  .deal-card { grid-template-columns: 1fr; }

  /* Hero numbers in page-header */
  .page-header .num { font-size: 18px; }
}

/* Small phone: extra-tight */
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi:nth-child(n) { border-left: 0; padding-left: 0; }
  .kpi:nth-child(n+2) { border-top: 1px solid var(--rule); }
  .grid-4 { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 22px; }
  .topbar-brand-name { display: none; }
  .topbar .crumbs::before { display: none; }
  .topbar .crumbs { font-size: 16px; padding-left: 6px; }
  .topbar { gap: 4px; padding: 10px 10px; }
}
