/* ── Variables ───────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  --bg:           #F2EFE9;
  --surface:      #FFFFFF;
  --surface-soft: #ECEAE4;
  --line:         #DDD9D0;
  --line-soft:    #E8E5DE;
  --text:         #141414;
  --muted:        #6B6560;
  --muted-soft:   #A09890;
  --border:       #DDD9D0;   /* alias used by plan page */

  --blue:         #1254CC;
  --blue-bg:      #EAF0FC;
  --green:        #1A8A4A;
  --green-bg:     #E5F4EC;
  --amber:        #B86E18;
  --amber-bg:     #FBF1E2;
  --red:          #B83232;
  --red-bg:       #FDECEA;

  --sidebar:      #1A3D2B;
  --sidebar-text: #B8CFBF;
  --sidebar-acc:  #5CBF7A;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow:    0 4px 14px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);

  --font-display: 'Barlow Condensed', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

/* ── App shell ───────────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 204px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--sidebar);
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.brand-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-season {
  display: block;
  font-size: 11px;
  color: var(--sidebar-text);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.sidebar-nav {
  padding: 10px 8px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.sidebar-nav a svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.75; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a:hover svg { opacity: 1; }

.sidebar-nav a[aria-current="page"],
.sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: var(--sidebar-acc);
  font-weight: 600;
}

.sidebar-nav a[aria-current="page"] svg,
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-seasons {
  padding: 10px 8px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-seasons-label {
  display: block;
  padding: 0 10px 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(184,207,191,0.45);
  font-family: var(--font-mono);
}

.season-link {
  display: block;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--sidebar-text);
  font-family: var(--font-mono);
}

.season-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.season-link.active { color: #fff; font-weight: 500; }

/* ── Main + status strip ─────────────────────────────────────────────────── */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  height: 37px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.strip-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.strip-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.strip-sep { color: var(--line); }

.strip-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.strip-link:hover { color: var(--text); }
.strip-link svg { width: 12px; height: 12px; }

.content {
  padding: 26px 28px 44px;
  flex: 1;
}

/* ── Typography ──────────────────────────────────────────────────────────── */

.page-eyebrow,
.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-mono);
}

.page-title {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--text);
  margin-bottom: 22px;
}

.subhead {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ── Old page-header (scraper, club_season, players) ─────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Status pill / icon button / search (old pages) ──────────────────────── */

.status-pill,
.icon-button,
.search-box {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 600;
  font-size: 13px;
}

.status-pill svg,
.icon-button svg,
.search-box svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 100%);
  padding: 0 12px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

/* ── Metric cards (scraper page) ─────────────────────────────────────────── */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card span,
.metric-card small { display: block; color: var(--muted); font-size: 12px; }

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.metric-card .small-value { font-size: 14px; font-family: var(--font-mono); overflow-wrap: anywhere; }

.category-card-single { border-top: 3px solid var(--blue); }
.category-card-double { border-top: 3px solid var(--green); }
.category-card-mix    { border-top: 3px solid var(--amber); }

.metric-card--stale { border-color: #fcd34d; background: #fffbeb; }

/* ── Panel ───────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #FAFAF7;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-action,
.text-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue);
}

.panel-action:hover,
.text-link:hover { opacity: 0.8; }

/* ── Dashboard grid (club_season, legacy) ────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel-wide { grid-column: 1 / -1; }

/* ── Table ───────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #FAFAF7;
  color: var(--muted-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

tbody tr:hover { background: #FAFAF7; transition: background 0.1s; }
tbody tr:last-child td { border-bottom: none; }

/* ── Data components ─────────────────────────────────────────────────────── */

.player-link {
  display: block;
  font-weight: 700;
  color: var(--text);
}

.player-link:hover { color: var(--blue); }

.muted { display: block; color: var(--muted); font-size: 12px; }
.rank  { display: block; color: var(--muted); font-size: 12px; font-family: var(--font-mono); }

.points {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
}

.result {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.result.win     { background: var(--green-bg); color: var(--green); }
.result.loss    { background: var(--red-bg);   color: var(--red); }
.result.neutral { background: var(--surface-soft); color: var(--muted); }
.result.w       { background: var(--green-bg); color: var(--green); }
.result.l       { background: var(--red-bg);   color: var(--red); }

.category {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.category-single { background: var(--blue-bg);  color: var(--blue); }
.category-double { background: var(--green-bg); color: var(--green); }
.category-mix    { background: var(--amber-bg); color: var(--amber); }

.cat-chip {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.cat-chip.s { background: var(--blue-bg);  color: var(--blue); }
.cat-chip.d { background: var(--green-bg); color: var(--green); }
.cat-chip.x { background: var(--amber-bg); color: var(--amber); }

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
}

.empty-state {
  margin: 0;
  padding: 18px 18px;
  color: var(--muted);
  font-size: 13px;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

/* ── Chart containers ────────────────────────────────────────────────────── */

.chart-frame { height: 280px; padding: 14px; }
.chart-tall  { height: 360px; }
.chart-wrap  { height: 240px; padding: 16px 18px 10px; }

/* ── Compact list / summary (head-to-head, etc.) ─────────────────────────── */

.compact-list,
.summary-stack { display: grid; gap: 0; }

.list-row,
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.list-row:last-child,
.summary-row:last-child { border-bottom: 0; }

.list-row small { display: block; color: var(--muted); font-size: 11.5px; }

.nemesis-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ── Flash / notice ──────────────────────────────────────────────────────── */

.flash-banner {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
}

.flash-ok   { background: #d1fae5; color: #065f46; }
.flash-info { background: var(--blue-bg); color: #1e40af; }

/* ── Segmented control ───────────────────────────────────────────────────── */

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  gap: 1px;
}

.segmented button {
  min-height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  padding: 0 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ── ─────────────────────────────────────────────────────────────────────── */
/* ── DASHBOARD: ranking hero table ──────────────────────────────────────── */
/* ── ─────────────────────────────────────────────────────────────────────── */

.hero-panel { margin-bottom: 18px; }

.ranking-table { width: 100%; border-collapse: collapse; }

.ranking-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-soft);
  font-family: var(--font-mono);
  background: #FAFAF7;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.ranking-table th.col-cat  { text-align: center; }
.ranking-table th.col-single { color: var(--blue); }
.ranking-table th.col-double { color: var(--green); }
.ranking-table th.col-mix    { color: var(--amber); }

.ranking-table td { border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.ranking-table tbody tr:last-child td { border-bottom: none; }
.ranking-table tbody tr { transition: background 0.1s; }
.ranking-table tbody tr:hover { background: #FAFAF7; }

.td-rank   { padding: 12px 8px 12px 18px; width: 36px; }
.td-player { padding: 12px 20px 12px 2px; }
.td-cat    { padding: 10px 14px; text-align: center; min-width: 106px; }
.td-form   { padding: 10px 14px; min-width: 84px; }
.td-last   { padding: 10px 18px 10px 14px; white-space: nowrap; }

.rank-num {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--muted-soft);
  line-height: 1;
}

.player-name-display {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--text);
}

.player-name-display:hover { color: var(--blue); }

.player-club-small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.cat-pts {
  display: block;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.cat-pts.s    { color: var(--blue); }
.cat-pts.d    { color: var(--green); }
.cat-pts.x    { color: var(--amber); }
.cat-pts.none { color: var(--line); font-size: 24px; }

.cat-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
}

/* Form dots */
.form-dots { display: flex; gap: 3px; margin-bottom: 4px; }

.form-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.form-dot.w { background: var(--green); }
.form-dot.l { background: var(--red); opacity: 0.35; }

.form-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}

.fw { color: var(--green); }
.fl { color: var(--red); }

.last-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* Dashboard bottom grid */
.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr);
  gap: 18px;
}

/* Match feed */
.match-feed { list-style: none; }

.match-item {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.1s;
}

.match-item:last-child { border-bottom: none; }
.match-item:hover { background: #FAFAF7; }

.match-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.match-info { min-width: 0; }

.match-player {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.match-opp {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.match-score {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* Team rows panel */
.row-list { list-style: none; }

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.row-item:last-child { border-bottom: none; }
.row-name   { display: block; font-weight: 600; font-size: 13.5px; }
.row-league { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.row-count {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--surface-soft);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ── ─────────────────────────────────────────────────────────────────────── */
/* ── PLAYER DETAIL ───────────────────────────────────────────────────────── */
/* ── ─────────────────────────────────────────────────────────────────────── */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 14px;
}

.back-link:hover { color: var(--text); }
.back-link svg { width: 14px; height: 14px; }

.player-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.player-title {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--text);
  margin-bottom: 0;
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.player-meta-item {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.player-meta-item svg { width: 12px; height: 12px; opacity: 0.6; }
.player-meta-sep { color: var(--line); }

/* Form strip */
.form-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.form-strip-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-soft);
  white-space: nowrap;
}

.form-squares { display: flex; gap: 3px; }

.fsq {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.fsq.w { background: var(--green); }
.fsq.l { background: var(--red); opacity: 0.3; }

.form-tally {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.ft-w { color: var(--green); font-weight: 500; }
.ft-l { color: var(--red);   font-weight: 500; }
.ft-sep { color: var(--line); }

/* Stat tiles */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
}

.stat-tile.s { border-top: 3px solid var(--blue);  background: linear-gradient(180deg, rgba(18,84,204,0.05) 0%, transparent 55%); }
.stat-tile.d { border-top: 3px solid var(--green); background: linear-gradient(180deg, rgba(26,138,74,0.05) 0%, transparent 55%); }
.stat-tile.x { border-top: 3px solid var(--amber); background: linear-gradient(180deg, rgba(184,110,24,0.05) 0%, transparent 55%); }

.tile-cat {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-tile.s .tile-cat { color: var(--blue); }
.stat-tile.d .tile-cat { color: var(--green); }
.stat-tile.x .tile-cat { color: var(--amber); }

.tile-pts {
  display: block;
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
}

.stat-tile.s .tile-pts { color: var(--blue); }
.stat-tile.d .tile-pts { color: var(--green); }
.stat-tile.x .tile-pts { color: var(--amber); }

.tile-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.tile-class {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
}

.stat-tile.s .tile-class { background: var(--blue-bg);  color: var(--blue); }
.stat-tile.d .tile-class { background: var(--green-bg); color: var(--green); }
.stat-tile.x .tile-class { background: var(--amber-bg); color: var(--amber); }

.tile-rank    { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tile-matches { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Timeline panel */
.timeline-panel { margin-bottom: 18px; }

.tl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #FAFAF7;
}

.tl-legend {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tl-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}

.tl-legend-item.dim { opacity: 0.35; }

.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tl-dot.s { background: var(--blue); }
.tl-dot.d { background: var(--green); }
.tl-dot.x { background: var(--amber); }

/* Player detail bottom grid */
.player-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 286px;
  gap: 18px;
  align-items: start;
}

.side-panels { display: flex; flex-direction: column; gap: 14px; }

/* Match history table (player detail) */
.match-table { width: 100%; border-collapse: collapse; }

.match-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-soft);
  font-family: var(--font-mono);
  background: #FAFAF7;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.match-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}

.match-table tbody tr:last-child td { border-bottom: none; }
.match-table tbody tr:hover { background: #FAFAF7; transition: background 0.1s; }

.td-date  { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.td-trn   { max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.td-score { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.td-pts   { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; }
.td-pts.pos { color: var(--green); }
.td-pts.neg { color: var(--muted-soft); }

/* W/L breakdown */
.wl-item {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.wl-item:last-child { border-bottom: none; }

.wl-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.wl-cat.s { color: var(--blue); }
.wl-cat.d { color: var(--green); }
.wl-cat.x { color: var(--amber); }

.wl-counts {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 5px;
}

.wl-wins {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--green);
}

.wl-sep { font-size: 13px; color: var(--line); }

.wl-losses {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted-soft);
}

.wl-pct {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.wl-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--line-soft);
  overflow: hidden;
}

.wl-bar-fill { height: 100%; border-radius: 2px; }

.wl-item:nth-child(1) .wl-bar-fill { background: var(--blue); }
.wl-item:nth-child(2) .wl-bar-fill { background: var(--green); }
.wl-item:nth-child(3) .wl-bar-fill { background: var(--amber); }

/* Partners / opponents */
.person-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.person-item:last-child { border-bottom: none; }

.person-name { font-weight: 600; font-size: 13px; display: block; }
.person-sub  { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }

.person-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.person-wl { display: flex; gap: 4px; }

.mini-w, .mini-l {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
}

.mini-w { background: var(--green-bg); color: var(--green); }
.mini-l { background: var(--red-bg);   color: var(--red); }

/* ── Movers / delta display ─────────────────────────────────────────────── */

.delta-positive,
.delta-negative,
.delta-neutral {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.delta-positive { color: var(--green); }
.delta-negative { color: var(--red); }
.delta-neutral  { color: var(--muted-soft); }

/* player-name-display is used in rankings table and movers */
.td-rank  { padding: 12px 8px 12px 18px; width: 36px; }
.td-player { padding: 12px 20px 12px 2px; }

/* ── Login page ──────────────────────────────────────────────────────────── */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar);
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-brand .brand-mark { background: var(--bg); color: var(--sidebar); }
.login-brand strong { font-size: 16px; color: var(--text); }

.login-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.login-input:focus { border-color: var(--blue); }

.login-error { color: var(--red); font-size: 13px; margin: 8px 0 0; }

.login-button {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.login-button:hover { opacity: 0.9; }

/* ── Scraper / observability ─────────────────────────────────────────────── */

.run-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: var(--font-mono);
}

.run-status--success { background: #dcfce7; color: #15803d; }
.run-status--partial { background: #fef9c3; color: #854d0e; }
.run-status--failed,
.run-status--error   { background: #fee2e2; color: #b91c1c; }
.run-status--running {
  background: var(--blue-bg);
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.player-status {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: var(--font-mono);
}

.player-status--imported { background: #dcfce7; color: #15803d; }
.player-status--queued   { background: #f3f4f6; color: #6b7280; }
.player-status--fetching,
.player-status--enriching { background: var(--blue-bg); color: #1d4ed8; }
.player-status--fetched  { background: #fef9c3; color: #854d0e; }
.player-status--failed   { background: #fee2e2; color: #b91c1c; }

.scraper-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 2px solid #93c5fd;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.stale-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--amber-bg);
  color: var(--amber);
  vertical-align: middle;
}

.add-player-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.add-player-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.add-player-form button {
  padding: 8px 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* ── Plan page ───────────────────────────────────────────────────────────── */

.plan-config-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .88rem;
}

.plan-config-form label {
  font-weight: 600;
  font-size: .82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.plan-config-form select,
.plan-config-form input[type="text"] {
  font-size: .9rem;
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.plan-generate-form { margin-bottom: 1.5rem; }

.plan-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .6rem;
}

.plan-control-label { font-size: .82rem; font-weight: 600; color: var(--muted); }

.plan-disclaimer {
  font-size: .78rem;
  color: var(--muted);
  border-left: 3px solid var(--border);
  padding: .3rem .65rem;
  margin-bottom: .75rem;
}

.plan-avail-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.plan-avail-table th,
.plan-avail-table td { white-space: nowrap; }

.plan-avail-table th.avail-col,
.plan-avail-table td.avail-col {
  text-align: center;
  padding: 8px 6px;
  min-width: 36px;
}

.badge-untracked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  cursor: help;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .9rem;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { opacity: .88; }

.btn-secondary {
  padding: .3rem .8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: .85rem;
  cursor: pointer;
}

.plan-results { margin-top: 1.5rem; }
.plan-results-heading { font-size: 15px; font-weight: 700; margin: 0 0 .75rem; }
.holdkort-scroll { overflow-x: auto; }

.holdkort-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(180px, 240px));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.holdkort-card { background: var(--surface); display: flex; flex-direction: column; }

.holdkort-card-header {
  padding: 8px 12px;
  background: #FAFAF7;
  border-bottom: 1px solid var(--line);
}

.holdkort-match-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.holdkort-warnings {
  margin: 0;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--line);
  list-style: none;
  background: #fffbeb;
}

.holdkort-warnings li { font-size: .75rem; color: #92400e; padding: 1px 0; }
.holdkort-warnings li::before { content: "⚠ "; }

.holdkort-players {
  margin: 0;
  padding: .5rem 0;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

.holdkort-player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 12px;
  font-size: .83rem;
}

.holdkort-player-row.has-flag .holdkort-player-name::after {
  content: " ⚠";
  font-size: .7rem;
  color: var(--amber);
}

.holdkort-player-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holdkort-player-pts { font-size: .78rem; flex-shrink: 0; margin-left: .5rem; }
.holdkort-rounds { padding: .5rem 0; }

.holdkort-round {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: 4px 12px;
}

.holdkort-round-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding-top: 2px;
  width: 20px;
  flex-shrink: 0;
}

.holdkort-courts {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.holdkort-court {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .8rem;
  flex-wrap: wrap;
}

.pair-record {
  font-size: .72rem;
  display: inline-flex;
  gap: 2px;
  margin-left: .25rem;
}

.lineup-grid { display: grid; gap: 1px; background: var(--line); }

.lineup-round {
  display: grid;
  grid-template-columns: 60px 1fr 1fr;
  align-items: stretch;
  background: var(--surface);
}

.lineup-round-label {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-right: 1px solid var(--line);
}

.lineup-court {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-right: 1px solid var(--line);
}

.lineup-court:last-child { border-right: none; }
.lineup-pair { font-size: 14px; font-weight: 500; }
.lineup-history { font-size: 12px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }

  .sidebar-brand { padding: 14px 10px; gap: 0; }
  .brand-name, .brand-season { display: none; }

  .sidebar-nav a { padding: 10px; justify-content: center; }
  .sidebar-nav a span { display: none; }
  .sidebar-nav a svg { width: 18px; height: 18px; }

  .sidebar-seasons { display: none; }

  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .bottom-grid    { grid-template-columns: minmax(0, 1fr); }
  .player-bottom-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar-brand {
    border-bottom: none;
    padding: 0 6px 0 0;
    flex-shrink: 0;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    padding: 0;
    flex: 1;
  }

  .sidebar-nav a { margin-bottom: 0; min-width: 40px; justify-content: center; }
  .sidebar-nav a span { display: none; }
  .sidebar-seasons { display: none; }

  .status-strip { padding: 0 16px; font-size: 11px; }
  .strip-left   { gap: 8px; }

  .content { padding: 16px 16px 32px; }

  .page-header { flex-direction: column; gap: 10px; }
  .page-header h1 { font-size: 28px; }
  .page-title { font-size: 32px; }

  .player-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .player-title  { font-size: 40px; }

  .stat-tiles { grid-template-columns: minmax(0, 1fr); }
  .metric-grid { grid-template-columns: minmax(0, 1fr); }

  .panel-header { padding: 10px 14px; }

  th, td { padding: 9px 10px; }
}
