/* ==========================================================
   SHL Mobile Lineup Client — design system
   Mobile-first, dark, app-like. Built to be sharp and fast to
   navigate on a phone — big tap targets, bottom sheets instead
   of drag & drop, sticky action bars.
   ========================================================== */

:root{
  --bg: #0b0f16;
  --bg-elevated: #11161f;
  --bg-card: #161c27;
  --bg-card-hover: #1c2330;
  --bg-inset: #0d121a;
  --border: #232b3a;
  --border-soft: #1a2130;

  --text: #eef1f7;
  --text-dim: #9aa5b8;
  --text-faint: #5d6980;

  --accent: #3aa8ff;
  --accent-dim: #1c5f96;
  --accent-ink: #04101c;
  --accent-soft: rgba(58,168,255,.14);

  --good: #34d399;
  --good-soft: rgba(52,211,153,.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251,191,36,.14);
  --bad: #fb5b5b;
  --bad-soft: rgba(251,91,91,.14);

  --pro-dress: #3aa8ff;
  --pro-scratch: #5d6980;
  --farm-dress: #a970ff;
  --farm-scratch: #3d4658;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  color-scheme: dark;
}

*{ box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  font-size:15px;
  line-height:1.45;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
  /* The lines editor fully rebuilds its content on every tap (stepper,
     +/-, manual entry…). Without this, the browser's own scroll-anchoring
     heuristic tries to "helpfully" keep whatever was under the cursor in
     place by nudging the scroll position whenever content above it changes
     size by even a pixel — which is exactly the small, direction-varying
     jump on every click that this is disabling. */
  overflow-anchor:none;
}
h1,h2,h3,h4{ margin:0; font-weight:700; letter-spacing:-.01em; }
p{ margin:0; }
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; }
ul{ list-style:none; margin:0; padding:0; }
input,select,textarea{ font-family:inherit; }

/* ---------- layout shell ---------- */
.app{
  max-width:560px;
  margin:0 auto;
  min-height:100%;
  display:flex;
  flex-direction:column;
  position:relative;
}
.app-main{
  flex:1;
  padding:14px 14px calc(150px + var(--safe-bottom));
}
.app-main.no-tabs{ padding-bottom:calc(24px + var(--safe-bottom)); }

/* ---------- top bar ---------- */
.topbar{
  position:sticky; top:0; z-index:40;
  padding:calc(12px + var(--safe-top)) 14px 12px;
  background:rgba(11,15,22,.86);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  border-bottom:1px solid var(--border-soft);
  display:flex; align-items:center; gap:10px;
}
.topbar .back{
  width:36px; height:36px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  background:var(--bg-card); border:1px solid var(--border);
  color:var(--text); flex:none;
}
.topbar .titles{ flex:1; min-width:0; }
.topbar .titles h1{ font-size:16px; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar .titles .sub{ font-size:12px; color:var(--text-dim); margin-top:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar .actions{ display:flex; gap:8px; flex:none; }
.iconbtn{
  width:36px; height:36px; border-radius:10px; border:1px solid var(--border);
  background:var(--bg-card); color:var(--text-dim); display:flex; align-items:center; justify-content:center;
}
.iconbtn:active{ background:var(--bg-card-hover); }

.league-banner{
  text-align:center; padding:6px 10px 0; font-size:11px; letter-spacing:.06em;
  text-transform:uppercase; color:var(--text-faint); font-weight:600;
}

/* ---------- bottom tab bar ---------- */
.tabbar{
  position:fixed; left:0; right:0; bottom:0; z-index:50;
  max-width:560px; margin:0 auto;
  display:flex;
  background:rgba(17,22,31,.92);
  backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
  border-top:1px solid var(--border-soft);
  padding:6px 6px calc(6px + var(--safe-bottom));
}
.tabbar a{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:8px 4px 6px; border-radius:12px; color:var(--text-faint); font-size:11px; font-weight:600;
}
.tabbar a svg{ width:21px; height:21px; }
.tabbar a.active{ color:var(--accent); }
.tabbar a:active{ background:var(--bg-card); }

/* ---------- cards / list ---------- */
.card{
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
}
.card + .card{ margin-top:10px; }
.stack{ display:flex; flex-direction:column; gap:10px; }

.section-title{
  font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.07em;
  color:var(--text-faint); margin:20px 2px 8px;
}
.section-title:first-child{ margin-top:2px; }

/* team picker */
.search{
  display:flex; align-items:center; gap:8px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  padding:11px 12px; margin-bottom:12px;
}
.search svg{ width:17px; height:17px; color:var(--text-faint); flex:none; }
.search input{
  flex:1; background:none; border:none; outline:none; color:var(--text); font-size:15px;
}
.search input::placeholder{ color:var(--text-faint); }

.team-row{
  display:flex; align-items:center; gap:12px;
  padding:12px 14px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
}
.team-row + .team-row{ margin-top:8px; }
.team-row:active{ background:var(--bg-card-hover); }
.team-badge{
  width:42px; height:42px; border-radius:11px; flex:none;
  background:var(--bg-inset); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:13px; color:var(--accent); letter-spacing:.02em;
}
.team-row .meta{ flex:1; min-width:0; }
.team-row .meta .name{ font-weight:700; font-size:14.5px; }
.team-row .meta .gm{ font-size:12.5px; color:var(--text-dim); margin-top:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.team-row .chev{ color:var(--text-faint); flex:none; }
.lock-chip{
  display:flex; align-items:center; gap:4px; font-size:11px; color:var(--text-faint);
  background:var(--bg-inset); border:1px solid var(--border); padding:3px 7px; border-radius:20px; flex:none;
}

/* ---------- buttons ---------- */
.btn{
  appearance:none; border:none; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  font-weight:700; font-size:14.5px; border-radius:12px;
  padding:12px 18px; transition:transform .06s ease;
}
.btn:active{ transform:scale(.97); }
.btn-primary{ background:var(--accent); color:var(--accent-ink); }
.btn-primary:disabled{ background:var(--bg-card); color:var(--text-faint); border:1px solid var(--border); }
.btn-ghost{ background:var(--bg-card); color:var(--text); border:1px solid var(--border); }
.btn-danger-ghost{ background:var(--bad-soft); color:var(--bad); }
.btn-block{ width:100%; }
.btn-sm{ padding:8px 12px; font-size:13px; border-radius:10px; }

/* ---------- action bar (sticky save) ---------- */
.actionbar{
  position:sticky; bottom:calc(66px + var(--safe-bottom)); z-index:30;
  display:flex; gap:8px; margin:14px 0 4px;
}
.actionbar.floating{
  position:fixed; left:14px; right:14px; bottom:calc(78px + var(--safe-bottom));
  max-width:532px; margin:0 auto;
}
.actionbar .btn{ flex:1; }

/* ---------- status summary banner ---------- */
.status-banner{
  border-radius:var(--radius); padding:12px 14px; margin-bottom:12px;
  display:flex; align-items:flex-start; gap:10px; font-size:13.5px; font-weight:600;
}
.status-banner.ok{ background:var(--good-soft); color:var(--good); }
.status-banner.bad{ background:var(--bad-soft); color:var(--bad); }
.status-banner svg{ flex:none; margin-top:1px; width:18px; height:18px; }
.status-banner .details{ font-weight:500; color:var(--text-dim); margin-top:4px; }
.status-banner ul{ margin-top:6px; display:flex; flex-direction:column; gap:3px; }
.status-banner li{ font-weight:500; }

.notice{
  border-radius:var(--radius); padding:11px 14px; margin-bottom:12px; font-size:13.5px; font-weight:600;
  background:var(--warn-soft); color:var(--warn);
}

/* ---------- segmented filter chips ---------- */
.chipbar{ display:flex; gap:6px; overflow-x:auto; padding-bottom:2px; margin-bottom:12px; scrollbar-width:none; }
.chipbar::-webkit-scrollbar{ display:none; }
.chip{
  flex:none; padding:7px 13px; border-radius:20px; font-size:12.5px; font-weight:700;
  background:var(--bg-card); border:1px solid var(--border); color:var(--text-dim);
}
.chip.active{ background:var(--accent-soft); border-color:var(--accent-dim); color:var(--accent); }

/* ---------- roster player card ---------- */
.player-card{
  display:flex; align-items:center; gap:11px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  padding:10px 11px;
}
.player-card + .player-card{ margin-top:8px; }
.pos-badge{
  width:34px; height:34px; border-radius:9px; flex:none;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:11.5px; background:var(--bg-inset); border:1px solid var(--border); color:var(--text-dim);
}
.player-card .info{ flex:1; min-width:0; }
.player-card .info .name{ font-weight:700; font-size:14px; display:flex; align-items:center; gap:6px; }
.player-card .info .tags{ display:flex; gap:5px; margin-top:3px; flex-wrap:wrap; }
.tag{ font-size:10.5px; font-weight:700; padding:2px 6px; border-radius:6px; letter-spacing:.02em; }
.tag.ov{ background:var(--bg-inset); color:var(--text-dim); border:1px solid var(--border); }
.tag.injury{ background:var(--bad-soft); color:var(--bad); }
.tag.suspension{ background:var(--bad-soft); color:var(--bad); }
.tag.waiver{ background:var(--warn-soft); color:var(--warn); }
.tag.nocontract{ background:var(--bg-inset); color:var(--text-faint); }

.status-toggle{
  display:flex; flex:none; background:var(--bg-inset); border:1px solid var(--border);
  border-radius:10px; padding:2px; gap:2px;
}
.status-toggle button{
  appearance:none; border:none; background:none; color:var(--text-faint);
  width:30px; height:30px; border-radius:8px; font-size:10.5px; font-weight:800;
  display:flex; align-items:center; justify-content:center;
}
.status-toggle button.on[data-status="3"]{ background:var(--pro-dress); color:#04101c; }
.status-toggle button.on[data-status="2"]{ background:var(--pro-scratch); color:#fff; }
.status-toggle button.on[data-status="1"]{ background:var(--farm-dress); color:#0c0417; }
.status-toggle button.on[data-status="0"]{ background:var(--farm-scratch); color:#fff; }

/* status pill used in list headers / counts */
.count-pill{
  display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:700;
  padding:4px 9px; border-radius:20px; background:var(--bg-inset); border:1px solid var(--border); color:var(--text-dim);
}
.count-pill.short{ color:var(--bad); background:var(--bad-soft); border-color:transparent; }
.count-pill.ok{ color:var(--good); background:var(--good-soft); border-color:transparent; }

/* ---------- line editor slot grid ---------- */
.linegroup{
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  padding:13px; margin-bottom:10px;
}
.linegroup .lg-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.linegroup .lg-head h4{ font-size:13.5px; }
.slot-grid{ display:flex; flex-direction:column; gap:6px; }
.slot{
  display:flex; align-items:center; gap:10px;
  background:var(--bg-inset); border:1px solid var(--border-soft); border-radius:10px;
  padding:9px 10px;
}
.slot .slot-pos{
  width:30px; flex:none; font-size:11px; font-weight:800; color:var(--text-faint); text-align:center;
}
.slot .slot-name{ flex:1; font-size:13.5px; font-weight:600; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.slot .slot-name.empty{ color:var(--text-faint); font-weight:500; }
.slot .slot-chev{ color:var(--text-faint); flex:none; }
.slot.invalid{ border-color:rgba(251,91,91,.5); background:rgba(251,91,91,.07); }

/* Per-line ratings ribbon — one chip per PlayerInfo rating, averaged
   across the players currently assigned to that line. Horizontally
   scrollable (swipe on touch, wheel/drag on desktop via wireHorizontalScroll)
   and clipped to the card width so it never overflows/wraps. */
.ratings-strip{
  display:flex; gap:6px; overflow-x:auto; -webkit-overflow-scrolling:touch;
  scrollbar-width:none; margin-top:10px; padding-top:10px; border-top:1px dashed var(--border);
  cursor:grab; user-select:none;
}
.ratings-strip::-webkit-scrollbar{ display:none; }
.ratings-strip.dragging{ cursor:grabbing; }
.ratings-chip{
  flex:none; min-width:38px; text-align:center;
  background:var(--bg-inset); border:1px solid var(--border-soft); border-radius:8px; padding:6px 8px;
}
.ratings-chip .rc-label{ font-size:9.5px; font-weight:800; color:var(--text-faint); letter-spacing:.03em; }
.ratings-chip .rc-val{ font-size:13px; font-weight:700; margin-top:2px; }

.sliders{ margin-top:10px; padding-top:10px; border-top:1px dashed var(--border); }
.slider-row{ display:flex; align-items:center; gap:8px; margin-top:6px; }
.slider-row:first-child{ margin-top:0; }
.slider-row .slabel{ width:46px; flex:none; font-size:11.5px; font-weight:700; color:var(--text-dim); }
.stepper{ display:flex; align-items:center; gap:0; flex:1; }
.stepper button{
  width:30px; height:30px; border-radius:8px; border:1px solid var(--border); background:var(--bg-card);
  color:var(--text); font-size:16px; font-weight:700; flex:none; display:flex; align-items:center; justify-content:center;
}
.stepper button:active{ background:var(--bg-card-hover); }
.stepper .val-wrap{ flex:1; display:flex; align-items:center; justify-content:center; gap:0; min-width:0; }
/* Looks identical to a plain number until tapped/clicked — a subtle inset
   highlight on focus is the only hint it's editable, so the row stays as
   sharp/minimal as the old read-only version. Width is set inline per
   stepper (see stepperRow) so it hugs the digit count instead of leaving a
   gap before the suffix. */
.stepper .val-input{
  flex:none; min-width:0;
  text-align:center; font-weight:800; font-size:13.5px; color:var(--text);
  background:transparent; border:none; border-radius:6px; padding:2px 0;
  font-family:inherit; -moz-appearance:textfield;
}
/* When there's a suffix (%, s), right-align the digits so they sit flush
   against it instead of leaving a gap in the middle when the value has
   fewer digits than the field's max (e.g. "40" in a 3-digit-wide box).
   While actually being edited, though, the input gets its own visible box
   (see :focus below) — center inside THAT box instead, since flush-right
   against the suffix reads as off-center once there's a border around it. */
.stepper .val-input.suffixed{ text-align:right; padding-right:1px; }
.stepper .val-input.suffixed:focus{ text-align:center; padding-right:0; }
.stepper .val-input::-webkit-outer-spin-button,
.stepper .val-input::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
.stepper .val-input:focus{ outline:none; background:var(--bg-inset); box-shadow:0 0 0 1px var(--accent-dim); }
.stepper .val-suffix{ flex:none; font-weight:800; font-size:13.5px; color:var(--text); }
.time-total{ font-size:11px; font-weight:700; margin-left:6px; padding:2px 7px; border-radius:20px; }
.time-total.ok{ color:var(--good); background:var(--good-soft); }
.time-total.bad{ color:var(--bad); background:var(--bad-soft); }

.tabs-scroll{ display:flex; gap:6px; overflow-x:auto; padding:2px 2px 10px; scrollbar-width:none; margin: -2px -2px 8px; cursor:grab; user-select:none; }
.tabs-scroll::-webkit-scrollbar{ display:none; }
.tabs-scroll.dragging{ cursor:grabbing; }
.tabs-scroll button{
  flex:none; padding:9px 14px; border-radius:12px; font-size:13px; font-weight:700;
  background:var(--bg-card); border:1px solid var(--border); color:var(--text-dim);
}
.tabs-scroll button.active{ background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }

/* ---------- bottom sheet ---------- */
.sheet-backdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:90; opacity:0;
  transition:opacity .18s ease; pointer-events:none;
}
.sheet-backdrop.open{ opacity:1; pointer-events:auto; }
.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:91;
  max-width:560px; margin:0 auto;
  background:var(--bg-elevated); border-radius:20px 20px 0 0;
  border:1px solid var(--border); border-bottom:none;
  box-shadow:0 -12px 40px rgba(0,0,0,.5);
  transform:translateY(100%); transition:transform .22s cubic-bezier(.32,.72,0,1);
  max-height:82vh; display:flex; flex-direction:column;
}
.sheet.open{ transform:translateY(0); }
.sheet .grabber{ width:36px; height:4px; border-radius:3px; background:var(--border); margin:10px auto 4px; flex:none; }
.sheet-head{ padding:8px 16px 10px; display:flex; align-items:center; justify-content:space-between; flex:none; border-bottom:1px solid var(--border-soft); }
.sheet-head h3{ font-size:15px; }
.sheet-head .close{
  color:var(--text-faint); width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  background:none; border:none; -webkit-appearance:none; appearance:none; border-radius:8px; cursor:pointer; padding:0;
}
.sheet-head .close:active{ background:var(--bg-card); color:var(--text); }
.sheet-body{ overflow-y:auto; padding:8px 12px calc(16px + var(--safe-bottom)); -webkit-overflow-scrolling:touch; }
.sheet-search{ margin:8px 4px 10px; }

.pick-row{
  display:flex; align-items:center; gap:11px; padding:10px 8px; border-radius:12px;
}
.pick-row:active{ background:var(--bg-card); }
.pick-row + .pick-row{ border-top:1px solid var(--border-soft); }
.pick-row .info{ flex:1; min-width:0; }
.pick-row .info .name{ font-weight:700; font-size:14px; }
.pick-row .info .sub{ font-size:12px; color:var(--text-dim); margin-top:1px; }
.pick-row .pos{ flex:none; font-size:12px; font-weight:700; color:var(--text-dim); white-space:nowrap; }
.pick-row .check{ color:var(--accent); flex:none; opacity:0; }
.pick-row.selected .check{ opacity:1; }
.pick-row.disabled{ opacity:.35; pointer-events:none; }
.pick-empty{ text-align:center; padding:26px 10px; color:var(--text-faint); font-size:13.5px; }

/* ---------- login sheet ---------- */
.field{ margin-bottom:12px; }
.field label{ display:block; font-size:12px; font-weight:700; color:var(--text-dim); margin-bottom:6px; }
.field input{
  width:100%; background:var(--bg-inset); border:1px solid var(--border); border-radius:10px;
  padding:12px 13px; color:var(--text); font-size:15px; outline:none;
}
.field input:focus{ border-color:var(--accent); }
.field .error{ color:var(--bad); font-size:12.5px; margin-top:6px; font-weight:600; }

/* ---------- toast ---------- */
.toast-wrap{ position:fixed; left:14px; right:14px; bottom:calc(78px + var(--safe-bottom)); z-index:120; max-width:532px; margin:0 auto; display:flex; flex-direction:column; gap:8px; pointer-events:none; }
.toast{
  background:var(--bg-elevated); border:1px solid var(--border); box-shadow:var(--shadow);
  border-radius:12px; padding:12px 14px; font-size:13.5px; font-weight:600; display:flex; align-items:center; gap:9px;
  transform:translateY(10px); opacity:0; transition:all .2s ease;
}
.toast.show{ transform:translateY(0); opacity:1; }
.toast.ok svg{ color:var(--good); }
.toast.bad svg{ color:var(--bad); }
.toast svg{ flex:none; width:18px; height:18px; }

/* ---------- misc ---------- */
.empty-state{ text-align:center; padding:60px 20px; color:var(--text-faint); }
.empty-state svg{ width:40px; height:40px; margin-bottom:10px; opacity:.6; }
.skeleton{ background:linear-gradient(90deg,var(--bg-card) 25%,var(--bg-card-hover) 37%,var(--bg-card) 63%); background-size:400% 100%; animation:shimmer 1.4s ease infinite; border-radius:var(--radius); }
@keyframes shimmer{ 0%{background-position:100% 50%;} 100%{background-position:0 50%;} }

.spinner{ width:16px; height:16px; border-radius:50%; border:2px solid rgba(255,255,255,.25); border-top-color:#fff; animation:spin .6s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

.legend{ display:flex; flex-wrap:wrap; gap:10px; font-size:11.5px; color:var(--text-dim); margin-bottom:12px; }
.legend span{ display:inline-flex; align-items:center; gap:5px; }
.legend i{ width:9px; height:9px; border-radius:3px; display:inline-block; }

.center-loader{ display:flex; align-items:center; justify-content:center; padding:60px 0; color:var(--text-faint); gap:10px; font-size:13.5px; }

@media (min-width: 561px){
  body{ background:var(--bg-inset); }
  .app{ background:var(--bg); min-height:100vh; box-shadow:var(--shadow); }
}
