:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #17201a;
  --muted: #5d6b61;
  --border: #d9e0d8;
  --primary: #0b6e3a;
  --primary-ink: #ffffff;
  --primary-soft: #dcefe3;
  --warn: #f5c518;
  --warn-soft: #fff4c7;
  --warn-ink: #5c4600;
  --danger: #c0392b;
  --danger-soft: #fbe3e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411;
    --surface: #182019;
    --surface-2: #1f2a22;
    --text: #e8efe9;
    --muted: #9aaa9f;
    --border: #2b382f;
    --primary: #2fae66;
    --primary-ink: #04160b;
    --primary-soft: #193a26;
    --warn-soft: #3a3210;
    --warn-ink: #ffe27a;
    --danger-soft: #3d1d1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 1.6rem; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.top {
  background: var(--primary);
  color: var(--primary-ink);
  padding-top: env(safe-area-inset-top);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top nav { margin-left: auto; display: flex; gap: 8px; flex: none; }
.top nav a, .top nav button {
  color: inherit; background: rgba(255, 255, 255, 0.16); border: 0; border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 0.9rem; text-decoration: none; cursor: pointer;
}

main { padding-top: 12px; padding-bottom: 48px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
.card.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-ink); }
.card.good { background: var(--primary-soft); border-color: transparent; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 44px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #3a2c00; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 0.875rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input[type='checkbox'] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* Match list */
.matches { list-style: none; margin: 0; padding: 0; }
.match {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; margin: 8px 0;
}
.match .date { text-align: center; background: var(--surface-2); border-radius: 10px; padding: 6px 0; line-height: 1.1; }
.match .date .dow { display: block; font-size: 0.75rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.match .date .day { display: block; font-size: 1.4rem; font-weight: 800; }
.match .date .mon { display: block; font-size: 0.75rem; color: var(--muted); }
.match .title { font-weight: 700; }
.match .meta { font-size: 0.85rem; color: var(--muted); }
.match .who { text-align: right; font-weight: 600; max-width: 45vw; }
.match .who div { overflow-wrap: anywhere; }
.match.next { border: 2px solid var(--primary); }
.match.mine { background: var(--primary-soft); }
.match.cancelled { opacity: 0.6; }
.match.cancelled .title { text-decoration: line-through; }
.match.needs { border-color: var(--warn); }
.match .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }

.chip { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.warn { background: var(--warn); color: #3a2c00; }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.good { background: var(--primary-soft); color: var(--primary); }

.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.925rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 0.8rem; margin-right: 6px; }

details summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 12px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #17201a; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); z-index: 100; font-weight: 600;
}
#toast.error { background: var(--danger); }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.big-date { font-size: 1.6rem; font-weight: 800; margin: 4px 0; }

/* Admin */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 12px 0; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 12px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.slot { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.slot select { flex: 1; min-height: 38px; padding: 6px 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100% - 24px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form { padding: 18px; }
.datelist { max-height: 40vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin-top: 10px; }
.datelist label { margin: 6px 0; }
code.link { display: block; padding: 10px; background: var(--surface-2); border-radius: 8px; overflow-wrap: anywhere; font-size: 0.85rem; }
.msg { border-bottom: 1px solid var(--border); padding: 10px 0; font-size: 0.9rem; }
.msg p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
