:root {
  --chalk: #edf1ed;
  --paper: #ffffff;
  --ink: #14213d;
  --ink-2: #33415c;
  --muted: #5b6878;
  --line: #cfd8d2;
  --line-2: #e3e9e5;
  --turf: #1d5a43;
  --turf-2: #2f7d5c;
  --turf-soft: #dcebe3;
  --amber: #d99520;
  --amber-soft: #fbefd6;
  --red: #a83232;
  --red-soft: #f8e1e1;
  --focus: #2d6cdf;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chalk: #0f1a17; --paper: #16241f; --ink: #e8efe9; --ink-2: #c3cfc7; --muted: #93a39a;
    --line: #2c3d36; --line-2: #22322c; --turf: #5fbf94; --turf-2: #7fd3ab; --turf-soft: #1d3a2f;
    --amber: #f0b24a; --amber-soft: #3a2f17; --red: #ef7f7f; --red-soft: #3a1f1f; --focus: #7aa7ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--chalk); color: var(--ink); font: 16px/1.5 var(--body); font-variant-numeric: tabular-nums; }
a { color: var(--turf); text-underline-offset: 2px; }
a:hover { color: var(--turf-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .75rem; max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- top bar */
.topbar { background: var(--turf); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .55rem 16px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.5rem; color: #fff; text-decoration: none; display: flex; align-items: center; gap: .5rem; letter-spacing: .02em; }
.brand:hover { color: #fff; }
.brand-mark { width: 26px; height: 26px; }
.nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a, .nav button { color: #e4f1ea; text-decoration: none; padding: .35rem .65rem; border-radius: var(--radius); font: 500 .95rem var(--body); background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav a.on, .nav button:hover { background: rgba(255,255,255,.14); color: #fff; }
.nav .count { display: inline-block; min-width: 1.3em; padding: 0 .3em; margin-left: .25rem; border-radius: 99px; background: var(--amber); color: #1b1300; font-size: .75rem; font-weight: 600; text-align: center; }
.units { border: 1px solid rgba(255,255,255,.35) !important; }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }

/* ------------------------------------------------------------- controls */
button, .btn { font: 600 .95rem var(--body); border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: .45rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .btn:hover { border-color: var(--turf); color: var(--ink); }
.btn-primary { background: var(--turf); border-color: var(--turf); color: #fff; }
.btn-primary:hover { background: var(--turf-2); border-color: var(--turf-2); color: #fff; }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-small { padding: .2rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: 400 1rem var(--body); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .6rem; width: 100%; min-width: 0; }
textarea { min-height: 6rem; resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 .8rem; }
.check { display: flex; gap: .45rem; align-items: center; font-weight: 500; }
.check input { width: auto; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.panel-head h2, .panel-head h3 { margin: 0; }

.notice { border-left: 4px solid var(--amber); background: var(--amber-soft); padding: .7rem .9rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1rem; }
.notice.err { border-color: var(--red); background: var(--red-soft); }
.notice.ok { border-color: var(--turf); background: var(--turf-soft); }

/* badges: verification state is information, so it is always spelled out */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 600; padding: .05rem .5rem; border-radius: 99px; border: 1px solid; white-space: nowrap; }
.badge::before { content: ''; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.b-verified { color: var(--turf); border-color: color-mix(in srgb, var(--turf) 45%, transparent); background: var(--turf-soft); }
.b-partial { color: #8a5a00; border-color: color-mix(in srgb, var(--amber) 55%, transparent); background: var(--amber-soft); }
.b-unverified { color: var(--muted); border-color: var(--line); background: transparent; }
@media (prefers-color-scheme: dark) { .b-partial { color: var(--amber); } }
.pos { font-family: var(--display); font-weight: 700; font-size: .95rem; background: var(--ink); color: var(--paper); padding: 0 .4rem; border-radius: 4px; letter-spacing: .03em; }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .85rem; white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: color-mix(in srgb, var(--turf-soft) 45%, transparent); }
.name-cell a { font-weight: 600; text-decoration: none; color: var(--ink); }
.name-cell a:hover { color: var(--turf); text-decoration: underline; }

/* ------------------------------------------------------------- search */
.search-layout { display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; }
.filters { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.filters .field { margin-bottom: .75rem; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: .35rem; align-items: center; }
.pos-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { font: 600 .82rem var(--display); letter-spacing: .04em; padding: .25rem .5rem; border-radius: 4px; border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.results-head h1 { margin: 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.active-filters button { font-size: .82rem; padding: .15rem .55rem; border-radius: 99px; background: var(--turf-soft); border-color: transparent; color: var(--turf); }
.filter-toggle { display: none; }

/* multiselect */
.ms { position: relative; }
.ms > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .6rem; background: var(--paper); display: flex; justify-content: space-between; gap: .5rem; }
.ms > summary::-webkit-details-marker { display: none; }
.ms > summary::after { content: '▾'; color: var(--muted); }
.ms[open] > summary { border-color: var(--turf); }
.ms-pop { position: absolute; z-index: 15; left: 0; right: 0; margin-top: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,33,61,.12); padding: .4rem; max-height: 300px; overflow: auto; }
.ms-pop input[type=search] { margin-bottom: .35rem; }
.ms-opt { display: flex; align-items: center; gap: .45rem; padding: .25rem .3rem; border-radius: 4px; font-weight: 400; margin: 0; cursor: pointer; }
.ms-opt:hover { background: var(--line-2); }
.ms-opt input { width: auto; }
.ms-opt .n { margin-left: auto; color: var(--muted); font-size: .8rem; }
.ms-empty { padding: .4rem; color: var(--muted); font-size: .9rem; }

.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .8rem; }

/* ------------------------------------------------------------- profile */
.profile-head { display: grid; grid-template-columns: 132px 1fr auto; gap: 22px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 18px; position: relative; overflow: hidden; }
.profile-head::after { /* hash marks along the bottom edge, like a sideline */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: repeating-linear-gradient(90deg, var(--turf) 0 2px, transparent 2px 24px); opacity: .5; }
.avatar { width: 132px; height: 132px; border-radius: 8px; object-fit: cover; background: var(--turf); color: #fff; display: grid; place-items: center; font: 700 2.8rem var(--display); }
.profile-head h1 { font-size: 2.6rem; margin-bottom: .2rem; }
.facts { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; color: var(--ink-2); }
.facts b { font-weight: 600; color: var(--ink); }
.index-box { text-align: center; min-width: 120px; }
.index-num { font: 700 3.4rem/1 var(--display); color: var(--turf); }
.index-lbl { font-size: .82rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }

.cols > *, .search-layout > *, .admin-layout > * { min-width: 0; }
.cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: start; }

/* The yard-line percentile strip: the signature element. */
.yard { display: grid; grid-template-columns: 9.5rem 1fr 6.5rem; gap: .2rem .8rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line-2); }
.yard:last-child { border-bottom: 0; }
.yard-name { font-weight: 600; }
.yard-val { text-align: right; font-weight: 600; font-family: var(--display); font-size: 1.15rem; }
.field-bar { position: relative; height: 22px; border-radius: 3px; background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), color-mix(in srgb, var(--turf) 35%, transparent) calc(10% - 1px) 10%),
    var(--turf-soft); overflow: hidden; }
.field-fill { position: absolute; inset: 0 auto 0 0; background: var(--turf); transition: width .5s ease-out; }
.field-fill.elite { background: linear-gradient(90deg, var(--turf) 80%, var(--amber)); }
.field-pct { position: absolute; top: 50%; transform: translateY(-50%); font: 700 .8rem var(--display); color: #fff; padding: 0 .35rem; }
.field-pct.out { color: var(--ink); }
.yard-meta { grid-column: 2 / 4; font-size: .8rem; color: var(--muted); display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.yard-nopool .field-bar { background: repeating-linear-gradient(135deg, var(--line-2) 0 6px, transparent 6px 12px); }
@media (prefers-reduced-motion: reduce) { .field-fill { transition: none; } }

.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.spark { border: 1px solid var(--line-2); border-radius: var(--radius); padding: .6rem .7rem; }
.spark svg { width: 100%; height: 90px; display: block; }
.spark .t { font-weight: 600; font-size: .9rem; display: flex; justify-content: space-between; }
.up { color: var(--turf); font-weight: 600; }
.down { color: var(--red); font-weight: 600; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius); background: var(--line-2); }
.photos figcaption { font-size: .78rem; color: var(--muted); }

.eval { border-left: 3px solid var(--turf); padding: .2rem 0 .2rem .9rem; margin-bottom: 1rem; }
.eval-head { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: baseline; margin-bottom: .3rem; }
.grade { font: 700 1.25rem var(--display); color: var(--turf); }
.eval h4 { margin: .4rem 0 .1rem; font-size: .85rem; color: var(--muted); }
.eval p { white-space: pre-wrap; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h2 { color: var(--ink); }

/* ------------------------------------------------------------- compare */
.cmp td.best { background: var(--turf-soft); font-weight: 700; }
.cmp th.pl { min-width: 150px; vertical-align: bottom; color: var(--ink); font-size: .95rem; }
.mini-bar { height: 5px; background: var(--line-2); border-radius: 3px; margin-top: 3px; }
.mini-bar span { display: block; height: 100%; background: var(--turf); border-radius: 3px; }

/* ------------------------------------------------------------- admin */
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 70px; }
.admin-nav a { padding: .45rem .7rem; border-radius: var(--radius); text-decoration: none; color: var(--ink-2); font-weight: 500; }
.admin-nav a:hover { background: var(--line-2); }
.admin-nav a.on { background: var(--ink); color: var(--paper); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.stat b { display: block; font: 700 2rem/1.1 var(--display); }
.stat span { color: var(--muted); font-size: .85rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: .55rem .8rem; color: var(--muted); white-space: nowrap; }
.tabs button.on { border-bottom-color: var(--turf); color: var(--ink); }
.inline-form { background: var(--line-2); border-radius: var(--radius); padding: 12px; margin-top: .8rem; }
.import-log td { font-size: .88rem; vertical-align: top; }
.act-create { color: var(--turf); font-weight: 600; }
.act-attach { color: var(--focus); font-weight: 600; }
.act-skip { color: #8a5a00; font-weight: 600; }
.act-error { color: var(--red); font-weight: 600; }
.dup-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dup-card { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; font-size: .9rem; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: var(--radius); z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--red); color: #fff; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .search-layout, .admin-layout, .cols { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .filters.collapsed { display: none; }
  .filter-toggle { display: inline-flex; }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto; }
  .admin-nav a { white-space: nowrap; }
  .profile-head { grid-template-columns: 84px 1fr; }
  .avatar { width: 84px; height: 84px; font-size: 2rem; }
  .index-box { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: .6rem; }
  .profile-head h1 { font-size: 2rem; }
}
@media (max-width: 640px) {
  h1 { font-size: 2rem; }
  .topbar-in { flex-wrap: wrap; gap: .3rem; }
  .nav { margin-left: 0; width: 100%; justify-content: space-between; }
  .brand span { display: inline !important; font-size: 1.25rem; }
  .nav a, .nav button { padding: .3rem .45rem; font-size: .88rem; }
  .brand span { display: none; }
  .yard { grid-template-columns: 1fr auto; }
  .yard .field-bar { grid-column: 1 / -1; grid-row: 2; }
  .yard-meta { grid-column: 1 / -1; }
  .dup-pair { grid-template-columns: 1fr; }
  table.cards thead { display: none; }
  table.cards tr { display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .6rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line-2); }
  table.cards td { border: 0; padding: 0; }
  table.cards td[data-k] { grid-column: 2 / 4; font-size: .88rem; color: var(--ink-2); }
  table.cards td[data-k]::before { content: attr(data-k) ': '; color: var(--muted); }
  table.cards tr { grid-template-columns: 28px 1fr auto; }
  table.cards td.c-check { grid-row: 1 / 4; }
  table.cards td.num { text-align: left; }
  table.cards td:last-child { grid-column: 2 / 4; margin-top: .25rem; }
}

/* ------------------------------------------------------------- print (scouting report) */
@media print {
  .topbar, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .panel, .profile-head { border: 0; padding: 0; margin-bottom: 14pt; break-inside: avoid; }
  .field-bar { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .field-fill, .pos, .avatar { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
  .cols { grid-template-columns: 1fr 1fr; }
}
