/* Road to Lombardi trade tool. A working tool: dense tables, tabular numbers, system fonts.
   Light and dark follow prefers-color-scheme. No external requests. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #17201a;
  --muted: #5d685f;
  --line: #d9ded7;
  --accent: #1f6f4a;
  --accent-text: #ffffff;
  --accent-soft: #e2f1e8;
  --me: #fff6d6;
  --me-line: #e2c24a;
  --warn-bg: #fff2d9;
  --warn-text: #6b4500;
  --bad: #b3261e;
  --good: #1f7a3f;
  --contend: #1f7a3f;
  --contend-bg: #dcf1e2;
  --bubble: #7a5600;
  --bubble-bg: #fbecc4;
  --retool: #1d5d99;
  --retool-bg: #dceafa;
  --rebuild: #9b2c22;
  --rebuild-bg: #f8dedb;
  --chip-bg: #eceee9;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #181d1a;
    --surface-2: #1f2622;
    --text: #e6ebe7;
    --muted: #9aa69e;
    --line: #2c3530;
    --accent: #57c08b;
    --accent-text: #0d1a12;
    --accent-soft: #1d3a2a;
    --me: #3a3317;
    --me-line: #a8902f;
    --warn-bg: #3b2e12;
    --warn-text: #f3d48c;
    --bad: #ff8a80;
    --good: #7fd69b;
    --contend: #8fe0a8;
    --contend-bg: #1e3a27;
    --bubble: #f2cf73;
    --bubble-bg: #3b3115;
    --retool: #9cc8f5;
    --retool-bg: #1b2d42;
    --rebuild: #ffaaa1;
    --rebuild-bg: #432220;
    --chip-bg: #262e29;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
small, .muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }

/* ---- header */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 8px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1280px; margin: 0 auto; }
.top-row + .top-row { margin-top: 6px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; display: flex; align-items: baseline; gap: 8px; }
.brand-sub { font-weight: 400; font-size: 13px; color: var(--muted); }
.viewas { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.viewas select {
  font: inherit; font-weight: 500; padding: 5px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); max-width: 60vw;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a, .nav .soon { padding: 4px 10px; border-radius: 6px; font-size: 13px; text-decoration: none; }
.nav a { color: var(--text); }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.nav .soon { color: var(--muted); cursor: default; }
.nav .soon small { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 2px; }
.asof { font-size: 12px; color: var(--muted); }
.warn {
  max-width: 1280px; margin: 10px auto 0; padding: 8px 12px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn-text); font-size: 13px;
}
.warn[hidden] { display: none; }

/* ---- layout */
main { max-width: 1280px; margin: 0 auto; padding: 16px; outline: none; }
.foot { max-width: 1280px; margin: 0 auto; padding: 8px 16px 32px; font-size: 12px; color: var(--muted); }
.loading { padding: 64px 0; text-align: center; color: var(--muted); }
.loading progress { width: min(420px, 80vw); height: 8px; }
.error { padding: 16px; border: 1px solid var(--bad); border-radius: var(--radius); color: var(--bad); background: var(--surface); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: 13px; margin-bottom: 6px; }

/* ---- tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
th.l, td.l { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.me td { background: var(--me); }
tr.me td:first-child { box-shadow: inset 3px 0 0 var(--me-line); }
tr.clickable { cursor: pointer; }
th button.sort {
  all: unset; cursor: pointer; display: inline-flex; gap: 3px; align-items: center;
}
th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th[aria-sort="ascending"] button.sort::after { content: "▲"; font-size: 9px; }
th[aria-sort="descending"] button.sort::after { content: "▼"; font-size: 9px; }
td .team-link { font-weight: 600; color: var(--text); text-decoration: none; }
td .team-link:hover { text-decoration: underline; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
td.num-dim { color: var(--muted); }
.pos { font-weight: 600; }
.up { color: var(--good); }
.down { color: var(--bad); }
.zero { color: var(--muted); }

/* ---- chips and tags */
.tag, .chip {
  display: inline-block; font-size: 11px; font-weight: 600; line-height: 1.6; padding: 0 7px;
  border-radius: 999px; background: var(--chip-bg); color: var(--muted); vertical-align: 1px;
}
.tag-contend { background: var(--contend-bg); color: var(--contend); }
.tag-bubble { background: var(--bubble-bg); color: var(--bubble); }
.tag-retool { background: var(--retool-bg); color: var(--retool); }
.tag-rebuild { background: var(--rebuild-bg); color: var(--rebuild); }
.chip-taxi, .chip-ir { background: var(--retool-bg); color: var(--retool); }
.chip-held { background: var(--accent-soft); color: var(--accent); }
.chip-warn { background: var(--warn-bg); color: var(--warn-text); }
.chip-bad { background: var(--rebuild-bg); color: var(--rebuild); }
.chip-starter { background: var(--contend-bg); color: var(--contend); }

/* ---- team view */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.verdict-line { margin: 4px 0 0; }
.player-btn { all: unset; cursor: pointer; font-weight: 600; color: var(--text); }
.player-btn:hover, .player-btn:focus-visible { text-decoration: underline; color: var(--accent); }
.player-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.inj { white-space: normal; min-width: 140px; max-width: 260px; text-align: left; font-size: 12px; }
.dist { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; }
.dist div { text-align: center; font-size: 11px; color: var(--muted); }
.dist .p { display: block; min-height: 15px; color: var(--text); font-weight: 600; }
.dist progress { width: 100%; height: 12px; display: block; }
.dist .k { display: block; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }

progress { accent-color: var(--accent); }

/* ---- player card */
dialog#card {
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
dialog#card::backdrop { background: rgba(0, 0, 0, 0.45); }
.card-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.card-head p { margin: 4px 0 0; color: var(--muted); }
.card-body { padding: 4px 16px 16px; }
.close { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; height: fit-content; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; }

@media (min-width: 721px) {
  table.roster { table-layout: fixed; }
  table.roster td { overflow: hidden; text-overflow: ellipsis; }
  table.roster td.inj { overflow: visible; }
  .c-lu { width: 108px; }
  .c-age { width: 52px; }
  .c-num { width: 76px; }
  .c-inj { width: 250px; }
  .c-wk { width: 58px; }
}

@media (max-width: 720px) {
  body { font-size: 13px; }
  main { padding: 12px; }
  .top { padding: 8px 12px 6px; position: static; }
  .hide-sm { display: none; }
  .two-col { grid-template-columns: 1fr; }
  th, td { padding: 5px 6px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewas select { max-width: 52vw; }
  .dist { gap: 2px; }
}
