/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --bg-card:   #1e293b;
  --bg-hover:  #263347;
  --border:    #334155;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --accent:    #38bdf8;
  --gold:      #fbbf24;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 0;
}
.header-title { display: flex; align-items: center; gap: .75rem; }
.trophy { font-size: 2rem; }
h1 { font-size: 1.4rem; font-weight: 700; color: var(--gold); }
.subtitle { font-size: .8rem; color: var(--text-muted); }
nav { display: flex; gap: .5rem; }
nav a {
  padding: .4rem .9rem; border-radius: 6px;
  color: var(--text-muted); font-size: .85rem; font-weight: 500;
  transition: background .15s, color .15s;
}
nav a:hover, nav a.active {
  background: var(--bg-hover); color: var(--accent); text-decoration: none;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
main {
  max-width: 1400px; margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex; flex-direction: column; gap: 2.5rem;
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.section h2 {
  font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.section h2 .note { font-size: .75rem; font-weight: 400; color: var(--text-muted); }

/* ── Stat Cards ─────────────────────────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1rem;
  text-align: center; box-shadow: var(--shadow);
  transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 1.8rem; line-height: 1; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--gold); margin: .25rem 0; }
.stat-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: .75rem; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th {
  background: #263450; color: var(--text-muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .6rem .75rem; border-bottom: 1px solid var(--border);
  white-space: nowrap; text-align: left;
}
td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:hover td { background: var(--bg-hover); }
.row-flag td { background: #2d1b4e; }
.row-flag:hover td { background: #3a2260; }
.rank-cell { font-size: 1rem; white-space: nowrap; }
.account-cell { white-space: nowrap; }
.score-cell { font-size: 1.05rem; color: var(--gold); text-align: right; }
.total-cell { font-size: 1.05rem; color: var(--gold); }
.links-cell a { margin-right: .5rem; font-size: .78rem; }
.notes-cell { max-width: 280px; font-size: .75rem; color: var(--text-muted); }
.center { text-align: center; }
.muted { color: var(--text-muted); }
.bonus { color: #4ade80; text-align: center; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 999px; font-size: .7rem; font-weight: 600;
  white-space: nowrap;
}
.plat-badge {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 999px; font-size: .7rem; font-weight: 600;
}
.plat-fplace { background: #0ea5e920; color: #38bdf8; border: 1px solid #38bdf8; }
.plat-teams  { background: #7c3aed20; color: #a78bfa; border: 1px solid #a78bfa; }

/* ── Pending note ────────────────────────────────────────────────────────── */
.pending-note {
  background: #1c2d1c; border: 1px solid #4ade80;
  color: #4ade80; border-radius: 6px;
  padding: .6rem 1rem; font-size: .82rem; margin-bottom: 1rem;
}

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.chart-card {
  background: #162032; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.chart-card h3 { font-size: .9rem; margin-bottom: .75rem; color: var(--text-muted); }
.chart-card--wide { grid-column: span 2; }
.chart-container { position: relative; height: 260px; }
.chart-container--tall { height: 420px; }
.chart-container--radar { height: 400px; max-width: 700px; margin: 0 auto; }
.empty-chart { color: var(--text-muted); font-size: .85rem; padding: 2rem; text-align: center; }

/* ── Issues ──────────────────────────────────────────────────────────────── */
.issues-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.issue-card {
  background: #162032; border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.issue-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.issue-url { font-size: .72rem; word-break: break-all; margin-top: .3rem; }

/* ── Rubric ──────────────────────────────────────────────────────────────── */
.rubric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.rubric-card {
  background: #162032; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.rubric-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; gap: .4rem; flex-wrap: wrap; }
.rubric-num { background: var(--accent); color: #0f172a; font-weight: 800; font-size: .75rem; padding: .1rem .4rem; border-radius: 4px; }
.rubric-max { margin-left: auto; color: var(--gold); font-weight: 700; font-size: .85rem; }
.rubric-weight { font-size: .72rem; color: var(--text-muted); margin-top: .4rem; }
.rubric-scale { display: flex; flex-direction: column; gap: 2px; }
.scale-item { font-size: .72rem; padding: .15rem .5rem; border-radius: 4px; }
.s5 { background: #16a34a22; color: #4ade80; }
.s4 { background: #0369a122; color: #38bdf8; }
.s3 { background: #92400e22; color: #fbbf24; }
.s2 { background: #c2410c22; color: #fb923c; }
.s1 { background: #b91c1c22; color: #f87171; }

/* ── Bonus Cards ─────────────────────────────────────────────────────────── */
.bonus-info h3 { font-size: 1rem; margin-bottom: .75rem; }
.bonus-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.bonus-card {
  background: #162032; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; text-align: center;
}
.bonus-card strong { display: block; margin: .4rem 0 .3rem; font-size: .9rem; }
.bonus-card p { font-size: .75rem; color: var(--text-muted); }
.bonus-icon { font-size: 1.5rem; }

/* ── Scoring inputs ─────────────────────────────────────────────────────── */
.score-input {
  width: 44px; background: #263347; border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: .2rem .3rem;
  font-size: .82rem; text-align: center;
}
.score-input:focus { outline: 1px solid var(--accent); }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-bar label { font-size: .82rem; color: var(--text-muted); display: flex; align-items: center; gap: .4rem; }
.filter-bar select {
  background: #263347; border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: .3rem .6rem; font-size: .82rem;
}
.btn-export {
  margin-left: auto; background: #16a34a; color: #fff; border: none;
  border-radius: 6px; padding: .4rem .9rem; font-size: .82rem; cursor: pointer;
  font-weight: 600; transition: background .15s;
}
.btn-export:hover { background: #15803d; }

/* ── AI Estimate Banner ───────────────────────────────────────────────────── */
.ai-banner {
  background: linear-gradient(90deg, #1e3a5f, #1c2d4a);
  border: 1px solid #3b82f6;
  color: #93c5fd;
  padding: .75rem 1.25rem;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  position: sticky; top: 56px; z-index: 90;
}
.ai-banner a { color: #60a5fa; }
.ai-badge {
  background: #3b82f6; color: #fff;
  font-size: .7rem; font-weight: 700;
  padding: .15rem .5rem; border-radius: 4px;
  white-space: nowrap;
}
.ai-dismiss {
  margin-left: auto; background: none; border: none;
  color: #60a5fa; cursor: pointer; font-size: 1rem; padding: 0 .25rem;
}

/* ── Evidence Tooltip ────────────────────────────────────────────────────── */
.evidence-wrap { position: relative; display: inline-block; }
.evidence-wrap .tooltip {
  display: none;
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: #1e293b; border: 1px solid #3b82f6;
  color: #cbd5e1; font-size: .72rem; line-height: 1.5;
  padding: .6rem .8rem; border-radius: 6px;
  width: 340px; max-width: 90vw;
  white-space: normal; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  pointer-events: none;
}
.evidence-wrap:hover .tooltip { display: block; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  text-align: center; padding: 2rem 1rem;
  color: var(--text-muted); font-size: .78rem;
  border-top: 1px solid var(--border);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card--wide { grid-column: span 1; }
}
@media (max-width: 600px) {
  header { padding: 0 1rem; }
  main { padding: 1rem .75rem 3rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  nav { flex-wrap: wrap; }
}
