/* Interclub — mobile-first stylesheet (no framework) */
:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e3e7e3;
  --primary: #1f6f4a;
  --primary-dark: #17563a;
  --primary-soft: #e3f2ea;
  --accent: #c8a84b;
  --win: #15803d;
  --win-bg: #dcfce7;
  --loss: #b91c1c;
  --loss-bg: #fee2e2;
  --nd: #4b5563;
  --nd-bg: #e5e7eb;
  --absent: #b45309;
  --absent-bg: #fef3c7;
  --unsure: #1d4ed8;
  --unsure-bg: #dbeafe;
  --court-bg: #f3f4f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.neg { color: var(--loss); font-weight: 600; }
.pos { color: var(--win); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* Layout */
.container { max-width: 1120px; margin: 0 auto; padding: 1rem; }
.footer { max-width: 1120px; margin: 2rem auto 1rem; padding: 0 1rem; display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.85rem; }

/* Top bar */
.topbar { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0.5rem 1rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand-team { font-size: 0.75rem; opacity: 0.85; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.lang-switch { display: flex; gap: 0.15rem; }
.lang-switch form { margin: 0; }
.lang-btn { background: transparent; border: 1px solid rgba(255,255,255,0.5); color: #fff; border-radius: 6px; padding: 0.15rem 0.45rem; font-size: 0.8rem; cursor: pointer; }
.lang-btn.active { background: #fff; color: var(--primary); border-color: #fff; font-weight: 700; }
.menu-btn { background: transparent; border: 1px solid rgba(255,255,255,0.5); color: #fff; border-radius: 6px; font-size: 1.2rem; line-height: 1; padding: 0.25rem 0.5rem; cursor: pointer; }
.nav { display: none; flex-basis: 100%; flex-direction: column; gap: 0.15rem; padding-top: 0.5rem; }
.nav.open { display: flex; }
.nav-link { color: #fff; text-decoration: none; padding: 0.5rem 0.6rem; border-radius: 6px; font-size: 0.95rem; }
.nav-link:hover { background: rgba(255,255,255,0.12); }
.nav-link.active { background: rgba(255,255,255,0.2); font-weight: 600; }
.nav-logout { margin: 0; }
.as-button { background: none; border: 0; cursor: pointer; font: inherit; width: 100%; text-align: left; }
.nav .muted { color: rgba(255,255,255,0.75); }
@media (min-width: 900px) {
  .menu-btn { display: none; }
  .nav { display: flex; flex-direction: row; flex-wrap: wrap; flex-basis: 100%; padding-top: 0.25rem; }
  .nav-logout { margin-left: auto; }
  .as-button { width: auto; }
}

.pref-bar { background: var(--absent-bg); color: var(--absent); font-size: 0.9rem; }
.pref-bar form { max-width: 1120px; margin: 0 auto; padding: 0.4rem 1rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

/* Cards & flashes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.auth-card { max-width: 420px; margin: 2rem auto; }
.flash { padding: 0.6rem 0.9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid transparent; }
.flash-success { background: var(--win-bg); color: var(--win); border-color: #bbf7d0; }
.flash-error { background: var(--loss-bg); color: var(--loss); border-color: #fecaca; }
.flash-warning { background: var(--absent-bg); color: var(--absent); border-color: #fde68a; }
.flash-info { background: var(--unsure-bg); color: var(--unsure); border-color: #bfdbfe; }

/* Stats tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 0.9rem; box-shadow: var(--shadow); }
.tile-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tile-value { font-size: 1.5rem; font-weight: 700; margin: 0.15rem 0; }
.tile-note { font-size: 0.78rem; color: var(--muted); }

/* Buttons */
.btn { display: inline-block; padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 0.95rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: #c9cfc9; background: #fafbfa; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--loss); border-color: #fecaca; background: #fff5f5; }
.btn-danger:hover { background: var(--loss-bg); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn-block { width: 100%; display: block; margin-top: 0.75rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

/* Segmented status buttons */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg-btn { border: 0; background: transparent; padding: 0.4rem 0.7rem; font: inherit; font-size: 0.88rem; cursor: pointer; color: var(--muted); border-right: 1px solid var(--border); white-space: nowrap; }
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: #f3f5f3; }
.seg-btn.is-active { font-weight: 700; color: #fff; }
.seg-btn.is-active.st-available, .seg-btn.is-active.st-present { background: var(--win); }
.seg-btn.is-active.st-unavailable { background: var(--nd); }
.seg-btn.is-active.st-absent { background: var(--absent); }
.seg-btn.is-active.st-unsure { background: var(--unsure); }
.seg.seg-compact .seg-btn { padding: 0.25rem 0.45rem; font-size: 0.8rem; }
.htmx-request .seg-btn { opacity: 0.6; }

/* Badges */
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge.win, .badge.st-available, .badge.st-present { background: var(--win-bg); color: var(--win); }
.badge.loss { background: var(--loss-bg); color: var(--loss); }
.badge.st-unavailable, .badge.neutral { background: var(--nd-bg); color: var(--nd); }
.badge.st-absent { background: var(--absent-bg); color: var(--absent); }
.badge.st-unsure { background: var(--unsure-bg); color: var(--unsure); }
.badge.court { background: var(--court-bg); color: var(--text); border: 1px solid var(--border); }
.badge.kind-match { background: var(--primary-soft); color: var(--primary-dark); }
.badge.kind-training { background: var(--court-bg); color: var(--muted); }
.badge.ha { background: #fff; border: 1px solid var(--border); color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.table th, .table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: #f7f9f7; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table tr.me td { background: #f2f8f4; }
.table tr.inactive td { color: var(--muted); font-style: italic; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { background: #f7f9f7; font-weight: 600; }

/* Session list (home) */
.session-list { list-style: none; margin: 0; padding: 0; }
.session-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.session-item:last-child { border-bottom: 0; }
.session-when { font-weight: 600; }
.session-what { font-size: 0.85rem; color: var(--muted); }
.session-item.past { opacity: 0.85; }

/* Upcoming table */
.upcoming th.match-head { text-align: center; text-transform: none; letter-spacing: 0; }
.upcoming td.status-cell { text-align: center; }
.match-head .opp { font-weight: 700; color: var(--text); font-size: 0.9rem; }
.match-head .when { display: block; color: var(--muted); font-weight: 400; }

/* Season grid */
.grid-wrap { overflow: auto; max-height: 80vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 0.82rem; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0.25rem 0.35rem; text-align: center; white-space: nowrap; background: var(--surface); }
.grid thead th { position: sticky; top: 0; z-index: 2; background: #f7f9f7; font-weight: 600; vertical-align: bottom; }
.grid .sticky { position: sticky; z-index: 1; background: var(--surface); }
.grid thead .sticky { z-index: 3; background: #f7f9f7; }
.grid .col-name { left: 0; min-width: 130px; text-align: left; font-weight: 600; }
.grid .col-s1 { left: 130px; min-width: 52px; }
.grid .col-s2 { left: 182px; min-width: 52px; }
.grid .col-s3 { left: 234px; min-width: 60px; border-right: 2px solid #c9cfc9; }
.grid .head-date { font-weight: 700; }
.grid .head-opp { font-size: 0.75rem; color: var(--muted); }
.grid .head-opp a { color: var(--primary-dark); text-decoration: none; }
.grid .head-score { font-size: 0.78rem; }
.grid th.kind-training { background: #fbfbfb; color: var(--muted); }
.grid td.cell { min-width: 44px; font-weight: 600; }
.grid td.cell.win { background: var(--win-bg); color: var(--win); }
.grid td.cell.loss { background: var(--loss-bg); color: var(--loss); }
.grid td.cell.court { background: var(--court-bg); }
.grid td.cell.unavailable { background: var(--nd-bg); color: var(--nd); }
.grid td.cell.absent { background: var(--absent-bg); color: var(--absent); }
.grid td.cell.unsure { background: var(--unsure-bg); color: var(--unsure); }
.grid td.cell.editable { cursor: pointer; }
.grid td.cell.editable:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.grid td.cell a { color: inherit; text-decoration: none; display: block; }
.grid tr.me td { box-shadow: inset 0 0 0 1px var(--primary-soft); }

/* Forms */
.form label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.25rem; }
.form input[type="text"], .form input[type="email"], .form input[type="tel"], .form input[type="date"], .form input[type="number"], .form select, .form textarea {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid #cfd6cf; border-radius: 8px; font: inherit; background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.form .check { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-weight: 600; font-size: 0.9rem; }
.form .check input { width: auto; }
.form .help { font-size: 0.82rem; color: var(--muted); margin-top: 0.2rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.code-input { font-size: 1.6rem; letter-spacing: 0.3em; text-align: center; }
.inline-form { display: inline-flex; gap: 0.35rem; align-items: center; margin: 0; }
.inline-form input { padding: 0.35rem 0.5rem; border: 1px solid #cfd6cf; border-radius: 6px; font: inherit; width: 7.5rem; text-align: right; }

/* Lineup form */
.courts { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .courts { grid-template-columns: repeat(3, 1fr); } }
.court { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; background: #fafbfa; }
.court h3 { margin: 0 0 0.5rem; }
.court select { width: 100%; margin-bottom: 0.4rem; }
.court .players { font-weight: 600; }
.court .result-btns { margin-top: 0.5rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.result-btn.is-active.win { background: var(--win); color: #fff; border-color: var(--win); }
.result-btn.is-active.loss { background: var(--loss); color: #fff; border-color: var(--loss); }

/* Lists */
.name-list { margin: 0.25rem 0; padding-left: 1.2rem; }
.legend dt { font-weight: 700; margin-top: 0.6rem; }
.legend dd { margin: 0.1rem 0 0 0; color: var(--text); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--court-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3rem; }
.score-line { font-size: 1.05rem; font-weight: 600; }
