:root {
  --bg: #101418;
  --panel: #171c22;
  --panel2: #1d242c;
  --line: #262d35;
  --line2: #323b45;
  --text: #e8e6e1;
  --sub: #8a939e;
  --faint: #5c656f;
  --tip-text: #c6ccd2;
  --grey-pill: #98a1ab;
  --brand: #00A7E1;
  --long: #3fb48f;
  --long-bg: rgba(63, 180, 143, .12);
  --short: #e0596b;
  --short-bg: rgba(224, 89, 107, .12);
  --gold: #d9a441;
  --gold-bg: rgba(217, 164, 65, .10);
  --gold-line: rgba(217, 164, 65, .3);
  --blue: #6aa3d8;
  --blue-bg: rgba(106, 163, 216, .12);
  --grey-bg: rgba(138, 147, 158, .14);
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

.app { max-width: 1080px; margin: 0 auto; padding: 18px 20px 32px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

a { color: inherit; }
button { font-family: inherit; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---------- header ---------- */
header.top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff; letter-spacing: -.02em;
}
.wordmark { font-size: 19px; font-weight: 700; color: var(--brand); letter-spacing: .01em; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; background: var(--grey-bg); color: var(--grey-pill);
  white-space: nowrap;
}
.qlinks { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.qlink {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--line); color: var(--tip-text);
  font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.qlink:hover { background: var(--panel2); border-color: var(--line2); }
.mfb-glyph {
  width: 15px; height: 15px; border-radius: 4px; background: #3b6ea5; color: #fff;
  font-size: 10px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- tabs ---------- */
nav.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding: 12px 0 10px; margin-bottom: 14px;
}
nav.tabs button {
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--sub);
}
nav.tabs button:hover { color: var(--text); background: var(--panel); }
nav.tabs button[aria-selected="true"] {
  background: var(--panel2); color: var(--text); border-color: var(--line2);
}
.tabpane { display: none; }
.tabpane.on { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .tabpane.on { animation: tabfade .18s ease; }
  @keyframes tabfade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* ---------- shared blocks ---------- */
.stack > * + * { margin-top: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.seclabel {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--brand); font-weight: 600;
}
.sublabel {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
}
.microlabel {
  color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  display: block; font-family: var(--sans);
}

/* pills */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pill.long  { background: var(--long-bg);  color: var(--long); }
.pill.short { background: var(--short-bg); color: var(--short); }
.pill.gold  { background: var(--gold-bg);  color: var(--gold); }
.pill.blue  { background: var(--blue-bg);  color: var(--blue); }
.pill.grey  { background: var(--grey-bg);  color: var(--grey-pill); }

/* chart link */
.chartlink {
  font-family: var(--mono); font-size: 11px; color: var(--sub); text-decoration: none;
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.chartlink:hover { color: var(--text); border-color: var(--line2); }

/* ---------- act now bar ---------- */
.actnow {
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  padding: 12px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.actnow .lead { min-width: 230px; flex: 1 1 230px; }
.actnow-label {
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold); font-weight: 700;
}
.actnow-count { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--sub); }
.actnow-sentence { font-size: 14.5px; font-weight: 600; margin-top: 2px; text-wrap: pretty; }
.actnow .cells {
  display: flex; gap: 0; flex-wrap: wrap; margin-left: auto;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.statcell { padding: 2px 16px; border-left: 1px solid var(--line); }
.statcell:last-child { padding-right: 0; }
.statcell .v { font-size: 15px; font-weight: 600; }
.statcell .v.neg { color: var(--short); }
.statcell .v.pos { color: var(--long); }
.statcell .cap { font-size: 11px; color: var(--faint); font-weight: 400; }

/* ---------- performance card ---------- */
.perf { padding: 16px 0 0; }
.perf .seclabel { padding: 0 18px; margin-bottom: 4px; }
.perf-cols { display: flex; flex-wrap: wrap; }
.perf-col { flex: 1 1 200px; padding: 8px 18px 14px; border-right: 1px solid var(--line); }
.perf-col.wide { flex: 2 1 300px; }
.perf-col:last-child { border-right: none; }
.perf-big { font-size: 22px; font-weight: 600; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.perf-big.pos { color: var(--long); }
.perf-sub { font-size: 11.5px; color: var(--text); }
.roi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 16px; margin-top: 4px; }
.roi-grid .k { font-size: 10.5px; color: var(--text); display: block; }
.roi-grid .v {
  font-size: 14px; font-weight: 600; color: var(--long);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

/* ---------- two-column row ---------- */
.row2 { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.row2 .left { flex: 7 1 400px; }
.row2 .right { flex: 5 1 300px; display: flex; flex-direction: column; }

/* ---------- tables ---------- */
.tblwrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; padding: 6px 10px 8px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--panel2); }
tbody tr.quiet:hover { background: transparent; }
td.sym { white-space: nowrap; }
td.sym .s { font-family: var(--mono); font-weight: 600; display: block; }
td.sym .n { font-size: 11px; color: var(--text); }
td.status { color: var(--text); font-size: 11px; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.right { text-align: right; }
tr.quiet td { color: var(--text); font-size: 12.5px; }

/* ---------- latest signals card ---------- */
.sig-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sig-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.sig-counter { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--sub); }
.sig-nav button {
  width: 24px; height: 24px; border-radius: 6px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--text); font-size: 14px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.sig-nav button:disabled { color: var(--faint); cursor: default; }
.sig-id { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sig-pair { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.sig-id .chartlink { margin-left: auto; }
.sig-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px;
}
.sig-grid .microlabel { font-size: 11px; }
.sig-grid .d-neg { color: var(--short); }
.sig-grid .d-pos { color: var(--long); }
.sig-grid .d-zero { color: var(--grey-pill); }
.sig-foot { margin-top: auto; padding-top: 12px; }

/* ---------- briefing (AI layer) ---------- */
.brief {
  background: var(--gold-bg); border: 1px solid var(--gold-line);
  border-radius: 10px; padding: 10px 12px;
}
.brief.pad { padding: 12px 14px; }
.brief-label {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 4px;
}
.brief-body { font-size: 12.5px; color: var(--text); }
.brief-meta { font-size: 11.5px; color: rgba(217, 164, 65, .7); margin-top: 10px; }

/* ---------- safety checks ---------- */
.safety {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center;
}
.tipwrap { position: relative; display: inline-block; }
.tippill {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600; cursor: help;
}
.tippill.gold { background: var(--gold-bg); color: var(--gold); }
.tippill.grey { background: var(--grey-bg); color: var(--grey-pill); }
.tip {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100% + 6px);
  width: 250px; max-width: 84vw; background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 8px 10px; font-size: 11.5px; line-height: 1.45;
  color: var(--tip-text); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5;
}
.tipwrap:hover .tip, .tipwrap:focus-within .tip { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }

/* ---------- signals tab ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--sub);
}
.chips button[aria-pressed="true"] {
  background: var(--panel2); color: var(--text); border-color: var(--line2);
}
.log-summary { font-size: 12.5px; color: var(--sub); }
.log-summary b { color: var(--text); }
td .res { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.res.pos { color: var(--long); }
.res.neg { color: var(--short); }
.res.zero { color: var(--faint); }
td.note { color: var(--faint); font-size: 12.5px; }

/* ---------- performance tab ---------- */
.chart-legend { margin-left: auto; display: flex; gap: 14px; font-size: 11px; color: var(--sub); }
.chart-legend .sw { display: inline-block; width: 16px; height: 2px; vertical-align: middle; margin-right: 5px; }
.chart-legend .sw.dash { height: 0; border-top: 2px dashed var(--faint); }
.chart-note { font-size: 12px; color: var(--faint); margin-top: 6px; }
.pcols { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.pcols > div { flex: 1 1 340px; }
.pcols .stackcol { display: flex; flex-direction: column; gap: 14px; }

/* ---------- intelligence tab ---------- */
.introws .r {
  display: flex; align-items: baseline; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.introws .r:last-of-type { border-bottom: none; }
.introws .name { font-weight: 600; }
.introws .net { margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.introws .delta {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--faint); min-width: 64px; text-align: right;
}
.srcline { font-size: 11.5px; color: var(--faint); margin-top: 10px; }
.cal .r { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cal .r:last-of-type { border-bottom: none; }
.cal .when { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--sub); font-size: 12px; white-space: nowrap; }
.cal .pill { margin-left: auto; }
.matrix table { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; }
.matrix th { text-align: right; padding: 5px 8px; }
.matrix th:first-child { text-align: left; }
.matrix td { text-align: right; padding: 5px 8px; color: var(--sub); border-bottom: none; }
.matrix td:first-child { text-align: left; color: var(--faint); font-weight: 600; }
.matrix tbody tr:hover { background: transparent; }

/* ---------- footer ---------- */
footer {
  margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px;
  font-size: 11.5px; color: var(--faint);
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .app { padding: 14px 14px 28px; }
  .actnow .cells { margin-left: 0; }
  .statcell { border-left: none; padding: 2px 16px 2px 0; }
  .perf-col { border-right: none; border-bottom: 1px solid var(--line); }
  .perf-col:last-child { border-bottom: none; }
}
