/* PuntIQ — racing-green terminal. One accent (brass) marks value; green/coral mark direction. */
:root {
  --base: #10241d;
  --panel: #152e25;
  --raised: #1b392e;
  --line: #2b4b3f;
  --line-soft: #22412f;
  --paper: #ebe6d6;
  --muted: #9fb3a8;
  --faint: #6f887c;
  --brass: #c8a04a;
  --brass-soft: rgba(200, 160, 74, 0.16);
  --up: #63c69c;
  --down: #e07a60;
  --warn: #e3b23c;
  --demo: #b98ad6;
  --radius-s: 4px;
  --radius-m: 8px;
  --kernny-w: 27%;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--base);
  color: var(--paper);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr) var(--kernny-w); grid-template-rows: auto 1fr; height: 100%; }
#root { height: 100%; }
.preview-banner { border: 1px solid var(--brass); background: var(--brass-soft); border-radius: var(--radius-m); padding: 9px 12px; margin-bottom: 14px; font-size: 13px; max-width: 110ch; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 22px; padding: 0 18px; height: 52px;
  border-bottom: 1px solid var(--line); background: var(--panel); position: relative; z-index: 3;
}
.brand { font: 600 19px/1 var(--font-cond); letter-spacing: 0.01em; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
.brand .iq { color: var(--brass); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 7px 10px; border-radius: var(--radius-s); white-space: nowrap;
  font: 500 14px/1 var(--font-cond);
}
.nav a:hover { color: var(--paper); background: var(--raised); }
.nav a.on { color: var(--paper); box-shadow: inset 0 -2px 0 var(--brass); border-radius: 0; }
.status { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 12.5px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px rgba(99, 198, 156, 0.18); }
.live-dot.stale { background: var(--warn); box-shadow: 0 0 0 3px rgba(227, 178, 60, 0.18); }
.live-dot.down { background: var(--down); box-shadow: 0 0 0 3px rgba(224, 122, 96, 0.18); }
.search { position: relative; }
.search input {
  width: 190px; background: var(--base); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 10px;
}
.search input::placeholder { color: var(--faint); }

.main { overflow-y: auto; padding: 18px 22px 60px; min-width: 0; }
.kernny-col { border-left: 1px solid var(--line); background: var(--panel); min-height: 0; display: flex; flex-direction: column; }

/* ---------- type ---------- */
h1 { font: 600 24px/1.2 var(--font-cond); margin: 0 0 4px; }
h2 { font: 600 17px/1.3 var(--font-cond); margin: 26px 0 10px; }
h3 { font: 600 15px/1.3 var(--font-cond); margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 16px; max-width: 70ch; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.brass { color: var(--brass); }

/* ---------- controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 14px 0 16px; }
.segment { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.segment button {
  background: none; border: 0; padding: 6px 11px; color: var(--muted); cursor: pointer; font: 500 13px/1 var(--font-cond);
}
.segment button + button { border-left: 1px solid var(--line); }
.segment button.on { background: var(--raised); color: var(--paper); }
.field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.field input, .field select, select.plain {
  background: var(--base); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 5px 8px; width: 74px;
}
select.plain { width: auto; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 7px 12px; cursor: pointer; text-decoration: none; font: 500 13.5px/1 var(--font-cond);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: #1b1606; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: none; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font: 500 11.5px/1.5 var(--font-cond);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.demo { border-color: var(--demo); color: var(--demo); }
.badge.stale { border-color: var(--warn); color: var(--warn); }
.badge.live { border-color: var(--up); color: var(--up); }
.badge.qualified, .badge.kernny { border-color: var(--brass); color: var(--brass); }
.badge.bad { border-color: var(--down); color: var(--down); }
.demo-banner {
  border: 1px dashed var(--demo); color: var(--demo); padding: 8px 12px; border-radius: var(--radius-m); margin-bottom: 14px; font-size: 13px;
}

/* ---------- opportunity (bet) cards ---------- */
.opps { display: grid; gap: 12px; }
.opp {
  display: grid; grid-template-columns: 190px 1fr 250px; gap: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-m); overflow: hidden;
}
.opp.kernny-bet { border-color: var(--brass); }
.opp > section { padding: 14px 16px; min-width: 0; }
.opp { min-width: 0; }
.opp .when { border-right: 1px solid var(--line-soft); }
.opp .when .event { font: 600 15px/1.25 var(--font-cond); text-decoration: none; }
.opp .when .countdown { font: 600 22px/1.1 var(--font-cond); margin-top: 8px; }
.opp .when .countdown.soon { color: var(--brass); }
.opp .sel { font: 600 20px/1.2 var(--font-cond); margin: 0 0 2px; }
.opp .sel .no { color: var(--muted); font-weight: 500; margin-right: 6px; }
.opp .metrics { border-left: 1px solid var(--line-soft); display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; align-content: start; }
.metric .k { color: var(--faint); font-size: 11.5px; }
.metric .v { font: 600 17px/1.2 var(--font-cond); white-space: nowrap; }
.metric .v.big { font-size: 22px; }
.prices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
.price .k { color: var(--faint); font-size: 11.5px; white-space: nowrap; }
.price .v { font: 600 18px/1.2 var(--font-cond); }
.price .v.na { color: var(--faint); font-size: 13px; font-weight: 500; }
.price .who { color: var(--muted); font-size: 11.5px; }
.opp-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* the price ruler: value zone starts at the minimum acceptable price */
.ruler { position: relative; height: 38px; margin: 14px 4px 0; }
.ruler .track { position: absolute; left: 0; right: 0; top: 17px; height: 4px; background: var(--line); border-radius: 2px; }
.ruler .zone { position: absolute; top: 12px; height: 14px; background: var(--brass-soft); border-left: 2px solid var(--brass); border-radius: 0 3px 3px 0; }
.ruler .tick { position: absolute; top: 10px; width: 2px; height: 18px; background: var(--muted); }
.ruler .dot { position: absolute; top: 12px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--paper); border: 2px solid var(--base); }
.ruler .dot.in { background: var(--brass); }
.ruler .lab { position: absolute; top: 28px; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.ruler .lab.top { top: -4px; }

/* ---------- why this bet ---------- */
.why { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); padding: 16px; background: rgba(0, 0, 0, 0.12); }
.why .thesis { max-width: 78ch; margin: 0 0 14px; font-size: 14.5px; }
.why-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 22px; }
.why ul { margin: 0; padding-left: 16px; }
.why li { margin: 3px 0; }
.why li b { font-weight: 600; }
.sources { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.sources td { padding: 5px 8px 5px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font: 500 12px/1.2 var(--font-cond); color: var(--faint); padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.r, table.grid th.r { text-align: right; }
table.grid tr.dim td { color: var(--faint); text-decoration: line-through; }
table.grid tr.hl td { background: var(--brass-soft); }
table.grid a { text-decoration: none; }
table.grid a:hover { text-decoration: underline; }

/* ---------- panels, lists ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 12px; color: var(--muted); cursor: pointer; font: 500 14px/1 var(--font-cond); white-space: nowrap; }
.tabs button.on { color: var(--paper); box-shadow: inset 0 -2px 0 var(--brass); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius-m); padding: 26px; color: var(--muted); max-width: 70ch; }
.empty h3 { color: var(--paper); }
.radar-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--muted); }
.meter.brass i { background: var(--brass); }
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .meter { height: 8px; }
.bar-row .meter i { background: linear-gradient(90deg, var(--line) 0 50%, transparent 50%); }
.split-bar { position: relative; height: 8px; background: var(--line); border-radius: 4px; }
.split-bar .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--faint); }
.split-bar .fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; }

/* speed map */
.speedmap { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.speedmap .lane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px; min-height: 90px; }
.speedmap .lane h3 { font-size: 13px; color: var(--muted); }
.speedmap .runner { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; border-top: 1px solid var(--line-soft); }

/* charts */
svg.chart { display: block; max-width: 100%; }
svg.chart text { fill: var(--faint); font: 11px var(--font); }
svg.chart .grid line { stroke: var(--line-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* ---------- Kernny ---------- */
.kernny { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kernny-head { display: flex; gap: 12px; align-items: center; padding: 16px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.kernny-head img { width: 62px; height: 62px; border-radius: 50%; border: 2px solid var(--brass); }
.kernny-head .name { font: 600 19px/1.1 var(--font-cond); }
.kernny-head .title { color: var(--muted); font-size: 12.5px; }
.kernny-status { margin: 10px 16px 0; padding: 8px 10px; border-radius: var(--radius-s); background: var(--raised); font: 600 12.5px/1.3 var(--font-cond); letter-spacing: 0.02em; }
.kernny-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.kernny-stats .metric .v { font-size: 16px; }
.feed { flex: 1; overflow-y: auto; padding: 8px 16px; min-height: 80px; }
.feed .item { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.feed .item .t { color: var(--faint); }
.feed .item.PAPER_BET .m { color: var(--brass); }
.feed .item.RESULT .m { color: var(--paper); }
.chat { border-top: 1px solid var(--line); display: flex; flex-direction: column; max-height: 48%; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { flex-shrink: 0; padding: 8px 10px; border-radius: var(--radius-m); font-size: 13px; white-space: pre-wrap; max-width: 92%; }
.bubble.user { align-self: flex-end; background: var(--raised); }
.bubble.kernny { align-self: flex-start; background: var(--base); border: 1px solid var(--line-soft); }
.chat form { display: flex; gap: 6px; padding: 10px 12px 12px; }
.chat input { flex: 1; background: var(--base); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.chips button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; font-size: 12px; color: var(--muted); cursor: pointer; }
.chips button:hover { color: var(--paper); border-color: var(--muted); }
.kernny-fab { display: none; }

/* toasts */
.toasts { position: fixed; bottom: 18px; left: 18px; display: grid; gap: 8px; z-index: 30; }
.toast { background: var(--raised); border: 1px solid var(--brass); border-radius: var(--radius-m); padding: 10px 12px; min-width: 260px; max-width: 360px; font-size: 13px; }
.toast b { display: block; font: 600 14px/1.3 var(--font-cond); }

/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.login label { display: grid; gap: 4px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.login input { background: var(--base); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 10px; }
.error { color: var(--down); font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .opp { grid-template-columns: 160px 1fr; }
  .opp .metrics { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line-soft); grid-template-columns: repeat(4, 1fr); }
  .why-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .brand { flex: none; }
  .search { display: none; }
  .kernny-col { display: none; }
  .kernny-col.open { display: flex; position: fixed; inset: 0; z-index: 20; }
  .kernny-fab {
    display: block; position: fixed; right: 16px; bottom: 16px; z-index: 21; width: 60px; height: 60px; border-radius: 50%;
    border: 2px solid var(--brass); padding: 0; overflow: hidden; background: var(--panel); cursor: pointer;
  }
  .kernny-fab img { width: 100%; height: 100%; }
  .kernny-close { display: inline-flex !important; }
  .topbar { gap: 12px; padding: 0 12px; }
  .search input { width: 120px; }
  .status .label { display: none; }
  .main { padding: 14px 14px 90px; }
  .opp { grid-template-columns: 1fr; }
  .opp .when { border-right: 0; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: baseline; }
  .opp .when .countdown { margin: 0; }
  .opp .metrics { grid-template-columns: repeat(2, 1fr); }
  .prices { grid-template-columns: repeat(2, 1fr); }
  .why-grid { grid-template-columns: 1fr; }
  .speedmap { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 110px 1fr 40px; }
}
.kernny-close { display: none; margin-left: auto; }
