/* ============================================================================
   BFL Hub — Admin panel
   Dark only. Calm, minimal, typography-led: muted slate surfaces, generous
   spacing, hairline borders, small square status marks. The league's mint
   (#65F1B4) is the accent, its teal (#33E6D5) is a detail colour only.
   Type: Montserrat throughout, normal case (uppercase only for tiny overlines).
   ========================================================================= */

/* ---------- tokens ---------- */
:root {
  --font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;

  --bg:       #0f1316;
  --bg-2:     #13181b;
  --panel:    #171d20;
  --panel-2:  #1d2428;
  --line:     #232b2f;
  --line-2:   #334046;

  --text:     #e9eef1;
  --text-2:   #9aa5ac;
  --text-3:   #69747b;

  /* league mint — the only loud colour, used for actions + done state */
  --accent:      #65f1b4;
  --accent-ink:  #06231a;
  --accent-soft: rgba(101, 241, 180, .12);
  --accent-line: rgba(101, 241, 180, .3);

  /* league teal — details only (loans, secondary numerals) */
  --teal:      #33e6d5;
  --teal-soft: rgba(51, 230, 213, .1);
  --teal-line: rgba(51, 230, 213, .28);

  --danger:      #ff7a72;
  --danger-soft: rgba(255, 122, 114, .1);
  --danger-line: rgba(255, 122, 114, .28);

  --tint:   rgba(255, 255, 255, .03);
  --tint-2: rgba(255, 255, 255, .055);
  --shadow: 0 16px 40px rgba(0, 0, 0, .42);
  --ring:   0 0 0 3px rgba(101, 241, 180, .22);

  --r:    10px;
  --r-sm: 7px;
  --r-xs: 5px;
  --sidebar-w: 264px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* phone behaviours: no grey tap flash, no rubber-banding the whole page,
     no double-tap-to-zoom delay on buttons */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: var(--accent-soft); }

.mono { font-family: var(--mono); font-size: 12px; }
.faint { color: var(--text-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hide { display: none !important; }

/* the one uppercase style in the app — tiny overlines */
.lbl, .kpi .k, .card-h h3, .section-head h2, table.tbl th, .field label, .divlabel, .listhead .lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
}

.pulse {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- shell ---------- */
/* dvh so the bottom of the app isn't hidden behind a phone's URL bar */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; z-index: 30;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
/* closes the drawer on a phone; pointless on desktop where it is always open */
.navclose {
  width: 34px; height: 34px; display: none;
  place-items: center; border-radius: var(--r-sm);
  font-size: 19px; line-height: 1; color: var(--text-3);
}
.navclose:hover { color: var(--text); background: var(--tint-2); }
.main {
  min-width: 0; overflow-y: auto; display: flex; flex-direction: column;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}

/* ---------- scroll frames ----------
   The frame and the club list are the two things that scroll. Both get a themed
   bar — thin, rounded, no track — because without this a browser with classic
   scrollbars (Windows, or "always show scrollbars" on Android) paints an opaque
   grey slab down the panel. scrollbar-color covers Chrome 121+/Firefox, the
   -webkit- rules cover Safari and older Chrome; iOS uses its own overlay bar. */
.main, .clublist, .tfscroll, .modal, .toastdetail {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.main::-webkit-scrollbar,
.clublist::-webkit-scrollbar,
.tfscroll::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.toastdetail::-webkit-scrollbar { width: 10px; height: 10px; }
.main::-webkit-scrollbar-track,
.clublist::-webkit-scrollbar-track,
.tfscroll::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.toastdetail::-webkit-scrollbar-track { background: transparent; }
/* inset via a transparent border so the thumb never touches the content edge */
.main::-webkit-scrollbar-thumb,
.clublist::-webkit-scrollbar-thumb,
.tfscroll::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.toastdetail::-webkit-scrollbar-thumb {
  background: var(--line-2); background-clip: padding-box;
  border: 3px solid transparent; border-radius: 99px;
}
.main::-webkit-scrollbar-thumb:hover,
.clublist::-webkit-scrollbar-thumb:hover { background: #46555c; background-clip: padding-box; }
.main::-webkit-scrollbar-corner, .clublist::-webkit-scrollbar-corner { background: transparent; }

/* brand — the wordmark sits straight on the surface, no plate behind it */
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 16px 18px; }
.brandmark { display: block; flex: none; }
.brandmark img { width: 74px; height: auto; }
.brandmark.lg img { width: 122px; }
.brand .meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.brand .meta .b { font-size: 12.5px; font-weight: 600; }
.brand .meta .s { font-size: 11px; color: var(--text-3); }
.brand .brand-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
/* small icon-only control (install) — a brand-row glyph, not a full-width button */
.iconbtn {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: var(--r-sm); color: var(--text-3);
  transition: color .12s, background .12s;
}
.iconbtn:hover { color: var(--text); background: var(--tint-2); }
.iconbtn svg { width: 16px; height: 16px; display: block; }

/* sidebar sections */
.side-block { padding: 0 14px 4px; }
.search { position: relative; }
.search input {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 28px 8px 10px; font-size: 12.5px;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--line-2); }
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; pointer-events: none;
}
.filters { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.chip {
  border: 1px solid transparent; background: var(--panel);
  border-radius: var(--r-xs); padding: 4px 8px; font-size: 11px; font-weight: 500;
  color: var(--text-3); transition: color .12s, background .12s, border-color .12s;
}
.chip:hover { color: var(--text-2); }
.chip.on { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.chip .n { color: var(--text-3); margin-left: 4px; font-weight: 400; }

.listhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 8px;
}
.clublist { flex: 1; overflow-y: auto; padding: 0 10px 16px; min-height: 0; }
.divlabel {
  padding: 14px 8px 5px; display: flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: .1em;
}
.divlabel .rule { flex: 1; height: 1px; background: var(--line); }

.clubitem {
  width: 100%; display: flex; align-items: center; gap: 9px; text-align: left;
  padding: 7px 8px; border-radius: var(--r-sm); transition: background .12s;
}
.clubitem:hover { background: var(--tint); }
.clubitem.on { background: var(--panel-2); }
.clubitem .meta { min-width: 0; flex: 1; }
.clubitem .nm { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clubitem .sb { font-size: 11px; color: var(--text-3); display: flex; gap: 8px; }
.clubitem .accent { width: 2px; height: 15px; border-radius: 2px; flex: none; opacity: .8; }

/* club crests — shown as they are: no plate, no circle, no border */
.crest, .crest-lg { object-fit: contain; flex: none; }
img.crest { width: 20px; height: 20px; }
img.crest-lg { width: 26px; height: 26px; }
div.crest { width: 20px; height: 20px; border-radius: var(--r-xs); background: var(--panel-2); }
div.crest-lg { width: 26px; height: 26px; border-radius: var(--r-xs); background: var(--panel-2); }

/* status marks (small squares, never icons) */
.mark { width: 6px; height: 6px; border-radius: 1px; flex: none; background: var(--text-3); }
.mark.on { background: var(--accent); }
.mark.draft { background: transparent; border: 1px solid var(--accent-line); }

.side-foot {
  border-top: 1px solid var(--line); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--panel-2); font-size: 11px; font-weight: 600; color: var(--text-2);
}
.side-foot .nm { font-size: 12.5px; font-weight: 500; }

/* ---------- topbar ---------- */
.topbar {
  /* flex: none is load-bearing: .main is a column flex container, so without it
     the bar is shrunk to its min-height and its contents spill over the page. */
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 16px 30px; border-bottom: 1px solid var(--line);
  background: var(--bg); position: sticky; top: 0; z-index: 20;
  min-height: 62px;
  padding-top: max(16px, env(safe-area-inset-top));
  transition: box-shadow .18s ease, border-color .18s ease;
}
/* set while the frame is scrolled, so the bar reads as floating over content */
.topbar.scrolled { border-bottom-color: var(--line-2); box-shadow: 0 14px 26px -22px rgba(0, 0, 0, .95); }
/* the two halves of the topbar — they stack on a phone, sit in one row here */
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.tb-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.tb-actions .btn { flex: none; }
.crumbs { display: flex; align-items: center; gap: 9px; min-width: 0; }
.crumbs .here { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
/* the club's own colour, from the same palette /team uses */
.clubdot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.pill {
  font-size: 10.5px; font-weight: 500; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
}

/* ---------- content ---------- */
.content {
  padding: 30px 30px 90px; width: 100%; flex: none;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}
.page-title { font-size: 21px; }
.page-sub { color: var(--text-2); font-size: 12.5px; margin-top: 8px; }
.section-head {
  display: flex; align-items: baseline; gap: 12px;
  margin: 34px 0 16px;
}
.section-head h2 { font-size: 10px; }
.section-head .spacer { flex: 1; }

.grid { display: grid; gap: 10px; }
/* the KPI band sits straight under the page header — no spacer element needed */
.page-sub + .grid { margin-top: 24px; }
/* .kpi-grid, not .kpi — "grid kpi" also matched the .kpi card rule below and
   painted an extra panel around the four cards */
.grid.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.clubs { grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); }

.kpi {
  padding: 16px 18px 18px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r);
}
.kpi .v {
  font-size: 26px; font-weight: 600; line-height: 1.1; margin-top: 10px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.kpi .d { color: var(--text-3); font-size: 11.5px; margin-top: 6px; }
.progress { height: 3px; background: var(--tint-2); border-radius: 2px; margin-top: 14px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

.card {
  padding: 18px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r);
}
.card-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-h h3 { font-size: 10px; }
.card-h .hint { font-size: 11px; color: var(--text-3); margin-left: auto; text-align: right; }
.card-h .spacer { flex: 1; }

/* list rows */
.rows { display: flex; flex-direction: column; }
.lrow {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 6px; border-radius: var(--r-sm); transition: background .12s;
}
.lrow:hover { background: var(--tint); }
.lrow .l1 { font-size: 12.5px; font-weight: 500; }
.lrow .l2 { font-size: 11px; color: var(--text-3); }
.lrow .when { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.badge {
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 7px; border-radius: var(--r-xs);
  background: var(--tint-2); color: var(--text-2); white-space: nowrap;
}
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.neutral { background: var(--tint-2); color: var(--text-3); }
.badge.loan { background: var(--teal-soft); color: var(--teal); }
.badge.miss, .badge.rem { background: var(--danger-soft); color: var(--danger); }
.badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.upd { background: var(--tint-2); color: var(--text-3); }

.clubcard {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 14px 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r); transition: border-color .12s, background .12s;
}
.clubcard:hover { border-color: var(--line-2); background: var(--panel-2); }
.clubcard .crest, .clubcard .crest-lg { width: 26px; height: 26px; }
.clubcard .nm { font-size: 13px; font-weight: 500; }
.clubcard .l2 { font-size: 11px; color: var(--text-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; font-weight: 600; padding: 8px 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--text-2); background: transparent; white-space: nowrap;
  transition: color .12s, border-color .12s, background .12s;
}
.btn:hover { color: var(--text); border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: var(--panel); color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 10px; font-size: 11.5px; }
.btn.link { border: none; padding: 0; font-size: 11.5px; color: var(--text-3); }
.btn.link:hover { color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }

.tgl {
  font-size: 12px; font-weight: 500; color: var(--text-3);
  padding: 5px 8px; border-radius: var(--r-sm); transition: color .12s, background .12s;
}
.tgl:hover { color: var(--text); background: var(--tint); }

/* ---------- forms ---------- */
.in {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 12.5px;
}
.in::placeholder { color: var(--text-3); }
.in:focus { border-color: var(--line-2); background: var(--panel-2); }
.in.num { font-variant-numeric: tabular-nums; }
select.in { appearance: none; padding-right: 26px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 10px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; padding: 10px 0; font-size: 12.5px; font-weight: 500; color: var(--text-3);
}
.tab:hover { color: var(--text-2); }
.tab.on { color: var(--text); }
.tab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tab .n { color: var(--text-3); margin-left: 6px; font-size: 11px; }

/* ---------- squad toolbar + table ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 18px 0 14px; }
.toolbar .search { max-width: 240px; flex: 1 1 180px; }
.count { font-size: 11.5px; color: var(--text-3); }
.count b { color: var(--text-2); font-weight: 600; margin-right: 3px; }

.tablewrap { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; padding: 11px 14px; font-size: 10px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: var(--text-2); }
table.tbl td { padding: 5px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--tint); }
table.tbl tbody tr.removing td { opacity: .4; }
table.tbl tbody tr.removing .in { text-decoration: line-through; }
table.tbl td .in { padding: 7px 9px; background: transparent; border-color: transparent; }
table.tbl td .in:hover { border-color: var(--line); }
table.tbl td .in:focus { background: var(--panel-2); border-color: var(--line-2); }
.tdname { width: 26%; }
.tdseason { width: 92px; }
.tdstatus { width: 132px; }
.tdact { width: 78px; text-align: right; }
.statuscell { white-space: nowrap; }
.statuscell .badge { display: inline-block; }
.statuscell .badge + .badge { margin-left: 5px; }
.rowact { font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.rowact:hover { color: var(--danger); }
.rowact.undo { color: var(--accent); }

/* ---------- owners / staff ---------- */
.ownrow {
  display: grid; grid-template-columns: minmax(0, 1fr) 84px auto 72px;
  gap: 7px; align-items: center; padding: 4px 0;
}
.ownrow .in { background: transparent; border-color: transparent; }
.ownrow .in:hover { border-color: var(--line); }
.ownrow .in:focus { background: var(--panel-2); border-color: var(--line-2); }
.perm {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 11.5px; font-weight: 500; color: var(--text-3); cursor: pointer; user-select: none;
}
.perm:hover { color: var(--text-2); border-color: var(--line-2); }
.perm.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.perm input { margin: 0; accent-color: var(--accent); }

/* ---------- draft ---------- */
textarea.in {
  min-height: 200px; resize: vertical; font-family: var(--mono); font-size: 12px;
  line-height: 1.75;
}
.fmt { font-size: 11.5px; color: var(--text-3); line-height: 1.9; margin-top: 14px; }
.fmt code {
  font-family: var(--mono); font-size: 11px; background: var(--tint-2);
  border-radius: 4px; padding: 1px 5px; color: var(--text-2);
}

/* ---------- transfer-funds sync ---------- */
.tfmeta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; }
.tfskel { display: flex; align-items: center; gap: 9px; color: var(--text-2); font-size: 12.5px; padding: 24px 2px; }
.tfscroll { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: auto; max-height: 46vh; }
.tfrow {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.tfrow:last-child { border-bottom: none; }
.tfrow:hover { background: var(--tint); }
.tfrow .tfchk { width: 14px; height: 14px; flex: none; accent-color: var(--accent); cursor: pointer; }
.tfrow .tfname { min-width: 0; flex: 1; }
.tfrow .tfname .nm { display: block; font-size: 12.5px; font-weight: 500; }
.tfrow .tfname .sb { font-size: 10.5px; color: var(--text-3); }
.tfamt { display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.tfamt .old { color: var(--text-3); }
.tfamt .arr { color: var(--text-3); }
.tfamt .new { font-weight: 600; }
.tfd {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: var(--r-xs);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tfd.up { color: var(--accent); background: var(--accent-soft); }
.tfd.down { color: var(--danger); background: var(--danger-soft); }
.tfnote { margin-top: 13px; font-size: 11.5px; color: var(--text-2); line-height: 1.75; }

/* ---------- modal ---------- */
.modalwrap {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: rgba(6, 9, 11, .6); opacity: 0; transition: opacity .14s ease; padding: 20px;
}
.modalwrap.show { opacity: 1; }
.modal {
  width: 100%; max-width: 560px; background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r); padding: 22px; box-shadow: var(--shadow);
  transform: translateY(6px); transition: transform .14s ease;
  max-height: 88vh; max-height: 88dvh; overflow: auto;
}
.modalwrap.show .modal { transform: none; }
.modal h3 { font-size: 15px; }
.modal .msub { color: var(--text-2); font-size: 12px; margin-top: 8px; }
.modal .sum { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 9px; }
.modal .sum .srow { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.sdot { width: 6px; height: 6px; border-radius: 1px; flex: none; background: var(--text-3); }
.sdot.accent { background: var(--accent); }
.sdot.blue { background: var(--teal); }
.sdot.red { background: var(--danger); }
.sdot.amber { background: var(--text-2); }
.modal .mbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal .danger-note {
  margin-top: 15px; font-size: 11.5px; color: var(--danger); background: var(--danger-soft);
  border-radius: var(--r-sm); padding: 10px 12px;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed; z-index: 200; display: flex; flex-direction: column; gap: 8px;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 340px; max-width: calc(100vw - 32px);
}
.toast {
  position: relative; background: var(--bg-2); border: 1px solid var(--line-2);
  border-left: 2px solid var(--line-2); border-radius: var(--r-sm);
  padding: 13px 38px 13px 15px; box-shadow: var(--shadow);
  animation: toastin .16s ease;
}
.toast.ok { border-left-color: var(--accent); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--teal); }
.toast b { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 3px; }
.toast span { font-size: 12px; color: var(--text-2); line-height: 1.6; }
.toast.out { animation: toastout .2s ease forwards; }
.toast.expanded { width: 620px; max-width: calc(100vw - 32px); }
.toastx {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: var(--r-xs);
  font-size: 15px; line-height: 1; color: var(--text-3);
}
.toastx:hover { color: var(--text); background: var(--tint-2); }
.toastmore { margin-top: 10px; font-size: 11.5px; font-weight: 600; color: var(--accent); }
.toastmore:hover { text-decoration: underline; }
.toastdetail { display: none; }
.toast.expanded .toastdetail {
  display: block; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  max-height: 46vh; overflow: auto; font-family: var(--mono); font-size: 11.5px;
  line-height: 1.8; color: var(--text-2);
}
.toastdetail .tl { white-space: pre-wrap; word-break: break-word; }
@keyframes toastin { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(10px); } }

/* ---------- states ---------- */
.empty { text-align: center; padding: 52px 20px; color: var(--text-3); }
.empty h3 { font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.empty p { font-size: 12px; max-width: 400px; margin: 0 auto; line-height: 1.75; }
.errorcard {
  border: 1px solid var(--danger-line); background: var(--danger-soft);
  border-radius: var(--r); padding: 18px; display: flex; align-items: center; gap: 16px;
}
.errorcard h3 { font-size: 13px; color: var(--danger); }
.errorcard p { font-size: 12px; color: var(--text-2); margin-top: 5px; word-break: break-word; }
.skel { background: linear-gradient(90deg, var(--tint) 25%, var(--tint-2) 37%, var(--tint) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r); }
.skel.line { height: 11px; }
.skel.card { height: 86px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* dirty flag */
.dirtyflag { display: none; align-items: center; gap: 7px; font-size: 11.5px; color: var(--accent); }
.dirtyflag.show { display: inline-flex; }
.dirtyflag .dot { width: 6px; height: 6px; border-radius: 1px; background: var(--accent); }

/* footer */
.foot {
  margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; font-size: 11.5px; color: var(--text-3);
}
.foot .up { display: inline-flex; align-items: center; gap: 8px; }
.foot .updot { width: 6px; height: 6px; border-radius: 1px; background: var(--accent); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.logincard {
  width: 100%; max-width: 384px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 30px; box-shadow: var(--shadow);
}
.logincard h1 { font-size: 17px; margin-top: 22px; }
.logincard p { color: var(--text-2); font-size: 12.5px; margin-top: 10px; line-height: 1.75; }
.logincard .btn { margin-top: 24px; width: 100%; padding: 11px; }
.login-foot { margin-top: 18px; font-size: 11px; color: var(--text-3); line-height: 1.75; }

/* ---------- no access (OAuth denied page) ---------- */
.logincard.deny { border-color: var(--danger-line); }
.denystate {
  display: inline-block; margin-top: 20px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--danger);
  background: var(--danger-soft); border: 1px solid var(--danger-line);
  border-radius: var(--r-xs); padding: 3px 7px;
}
.logincard.deny h1 { font-size: 18px; margin-top: 12px; }
.deny-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.deny-actions .btn { margin-top: 0; width: 100%; padding: 11px; }

/* ============================================================================
   Responsive

   Three stops:
     <= 980px  tablet — the sidebar becomes a slide-in drawer
     <= 720px  phone  — the squad table turns into one card per player, the
                        topbar stacks, inputs go to 16px (stops iOS zooming the
                        whole page in when you tap a field)
     <= 400px  small phone — single-column numbers, full-width actions
   Everything below only ever adjusts layout; no control is removed on mobile.
   ========================================================================= */

.mobilenav { display: none; }
.only-sm { display: none !important; }   /* phone-only controls (e.g. the squad sort) */

/* ---------- topbar overflow (⋯) ----------
   Secondary actions live in the bar on a desktop and in this sheet on a phone. */
.tb-more {
  display: none; position: absolute; top: calc(100% + 6px); right: 12px; z-index: 40;
  min-width: 210px; max-width: calc(100vw - 24px);
  flex-direction: column; gap: 6px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.tb-more.open { display: flex; }
.tb-more .btn { width: 100%; justify-content: flex-start; min-height: 44px; }
.tb-more .lbl { padding: 2px 2px 4px; }

/* ---------- tablet / small laptop ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 88vw);
    transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .mobilenav { display: inline-flex; }
  .navclose { display: grid; }
  .content { padding: 22px 18px 80px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .topbar { padding: 14px 18px; padding-top: max(14px, env(safe-area-inset-top)); flex-wrap: wrap; }
  .grid.kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .scrim { position: fixed; inset: 0; background: rgba(6, 9, 11, .6); z-index: 25; }
  body.nav-open { overflow: hidden; }

  /* tabs scroll sideways rather than wrapping onto two lines */
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
}

/* ---------- phone ---------- */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .only-sm { display: revert !important; }
  /* the ⋯ toggle: only a phone has anything in the sheet */
  .tb-more-btn { display: inline-flex; align-items: center; padding: 0 10px; }

  /* ---- topbar: crumbs on one row, actions on the next. Everything that isn't
     the primary action moves into the ⋯ sheet (see arrangeTopbar), so the
     header stays two short rows instead of growing as actions are added. ---- */
  .topbar { padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; }
  .tb-left { flex: 1 1 100%; gap: 8px; }
  .tb-actions { flex: 1 1 100%; flex-wrap: nowrap; gap: 8px; }
  .tb-actions .btn { flex: 0 1 auto; min-height: 42px; }
  .tb-actions .btn.primary { flex: 1 1 auto; min-height: 46px; }
  .tb-actions .dirtyflag { order: -1; flex: none; }
  .tb-actions .dirtyflag .txt { display: none; }
  .crumbs { flex-wrap: nowrap; }
  .crumbs .here { font-size: 15px; }
  .tb-left .crest-lg, .tb-left img.crest-lg { width: 22px; height: 22px; }

  /* ---- controls sized for a thumb, fields sized to stop iOS zooming ---- */
  .btn { min-height: 44px; padding: 10px 15px; font-size: 12.5px; }
  .btn.sm { min-height: 40px; }
  .btn.link { min-height: 0; padding: 6px 0; }
  .tgl { min-height: 42px; display: inline-flex; align-items: center; padding: 8px 11px; }
  .chip { padding: 7px 11px; font-size: 12px; }
  .filters { gap: 6px; }
  .rowact { min-height: 42px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm); }
  .rowact:hover { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
  .rowact.undo { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

  /* 16px is the threshold below which Safari and Chrome on phones zoom the
     viewport in when an input takes focus. */
  input.in, select.in, textarea.in, .search input, .toolbar .search input, table.tbl td .in {
    font-size: 16px;
  }
  .in { padding: 11px 12px; }
  select.in { padding-right: 30px; }
  .search kbd { display: none; }

  /* ---- sidebar drawer ---- */
  .clubitem { padding: 10px 9px; min-height: 48px; }
  .clubitem .nm { font-size: 13.5px; }
  .divlabel { padding: 16px 8px 6px; }
  .brand { padding: 16px 14px 14px; }

  /* ---- page furniture ---- */
  .content { padding: 18px 14px 70px; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 19px; }
  .section-head { margin: 26px 0 13px; flex-wrap: wrap; }
  .grid { gap: 8px; }
  .grid.kpi { gap: 8px; }
  .grid.clubs { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
  .kpi { padding: 14px 14px 15px; }
  .kpi .v { font-size: 22px; margin-top: 8px; }
  .card { padding: 15px 14px; }
  .card-h { flex-wrap: wrap; }
  .card-h .hint { margin-left: 0; text-align: left; flex: 1 1 100%; }
  .tab { padding: 12px 0; font-size: 13px; }
  .foot { flex-direction: column; align-items: flex-start; gap: 6px; }
  .empty { padding: 40px 16px; }
  .errorcard { flex-direction: column; align-items: flex-start; gap: 12px; }
  .tfscroll { max-height: 58dvh; }
  textarea.in { min-height: 230px; }

  /* ---- toolbar ---- */
  .toolbar { gap: 8px; margin: 14px 0 12px; }
  .toolbar .search { max-width: none; flex: 1 1 100%; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar .spacer { display: none; }
  .toolbar select.only-sm { flex: 1 1 100%; }
  .count { font-size: 12px; }

  /* ---- squad: the 5-column table becomes one card per player ---- */
  .tablewrap { border: 0; background: transparent; border-radius: 0; overflow: visible; }
  table.tbl, table.tbl tbody, table.tbl tr, table.tbl td { display: block; width: auto; }
  table.tbl thead { display: none; }
  table.tbl tbody tr {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
    padding: 13px; margin-bottom: 10px;
  }
  table.tbl tbody tr:last-child { margin-bottom: 0; }
  table.tbl tbody tr:hover { background: var(--panel); }
  table.tbl tbody tr.emptyrow { border: 0; background: transparent; padding: 0; margin-bottom: 0; }
  table.tbl td { border: 0; padding: 0; margin-top: 12px; }
  table.tbl td:first-child { margin-top: 0; }
  table.tbl td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 6px;
    font-size: 10px; font-weight: 600; letter-spacing: .09em;
    text-transform: uppercase; color: var(--text-3);
  }
  table.tbl td .in { padding: 11px 12px; background: var(--bg-2); border-color: var(--line); }
  table.tbl td .in:hover { border-color: var(--line); }
  table.tbl td .in:focus { background: var(--panel-2); border-color: var(--line-2); }
  .tdname, .tdseason, .tdstatus, .tdact { width: auto; }
  .statuscell { white-space: normal; }
  table.tbl td.tdact {
    display: flex; justify-content: flex-end;
    margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line);
  }

  /* ---- owners: name on its own line, then % / Hub / Remove ---- */
  .ownrow { grid-template-columns: 92px auto auto; gap: 8px; }
  .ownrow .nm { grid-column: 1 / -1; }
  .ownrow .in { background: var(--panel-2); border-color: var(--line); }
  .perm { min-height: 44px; }

  /* ---- modals become bottom sheets ---- */
  .modalwrap { padding: 0; place-items: end stretch; }
  .modal {
    max-width: none; border-radius: var(--r) var(--r) 0 0; max-height: 92dvh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(16px);
  }
  .modal .mbtns { flex-direction: column-reverse; }
  .modal .mbtns .btn { width: 100%; min-height: 48px; }
  .modal .sum { gap: 10px; }

  /* ---- toasts sit above the thumb instead of behind the clock ---- */
  .toasts {
    top: auto; left: 12px; right: 12px; width: auto;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .toast.expanded { width: auto; }
  .toastdetail { max-height: 40dvh; }

  /* ---- login / denied states ---- */
  .login { padding: 18px; }
  .logincard { padding: 24px 20px; }
  .logincard .btn, .deny-actions .btn { min-height: 48px; }
}

/* ---------- small phone ---------- */
@media (max-width: 400px) {
  .grid.kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .crumbs .pill { display: none; }
  .content { padding: 16px 12px 70px; }
}

/* ---------- touch: don't leave hover states stuck after a tap ---------- */
@media (hover: none) {
  .clubitem:hover, .lrow:hover, .tfrow:hover, .tgl:hover { background: none; }
  .clubcard:hover { border-color: var(--line); background: var(--panel); }
  .chip:hover { color: var(--text-3); }
  .tgl:hover, .perm:hover { color: var(--text-3); }
  .perm:hover { border-color: var(--line); }
  .btn:hover { border-color: var(--line-2); color: var(--text-2); }
  .btn.ghost:hover { background: var(--panel); color: var(--text-2); }
  .btn.primary:hover { filter: none; }
}

/* ---------- landscape phones: keep modals usable ---------- */
@media (max-height: 460px) and (max-width: 980px) {
  .modal { max-height: 96dvh; }
  .modalwrap { place-items: end stretch; }
  .sidebar { width: min(300px, 70vw); }
}
