/* =========================================================================
   Hindsight — Component styles (cards, heatmap, charts, modal)
   ========================================================================= */

/* ---- filter / sort bar ---- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 22px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); position: sticky; top: 104px; z-index: 20;
}
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 6px; transition: .15s; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.toolbar .tb-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin-left: 4px; }
.toolbar .spacer { flex: 1; }
.toolbar .count { font-size: 12.5px; color: var(--muted); }
.toolbar .count b { color: var(--ink); font-family: var(--font-mono); }

/* ---- fixtures grid ---- */
.day-group { margin-bottom: 30px; }
.day-head {
  display: flex; align-items: center; gap: 10px; margin: 0 2px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.day-head::after { content:""; flex:1; height:1px; background: var(--line); }
.day-head .cnt { color: var(--faint); font-weight: 600; letter-spacing: 0; text-transform: none; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }

.match-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer;
  transition: border-color .18s, box-shadow .18s, transform .18s;
  display: flex; flex-direction: column;
}
.match-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.match-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mc-top {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--faint);
}
.mc-top .city { font-weight: 600; color: var(--muted); }
.mc-top .mc-tags { margin-left: auto; display: flex; gap: 5px; }
.mc-pick {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 5px;
}
.mc-pick.home { color: var(--home-ink); background: var(--home-bg); }
.mc-pick.away { color: var(--away-ink); background: var(--away-bg); }
.mc-pick.draw { color: var(--draw-ink); background: var(--draw-bg); }

.mc-body { padding: 14px 16px 4px; }
.mc-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.mc-team { display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; min-width: 0; }
.mc-team .flag { width: 38px; height: 27px; border-radius: 3px; }
.mc-team .zh { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.mc-team.win .zh { color: var(--ink); }
.mc-score {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 4px;
}
.mc-score .top {
  font-family: var(--font-mono); font-weight: 600; font-size: 26px; letter-spacing: -.02em;
  color: var(--ink); display: flex; align-items: center; gap: 7px;
}
.mc-score .top .sep { color: var(--faint); font-weight: 400; }
.mc-score .lbl { font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.mc-score .actual {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; margin-top: 1px;
}
.verdict { display:inline-grid; place-items:center; width:15px;height:15px;border-radius:50%; font-size:9px; color:#fff; }
.verdict.ok { background: var(--home); }
.verdict.no { background: var(--away); }

/* W/D/L bar */
.wdl { margin: 14px 0 6px; }
.wdl-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--line); }
.wdl-bar i { display: block; height: 100%; }
.wdl-bar .h { background: var(--home); }
.wdl-bar .d { background: var(--draw); }
.wdl-bar .a { background: var(--away); }
.wdl-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; }
.wdl-legend span { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-weight: 500; }
.wdl-legend .k { width: 7px; height: 7px; border-radius: 2px; }
.wdl-legend .h .k { background: var(--home); } .wdl-legend .h { color: var(--home-ink); }
.wdl-legend .d .k { background: var(--draw); } .wdl-legend .d { color: var(--draw-ink); }
.wdl-legend .a .k { background: var(--away); } .wdl-legend .a { color: var(--away-ink); }

.mc-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; margin-top: 6px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.mc-foot .xg { font-family: var(--font-mono); font-weight: 500; }
.mc-foot .xg b { color: var(--ink); }
.mc-expand { display: inline-flex; align-items: center; gap: 5px; color: var(--faint); font-weight: 600; font-size: 11.5px; }

/* inline heatmap (expandable) */
.heat-wrap { padding: 4px 16px 16px; }
.heat {
  display: grid; gap: 2px; margin: 0 auto;
}
.heat-cell {
  aspect-ratio: 1; border-radius: 3px; position: relative;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 9px; color: var(--ink);
}
.heat-cell.peak { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; }
.heat-axis-h, .heat-axis-a { font-family: var(--font-mono); font-size: 9.5px; color: var(--faint); display: grid; place-items: center; }
.heat-legend { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.heat-legend span { display: inline-flex; align-items: center; gap: 5px; }
.heat-legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* =========================================================================
   ROLLING PANEL (Tab 2 core)
   ========================================================================= */
.amber-banner {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--warn-bg); border: 1px solid color-mix(in oklab, var(--warn) 35%, transparent);
  border-radius: var(--r-lg); padding: 14px 18px; margin-bottom: 18px;
}
.amber-banner .ab-ic { color: var(--warn); flex-shrink: 0; margin-top: 1px; }
.amber-banner .ab-ic svg { width: 20px; height: 20px; }
.amber-banner .ab-t { font-weight: 700; color: var(--warn-ink); font-size: 14px; }
.amber-banner .ab-d { color: var(--warn-ink); font-size: 13px; opacity: .92; margin-top: 2px; }

.bignum-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 18px; }
.bignum { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.bignum .bn-label { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.bignum .bn-val { font-family: var(--font-mono); font-weight: 600; font-size: 32px; letter-spacing: -.03em; margin-top: 6px; line-height: 1; display: flex; align-items: baseline; gap: 3px; }
.bignum .bn-val .sm { font-size: 16px; color: var(--faint); }
.bignum .bn-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.bignum.accent { background: linear-gradient(135deg, var(--home-bg), var(--surface)); border-color: color-mix(in oklab,var(--home) 25%, transparent); }

/* settled match list */
.settled-list { display: flex; flex-direction: column; }
.settled-row {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 14px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.settled-row:last-child { border-bottom: none; }
.settled-match { display: flex; align-items: center; gap: 10px; min-width: 0; }
.settled-match .vs { color: var(--faint); font-size: 11px; }
.settled-scores { display: flex; align-items: center; gap: 14px; font-family: var(--font-mono); }
.settled-scores .blk { text-align: center; }
.settled-scores .blk .v { font-weight: 600; font-size: 16px; }
.settled-scores .blk .k { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.settled-scores .blk.pred .v { color: var(--muted); }
.verdict-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.verdict-badge.exact { background: var(--home-bg); color: var(--home-ink); }
.verdict-badge.outcome { background: color-mix(in oklab,var(--home) 12%, var(--surface)); color: var(--home-ink); }
.verdict-badge.miss { background: var(--away-bg); color: var(--away-ink); }
.settled-rps { font-family: var(--font-mono); font-weight: 600; font-size: 14px; text-align: right; min-width: 56px; }

/* small per-tournament heat table */
.heat-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.heat-table th { padding: 8px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 700; text-align: center; white-space: nowrap; }
.heat-table th:first-child, .heat-table td:first-child { text-align: left; font-weight: 600; }
.heat-table td { padding: 0; text-align: center; }
.heat-table td.htc { position: relative; }
.htc .cellv {
  display: block; margin: 3px; padding: 9px 6px; border-radius: 6px;
  font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums;
}
.htc.best .cellv { box-shadow: inset 0 0 0 1.5px var(--ink); font-weight: 700; }

.chart-box { width: 100%; }
.chart-box.h280 { height: 280px; }
.chart-box.h320 { height: 320px; }
.chart-box.h360 { height: 360px; }
.chart-box.h420 { height: 420px; }
.calib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.calib-cell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 14px 6px; box-shadow: var(--shadow-sm); }
.calib-cell .ct { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.calib-cell .ct h4 { font-size: 14px; }
.calib-cell .ct .ece { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.calib-cell .ct .ece b { color: var(--ink); }

/* =========================================================================
   TAB 3 — SIMULATION
   ========================================================================= */
.win-bars { display: flex; flex-direction: column; gap: 3px; }
.win-row { display: grid; grid-template-columns: 26px 150px 1fr 52px; align-items: center; gap: 12px; padding: 5px 6px; border-radius: 7px; transition: background .15s; cursor: pointer; }
.win-row:hover { background: var(--surface-2); }
.win-row .rank { font-family: var(--font-mono); font-size: 12px; color: var(--faint); text-align: right; }
.win-row .barwrap { height: 22px; background: var(--surface-2); border-radius: 5px; overflow: hidden; position: relative; }
.win-row .bar { height: 100%; background: linear-gradient(90deg, var(--home), color-mix(in oklab,var(--home) 70%, var(--accent))); border-radius: 5px; min-width: 2px; }
.win-row .pct { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; text-align: right; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.group-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.group-card .gh { padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-family: var(--font-head); font-weight: 700; font-size: 13px; letter-spacing: .03em; display: flex; justify-content: space-between; }
.group-card .gh .gp { color: var(--faint); font-weight: 600; font-size: 11px; }
.group-row { display: flex; align-items: center; gap: 9px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.group-row:last-child { border-bottom: none; }
.group-row .gname { font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-row .gwin { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.group-row.q1 { background: color-mix(in oklab,var(--home) 6%, transparent); }
.group-row .qd { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.group-row.adv .qd { background: var(--home); }

/* =========================================================================
   TAB 4 — ENSEMBLE
   ========================================================================= */
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
  background: linear-gradient(120deg, var(--ribbon-bg), var(--ribbon-bg-2));
  color: var(--ribbon-ink); border-radius: var(--r-xl); padding: 24px 28px; box-shadow: var(--shadow);
}
.callout .co-fig { text-align: center; }
.callout .co-fig .vs { font-family: var(--font-mono); font-size: 13px; color: var(--ribbon-muted); }
.callout .co-fig .nums { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.callout .co-fig .nb { text-align: center; }
.callout .co-fig .nb .n { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.callout .co-fig .nb .l { font-size: 10.5px; color: var(--ribbon-muted); letter-spacing: .05em; text-transform: uppercase; }
.callout .co-fig .nb.worse .n { color: #F0C36B; }
.callout .co-fig .nb.better .n { color: var(--ribbon-live); }
.callout .co-fig .arrow { color: var(--ribbon-muted); font-size: 20px; }
.callout .co-txt h3 { font-size: 18px; color: #fff; }
.callout .co-txt p { font-size: 13.5px; color: var(--ribbon-muted); margin: 8px 0 0; line-height: 1.55; }

.weight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px,1fr)); gap: 14px; }
.weight-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.weight-card.lead { border-color: color-mix(in oklab,var(--home) 40%, transparent); }
.weight-card .wc-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.weight-card .wc-name { font-family: var(--font-head); font-weight: 700; font-size: 15px; }
.weight-card .wc-w { font-family: var(--font-mono); font-weight: 600; font-size: 24px; letter-spacing: -.02em; }
.weight-card.lead .wc-w { color: var(--home); }
.weight-card .wc-w.zero { color: var(--faint); }
.weight-card .wc-bar { height: 6px; background: var(--surface-2); border-radius: 4px; margin: 12px 0; overflow: hidden; }
.weight-card .wc-bar i { display: block; height: 100%; background: var(--home); border-radius: 4px; }
.weight-card .wc-rps { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.weight-card .wc-rps b { color: var(--ink); }
.weight-card .wc-desc { font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; text-wrap: pretty; }

.method-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 12px; }
.method-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-sm); }
.method-item .mi-n { font-family: var(--font-mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.method-item h4 { font-size: 14.5px; margin: 6px 0 5px; }
.method-item p { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.55; text-wrap: pretty; }
.source-row { display: flex; flex-wrap: wrap; gap: 8px; }
.source-row .src { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 13px; font-size: 12.5px; }
.source-row .src .sk { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; }
.source-row .src .sv { font-weight: 600; }

.blend-bar { display: flex; height: 40px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); margin: 14px 0; }
.blend-bar .seg-book { background: var(--ink); color: var(--paper); }
.blend-bar .seg-elo { background: var(--home-bg); color: var(--home-ink); }
.blend-bar .blend-bar-seg { display: grid; place-items: center; font-size: 12.5px; font-weight: 700; font-family: var(--font-mono); }

/* =========================================================================
   MODAL (match detail + team detail)
   ========================================================================= */
.scrim {
  position: fixed; inset: 0; z-index: 100; background: rgba(8,12,10,.46);
  backdrop-filter: blur(3px); display: grid; place-items: start center;
  padding: 40px 18px; overflow-y: auto;
}
[data-theme="dark"] .scrim { background: rgba(0,0,0,.6); }
.modal {
  width: 100%; max-width: 720px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal.wide { max-width: 920px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head .mh-meta { font-size: 12px; color: var(--faint); }
.modal-head .mh-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 22px; }
.modal-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-bottom: 22px; }
.modal-teams .mt-side { display: flex; flex-direction: column; align-items: center; gap: 9px; text-align: center; }
.modal-teams .mt-side .zh { font-weight: 700; font-size: 16px; font-family: var(--font-head); }
.modal-teams .mt-mid { text-align: center; }
.modal-teams .mt-mid .top { font-family: var(--font-mono); font-weight: 600; font-size: 38px; letter-spacing: -.03em; }
.modal-teams .mt-mid .top .sep { color: var(--faint); font-weight: 300; }
.modal-teams .mt-mid .lbl { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }

.subgrid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; align-items: start; }
.modelbreak { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.modelbreak th, .modelbreak td { padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: right; }
.modelbreak th { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 700; }
.modelbreak th:first-child, .modelbreak td:first-child { text-align: left; }
.modelbreak .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.modelbreak tr.deployed td { background: var(--home-bg); }
.modelbreak tr.deployed td:first-child { box-shadow: inset 3px 0 0 var(--home); font-weight: 700; }
.modelbreak td.na { color: var(--faint); }
.modelbreak .mname { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mtag { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: var(--accent); color: #fff; letter-spacing: .03em; }
[data-theme="dark"] .mtag { color: #07120D; }

/* team detail */
.td-stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px,1fr)); gap: 10px; margin: 16px 0 20px; }
.td-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.td-stat .v { font-family: var(--font-mono); font-weight: 600; font-size: 22px; letter-spacing: -.02em; }
.td-stat .l { font-size: 11px; color: var(--faint); font-weight: 600; margin-top: 2px; }
.td-fix { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; border-radius: 6px; }
.td-fix:hover { background: var(--surface-2); }
.td-fix .date { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); width: 48px; flex-shrink: 0; }
.td-fix .opp { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.td-fix .pr { font-family: var(--font-mono); font-size: 12px; }

/* survival heat table reuse */
.surv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.surv-table th { padding: 8px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 700; text-align: center; }
.surv-table th:first-child, .surv-table td:first-child { text-align: left; }
.surv-table td { padding: 0; text-align: center; }
.surv-table td.sc { position: relative; }
.surv-table .sv { display: block; margin: 2px; padding: 8px 4px; border-radius: 5px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.surv-table td:first-child { padding: 6px 8px; font-weight: 600; }
.surv-name { display: flex; align-items: center; gap: 8px; }

.empty { text-align: center; color: var(--faint); padding: 60px 20px; font-size: 14px; }

/* responsive */
@media (max-width: 900px) {
  .calib-grid { grid-template-columns: 1fr; }
  .subgrid { grid-template-columns: 1fr; }
  .callout { grid-template-columns: 1fr; text-align: center; }
  .callout .co-fig .nums { justify-content: center; }
}
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; padding: 11px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .main { padding: 20px 16px 70px; }
  .ribbon { top: 0; position: relative; }
  .app-header { position: relative; }
  .toolbar { position: relative; top: 0; }
  .grid-cards { grid-template-columns: 1fr; }
  .win-row { grid-template-columns: 22px 110px 1fr 46px; gap: 8px; }
  .settled-row { grid-template-columns: 1fr auto; gap: 8px 14px; }
  .view-head h2 { font-size: 22px; }
}
