/* =====================================================================
   Padel 8oyz Club Manager — desktop stylesheet
   Fonts: Bahnschrift (Windows, DIN-style) for display & figures,
          Segoe UI Variable for text. No web fonts: works offline.
   ===================================================================== */

:root {
  /* palette — court green ink on warm paper, padel-ball lime accent */
  --paper: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --surface-3: #f0efe8;
  --line: #e5e3da;
  --line-2: #d6d3c7;
  --ink: #15211c;
  --ink-2: #3c4842;
  --muted: #737a72;
  --faint: #a2a79f;

  --court: #12382c;
  --court-2: #194636;
  --court-3: #23584a;
  --court-ink: #e6eee9;
  --court-muted: #8fa89d;

  --accent: #1d6b4d;
  --accent-hover: #175a40;
  --accent-soft: #e6f0eb;
  --ball: #c8e64b;
  --ball-ink: #3d4a0a;

  --green: #2b7a4b;
  --green-soft: #e5f2ea;
  --amber: #a5630a;
  --amber-soft: #fbf0dc;
  --amber-line: #efd7aa;
  --red: #b42b22;
  --red-soft: #fbe8e6;
  --red-line: #f0c3be;
  --blue: #2c5d8a;
  --blue-soft: #e8eff6;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-1: 0 1px 2px rgba(21, 33, 28, 0.05);
  --shadow-2: 0 2px 6px rgba(21, 33, 28, 0.06), 0 1px 2px rgba(21, 33, 28, 0.04);
  --shadow-pop: 0 18px 50px rgba(15, 30, 24, 0.22), 0 2px 8px rgba(15, 30, 24, 0.08);

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "Courier New", monospace;

  --sidebar-w: 236px;
  --rail-w: 64px;
  --content-max: 1240px;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

::selection { background: var(--ball); color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.noscript { padding: 40px; font-size: 16px; }

/* ---------- utilities ---------- */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fig { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: 0.005em; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn-text { color: var(--amber); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sep-dot::before { content: "·"; margin: 0 6px; color: var(--faint); }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--ink-2); }

/* =====================================================================
   App layout
   ===================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns 0.18s ease; }
.app.sb-collapsed { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--court);
  color: var(--court-ink);
  border-right: 1px solid #0c2a20;
  overflow: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 12px 20px 20px; white-space: nowrap; }
.brand-text { min-width: 0; }
.sb-toggle {
  margin-left: auto; flex: none; width: 30px; height: 30px; border: 0; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--court-muted); cursor: pointer; transition: background 0.12s, color 0.12s;
}
.sb-toggle:hover { background: var(--court-2); color: #fff; }
.sb-toggle:focus-visible { outline-color: var(--ball); }
.sb-backdrop { display: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: 0.01em; line-height: 1.05; color: #fff; }
.brand-name span { color: var(--ball); }
.brand-sub { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--court-muted); margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.nav-label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--court-muted); padding: 14px 10px 6px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 7px;
  color: var(--court-ink); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--court-2); text-decoration: none; }
.nav-item .i { color: var(--court-muted); transition: color 0.12s; }
.nav-item.active { background: var(--court-3); color: #fff; }
.nav-item.active .i { color: var(--ball); }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ball); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: rgba(200, 230, 75, 0.16); color: var(--ball); }

.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.07); position: relative; z-index: 1; }
.dbbox { margin-top: 8px; padding: 12px; border-radius: 9px; background: rgba(0, 0, 0, 0.18); border: 1px solid rgba(255, 255, 255, 0.06); }
.dbbox-folder { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--court-ink); }
.dbbox-folder .i { color: var(--court-muted); }
.dbbox-status { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-size: 12px; color: var(--court-muted); }
.dbbox-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--court-muted); flex: none; }
.dbbox-status[data-state="saved"] .dot { background: #6fcf97; }
.dbbox-status[data-state="dirty"] .dot, .dbbox-status[data-state="saving"] .dot { background: var(--ball); }
.dbbox-status[data-state="saving"] .dot { animation: pulse 0.9s ease-in-out infinite; }
.dbbox-status[data-state="error"] .dot, .dbbox-status[data-state="conflict"] .dot, .dbbox-status[data-state="permission"] .dot { background: #ff8a7a; }
.dbbox-status[data-state="error"], .dbbox-status[data-state="conflict"], .dbbox-status[data-state="permission"] { color: #ffb4a8; }
.dbbox-actions { display: flex; gap: 6px; margin-top: 10px; }
.sb-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04); color: var(--court-ink); font-size: 12px; cursor: pointer;
}
.sb-btn:hover { background: rgba(255, 255, 255, 0.1); }
.sb-btn .i { width: 15px; height: 15px; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* collapsed sidebar: icon rail */
.sb-collapsed .brand { flex-direction: column; gap: 10px; padding: 18px 0 10px; }
.sb-collapsed .brand-text, .sb-collapsed .nav-text, .sb-collapsed .nav-label,
.sb-collapsed .dbbox-folder, .sb-collapsed .dbbox-status .txt, .sb-collapsed .sb-btn-text { display: none; }
.sb-collapsed .sb-toggle { margin-left: 0; }
.sb-collapsed .nav { padding: 8px 10px; }
.sb-collapsed .nav-item { justify-content: center; gap: 0; padding: 10px 0; }
.sb-collapsed .nav-item.active::before { left: -10px; }
.sb-collapsed .nav-count {
  position: absolute; top: 5px; right: 8px; width: 10px; height: 10px; padding: 0;
  font-size: 0; border-radius: 50%; background: var(--ball); border: 2px solid var(--court);
}
.sb-collapsed .sidebar-foot { padding: 10px; }
.sb-collapsed .dbbox { display: flex; flex-direction: column; align-items: center; padding: 8px 0 2px; background: transparent; border: 0; }
.sb-collapsed .dbbox-status { margin-top: 0; justify-content: center; }
.sb-collapsed .dbbox-actions { flex-direction: column; gap: 6px; margin-top: 10px; }
.sb-collapsed .sb-btn { flex: none; width: 40px; height: 32px; padding: 0; }

/* narrow window: full menu slides over the content (the grid keeps the rail column) */
.app.sb-overlay { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.app.sb-overlay .sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 900; width: var(--sidebar-w);
  box-shadow: var(--shadow-pop); animation: sb-in 0.16s ease-out;
}
.app.sb-overlay .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 899; background: rgba(14, 26, 21, 0.38); animation: page-in 0.16s ease-out; }
@keyframes sb-in { from { transform: translateX(-24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.main { grid-column: 2; min-width: 0; container: main / inline-size; }
.page { max-width: var(--content-max); margin: 0 auto; padding: 26px 36px 64px; animation: page-in 0.14s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- page header ---------- */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .i { width: 13px; height: 13px; color: var(--faint); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-title { font-family: var(--font-display); font-size: 27px; font-weight: 600; letter-spacing: -0.005em; line-height: 1.12; }
.page-sub { margin-top: 5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex: none; align-items: center; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-1); transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: #c6c2b4; text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn .i { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-dark { background: var(--court); border-color: var(--court); color: #fff; }
.btn-dark:hover { background: var(--court-2); border-color: var(--court-2); }
.btn-danger { color: var(--red); border-color: var(--red-line); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger-solid:hover { background: #9b231c; border-color: #9b231c; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn .i { width: 16px; height: 16px; }

/* dropdown menu built on <details> */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-pop);
  padding: 5px;
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; text-align: left; cursor: pointer; color: var(--ink); font-size: 13.5px;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item .i { width: 16px; height: 16px; color: var(--muted); }
.menu-item.danger { color: var(--red); }
.menu-item.danger .i { color: var(--red); }
.menu-item:disabled { color: var(--faint); cursor: not-allowed; background: transparent; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-note { padding: 4px 10px 6px; font-size: 11.5px; color: var(--muted); max-width: 260px; }

/* =====================================================================
   Cards & stats
   ===================================================================== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card + .card { margin-top: 18px; }
.grid-2 > .card, .grid-main-side > .card, .editor-grid > .card, .stats > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head.plain { border-bottom: 0; padding-bottom: 6px; }
.card-title { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title .count { font-weight: 500; color: var(--muted); font-size: 13px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 11px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-link { font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.grid-main-side.side-400 { grid-template-columns: minmax(0, 1fr) 400px; }
.section { margin-top: 22px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }

.stats { display: grid; gap: 14px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stats.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats.hero-first { grid-template-columns: 1.55fr repeat(4, minmax(0, 1fr)); }
.stat {
  position: relative; padding: 15px 16px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); min-width: 0;
}
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.01em; }
.stat-label .i { width: 15px; height: 15px; }
.stat-value { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 23px; font-weight: 600; margin-top: 6px; line-height: 1.1; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.stat-sub b { color: var(--ink-2); font-weight: 600; }
.stat.hero { background: var(--court); border-color: var(--court); color: #fff; }
.stat.hero .stat-label { color: var(--court-muted); }
.stat.hero .stat-value { font-size: 31px; color: #fff; }
.stat.hero .stat-sub { color: var(--court-muted); }
.stat.hero .stat-sub b { color: var(--court-ink); }
.stat.hero .stat-foot { margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 12px; color: var(--court-ink); display: flex; justify-content: space-between; gap: 8px; }
.stat.hero .stat-foot a { color: var(--ball); }
.stat.tone-amber { background: var(--amber-soft); border-color: var(--amber-line); }
.stat.tone-amber .stat-label { color: var(--amber); }
.stat.tone-amber .stat-value { color: #7a4705; }
.stat.tone-green .stat-value { color: var(--green); }
.stat.tone-red .stat-value { color: var(--red); }
.stat.tone-accent::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ball); }

.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv .total { padding-top: 8px; border-top: 1px solid var(--line); font-weight: 600; }

.formula { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 12px 16px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.formula .op { color: var(--faint); font-weight: 600; }
.formula .term { display: inline-flex; flex-direction: column; }
.formula .term small { font-size: 11px; color: var(--muted); }
.formula .term b { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14.5px; }

/* =====================================================================
   Tables
   ===================================================================== */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.2px; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th:first-child, .tbl td:first-child { padding-left: 18px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 18px; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background 0.08s; }
.tbl tbody tr:hover td { background: #fbfaf6; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.muted-row td { color: var(--muted); }
.tbl tr.subrow td { background: var(--surface-2); font-size: 12.8px; padding-top: 7px; padding-bottom: 7px; }
.tbl tr.subrow td:first-child { padding-left: 46px; }
.tbl tr.open-row td { background: #fffdf6; }
.tbl th.right, .tbl td.right { text-align: right; }
.tbl th.center, .tbl td.center { text-align: center; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .sort-ind { display: inline-block; width: 8px; margin-left: 4px; color: var(--accent); }
.tbl th.sorted-asc .sort-ind::after { content: "↑"; }
.tbl th.sorted-desc .sort-ind::after { content: "↓"; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.tbl .cell-main { font-weight: 550; color: var(--ink); }
.tbl .cell-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions .icon-btn { width: 28px; height: 28px; }
.tbl.compact td { padding-top: 7px; padding-bottom: 7px; }
.tbl.compact th { padding-top: 7px; padding-bottom: 7px; }
.tbl-empty { padding: 26px 18px; text-align: center; color: var(--muted); font-size: 13px; }

.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent);
}
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.off { background: var(--surface-3); color: var(--faint); }

/* =====================================================================
   Badges, chips, banners
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 11px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--ink-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.court { background: var(--court); color: #fff; }
.badge.lime { background: #eef7cf; color: var(--ball-ink); }
.badge.outline { background: transparent; border: 1px solid var(--line-2); color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 5px;
  background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip.donation { background: #eef7cf; color: var(--ball-ink); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }

.banner {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); font-size: 13.2px; line-height: 1.5;
}
.banner + .banner { margin-top: 10px; }
.banner .i { margin-top: 1px; }
.banner-title { font-weight: 600; }
.banner.info { background: var(--blue-soft); border-color: #cddcea; color: #24486b; }
.banner.warn { background: var(--amber-soft); border-color: var(--amber-line); color: #6d4206; }
.banner.danger { background: var(--red-soft); border-color: var(--red-line); color: #7d1d16; }
.banner.success { background: var(--green-soft); border-color: #bfdcc9; color: #1f5a37; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner .btn { margin-left: auto; flex: none; }
.banners { margin-bottom: 18px; }

/* =====================================================================
   Forms
   ===================================================================== */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field > label .opt { font-weight: 400; color: var(--faint); }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.field-error { font-size: 12px; color: var(--red); display: none; }
.field.invalid .field-error { display: block; }
.field.invalid .input, .field.invalid .money { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.input { height: auto; min-height: 70px; padding: 8px 11px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: #c4c0b2; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 107, 77, 0.14); }
.input:disabled { background: var(--surface-3); color: var(--muted); }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737a72' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }
input[type="date"].input { padding-right: 6px; }
.input.sm { height: 30px; font-size: 13px; padding: 0 9px; }

.money { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); transition: border-color 0.12s, box-shadow 0.12s; }
.money:hover { border-color: #c4c0b2; }
.money:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 107, 77, 0.14); }
.money > span { display: flex; align-items: center; padding: 0 0 0 11px; color: var(--muted); font-size: 13px; font-weight: 500; }
.money > input { flex: 1; min-width: 0; height: 34px; border: 0; outline: none; background: transparent; padding: 0 11px 0 6px; text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-display); font-size: 15px; }
.money.sm > input { height: 28px; font-size: 14px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.cb { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 28px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search input { height: 32px; width: 260px; padding: 0 10px 0 33px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); outline: none; font-size: 13.2px; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 107, 77, 0.14); }
.filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filters .field > label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.filters .input { height: 32px; font-size: 13px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { position: relative; padding: 10px 14px; color: var(--muted); font-weight: 500; text-decoration: none; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab .badge { margin-left: 6px; height: 19px; }

/* =====================================================================
   Empty states
   ===================================================================== */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 42px 24px; gap: 8px; }
.empty-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--muted); margin-bottom: 6px; }
.empty-icon .i { width: 22px; height: 22px; }
.empty-title { font-weight: 600; font-size: 14.5px; }
.empty-text { color: var(--muted); max-width: 420px; font-size: 13.2px; }
.empty .btn { margin-top: 8px; }

.checklist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.check-step { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.check-step.done { background: var(--green-soft); border-color: #c9e2d2; }
.check-step .n { font-family: var(--font-display); font-weight: 600; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--line-2); font-size: 12.5px; }
.check-step.done .n { background: var(--green); color: #fff; border-color: var(--green); }
.check-step h4 { font-size: 13.5px; margin: 10px 0 4px; }
.check-step p { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }

/* =====================================================================
   Modal (native <dialog>)
   ===================================================================== */
dialog.modal {
  padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-pop); width: 560px; max-width: calc(100vw - 48px); max-height: calc(100vh - 48px);
}
dialog.modal::backdrop { background: rgba(14, 26, 21, 0.42); }
dialog.modal[open] { animation: modal-in 0.14s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }
dialog.modal.sm { width: 440px; }
dialog.modal.lg { width: 880px; }
dialog.modal.xl { width: 1040px; }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.25; }
.modal-head .modal-sub { font-size: 12.8px; color: var(--muted); margin-top: 3px; }
.modal-head .icon-btn { margin-left: auto; margin-top: -3px; margin-right: -6px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.modal-foot .left { margin-right: auto; }
.modal-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; }
.modal-aside { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.modal-aside h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.copy-area { width: 100%; min-height: 260px; font-family: var(--font-mono); font-size: 12.5px; padding: 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); resize: vertical; }
.confirm-text { color: var(--ink-2); line-height: 1.55; }
.confirm-text + .confirm-text { margin-top: 8px; }
.detail-list { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.detail-list li + li { margin-top: 3px; }

/* allocation preview list */
.alloc-list { display: flex; flex-direction: column; gap: 0; }
.alloc-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.alloc-row:last-child { border-bottom: 0; }
.alloc-row .alloc-title { font-weight: 550; }
.alloc-row .alloc-meta { font-size: 12px; color: var(--muted); }
.alloc-row .alloc-amt { text-align: right; font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 600; }
.alloc-row.skip { opacity: 0.55; }
.alloc-total { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.alloc-total .big { font-family: var(--font-display); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.donation-callout { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: #eef7cf; color: var(--ball-ink); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.donation-callout b { font-family: var(--font-display); font-size: 16px; font-variant-numeric: tabular-nums; }

/* =====================================================================
   Toasts
   ===================================================================== */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 11px; min-width: 300px; max-width: 460px;
  padding: 12px 12px 12px 14px; border-radius: 10px; background: var(--ink); color: #f2f4f1; box-shadow: var(--shadow-pop);
  animation: toast-in 0.18s ease-out; font-size: 13.2px;
}
.toast .i { margin-top: 1px; }
.toast-success .i.lead { color: var(--ball); }
.toast-error { background: #4a1612; }
.toast-error .i.lead { color: #ff9c8f; }
.toast-info .i.lead { color: #9ec5ea; }
.toast-title { font-weight: 600; }
.toast-detail { margin-top: 2px; color: rgba(242, 244, 241, 0.75); font-size: 12.5px; line-height: 1.45; }
.toast-detail ul { margin: 4px 0 0; padding-left: 16px; }
.toast-close { margin-left: auto; border: 0; background: transparent; color: rgba(255,255,255,0.55); cursor: pointer; padding: 0 2px; font-size: 18px; line-height: 1; }
.toast-close:hover { color: #fff; }
.toast-action { margin-top: 6px; border: 1px solid rgba(255,255,255,0.25); background: transparent; color: #fff; border-radius: 5px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Start screen
   ===================================================================== */
.start { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.start-left {
  position: relative; background: var(--court); color: var(--court-ink); padding: 56px 64px;
  display: flex; flex-direction: column; overflow: hidden;
}
.start-court { position: absolute; right: -70px; top: 50%; transform: translateY(-58%); width: 290px; opacity: 0.13; }
.start-court * { fill: none; stroke: #fff; stroke-width: 2; }
.start-brand { display: flex; align-items: center; gap: 14px; }
.start-brand .brand-mark { width: 44px; height: 44px; }
.start-brand .brand-name { font-size: 24px; }
.start-hero { margin-top: auto; max-width: 460px; position: relative; z-index: 1; }
.start-hero h1 { font-family: var(--font-display); font-weight: 600; font-size: 40px; line-height: 1.08; color: #fff; letter-spacing: -0.01em; }
.start-hero h1 em { font-style: normal; color: var(--ball); }
.start-hero p { margin-top: 16px; color: var(--court-muted); font-size: 15px; line-height: 1.6; }
.start-facts { margin-top: 30px; display: flex; gap: 26px; font-size: 12.5px; color: var(--court-muted); }
.start-facts b { display: block; color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.start-right { display: flex; align-items: center; justify-content: center; padding: 48px; }
.start-card { width: 440px; }
.start-card h2 { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.start-card .lead { color: var(--muted); margin-top: 6px; line-height: 1.55; }
.start-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.start-option {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-1);
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.start-option:hover { border-color: var(--accent); background: #fcfdfb; }
.start-option .ic { width: 38px; height: 38px; border-radius: 9px; background: var(--surface-3); color: var(--ink-2); display: flex; align-items: center; justify-content: center; flex: none; }
.start-option.primary { background: var(--court); border-color: var(--court); color: #fff; }
.start-option.primary:hover { background: var(--court-2); }
.start-option.primary .ic { background: rgba(200, 230, 75, 0.15); color: var(--ball); }
.start-option .t { display: block; font-weight: 600; font-size: 14.5px; }
.start-option .d { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.start-option.primary .d { color: var(--court-muted); }
.start-option .i.chev { margin-left: auto; color: var(--faint); }
.start-note { margin-top: 22px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.start-error { margin-top: 18px; }

/* =====================================================================
   Match editor
   ===================================================================== */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 450px; gap: 18px; align-items: start; }
.sticky-col { position: sticky; top: 18px; }
.cost-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 14px; }
.cost-summary { display: flex; gap: 22px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line-2); font-size: 12.5px; color: var(--muted); }
.cost-summary b { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 1px; }
.picker-tbl td, .picker-tbl th { padding-top: 6px; padding-bottom: 6px; }
.picker-tbl th.cbcol, .picker-tbl td.cbcol { width: 62px; text-align: center; padding-left: 6px; padding-right: 6px; }
.picker-tbl th.cbcol:first-child, .picker-tbl td.cbcol:first-child { padding-left: 14px; }
.picker-tbl tr.sel td { background: #f6faf3; }
.picker-tbl tr.sel:hover td { background: #eff6ea; }
.picker-tbl .inactive-tag { margin-left: 6px; }
.picker-scroll { max-height: 520px; overflow-y: auto; }
.preview-tbl td, .preview-tbl th { padding: 6px 8px; font-size: 12.8px; }
.preview-tbl th:first-child, .preview-tbl td:first-child { padding-left: 16px; }
.preview-tbl th:last-child, .preview-tbl td:last-child { padding-right: 16px; }
.preview-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.preview-sum > div { background: var(--surface); padding: 11px 14px; }
.preview-sum small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.preview-sum b { display: block; margin-top: 3px; font-family: var(--font-display); font-weight: 600; font-size: 16.5px; font-variant-numeric: tabular-nums; }
.preview-msgs { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.msg { display: flex; gap: 8px; font-size: 12.8px; line-height: 1.45; }
.msg .i { width: 16px; height: 16px; margin-top: 1px; }
.msg.error { color: var(--red); }
.msg.warn { color: var(--amber); }
.msg.ok { color: var(--green); }
.preview-actions { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.preview-actions .btn { flex: 1; }
.weight-pill { display: inline-block; min-width: 40px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); font-variant-numeric: tabular-nums; font-size: 12px; text-align: center; color: var(--ink-2); }

/* cost lines in match detail */
.cost-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.cost-line:last-child { border-bottom: 0; }
.cost-line .name { font-weight: 550; }
.cost-line .meta { font-size: 12px; color: var(--muted); }
.cost-line .amt { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* profile header */
.profile { display: flex; align-items: center; gap: 16px; }
.profile-meta { display: flex; gap: 22px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.profile-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* diff tables in impact dialogs */
.diff-arrow { color: var(--faint); margin: 0 6px; }
.diff-up { color: var(--red); }
.diff-down { color: var(--green); }
.strike { text-decoration: line-through; color: var(--faint); }

/* weight example in settings */
.weight-demo td.bar-cell { width: 40%; }
.wbar { height: 6px; border-radius: 3px; background: var(--accent); opacity: 0.8; }

.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; font-size: 13px; padding: 8px 10px; border-radius: 6px; background: var(--red-soft); color: #7d1d16; }
.issue.warning { background: var(--amber-soft); color: #6d4206; }
.issue .i { width: 16px; height: 16px; margin-top: 1px; }

.backup-list { margin: 8px 0 0; padding: 0; list-style: none; font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.backup-list li { padding: 3px 0; }

/* unsupported / boot */
.boot { min-height: 100vh; }
.unsupported { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px; }
.unsupported .card { max-width: 520px; padding: 30px; }
.unsupported h1 { font-family: var(--font-display); font-size: 24px; margin-bottom: 10px; }
.unsupported p { color: var(--ink-2); line-height: 1.6; }
.unsupported p + p { margin-top: 10px; }

.btn-stack .btn { justify-content: flex-start; }
.tbl .actions .btn, .tbl .actions .icon-btn { vertical-align: middle; }

/* =====================================================================
   Date field (dd/mm/yyyy) + calendar popup
   ===================================================================== */
svg.i.flip { transform: scaleX(-1); }
.datefield { position: relative; display: flex; align-items: center; min-width: 0; }
.datefield .input { padding-right: 38px; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.datefield-btn {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: 0; border-radius: 5px; background: transparent; color: var(--muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.datefield-btn:hover { background: var(--surface-3); color: var(--accent); }
.datefield-btn .i { width: 17px; height: 17px; }
.datefield.sm .datefield-btn { width: 26px; height: 26px; }
.datefield.sm .datefield-btn .i { width: 15px; height: 15px; }
.datefield.bad .input { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

.calpop {
  position: fixed; z-index: 2000; width: 278px; padding: 10px 10px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-pop);
  animation: modal-in 0.1s ease-out;
}
.calpop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.calpop-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.calpop-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calpop-dow { padding: 5px 0 4px; text-align: center; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.calpop-day {
  position: relative; height: 33px; border: 0; border-radius: 7px; background: transparent; color: var(--ink);
  font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.calpop-day:hover { background: var(--surface-3); }
.calpop-day.out { color: var(--faint); }
.calpop-day.club::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ball); box-shadow: 0 0 0 1px rgba(61, 74, 10, 0.25); }
.calpop-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 600; }
.calpop-day.sel { background: var(--accent); color: #fff; font-weight: 600; }
.calpop-day.sel::after { background: #fff; box-shadow: none; }
.calpop-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.calpop-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.calpop-legend .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ball); box-shadow: 0 0 0 1px rgba(61, 74, 10, 0.25); }

/* =====================================================================
   Responsive layout
   Breakpoints on the content area (container "main"), not the window,
   so the layout is right whether the sidebar is expanded or a rail.
   ===================================================================== */
@container main (max-width: 1100px) {
  .stat.hero .stat-value { font-size: 27px; }
}

@container main (max-width: 980px) {
  .page { padding: 20px 22px 56px; }
  .grid-main-side, .grid-main-side.side-400, .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .sticky-col { position: static; }
  .picker-scroll { max-height: none; }
  .checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container main (max-width: 760px) {
  .page { padding: 16px 16px 48px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; gap: 12px; }
  .page-actions { flex-wrap: wrap; }
  .page-title { font-size: 23px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid.cols-3, .cost-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-3 .span-3 { grid-column: 1 / -1; }
  .card-head { flex-wrap: wrap; padding: 12px 14px; }
  .card-body { padding: 14px; }
  .toolbar { padding: 10px 14px; }
  .search, .search input { width: 100%; }
  .tabs { overflow-x: auto; scrollbar-width: thin; }
  .tab { white-space: nowrap; }
  .profile { flex-wrap: wrap; }
  .profile-meta { flex-wrap: wrap; gap: 6px 16px; }
  .cost-summary { flex-wrap: wrap; gap: 10px 18px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 14px; }
  .tbl th:last-child, .tbl td:last-child { padding-right: 14px; }
}

@container main (max-width: 520px) {
  .form-grid, .form-grid.cols-3, .cost-grid, .checklist { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .form-grid .span-3 { grid-column: 1 / -1; }
  .preview-sum { grid-template-columns: minmax(0, 1fr); }
}

/* outside the app shell: dialogs, start screen, toasts */
@media (max-width: 900px) {
  .modal-split { grid-template-columns: minmax(0, 1fr); }
  dialog.modal { max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .modal-inner { max-height: calc(100vh - 24px); }
  .start { grid-template-columns: minmax(0, 1fr); }
  .start-left { padding: 28px 24px; }
  .start-court { display: none; }
  .start-hero { margin-top: 28px; }
  .start-hero h1 { font-size: 30px; }
  .start-facts { flex-wrap: wrap; gap: 12px 22px; }
  .start-right { padding: 28px 20px; }
  .start-card { width: 100%; max-width: 440px; }
}

@media (max-width: 600px) {
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: 100%; }
  .modal-body { padding: 14px 16px; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot { flex-wrap: wrap; }
}

/* stat rows: avoid a lone card on the last row */
@container main (max-width: 1100px) {
  .stats, .stats.hero-first { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.hero-first > .stat.hero { grid-column: span 2; }
}
@container main (max-width: 760px) {
  .stats, .stats.cols-3, .stats.cols-4, .stats.hero-first { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container main (max-width: 520px) {
  .stats, .stats.cols-3, .stats.cols-4, .stats.hero-first { grid-template-columns: minmax(0, 1fr); }
  .stats.hero-first > .stat.hero { grid-column: auto; }
}

/* =====================================================================
   Akses (Admin / Viewer), layar kunci
   ===================================================================== */
.role-badge { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.role-badge .rb-short { display: none; }
.role-badge.admin { background: rgba(200, 230, 75, 0.16); color: var(--ball); }
.role-badge.viewer { background: rgba(255, 255, 255, 0.1); color: var(--court-ink); }
.dbbox-folder.role-line { margin-bottom: 2px; }
.sb-lock { width: 100%; flex: none; margin-top: 8px; }
.sb-collapsed .dbbox-folder.role-line { display: flex; justify-content: center; margin-bottom: 8px; }
.sb-collapsed .sidebar .role-badge { width: 28px; height: 24px; padding: 0; border-radius: 7px; }
.sb-collapsed .sidebar .role-badge .rb-text { display: none; }
.sb-collapsed .sidebar .role-badge .rb-short { display: inline; }
[data-role="viewer"] .admin-only { display: none !important; }

.boot-msg { display: flex; align-items: center; justify-content: center; min-height: 100vh; color: var(--muted); font-size: 15px; }
.unlock-form { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; }
.unlock-form .btn { width: 100%; }
.unlock-form .start-error { margin-top: 0; }
.unlock-form .input { height: 42px; font-size: 15px; }
#reauth-secret { height: 40px; }

/* =====================================================================
   Table scroll hints (all widths; kicks in only when a table overflows)
   .tbl-wrap is a flex row: [::before fade] [table] [::after fade].
   The fades have negative margins so they overlay the table edges without
   taking space, and are sticky so they stay pinned to the visible edges.
   JS (ui.syncScrollHints) toggles is-scrollable / can-left / can-right / at-scrolled.
   ===================================================================== */
.tbl-wrap { display: flex; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tbl-wrap > .tbl { flex: none; }
.tbl-wrap::before, .tbl-wrap::after {
  content: ""; flex: none; align-self: stretch; width: 28px; position: sticky; z-index: 5;
  pointer-events: none; opacity: 0; transition: opacity 0.15s;
}
.tbl-wrap::before { left: 0; margin-right: -28px; background: linear-gradient(to right, rgba(21, 33, 28, 0.14), transparent); }
.tbl-wrap::after {
  right: 0; margin-left: -28px; background: linear-gradient(to left, rgba(21, 33, 28, 0.16), transparent);
  display: flex; align-items: center; justify-content: flex-end; padding-right: 5px;
  content: "›"; font-size: 24px; font-weight: 600; color: var(--accent);
}
.tbl-wrap.can-right::after { opacity: 1; }
.tbl-wrap.can-right:not(.touched)::after { animation: nudge 1.3s ease-in-out infinite; }
.tbl-wrap.can-left.no-sticky::before { opacity: 1; }
@keyframes nudge { 50% { padding-right: 0; } }

/* =====================================================================
   Mobile shell: floating bottom nav + top bar (≤720px)
   ===================================================================== */
.mtop, .bnav { display: none; }

@media (max-width: 720px) {
  .app, .app.sb-collapsed, .app.sb-overlay { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .app.sb-overlay .sidebar, .sb-backdrop, .app.sb-overlay .sb-backdrop { display: none; }
  .main { grid-column: 1; }

  .mtop {
    position: sticky; top: 0; z-index: 700; display: flex; align-items: center; gap: 4px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px 14px; background: var(--court); color: #fff;
  }
  .mtop-brand { display: flex; align-items: center; gap: 9px; margin-right: auto; min-width: 0; }
  .mtop-brand .brand-mark { width: 28px; height: 28px; }
  .mtop-brand .brand-name { font-size: 16px; white-space: nowrap; }
  .mtop-brand .role-badge { height: 20px; padding: 0 8px; font-size: 10.5px; margin-left: 2px; }
  .mtop-status { width: 10px; height: 10px; margin-right: 8px; }
  .mtop-status .dot { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--court-muted); }
  .mtop-status[data-state="saved"] .dot { background: #6fcf97; }
  .mtop-status[data-state="dirty"] .dot, .mtop-status[data-state="saving"] .dot { background: var(--ball); }
  .mtop-status[data-state="saving"] .dot { animation: pulse 0.9s ease-in-out infinite; }
  .mtop-status[data-state="error"] .dot, .mtop-status[data-state="conflict"] .dot, .mtop-status[data-state="permission"] .dot { background: #ff8a7a; }
  .mtop-btn {
    width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--court-ink);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  }
  .mtop-btn:active { background: var(--court-2); }

  .bnav {
    position: fixed; z-index: 800; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 6px;
    background: rgba(18, 56, 44, 0.95); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 22px; box-shadow: var(--shadow-pop);
    transition: transform 0.2s ease;
  }
  .bnav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 50px; padding: 5px 2px; border-radius: 16px; color: var(--court-muted);
    font-size: 10.5px; font-weight: 500; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .bnav-item:hover { text-decoration: none; }
  .bnav-item .i { width: 22px; height: 22px; }
  .bnav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bnav-item.active { background: var(--court-3); color: #fff; }
  .bnav-item.active .i { color: var(--ball); }
  .bnav-ic { position: relative; display: inline-flex; overflow: visible !important; }
  .bnav-badge { position: absolute; top: -2px; right: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--ball); border: 2px solid var(--court); }
  .bnav-badge[hidden] { display: none; }
  .app.kb-open .bnav { transform: translateY(160%); }

  .main .page { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  /* never let one wide element make the whole page scroll sideways (it drags the fixed nav with it) */
  .app { overflow-x: clip; }
  .page-head > *, .page-actions { min-width: 0; max-width: 100%; }
  .page-actions { flex: 1 1 100%; flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; }
  .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

/* =====================================================================
   Mobile tables: sticky first column + denser cells
   ===================================================================== */
@media (max-width: 720px) {
  .tbl { font-size: 12.8px; }
  .tbl th { letter-spacing: 0.02em; padding: 8px 10px; }
  .tbl td { padding: 8px 10px; }

  .tbl-wrap:not(.no-sticky) .tbl th:first-child,
  .tbl-wrap:not(.no-sticky) .tbl td:first-child {
    position: sticky; left: 0; z-index: 2; max-width: 44vw; background: var(--surface);
  }
  .tbl-wrap:not(.no-sticky) .tbl th:first-child { z-index: 4; background: var(--surface-2); }
  .tbl-wrap:not(.no-sticky) .tbl tfoot td:first-child { background: var(--surface-2); }
  .tbl-wrap:not(.no-sticky) .tbl tbody tr:hover td:first-child { background: #fbfaf6; }
  .tbl-wrap:not(.no-sticky) .tbl tr.subrow td:first-child { background: var(--surface-2); }
  .tbl-wrap:not(.no-sticky) .tbl tr.open-row td:first-child { background: #fffdf6; }
  .tbl-wrap:not(.no-sticky) .tbl tr.sel td:first-child { background: #f6faf3; }
  .tbl-wrap.at-scrolled:not(.no-sticky) .tbl th:first-child,
  .tbl-wrap.at-scrolled:not(.no-sticky) .tbl td:first-child { box-shadow: 6px 0 8px -6px rgba(21, 33, 28, 0.28); }
  .tbl-wrap .tbl .cell-main, .tbl-wrap .tbl .cell-sub { white-space: normal; }
  .tbl-wrap .tbl td:first-child .nowrap { white-space: normal; }
}

/* low-priority columns (detail is one tap away: list rows open the item) */
@media (max-width: 520px) {
  .hide-sm { display: none; }
}
