:root {
  --bg: #07080a;
  --panel: #101318;
  --line: #1d232c;
  --text: #e7eadc;
  --muted: #7c8273;
  --lime: #c8ff3d;
  --bid: #3dff9a;
  --ask: #ff5a4a;
  --cyan: #8fd3ff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

body.dash {
  overflow: hidden;
  height: 100%;
}

body.stale {
  cursor: progress;
}

#reconnect {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: 8px 14px;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  color: #101318;
  background: var(--lime);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.mark { color: var(--lime); }
h1 { font-size: 16px; letter-spacing: 0.18em; font-weight: 700; }
.ver {
  color: var(--lime);
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.sub { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; }

.stats { display: flex; gap: 12px; color: var(--muted); flex-wrap: wrap; }
.stats span { letter-spacing: 0.04em; }
.stats .hot { color: var(--lime); }

.venues {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.venue-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  padding: 3px 8px;
  background: #0c0f13;
  font-size: 11px;
}
.venue-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5a5e54;
}
.venue-chip.conn .dot { background: #d2b48c; }
.venue-chip.live .dot { background: var(--bid); }

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.filters input, .filters select {
  font: inherit;
  color: var(--text);
  background: #0c0f13;
  border: 1px solid var(--line);
  padding: 6px 8px;
  min-width: 0;
  flex: 1;
}
.book-meta { margin-bottom: 6px; font-size: 11px; flex-shrink: 0; }
tr.stale td { opacity: 0.45; }
.tab.live .id { color: var(--bid); }

.grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 280px;
  gap: 1px;
  background: var(--line);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  padding: 10px 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h2 {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.list { overflow: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }

.tab, .arb {
  border: 1px solid var(--line);
  padding: 6px 8px;
  background: #0c0f13;
}

.tab .id { color: var(--lime); }
.tab .url {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap { overflow: auto; flex: 1; min-height: 0; }
#book { display: flex; flex-direction: column; flex: 1; min-height: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
td.event { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
td.sport { color: var(--cyan); text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; }
.bid { color: var(--bid); }
.ask { color: var(--ask); }
.delta { font-size: 11px; margin-left: 4px; }
.delta.up { color: var(--bid); }
.delta.down { color: var(--ask); }
td.px.up {
  animation: tick-up 2.8s ease-out;
}
td.px.down {
  animation: tick-down 2.8s ease-out;
}
@keyframes tick-up {
  0% { background-color: rgba(61, 255, 154, 0.5); }
  100% { background-color: transparent; }
}
@keyframes tick-down {
  0% { background-color: rgba(255, 90, 74, 0.45); }
  100% { background-color: transparent; }
}
.team { color: var(--text); white-space: nowrap; }
th.venue-col { color: var(--cyan); text-transform: lowercase; }
td.venue-px { white-space: nowrap; }
tr.cross td.event { color: var(--cyan); }
tr.inplay td.event { font-weight: 600; }
.inplay { color: var(--bid); }
.xvenue { color: var(--cyan); }
.soon { color: var(--lime); }
.venue { color: var(--cyan); }
.muted { color: var(--muted); }

.arb.cross { border-color: var(--lime); }
.arb.late { border-color: var(--cyan); }
.arb.late .edge { color: var(--cyan); }
.arb.learned { border-color: var(--lime); }
.arb.learned .edge { color: var(--lime); }
.arb .edge { color: var(--lime); font-size: 15px; }
.arb .kind { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.arb p { margin-top: 4px; line-height: 1.35; }
.arb .late-meta { color: var(--cyan); font-size: 12px; }
.arb-hd { display: flex; align-items: baseline; gap: 8px; }
.arb-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arb-title a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.arb-title a:hover { color: var(--cyan); }

.empty { color: var(--muted); }

.hands-h { margin-top: 12px; }
.hands { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.hands input, .hands select, .hands button {
  font: inherit;
  color: var(--text);
  background: #0c0f13;
  border: 1px solid var(--line);
  padding: 6px 8px;
}
.hands button { cursor: pointer; color: var(--lime); }
.hands button:hover { border-color: var(--lime); }
.row-btns { display: flex; gap: 8px; }
.row-btns button { flex: 1; }

.nav { display: flex; gap: 12px; margin-left: 16px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav a:hover { color: var(--lime); }

.games-page { overflow: auto; }
.games-main {
  flex: 1;
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.games-hd h2 { font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; }
.games-hd .muted { margin-top: 4px; font-size: 11px; }
.games-filters { margin-bottom: 0; }
#games-table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.games-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); }
table.games { width: 100%; border-collapse: collapse; }
table.games th, table.games td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.games th {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
table.games td.matchup { white-space: normal; max-width: 280px; }
table.games td.matchup .prior { font-size: 11px; font-variant-numeric: tabular-nums; }
table.games td.start { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.games td.start .muted { font-size: 11px; }
table.games td.score { font-variant-numeric: tabular-nums; }
table.games td.lead { font-variant-numeric: tabular-nums; }
table.games td.lead.hot { color: var(--lime); }
table.games tr.live td { background: rgba(61, 255, 154, 0.04); }
table.games tr.final td { opacity: 0.55; }
table.games .sport { color: var(--cyan); text-transform: uppercase; font-size: 11px; }
table.games .clock { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.games td.team { max-width: 160px; white-space: normal; }
table.games td.team.leader { color: var(--lime); }
table.games td.rec { max-width: 180px; white-space: normal; font-size: 11px; }
table.games td.rec .rec-act { text-transform: uppercase; letter-spacing: 0.06em; }
table.games tr.live td.rec.inplay { color: var(--lime); }
table.games tr.unmatched td.venue-px { opacity: 0.35; }
table.games th.venue-col { text-transform: none; letter-spacing: 0; }

.heat-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}
.heat-scale {
  width: 160px;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #1b4332, #3dff9a, #e6c84a, #ff5a4a);
}
.heat-block { margin: 8px 0 18px; }
.heat-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.heat-hd h3 {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}
.lock-heat { position: relative; overflow-x: auto; max-width: 100%; }
.lock-heat .heat-json { display: none; }
.lock-heat svg { display: block; }
.lock-heat .heat-axis { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.heat-tip {
  position: absolute;
  z-index: 3;
  background: #0c0f13;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 8px;
  font-size: 11px;
  pointer-events: none;
  max-width: 240px;
}
.heat-empty { padding: 20px 0; }
.lock-raw { margin-top: 8px; }
.lock-raw summary { cursor: pointer; margin-bottom: 8px; }

.accounts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}
.acct-flash {
  grid-column: 1 / -1;
  padding: 10px 16px;
  background: var(--panel);
}
.accounts .panel { min-height: 0; }
.accounts .panel:last-child,
.span-2 { grid-column: 1 / -1; }
.site-add { display: grid; grid-template-columns: 1fr 2fr 1fr auto auto auto; gap: 8px; align-items: end; }
.site-add button { height: 32px; }
.site-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  padding: 10px;
  margin-top: 12px;
  background: #0c0f13;
}
.cred-form { margin-top: 0; }
.playbook-meta { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.playbook-meta .row-btns button { font: inherit; color: var(--lime); background: #0c0f13; border: 1px solid var(--line); padding: 6px 8px; cursor: pointer; }
.playbook-meta .row-btns button:hover { border-color: var(--lime); }
.playbook-meta .row-btns button:disabled { opacity: 0.4; cursor: wait; }
.acct-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.acct-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
#llm-models { display: flex; flex-direction: column; gap: 6px; }
#llm-models select { width: 100%; }
.acct-form input, .acct-form select, .acct-form button {
  font: inherit;
  color: var(--text);
  background: #0c0f13;
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-transform: none;
  letter-spacing: 0;
}
.acct-form button { color: var(--lime); cursor: pointer; }
.acct-form h3 { color: var(--cyan); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.imap-row { display: grid; grid-template-columns: 2fr 1fr 2fr 2fr; gap: 8px; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; text-transform: none !important; letter-spacing: 0 !important; }
.saved { color: var(--bid); margin-left: 6px; }
.code { font-size: 16px; color: var(--lime); }

a.btn {
  font: inherit;
  color: var(--lime);
  background: #0c0f13;
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
}
a.btn:hover { border-color: var(--lime); }

.record {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  gap: 1px;
  background: var(--line);
  flex: 1;
  min-height: 0;
}
.record .panel { min-height: 0; }
.rec-side { overflow: auto; }
.lanes {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}
.lanes a { color: var(--muted); text-decoration: none; }
.lanes a.on, .lanes a:hover { color: var(--lime); }
.rec-url { word-break: break-all; margin: 8px 0; }
.rec-shot { padding: 10px 12px; }
#record-fields { display: none; }
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
.tools label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.tools label:has(input:checked) { color: var(--lime); }
.tools .tool-text {
  font: inherit;
  color: var(--text);
  background: #0c0f13;
  border: 1px solid var(--line);
  padding: 4px 8px;
  min-width: 160px;
}
.shot-wrap {
  background: #050607;
  overflow: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  border: 1px solid var(--line);
}
.shot-wrap img {
  max-width: 100%;
  height: auto;
  cursor: crosshair;
  display: block;
  user-select: none;
}
.shot-wrap img.htmx-request { opacity: 0.5; cursor: wait; }
.steps {
  list-style: decimal;
  padding-left: 18px;
  overflow: auto;
  flex: 1;
  min-height: 80px;
  margin-bottom: 10px;
}
.steps li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
  font-size: 12px;
}
.steps li span { flex: 1; min-width: 0; }
.steps li button {
  font: inherit;
  color: var(--ask);
  background: transparent;
  border: 1px solid var(--line);
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.steps li button:hover { border-color: var(--ask); }
.slot-grid {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}
.slot-grid code {
  font: inherit;
  font-size: 11px;
  color: var(--cyan);
  word-break: break-all;
}
.slot-grid button { padding: 4px 8px; }

@media (max-width: 980px) {
  body.dash { overflow: auto; height: auto; }
  .grid { grid-template-columns: 1fr; overflow: visible; }
  .top { padding: 10px 12px; }
  .accounts { grid-template-columns: 1fr; }
  .accounts .panel:last-child,
  .span-2 { grid-column: auto; }
  .imap-row { grid-template-columns: 1fr 1fr; }
  .site-add { grid-template-columns: 1fr; }
  .site-card { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr; }
}
