/* ============================================================================
   PredictionX — live-portfolio dashboard
   Dark, mobile-first, tabbed. Tracks the real Kalshi (live Kelly) account only.
   ========================================================================= */

:root {
  --bg:        #1d2429;
  --bg-grad:   #232c32;
  --surface:   #2a333a;
  --surface-2: #333e46;
  --inset:     #232c32;
  --border:    #3a464e;
  --border-2:  #475560;

  --text:      #ffffff;
  --text-2:    #cdd5da;
  --muted:     #8c98a0;
  --muted-2:   #5f6a72;

  --green:     #00d98a;
  --green-dim: rgba(0, 217, 138, 0.14);
  --red:       #ff5d5d;
  --red-dim:   rgba(255, 93, 93, 0.14);
  --blue:      #5b9dff;
  --amber:     #f5b13d;
  --orange:    #f97316;

  /* AI / agent accent — used only on agent surfaces + the Agent nav item */
  --ai:        #a78bfa;
  --ai-2:      #c4b5fd;
  --ai-dim:    rgba(167, 139, 250, 0.15);
  --ai-dim-2:  rgba(167, 139, 250, 0.30);

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -12px rgba(0,0,0,0.5);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --nav-h: 62px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; background: var(--bg); color: var(--text); }

body {
  font-family: var(--font);
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background:
    radial-gradient(1100px 380px at 50% -120px, var(--bg-grad), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-2); }
.dim      { color: var(--muted); }

/* ── App bar ──────────────────────────────────────────────────────────────── */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(29, 36, 41, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: max(env(safe-area-inset-top), 8px) 16px 8px;
}

.app-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
}

.logo { height: 25px; width: auto; display: block; margin-left: -2px; }

.agent-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.agent-pill:active { transform: scale(0.97); }

.agent-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}
.agent-dot.online  { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.agent-dot.shadow  { background: var(--blue);  box-shadow: 0 0 0 3px rgba(91,157,255,0.16); }
.agent-dot.stale   { background: var(--amber); box-shadow: 0 0 0 3px rgba(245,177,61,0.16); }
.agent-dot.offline { background: var(--red);   box-shadow: 0 0 0 3px var(--red-dim); }

.last-updated { font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }

/* ── Agent tab ────────────────────────────────────────────────────────────── */
.section-head.ai-head { color: var(--ai-2); }
.section-head.ai-head .section-hint { color: var(--muted); }

.ai-tag {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ai-2); background: var(--ai-dim);
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--ai-dim-2);
}

/* Status hero */
.agent-hero { padding: 14px 14px 0; }
.agent-hero-card {
  position: relative; overflow: hidden;
  background:
    radial-gradient(440px 170px at 8% -50%, var(--ai-dim), transparent 72%),
    var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 16px 16px 15px 18px;
  box-shadow: var(--shadow);
}
.agent-hero-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--ai), var(--ai-dim-2));
}
.agent-hero-top { display: flex; align-items: center; gap: 10px; }
.agent-hero-label { font-size: 23px; font-weight: 800; letter-spacing: -0.5px; }
.agent-hero-phrase { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.agent-hero-sub { font-size: 11.5px; color: var(--muted); margin-top: 7px; font-family: var(--mono); }
.agent-next-run { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Pulsing dot */
.agent-dot.pulse { width: 11px; height: 11px; position: relative; }
.agent-dot.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: inherit; z-index: -1;
  animation: dotpulse 1.9s ease-out infinite;
}
@keyframes dotpulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  70%  { transform: scale(3.4); opacity: 0; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* Self-review prose */
.review-card {
  margin: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ai);
  border-radius: var(--radius);
  padding: 14px 16px 4px;
  box-shadow: var(--shadow);
}
.review-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.review-trigger {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ai-2); background: var(--ai-dim); padding: 3px 8px; border-radius: 6px;
}
.review-time { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.review-prose {
  font-size: 13.5px; line-height: 1.62; color: var(--text-2);
  max-width: 64ch; word-break: break-word; overflow-wrap: anywhere;
}
.review-prose p { margin-bottom: 11px; }
.review-prose p:last-child { margin-bottom: 0; }
.review-foot {
  display: flex; gap: 18px; margin-top: 13px; padding: 11px 0 13px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); font-family: var(--mono);
}
.review-card > .empty { padding: 22px 6px; }

/* Active overrides */
.override-list { list-style: none; margin: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.override-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px;
}
.override-row .ov-left { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ov-seg { font-size: 12.5px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; }
.ov-reason { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.ov-chip {
  flex-shrink: 0; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: var(--ai-2); background: var(--ai-dim); border: 1px solid var(--ai-dim-2);
  padding: 4px 10px; border-radius: 999px;
}
.ov-chip.ov-exclude { color: var(--red); background: var(--red-dim); border-color: rgba(255, 93, 93, 0.28); }
.ov-expires { font-size: 10.5px; color: var(--amber); font-family: var(--mono); margin-top: 1px; }
.override-list > .empty {
  background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--radius);
}

/* Review engine */
.ai-engine { margin: 0 14px; padding: 14px; }
.ai-engine-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-engine-main .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.ai-engine-main .v { font-size: 15px; font-weight: 700; font-family: var(--mono); margin-top: 3px; }
.ai-engine-main .v.ai { color: var(--ai-2); }
.ai-badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--inset); color: var(--muted); border: 1px solid var(--border);
}
.ai-badge.ok   { color: var(--green); background: var(--green-dim); border-color: rgba(0, 217, 138, 0.28); }
.ai-badge.warn { color: var(--amber); background: rgba(245, 177, 61, 0.14); border-color: rgba(245, 177, 61, 0.28); }
.ai-engine-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border);
}
.ai-engine-grid .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.ai-engine-grid .v { font-size: 13px; font-weight: 700; font-family: var(--mono); margin-top: 3px; }
.ai-engine-err {
  margin-top: 12px; font-size: 11.5px; color: var(--red); font-family: var(--mono);
  background: var(--red-dim); border-radius: var(--radius-sm); padding: 8px 10px; word-break: break-word;
}

.stat-tile .value.ai { color: var(--ai-2); }

/* ── Banner ───────────────────────────────────────────────────────────────── */
.banner {
  margin: 8px 16px 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 500;
  display: none;
}
.banner.error { background: var(--red-dim);  color: var(--red);   display: block; }
.banner.stale { background: rgba(245,177,61,0.14); color: var(--amber); display: block; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.main { padding-top: 4px; }
.tab-view { display: none; animation: fade 0.18s ease; }
.tab-view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Bottom navigation ────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(29, 36, 41, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 40;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--muted-2);
  font-family: var(--font); font-size: 10px; font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.12s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--green); }
.nav-btn.nav-agent.active { color: var(--ai-2); }
.nav-btn.nav-agent.active svg { filter: drop-shadow(0 0 7px var(--ai-dim-2)); }

/* ── Section heads ────────────────────────────────────────────────────────── */
.section-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted);
  padding: 22px 18px 9px;
}
.section-hint {
  font-size: 10px; font-weight: 500; letter-spacing: 0.02em;
  text-transform: none; color: var(--muted-2);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  margin: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chart-card { overflow: hidden; position: relative; }
.chart-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2) 35%, var(--border-2) 65%, transparent);
}
.chart-wrap { padding: 8px 8px 6px; }

/* Trade-detail P&L chart: fixed height so the full-width desktop overlay can't
   stretch it tall (maintainAspectRatio is off for this chart). */
.pnl-wrap { position: relative; height: 220px; }

/* Unified key for the P&L chart (datasets + fwd/strike/settle markers). */
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: 2px 12px 12px; font-size: 10.5px; color: var(--muted);
}
.chart-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { display: inline-block; flex-shrink: 0; }
.chart-legend .swatch-line { width: 16px; height: 2.5px; border-radius: 2px; background: var(--sw); }
.chart-legend .swatch-dash {
  width: 16px; height: 0; border-top: 2px dashed var(--sw);
}
.chart-legend .swatch-bar { width: 3px; height: 12px; border-radius: 1px; background: var(--sw); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero { padding: 16px 18px 8px; position: relative; }
.hero::before {
  content: ""; position: absolute; left: 10px; top: 4px;
  width: 200px; height: 130px; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at 28% 32%, var(--green-dim), transparent 68%);
  opacity: 0.85; filter: blur(6px);
}
.hero-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted);
}
.hero-value {
  font-size: clamp(40px, 13.5vw, 54px); font-weight: 800; letter-spacing: -2.5px;
  font-family: var(--mono); line-height: 1.0; margin-top: 4px;
  word-break: break-word;
  background: linear-gradient(176deg, #ffffff 12%, #aebac1 125%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero-change {
  display: flex; align-items: center; gap: 8px;
  margin-top: 7px; font-size: 14px; font-weight: 700; font-family: var(--mono);
}
.hero-change .pill {
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 6px; font-family: var(--font);
}
.hero-change .pill.positive { background: var(--green-dim); }
.hero-change .pill.negative { background: var(--red-dim); }
.hero-change .since { color: var(--muted-2); font-weight: 500; font-family: var(--font); font-size: 12px; }

.hero-empty {
  margin: 14px;
  padding: 26px 18px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  text-align: center;
}
.hero-empty .big { font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.hero-empty .small { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.seg-group {
  display: flex; gap: 3px;
  background: var(--inset);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 3px;
  margin: 10px 10px 0;
  width: fit-content;
}
.seg-btn {
  padding: 5px 12px;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: none; border: none; cursor: pointer;
  border-radius: 6px; font-family: var(--font);
}
.seg-btn.active { background: var(--surface-2); color: var(--text); }

/* ── Stat grid ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  margin: 14px 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat-tile {
  background: var(--surface);
  padding: 13px 14px;
}
.stat-tile .label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.stat-tile .value {
  font-size: 19px; font-weight: 700; font-family: var(--mono);
  letter-spacing: -0.5px; margin-top: 4px;
}
.stat-tile .sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* ── Feed (compact key/value rows) ────────────────────────────────────────── */
.feed { list-style: none; margin: 0 14px; }
.feed-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
}
.feed-row:first-child { border-top: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.feed-row:last-child  { border-radius: 0 0 var(--radius) var(--radius); }
.feed-row:only-child  { border-radius: var(--radius); }
.feed-left  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feed-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.feed-k     { font-size: 13px; font-weight: 600; }
.feed-sub   { font-size: 11.5px; color: var(--muted); }
.feed-v     { font-size: 14px; font-weight: 700; font-family: var(--mono); }
.feed-vsub  { font-size: 11px; color: var(--muted-2); font-family: var(--mono); }

/* ── Bar meter (edge / series rows) ───────────────────────────────────────── */
.meter { height: 4px; border-radius: 2px; background: var(--inset); margin-top: 6px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 2px; }
.meter > span.pos { background: var(--green); }
.meter > span.neg { background: var(--red); }

/* ── Position cards ───────────────────────────────────────────────────────── */
.card-list { list-style: none; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pos-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow);
}
.pos-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.pos-ticker { font-size: 13px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; }
.pos-contract { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pos-cost { font-size: 17px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.5px; }
.pos-cost-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; text-align: right; }
.pos-meta {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.pos-meta .m { display: flex; flex-direction: column; gap: 1px; }
.pos-meta .m .mk { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); font-weight: 600; }
.pos-meta .m .mv { font-size: 12px; font-weight: 600; font-family: var(--mono); }

/* ── Badges / chips ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 6px; border-radius: 5px;
}
.badge.side-yes { background: var(--green-dim); color: var(--green); }
.badge.side-no  { background: rgba(91,157,255,0.16); color: var(--blue); }
.badge.st-filled,
.badge.st-executed  { background: var(--green-dim); color: var(--green); }
.badge.st-pending   { background: rgba(245,177,61,0.16); color: var(--amber); }
.badge.st-cancelled,
.badge.st-unfilled  { background: var(--red-dim); color: var(--red); }
.badge.st-unknown   { background: var(--inset); color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; font-family: var(--mono);
  padding: 2px 7px; border-radius: 6px;
  background: var(--inset); color: var(--text-2);
  border: 1px solid var(--border);
}

/* ── Activity feed ────────────────────────────────────────────────────────── */
.day-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 18px 18px 7px;
}
.act-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.act-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-weight: 800; font-size: 15px;
}
.act-icon.buy  { background: rgba(91,157,255,0.14); color: var(--blue); }
.act-icon.win  { background: var(--green-dim); color: var(--green); }
.act-icon.loss { background: var(--red-dim); color: var(--red); }
.act-icon.flat { background: var(--inset); color: var(--muted); }
.act-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.act-title { font-size: 13px; font-weight: 600; }
.act-sub { font-size: 11.5px; color: var(--muted); }
.act-right { text-align: right; flex-shrink: 0; }
.act-amt { font-size: 14px; font-weight: 700; font-family: var(--mono); }
.act-time { font-size: 10.5px; color: var(--muted-2); margin-top: 1px; }

/* ── Sub-summary grid (positions) ─────────────────────────────────────────── */
.sub-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 14px 0;
}
.sub-summary .ss {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.sub-summary .ss .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.sub-summary .ss .v { font-size: 19px; font-weight: 700; font-family: var(--mono); margin-top: 3px; }

/* ── Fill-quality card ────────────────────────────────────────────────────── */
.fill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; }
.fill-cell .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.fill-cell .v { font-size: 18px; font-weight: 700; font-family: var(--mono); margin-top: 3px; }
.fill-cell .s { font-size: 11px; color: var(--muted-2); margin-top: 1px; }

/* ── Model fit table ──────────────────────────────────────────────────────── */
.model-caption {
  margin: 14px 14px 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.model-coeff-card {
  margin: 14px 14px 0;
  padding: 14px;
}
.model-coeff-head .k,
.model-coeff-side .k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.model-coeff-head .s,
.model-coeff-side .s {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 2px;
}
.model-coeff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}
.model-coeff-side .v {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--mono);
  margin-top: 4px;
}
.model-coeff-side .v.ai { color: var(--ai-2); }
.model-table {
  width: calc(100% - 28px);
  margin: 0 14px;
  border-collapse: collapse;
  font-size: 13px;
}
.model-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.model-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
}
.model-table tr:last-child td { border-bottom: none; }
.model-table .mt-series { font-weight: 600; color: var(--text-2); }
.model-table .mt-num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.model-table th.mt-num { text-align: right; }
.model-table td.mt-num.positive { color: var(--green); }
.model-table .mt-muted {
  color: var(--muted-2);
  font-size: 10.5px;
  margin-top: 2px;
}

/* ── Empty / skeleton ─────────────────────────────────────────────────────── */
.empty {
  padding: 26px 16px; text-align: center;
  font-size: 12.5px; color: var(--muted-2);
}
@keyframes shimmer { 0% { background-position: -380px 0; } 100% { background-position: 380px 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 760px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
.sk-hero { height: 96px; }
.sk-tile { height: 46px; }
.sk-line { height: 13px; margin: 9px 0; }
.sk-line.short { width: 58%; }

/* ── Trade detail (full-screen overlay) ───────────────────────────────────── */
.act-row.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.act-row.tappable:active { background: var(--inset); }

.detail-view {
  position: fixed; inset: 0; z-index: 60;
  background:
    radial-gradient(1100px 380px at 50% -120px, var(--bg-grad), transparent 70%),
    var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s ease;
  visibility: hidden;
  overscroll-behavior: contain;
}
.detail-view.active { transform: translateX(0); visibility: visible; }
body.detail-open { overflow: hidden; }

.detail-header {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.detail-back {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-2); border-radius: 10px;
  background: var(--inset); color: var(--text); cursor: pointer;
}
.detail-back svg { width: 20px; height: 20px; }
.detail-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }

.detail-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); }
.detail-sec { margin-bottom: 18px; }
.detail-sec-head {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); margin: 4px 0 8px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.detail-hint, .detail-foot { font-size: 10.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted-2); }
.detail-foot { margin-top: 4px; text-align: center; }
.kv-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-k { font-size: 12.5px; color: var(--muted); }
.kv-v { font-size: 13px; font-weight: 600; font-family: var(--mono); text-align: right; }
.kv-v.positive { color: var(--green); }
.kv-v.negative { color: var(--red); }
.kv-dim { color: var(--muted-2); font-family: var(--font); font-weight: 500; font-size: 11px; }
.detail-prose { font-size: 12.5px; line-height: 1.55; color: var(--text-2); word-break: break-word; }

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .agent-dot.pulse::after { animation: none; opacity: 0; }
  .tab-view { animation: none; }
  .detail-view { transition: none; }
}
