:root {
  --baize-dark: #0e3a2b;
  --baize: #14533d;
  --baize-light: #1e6f52;
  --gold: #c9973b;
  --gold-soft: #f5ebd6;
  --cream: #f7f4ee;
  --surface: #ffffff;
  --ink: #1b1f1d;
  --muted: #606c66;
  --border: #e2ddd3;
  --win-bg: #e7f6ee;
  --win-fg: #12613c;
  --draw-bg: #fef5e2;
  --draw-fg: #8c5c0c;
  --loss-bg: #fdecec;
  --loss-fg: #9f2626;
  --red-ball: #b92b27;
  --yellow-ball: #e2b22c;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(14, 58, 43, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.45;
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, var(--baize) 0%, var(--baize-dark) 75%);
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 410px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 22px;
}

.login-brand h1 {
  margin: 12px 0 2px;
  font-size: 1.45rem;
  color: var(--baize-dark);
  letter-spacing: 0.03em;
}

.login-error {
  background: var(--loss-bg);
  color: var(--loss-fg);
  border: 1px solid #f3c4c4;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.login-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 0.8rem;
}

.login-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}

.login-mode-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.login-mode-btn.active {
  background: var(--baize);
  color: #fff;
}

.pin-input {
  text-align: center;
  font-size: 1.65rem !important;
  letter-spacing: 0.45em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 10px 12px !important;
}

.pin-input-sm {
  text-align: center;
  font-size: 1.15rem !important;
  letter-spacing: 0.3em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

body.role-player .manager-only {
  display: none !important;
}

.btn-full { width: 100%; justify-content: center; padding: 10px 14px; }

/* Header */
.topbar {
  background: linear-gradient(135deg, var(--baize-dark) 0%, var(--baize) 100%);
  color: #fff;
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.14);
}

.topbar-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.78);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.autosave-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.92);
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-saved { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); }
.dot-dirty { background: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, 0.7); }
.dot-saving { background: #60a5fa; }
.dot-error { background: #f87171; }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.88);
}

.btn-link-light {
  background: none;
  border: none;
  color: #fde68a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.btn-link-light:hover { color: #fff; }

.btn-outline-light {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.22); }

.balls-emblem {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.22);
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  gap: 5px;
}

.ball {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset -3px -3px 5px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.35);
}
.ball-white { background: radial-gradient(circle at 30% 30%, #ffffff, #dcd8ce); }
.ball-yellow { background: radial-gradient(circle at 30% 30%, #ffe680, #d4a017); }
.ball-red { background: radial-gradient(circle at 30% 30%, #ef5350, #9b1c1c); }

.ball-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

/* Tabs */
.tabs {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab {
  appearance: none;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  padding: 11px 15px;
  font-size: 0.91rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.tab.active { color: #fff; border-bottom-color: var(--gold); }

.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.74rem;
  margin-left: 4px;
}

.badge-gold {
  background: var(--gold);
  color: #1b1508;
  font-weight: 700;
}

/* Pending Banner & Approval Queue */
.pending-banner {
  background: var(--gold-soft);
  border: 1px solid #dfc183;
  border-left: 5px solid var(--gold);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.92rem;
  font-weight: 600;
  color: #5c4100;
}

.pending-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pending-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 11px;
  padding: 14px 16px;
  background: #fdfcf9;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pending-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pending-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 8px;
  background: var(--cream);
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.pending-edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.pending-edit-grid input {
  padding: 6px 8px;
  font-size: 0.88rem;
}

/* Mini DB Storage Progress Bar */
.mini-progress {
  height: 6px;
  background: #e7e1d5;
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 3px;
}

.mini-progress-fill {
  height: 100%;
  background: var(--baize);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.mini-progress-fill.warn { background: var(--gold); }
.mini-progress-fill.danger { background: var(--red-ball); }

/* Mobile-First Player Score Submission Shell */
.mobile-shell {
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
}

.mobile-header {
  background: linear-gradient(135deg, var(--baize-dark) 0%, var(--baize) 100%);
  color: #fff;
  padding: 14px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

.mobile-header-inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-header h1 {
  margin: 0;
  font-size: 1.15rem;
}

.mobile-main {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px 36px;
  flex: 1;
}

.mobile-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-player-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-white-ball { border-top: 4px solid #b5afa2; }
.card-yellow-ball { border-top: 4px solid var(--yellow-ball); }

.mobile-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1rem;
  color: var(--baize-dark);
}

.mobile-target-badge {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 700;
  color: #6b4c10;
  background: var(--gold-soft);
  padding: 3px 9px;
  border-radius: 999px;
}
.mobile-target-badge:empty { display: none; }

.mobile-input {
  min-height: 48px !important;
  font-size: 1.05rem !important;
  padding: 10px 12px !important;
  border-radius: 10px !important;
}

.mobile-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mobile-car-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.mobile-uit-btn {
  min-height: 48px;
  padding: 0 18px;
  font-size: 1rem;
  border-radius: 10px;
  white-space: nowrap;
}

.mobile-estimate {
  background: #f3efe6;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 15px;
  font-size: 0.94rem;
  line-height: 1.45;
}
.mobile-estimate.valid {
  background: var(--win-bg);
  border-color: #b7e4cc;
  color: var(--baize-dark);
}
.mobile-estimate.invalid {
  background: var(--loss-bg);
  border-color: #f3c4c4;
  color: var(--loss-fg);
}

.mobile-submit-btn {
  width: 100%;
  min-height: 54px;
  font-size: 1.08rem;
  justify-content: center;
  border-radius: 12px;
}

.mobile-success {
  background: #fff;
  border: 1px solid #b7e4cc;
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--win-bg);
  color: var(--win-fg);
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-storage-bar {
  margin-top: 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Main container */
.container {
  max-width: 1260px;
  margin: 22px auto 60px;
  padding: 0 20px;
}

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 1.38rem;
  color: var(--baize-dark);
  font-variant-numeric: tabular-nums;
}

.kpi-sub { font-size: 0.81rem; color: var(--muted); }

/* Views & Cards */
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--baize-dark);
}

.muted { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-12 { margin-bottom: 12px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--baize); color: #fff; }
.btn-primary:hover { background: var(--baize-light); }
.btn-gold { background: var(--gold); color: #1b1508; }
.btn-gold:hover { background: #d9a748; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { background: var(--cream); border-color: #c8c1b3; }
.btn-danger { background: var(--loss-bg); color: var(--loss-fg); border-color: #f3c4c4; }
.btn-danger:hover { background: #f9d8d8; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--cream); color: var(--ink); }

/* Inputs */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(20, 83, 61, 0.25);
  border-color: var(--baize);
}

.input-sm { width: 68px; padding: 6px 8px !important; }
.input-search { width: 190px; }
.input-select-sm { padding: 6px 10px !important; }

.inline-edit-input {
  padding: 4px 7px !important;
  font-size: 0.86rem !important;
  border-color: transparent !important;
  background: transparent !important;
  border-radius: 6px !important;
}
.inline-edit-input:hover { border-color: var(--border) !important; background: #fff !important; }
.inline-edit-input:focus { border-color: var(--baize) !important; background: #fff !important; }
.inline-edit-num { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
tr.row-dirty { background: #fffbeb !important; }

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  background: var(--cream);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  background: #f3efe6;
  color: var(--baize-dark);
  font-weight: 700;
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { background: #eae3d4; }
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #efebe3;
  white-space: nowrap;
}
.data-table tbody tr:hover { background: #faf7f0; }
.data-table .num { text-align: right; }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  background: #f1ede4;
  color: var(--muted);
}
.rank-1 { background: #f6d57a; color: #5c4100; }
.rank-2 { background: #dfe3e6; color: #3d464d; }
.rank-3 { background: #e8c3a3; color: #5d3311; }

.player-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--baize-dark);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(20, 83, 61, 0.25);
  text-underline-offset: 2px;
}
.player-link:hover { color: var(--baize-light); text-decoration-color: var(--baize); }

.car-chip {
  display: inline-block;
  background: var(--gold-soft);
  color: #6b4c10;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  min-width: 30px;
  text-align: center;
}

.pos-diff { color: var(--win-fg); font-weight: 600; }
.neg-diff { color: var(--loss-fg); font-weight: 600; }

/* Match Entry & Split layout */
.split-layout {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: start;
}

.match-form, .stack-form { display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1.3fr 0.8fr 1fr; gap: 10px; }
.versus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.player-box {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.player-box-head { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--baize-dark); }

.target-pill-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.target-pill {
  flex: 1;
  background: #fff;
  border: 1px dashed #d3c9b4;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.83rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.preview-panel {
  border-radius: 10px;
  padding: 12px 14px;
  background: #f3efe6;
  border: 1px solid var(--border);
  font-size: 0.88rem;
}
.preview-panel.valid { background: var(--win-bg); border-color: #b7e4cc; }
.preview-panel.invalid { background: var(--loss-bg); border-color: #f3c4c4; }
.preview-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.preview-side { background: rgba(255, 255, 255, 0.78); padding: 8px 10px; border-radius: 8px; }
.preview-errors { margin: 0; padding-left: 18px; color: var(--loss-fg); }
.form-actions { display: flex; gap: 10px; align-items: center; }

/* Matches list */
.matches-list { display: flex; flex-direction: column; gap: 10px; max-height: 600px; overflow-y: auto; }
.match-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  background: #fdfcf9;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.match-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--muted); }
.match-card-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.match-side { display: flex; flex-direction: column; gap: 2px; }
.match-side.right { text-align: right; }
.match-score-pill { background: var(--baize-dark); color: #fff; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; white-space: nowrap; }

.pts-tag { display: inline-block; font-size: 0.75rem; padding: 1px 6px; border-radius: 5px; font-weight: 600; }
.pts-w { background: var(--win-bg); color: var(--win-fg); }
.pts-r { background: var(--draw-bg); color: var(--draw-fg); }
.pts-v { background: var(--loss-bg); color: var(--loss-fg); }

/* Segmented control */
.segmented { display: inline-flex; background: var(--cream); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn { border: none; background: transparent; padding: 6px 12px; font-size: 0.84rem; font-weight: 600; color: var(--muted); border-radius: 6px; cursor: pointer; }
.seg-btn.active { background: var(--baize); color: #fff; }

/* Unplayed Grid */
.unplayed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; max-height: 540px; overflow-y: auto; }
.unplayed-item { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #fdfcf9; }
.unplayed-item:hover { border-color: var(--baize); background: #f5faf7; }

/* Matrix Table */
.matrix-wrap { max-height: 620px; }
.matrix-table { border-collapse: collapse; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border); padding: 5px 6px; text-align: center; min-width: 34px; }
.matrix-table th { background: #f3efe6; color: var(--baize-dark); position: sticky; top: 0; z-index: 2; }
.matrix-table th.row-head { text-align: left; position: sticky; left: 0; z-index: 3; white-space: nowrap; }
.matrix-diag { background: #e8e4da; }
.matrix-empty { cursor: pointer; color: #bbb; }
.matrix-empty:hover { background: var(--gold-soft); color: var(--baize-dark); }
.matrix-w { background: var(--win-bg); color: var(--win-fg); font-weight: 700; }
.matrix-r { background: var(--draw-bg); color: var(--draw-fg); font-weight: 700; }
.matrix-v { background: var(--loss-bg); color: var(--loss-fg); font-weight: 700; }

/* Config Grid & Files */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; padding: 6px 8px; border-radius: 7px; background: var(--cream); cursor: pointer; }
.scales-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.scale-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: center; }
.calc-box { margin-top: 14px; padding: 10px 12px; background: var(--gold-soft); border-radius: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.88rem; }
.legacy-actions { display: flex; flex-direction: column; gap: 12px; }
.legacy-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--cream); }

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  font-size: 0.86rem;
}

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(14, 30, 22, 0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal-lg { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.modal-head h3 { margin: 0; color: var(--baize-dark); }

/* Toast */
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--baize-dark); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); font-size: 0.9rem; font-weight: 500; z-index: 200; }
.toast.error { background: var(--red-ball); }
.empty-state { text-align: center; padding: 24px 16px; color: var(--muted); }

/* Statistics, SVG Charts & Player Profile */
.progress-card {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  margin-bottom: 16px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.progress-track {
  height: 10px;
  background: #e5dfd2;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--baize) 0%, var(--gold) 100%);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.record-tile {
  background: #fdfcf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.record-tile .rec-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.record-tile .rec-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--baize-dark);
  font-variant-numeric: tabular-nums;
}

.record-tile .rec-who {
  font-size: 0.8rem;
  color: var(--muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  align-items: start;
}

.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fdfcf9;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.chart-head h3 {
  margin: 0;
  font-size: 0.98rem;
  color: var(--baize-dark);
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: inherit;
}

.chart-bar-clickable { cursor: pointer; transition: opacity 0.12s; }
.chart-bar-clickable:hover { opacity: 0.8; }

/* Player Profile */
.profile-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: linear-gradient(135deg, var(--baize-dark) 0%, var(--baize) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.profile-hero h3 {
  margin: 0;
  font-size: 1.4rem;
}

.profile-hero .hero-meta {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 3px;
}

.form-strip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-pill {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
}
.form-W { background: #22c55e; color: #052e16; }
.form-R { background: #fbbf24; color: #451a03; }
.form-V { background: #f87171; color: #450a0a; }

.profile-kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.profile-charts-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.opponent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.opp-chip {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 500;
}
.opp-chip:hover {
  border-color: var(--baize);
  background: var(--win-bg);
  color: var(--baize-dark);
}

/* Club Night Pairing Picker */
.night-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 7px;
}

.night-pair-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 9px;
  padding: 10px 14px;
  background: #fdfcf9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .records-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-kpis { grid-template-columns: repeat(3, 1fr); }
  .split-layout, .config-grid, .charts-grid, .profile-charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .versus-grid, .form-row-3, .checkbox-grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .topbar { background: none; color: #000; box-shadow: none; border-bottom: 2px solid #000; }
  .subtitle { color: #333; }
  .balls-emblem { display: none; }
  .card { border: none; box-shadow: none; padding: 0; }
  .data-table th { background: #eee !important; color: #000 !important; }
}
