/* Blues Team Manager: phone-first, large targets, little typing. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #15213a;
  --muted: #5b6983;
  --line: #d9e0ec;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #dbe6ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(21, 33, 58, 0.06), 0 4px 16px rgba(21, 33, 58, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1526;
    --surface: #182038;
    --surface-2: #1f2a47;
    --text: #e8edf8;
    --muted: #9fb0cc;
    --line: #2d3a5c;
    --accent: #6b93ff;
    --accent-ink: #0b1430;
    --accent-soft: #233564;
    --ok: #4ade80;
    --ok-soft: #14402a;
    --warn: #fbbf24;
    --warn-soft: #4a3308;
    --bad: #f87171;
    --bad-soft: #4c1d1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 0.95em; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 12px; display: flex; align-items: center; gap: 8px; min-height: 56px; }
@media (max-width: 640px) {
  .brand-text { display: none; }
  .topbar-inner { padding: 0 8px; }
  .nav { overflow-x: auto; flex: 1 1 auto; min-width: 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav > a, .nav summary { padding: 0 8px; font-size: 0.9rem; flex: 0 0 auto; }
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; margin-right: auto; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.nav { display: flex; gap: 2px; align-items: center; }
.nav > a, .nav summary { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.95rem; cursor: pointer; list-style: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav > a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.menu { position: relative; }
.menu-panel { position: fixed; right: 8px; top: 56px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 220px; padding: 6px; display: flex; flex-direction: column; }
.menu-panel a, .menu-panel button { display: block; width: 100%; text-align: left; padding: 12px; border-radius: 8px; text-decoration: none; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }

.container { max-width: 1100px; width: 100%; margin: 0 auto; padding: 16px 12px 48px; flex: 1; }
.footer { padding: 16px 12px 32px; text-align: center; color: var(--muted); font-size: 0.85rem; }

.messages { margin-bottom: 12px; }
.message { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; background: var(--accent-soft); border-left: 4px solid var(--accent); }
.message-success { background: var(--ok-soft); border-color: var(--ok); }
.message-warning { background: var(--warn-soft); border-color: var(--warn); }
.message-error { background: var(--bad-soft); border-color: var(--bad); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; flex: 1 1 auto; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin-bottom: 10px; }
.card-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card-row > * { min-width: 0; }
@media (min-width: 760px) { .card-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .card-row > .card { margin-bottom: 0; } .card-row { margin-bottom: 14px; } }

.btn, button, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  touch-action: manipulation;
}
.btn-primary, button.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-sm { min-height: 44px; padding: 0 12px; font-size: 0.92rem; }
.btn-block { width: 100%; }
.btn-xl { min-height: 64px; font-size: 1.15rem; }
.btn[aria-disabled="true"], button:disabled { opacity: 0.5; cursor: not-allowed; }
.linklike { background: none; border: 0; color: var(--accent); min-height: 44px; padding: 0; font-weight: 600; }
.inline-form { display: inline; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* forms */
form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="file"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; vertical-align: middle; margin-right: 8px; }
.helptext, .help { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 3px; }
.errorlist { color: var(--bad); margin: 4px 0 0; padding-left: 18px; }
.nonfield { background: var(--bad-soft); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: 1 / -1; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.score-input { font-size: 2rem; text-align: center; min-height: 72px; font-weight: 700; }
.score-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; }
.score-row .dash { font-size: 2rem; padding-bottom: 14px; color: var(--muted); }
.rating-input { font-size: 1.4rem; text-align: center; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.dim td { color: var(--muted); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.result-W { color: var(--ok); font-weight: 800; }
.result-D { color: var(--warn); font-weight: 800; }
.result-L { color: var(--bad); font-weight: 800; }

/* availability toggles */
.avail-list { display: flex; flex-direction: column; gap: 8px; }
.avail-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.avail-name { font-weight: 800; font-size: 1.1rem; }
.avail-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.avail-buttons button { min-height: 48px; min-width: 44px; padding: 0 4px; font-size: 0.85rem; }
.avail-buttons button.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.avail-buttons button.is-on.unavailable { background: var(--bad); border-color: var(--bad); color: #fff; }
.avail-buttons button.is-on.late { background: var(--warn); border-color: var(--warn); color: #fff; }

/* substitution sheet */
.sheet { font-size: 1.15rem; }
.sheet-half { margin-bottom: 14px; }
.sheet-half h3 { color: var(--accent); margin-bottom: 6px; }
.sheet-line { display: grid; grid-template-columns: 56px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.sheet-line .pos { font-weight: 800; color: var(--muted); }
.sheet-line .who { font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-line .seg { white-space: nowrap; }
.sheet-change { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
.sheet-minutes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sheet-minutes .chip { background: var(--surface-2); padding: 6px 10px; border-radius: 999px; font-weight: 700; }

/* planner grid */
.grid-wrap { overflow-x: auto; }
.grid { border-collapse: separate; border-spacing: 4px; }
.grid th { text-align: center; font-size: 0.8rem; }
.grid td.slot-label { font-weight: 800; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 2px 0 0 var(--line); }
.grid select { min-width: 92px; min-height: 48px; padding: 6px; font-weight: 700; }
.grid th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.grid td.half-start { border-left: 3px solid var(--accent); }
.issue-list { margin: 0; padding-left: 18px; }
.issue-list li { margin-bottom: 4px; }
.issue-error { color: var(--bad); }
.issue-warn { color: var(--warn); }
.issue-ack { color: var(--muted); }

/* option cards */
.option { border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface); }
.option.best { border-color: var(--accent); }
.option-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.reasoning { color: var(--muted); font-size: 0.92rem; padding-left: 18px; margin: 6px 0; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.tile .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tile .value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select { width: auto; min-width: 140px; }
.table-wrap td:first-child strong { white-space: nowrap; }
select[name^="lock_"], .user-role-select { min-height: 44px !important; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.fixture-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.fixture-item a.title { font-weight: 800; font-size: 1.05rem; text-decoration: none; color: var(--text); }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; z-index: 2; }
.copybox { display: flex; gap: 8px; }
.copybox input { font-family: var(--mono); font-size: 0.85rem; }

@media print {
  .topbar, .footer, .messages, .no-print, .sticky-actions { display: none !important; }
  body { background: #fff; color: #000; font-size: 14pt; }
  .card { box-shadow: none; border: 0; page-break-inside: avoid; }
  .sheet { font-size: 16pt; }
}

/* allauth pages render inside a narrow card */
body.auth .container { max-width: 540px; }
body.auth main > *:not(.messages) { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
body.auth main h1 { font-size: 1.4rem; }
body.auth main form { margin-top: 10px; }
body.auth main form p { margin-bottom: 12px; }
body.auth main ul { padding-left: 18px; }
body.auth main img { max-width: 220px; height: auto; display: block; margin: 10px auto; background: #fff; padding: 8px; border-radius: 8px; }
body.auth main .secretText, body.auth main code { word-break: break-all; }

/* Season plan grid: keep the player column in view while scrolling sideways */
.season-grid table { border-collapse: separate; border-spacing: 0; }
.season-grid th:first-child, .season-grid td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.season-grid th:last-child, .season-grid td:last-child { position: sticky; right: 0; background: var(--surface); z-index: 1; box-shadow: -6px 0 6px -6px rgba(0,0,0,0.25); }
.season-grid th { white-space: nowrap; }
.season-grid td.num { font-variant-numeric: tabular-nums; }

/* Team branding and menus */
.brand-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; background: var(--surface-2); }
.menu-section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 12px 2px; }

/* Player page chart (inline SVG; colours follow the theme tokens) */
.chart { max-width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-base { stroke: var(--muted); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 10px; font-family: inherit; }
.chart-bar { fill: var(--accent); }
.chart-bar-gk { fill: var(--accent-soft); }
.chart-bar-approx { fill: var(--accent); opacity: 0.55; }
.chart-target { stroke: var(--text); stroke-width: 2; }
.pos-bars { display: grid; gap: 8px; }
.pos-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 10px; align-items: center; }
.pos-label { color: var(--muted); font-size: 0.9rem; }
.pos-track { display: block; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.pos-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.pos-value { font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* Game Day */
.gd-clock-card { text-align: center; }
.gd-time { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.gd-phase { color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.8rem; margin-top: 4px; }
.gd-score { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin: 12px 0; }
.gd-score .gd-num { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.gd-score .gd-team { color: var(--muted); font-weight: 600; }
.gd-controls { justify-content: center; }
.gd-next { border: 2px solid var(--accent); }
.gd-lineup li strong { font-size: 1.1rem; }
