/* ---- Design tokens ----
   Palette: charcoal turf (#12151A bg), deep turf green (#1F6F4A), scoreboard amber (#F2B705),
   chalk (#EDEDE4 text), slate hairline (#3A4048).
   Type: Archivo Expanded (display, scoreboard headers), Inter (body/UI), Space Mono (stats/tabular numerals).
   Signature: the amber scoreboard ticker strip under the topbar showing live win-probability bars.
*/
:root {
  --bg: #12151A;
  --bg-raised: #191D24;
  --turf: #1F6F4A;
  --turf-bright: #2E9463;
  --amber: #F2B705;
  --chalk: #EDEDE4;
  --chalk-dim: #9AA0A8;
  --hairline: #2B3038;
  --danger: #D9534F;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--chalk);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Archivo Expanded', 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0 0 8px;
}

.hidden { display: none !important; }

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: var(--amber);
  color: #12151A;
  font-family: 'Archivo Expanded', sans-serif;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 4px;
}
.brand-name { font-family: 'Archivo Expanded', sans-serif; font-weight: 800; font-size: 18px; }
.sync-status { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--chalk-dim); }

/* ---- Signature: scoreboard ticker ---- */
.ticker {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
  white-space: nowrap;
  padding: 10px 0;
}
.ticker-track { display: inline-flex; gap: 28px; padding-left: 24px; }
.ticker-empty { font-family: 'Space Mono', monospace; color: var(--chalk-dim); font-size: 13px; }
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  padding: 4px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  flex-shrink: 0;
}
.ticker-bar {
  width: 60px;
  height: 6px;
  background: var(--hairline);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.ticker-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--amber); }

/* ---- Layout shell ---- */
.shell { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }

.panel.import-panel { max-width: 560px; margin: 40px auto; }
.import-panel .sub { color: var(--chalk-dim); margin-bottom: 24px; line-height: 1.5; }

.import-form { display: flex; flex-direction: column; gap: 16px; }
.field-row { display: flex; gap: 16px; }
.field-row > label { flex: 1; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--chalk-dim); }
input, select {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  color: var(--chalk);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}
input:focus, select:focus, button:focus {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}
.hint { font-size: 12px; color: var(--chalk-dim); margin: -8px 0 0; }

.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.btn-primary { background: var(--amber); color: #12151A; }
.btn-primary:hover { background: #ffcb2b; }
.btn-secondary { background: transparent; border: 1px solid var(--hairline); color: var(--chalk); }
.btn-secondary:hover { border-color: var(--amber); color: var(--amber); }

.error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 4px; }
.tab {
  background: none; border: none; color: var(--chalk-dim);
  padding: 12px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }

.tab-actions {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0; border-bottom: 1px solid var(--hairline); margin-bottom: 24px;
}
.my-team-picker { flex-direction: row; align-items: center; gap: 8px; }
.my-team-picker select { padding: 8px 10px; }

.rankings-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.rankings-toolbar .sub { margin: 0; max-width: 560px; }

/* ---- Overview ---- */
.league-meta { font-family: 'Space Mono', monospace; color: var(--chalk-dim); font-size: 13px; margin-bottom: 20px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.team-card {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px;
}
.team-card .team-name { font-weight: 700; margin-bottom: 4px; }
.team-card .team-record { font-family: 'Space Mono', monospace; color: var(--amber); font-size: 13px; }
.team-card .team-owner { color: var(--chalk-dim); font-size: 12px; margin-top: 4px; }

.roster-list { margin-top: 10px; border-top: 1px solid var(--hairline); padding-top: 8px; }
.roster-loading, .roster-error, .roster-empty { font-size: 12px; color: var(--chalk-dim); font-family: 'Space Mono', monospace; }
.roster-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: 'Space Mono', monospace; font-size: 12px; padding: 3px 0;
}
.roster-row.starter .roster-player-name { color: var(--chalk); }
.roster-row.bench .roster-player-name { color: var(--chalk-dim); }
.roster-player-points { color: var(--amber); flex-shrink: 0; margin-left: 8px; }

/* ---- Projections tab ---- */
.proj-team-total { font-family: 'Space Mono', monospace; color: var(--amber); font-size: 13px; margin-top: 2px; }
.roster-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--chalk-dim);
  margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--hairline);
}

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--chalk-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 8px; border-bottom: 1px solid var(--hairline); }
td { padding: 10px 8px; border-bottom: 1px solid var(--hairline); font-family: 'Space Mono', monospace; }
tr:hover td { background: rgba(242,183,5,0.04); }
.value-positive { color: var(--turf-bright); }
.value-negative { color: var(--danger); }

/* ---- Draft grade board ---- */
.grade-board { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.grade-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px;
}
.grade-letter {
  font-family: 'Archivo Expanded', sans-serif; font-weight: 800; font-size: 16px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; background: var(--turf); color: var(--chalk);
}
.grade-letter.low { background: var(--danger); }

/* ---- Toggle group (e.g. Draft Grades / Pre-season Power Ranking) ---- */
.toggle-group { display: flex; gap: 8px; margin-bottom: 20px; }
.toggle-btn {
  background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--radius);
  color: var(--chalk-dim); padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.toggle-btn.active { color: var(--amber); border-color: var(--amber); }

/* ---- Recommendations ---- */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.rec-card { background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 16px; }
.rec-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.rec-card-header h3 { margin: 0; }
.rec-card-header select { padding: 4px 8px; font-size: 12px; }
.rec-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; }
.rec-row:last-child { border-bottom: none; }
.rec-reason { color: var(--chalk-dim); font-size: 12px; margin-top: 2px; }

/* ---- Roster needs diverging bar chart ---- */
.needs-row { padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.needs-row:last-child { border-bottom: none; }
.needs-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 6px; }
.needs-pos { font-weight: 600; letter-spacing: 0.02em; }
.needs-bar-track { position: relative; height: 8px; background: var(--hairline); border-radius: 999px; overflow: hidden; }
.needs-bar-center { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--bg-raised); z-index: 1; }
.needs-bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.needs-bar-fill.positive { background: var(--turf-bright); }
.needs-bar-fill.negative { background: var(--danger); }

.activity-feed { background: var(--bg-raised); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 16px; }
.activity-row { padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; }
.activity-row:last-child { border-bottom: none; }

@media (max-width: 640px) {
  .field-row { flex-direction: column; }
  .tabs { overflow-x: auto; }
}
