/* VB Fantasy — vanilla CSS, custom-property theming (dark default + light override). */
:root {
  --bg: #14161a;
  --bg-elev: #1c1f26;
  --bg-elev2: #242832;
  --border: #2e333e;
  --text: #e7e9ee;
  --text-dim: #9aa2b1;
  --accent: #e8622c;
  --accent-dim: #b64a1f;
  --good: #4fb477;
  --bad: #d1596b;
  --row-hover: #262b35;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
  --radius: 10px;
}
:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --bg-elev2: #eef0f4;
  --border: #d9dde4;
  --text: #1a1d23;
  --text-dim: #63697a;
  --accent: #d9531e;
  --accent-dim: #b64a1f;
  --good: #2f8f56;
  --bad: #c23a51;
  --row-hover: #eef1f6;
  --shadow: 0 8px 28px rgba(20,30,50,.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .3px;
  white-space: nowrap;
}
.brand img { display: block; }

.search { position: relative; flex: 1 1 auto; max-width: 420px; }
.search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 30;
}
.search-results .group-label {
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
  background: var(--bg-elev2);
  position: sticky;
  top: 0;
}
.search-results .item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.search-results .item:hover, .search-results .item.active { background: var(--row-hover); }
.search-results .item .sub { color: var(--text-dim); font-size: 12px; }
.search-results .empty { padding: 12px; color: var(--text-dim); }

.controls { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-dim); }
.field span { text-transform: uppercase; letter-spacing: .5px; }
select, .field select {
  background: var(--bg-elev2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
}
select:focus { outline: none; border-color: var(--accent); }
.icon-btn {
  background: var(--bg-elev2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  overflow-x: auto;
}
.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 11px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---- View ---- */
.view { flex: 1 1 auto; overflow-y: auto; padding: 18px; }
.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.view-head h1 { font-size: 20px; margin: 0; flex: 0 0 auto; }
.view-head .spacer { flex: 1 1 auto; }
/* Team detail heading: short name on top, full institution name beneath. */
.team-title { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.team-title h1 { font-size: 20px; margin: 0; }
.team-title .team-fullname { font-size: 13px; font-weight: 400; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-title {
  padding: 12px 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title .badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-elev2);
  padding: 2px 8px;
  border-radius: 20px;
}

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: center; width: 44px; color: var(--text-dim); }
th.l, td.l { text-align: left; }
thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elev2);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  z-index: 1;
  cursor: default;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text); }
thead th.sorted::after { content: " ▾"; color: var(--accent); }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--row-hover); }
td.num { font-variant-numeric: tabular-nums; }
.link { color: var(--accent); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.pos-tag {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-elev2);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
}
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ---- Wide horizontally-scrolling table (team detail) ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wide-table { min-width: max-content; }
.wide-table th.sticky-col, .wide-table td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  min-width: 170px;
  width: auto;
  background: var(--bg-elev);
  box-shadow: 1px 0 0 var(--border);
}
.wide-table thead th.sticky-col { z-index: 3; background: var(--bg-elev2); }
tbody tr:hover td.sticky-col { background: var(--row-hover); }
.wide-table tbody tr.total-row td { font-weight: 700; border-top: 2px solid var(--border); }
.wide-table tbody tr.total-row td.sticky-col { background: var(--bg-elev2); }

/* ---- Conference group ---- */
.conf-group { margin-bottom: 18px; }

/* ---- Compare slots ---- */
.compare-slots { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.compare-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  flex: 0 1 230px;
  min-width: 200px;
}
.compare-card.add { border-style: dashed; }
.compare-card-name { font-weight: 700; margin-bottom: 2px; }
.compare-remove {
  position: absolute; top: 6px; right: 9px;
  background: none; border: none; color: var(--text-dim);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.compare-remove:hover { color: var(--bad); }
.compare-search {
  width: 100%; margin-top: 8px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 6px 8px; font-size: 13px;
}
.compare-search:focus { outline: none; border-color: var(--accent); }
.compare-results { margin-top: 6px; display: flex; flex-direction: column; }
.compare-result {
  padding: 6px 8px; cursor: pointer; border-radius: 6px;
  display: flex; justify-content: space-between; gap: 8px;
}
.compare-result:hover { background: var(--row-hover); }
.compare-result .sub { color: var(--text-dim); font-size: 12px; }

/* ---- Fantasy weights panel ---- */
.weights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
}
.weights label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-dim); }
.weights input {
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 7px;
  font-size: 13px;
}
.weights input:focus { outline: none; border-color: var(--accent); }
.weights-actions { padding: 0 14px 14px; display: flex; gap: 10px; }
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.btn:hover { background: var(--accent-dim); }
.btn.ghost { background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border); }

details.weights-wrap { margin-bottom: 16px; }
details.weights-wrap > summary {
  cursor: pointer;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  list-style: none;
}
details.weights-wrap[open] > summary { border-radius: var(--radius) var(--radius) 0 0; }
details.weights-wrap > summary::-webkit-details-marker { display: none; }
details.weights-wrap > summary::before { content: "⚙ "; }
details.weights-wrap .panel {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg-elev);
}

/* ---- Player detail ---- */
.player-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 6px;
}
.player-head h1 { margin: 0; font-size: 24px; }
.player-head .meta { color: var(--text-dim); font-size: 14px; }
.statline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.stat-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-box .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.stat-box .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-box .v.fp { color: var(--accent); }

.back-link { margin-bottom: 12px; }

/* ---- misc ---- */
.muted { color: var(--text-dim); }
.center { text-align: center; }
.empty-state { padding: 48px; text-align: center; color: var(--text-dim); }
.spinner { padding: 48px; text-align: center; color: var(--text-dim); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px; font-size: 13px;
}
.chip button { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px; line-height: 1; }
.chip button:hover { color: var(--bad); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}
.toast.err { border-color: var(--bad); }

@media (max-width: 720px) {
  .controls .field span { display: none; }
  .brand span { display: none; }
  .search { max-width: none; }
}
