:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #d5dce6;
  --border-dark: #475569;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --pos: #c81e1e;
  --neg: #0f172a;
  --zero: #15803d;
  --diag: #334155;
  --danger: #dc2626;
  --success: #15803d;
  --warn: #b45309;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: clip;
}
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

/* Top Navigation */
.topbar {
  background: #0f172a;
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  border-bottom: 2px solid #d9a426;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
  position: relative;
}
.topbar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 12px;
}
.nav-toggle {
  display: none;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.22);
}
.nav-toggle-icon {
  font-size: 16px;
  line-height: 1;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.45));
  transition: transform 0.18s ease;
}
.brand:hover .brand-logo {
  transform: rotate(-8deg) scale(1.05);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 auto;
}
.nav-formula-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px 5px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
}
.nav-op {
  color: #94a3b8;
  font-weight: 700;
  font-size: 13px;
  padding: 0 3px;
  user-select: none;
  line-height: 1;
}
.nav-op-eq {
  color: #facc15;
  font-size: 15px;
  padding: 0 5px;
}
.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-links a.nav-sum-tab {
  color: #f1f5f9;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.07);
}
.nav-links a:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.nav-links a.active {
  background: var(--primary);
  color: #fff;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-nav {
  background: rgba(255, 255, 255, 0.12);
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-nav:hover { background: rgba(255, 255, 255, 0.22); }
.btn-nav.active { background: #eab308; color: #0f172a !important; border-color: #eab308; }

@media (max-width: 1020px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0 14px;
    gap: 0;
  }
  .topbar-head {
    width: 100%;
    min-height: 54px;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .topbar-menu {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 0 14px 0;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
  }
  .topbar.menu-open .topbar-menu {
    display: flex;
  }
  .nav-links {
    flex-direction: column;
    align-items: stretch;
    margin: 0;
    gap: 6px;
  }
  .nav-links > a {
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
  }
  .nav-formula-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 7px;
  }
  .nav-formula-group a {
    text-align: center;
    padding: 8px 10px;
  }
  .nav-formula-group .nav-op {
    text-align: center;
    padding: 1px 0;
    font-size: 12px;
  }
  .nav-formula-group .nav-op-eq {
    font-size: 15px;
    padding: 2px 0;
  }
  .nav-right {
    padding-top: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    justify-content: stretch;
  }
  .nav-right > a,
  .nav-right > form {
    flex: 1;
  }
  .nav-right .btn-nav {
    display: block;
    width: 100%;
    text-align: center;
    padding: 9px 12px;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 10px;
    margin-top: 12px;
  }
  .card {
    padding: 12px;
  }
  .brand {
    font-size: 15px;
    gap: 8px;
  }
  .brand-logo {
    width: 28px;
    height: 28px;
  }
}

.container {
  max-width: 1440px;
  margin: 18px auto 40px auto;
  padding: 0 18px;
}

/* Flash messages */
.flashes { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: #dcfce7; color: #14532d; border-color: #86efac; }
.flash-danger  { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.flash-warning { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.flash-info    { background: #e0f2fe; color: #0c4a6e; border-color: #7dd3fc; }

/* Cards & headers */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.page-head h1 {
  margin: 0 0 3px 0;
  font-size: 20px;
  color: var(--text);
}
.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Buttons & inputs */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #f1f5f9; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}
.pill-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  margin-right: 4px;
}
.pill-badge.free {
  background: #fef3c7;
  color: #92400e;
}
.pill-badge.former {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  font-weight: 500;
}
.pill-badge.former-free {
  background: transparent;
  color: #94a3b8;
  border: 1px dashed #cbd5e1;
  font-weight: 500;
}
tr.row-former {
  background: #fafbfc;
}
.input-former {
  color: #64748b !important;
  background: #f8fafc !important;
}
.free-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.slot-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slot-sub {
  font-size: 12px !important;
  padding: 4px 8px !important;
  color: #475569 !important;
  background: #f8fafc !important;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.filter-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-form label {
  font-size: 12.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tournament 12x12 Matrix */
.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  background: #fff;
}
table.matrix {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
  font-size: 13px;
}
table.matrix th {
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border-dark);
  padding: 7px 4px;
  text-align: center;
  font-weight: 700;
  white-space: nowrap;
}
table.matrix th.col-num {
  font-size: 14.5px;
}
table.matrix td {
  border: 1px solid #64748b;
  text-align: center;
  vertical-align: middle;
  padding: 4px 5px;
  height: 52px;
}
table.matrix tbody tr:hover td:not(.diag) {
  background: #f8fafc;
}
table.matrix td.m-num {
  width: 36px;
  font-size: 14.5px;
  font-weight: 700;
  background: #f8fafc;
}
table.matrix td.m-name {
  text-align: left;
  padding: 5px 9px;
  min-width: 196px;
  max-width: 250px;
  line-height: 1.35;
}
table.matrix td.m-name .pl-line {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}
.pl-former {
  font-weight: 400;
  color: #94a3b8;
  font-size: 0.86em;
}
table.matrix td.diag {
  background: var(--diag);
}
table.matrix td.m-score {
  min-width: 66px;
  line-height: 1.22;
  cursor: default;
  position: relative;
}
table.matrix td.m-score.has-detail {
  cursor: pointer;
  transition: background 0.1s, box-shadow 0.1s;
}
/* Cross-table interactive hover highlight */
table.matrix td.mx-cross {
  background: #f1f5f9 !important;
}
table.matrix td.mx-head-a {
  background: #dbeafe !important;
}
table.matrix td.m-num.mx-head-a {
  box-shadow: inset 3px 0 0 #2563eb;
}
table.matrix th.mx-col-a {
  background: #dbeafe !important;
  box-shadow: inset 0 -2.5px 0 #2563eb;
}
table.matrix td.mx-cell-a {
  background: #dbeafe !important;
  box-shadow: inset 0 0 0 2px #2563eb;
}
table.matrix td.mx-head-b {
  background: #fef08a !important;
}
table.matrix td.m-num.mx-head-b {
  box-shadow: inset 3px 0 0 #ca8a04;
}
table.matrix th.mx-col-b {
  background: #fef08a !important;
  box-shadow: inset 0 -2.5px 0 #ca8a04;
}
table.matrix td.mx-cell-b {
  background: #fef08a !important;
  box-shadow: inset 0 0 0 2px #ca8a04;
}
.sc-diff {
  font-size: 15.5px;
  font-weight: 700;
}
.sc-games {
  font-size: 13.5px;
  font-weight: 600;
}
.sc-games.neg {
  font-weight: 500;
}
.sc-multi {
  font-size: 11.5px;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 2px;
}
.pos { color: var(--pos); font-weight: 700; }
.neg { color: var(--neg); }
.zero { color: var(--zero); font-weight: 700; }

table.matrix td.m-tot {
  width: 62px;
  min-width: 58px;
  padding: 0;
  white-space: nowrap;
}
table.matrix td.m-lbl {
  width: 82px;
  min-width: 82px;
  padding: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.tot-top, .lbl-top {
  border-bottom: 1px solid #94a3b8;
  height: 26px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 700;
}
.tot-top {
  font-size: 15px;
}
.tot-bot, .lbl-bot {
  height: 25px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.tot-bot {
  font-size: 14.5px;
  font-weight: 600;
}
table.matrix td.m-place {
  width: 52px;
  min-width: 50px;
  font-weight: 700;
  font-size: 16.5px;
  background: #f8fafc;
  white-space: nowrap;
}
.guest-stat-num {
  font-size: 15px;
}
.balance-bar {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.badge-ok {
  background: #dcfce7;
  color: #166534;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 13px;
}
.badge-ok .guest-stat-num {
  font-size: 14px;
}

/* Standard tables (History & Admin) */
.table-wrap { overflow-x: auto; }
table.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.list-table th {
  background: #f1f5f9;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  text-align: left;
  padding: 9px 10px;
  font-weight: 700;
  white-space: nowrap;
}
table.list-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  vertical-align: middle;
}
table.list-table tbody tr:hover { background: #f8fafc; }
.num-cell { text-align: center; white-space: nowrap; }
.score-pill {
  display: inline-block;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
.score-pill.total-pill {
  font-weight: 700;
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}
.score-pill.pos, .score-pill.total-pill.pos { color: var(--pos); }
.score-pill.neg, .score-pill.total-pill.neg { color: var(--neg); }
.score-pill.zero, .score-pill.total-pill.zero { color: var(--zero); }

/* Guest History table: equal player alignment, +15% numbers, hover highlight */
.history-table .hist-date {
  font-size: 15.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.team-cell-grid {
  display: flex;
  align-items: center;
  gap: 8px;
}
.team-num-badge {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #dbe2eb;
  border-radius: 6px;
  padding: 3px 5px;
  flex-shrink: 0;
}
.team-players-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.team-players-stack .pl-line {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  padding: 1px 6px;
  border-radius: 4px;
  transition: background 0.12s, box-shadow 0.12s, color 0.12s;
}
.history-table .guest-score-pill {
  font-size: 14.5px;
  padding: 4px 9px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.history-table .guest-score-pill.total-pill {
  font-size: 15px;
}
.history-table .guest-score-pill:hover,
.history-table td.hl-trigger:hover .guest-score-pill {
  background: #fef08a;
  border-color: #ca8a04;
  color: #0f172a;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.25);
}
.history-table .hist-diff {
  font-size: 14px;
  margin-left: 4px;
  font-weight: 700;
}
.history-table tr.hl-p1 .pl-1,
.history-table tr.hl-p2 .pl-2,
.history-table tr.hl-both .pl-1,
.history-table tr.hl-both .pl-2 {
  background: #fef08a;
  color: #0f172a;
  box-shadow: inset 0 0 0 1px #eab308;
}

/* Match detail modal popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-backdrop.open {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
  border: 1px solid #cbd5e1;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.modal-sub {
  margin: 3px 0 0 0;
  font-size: 13px;
  color: var(--muted);
}
.modal-close {
  border: none;
  background: #f1f5f9;
  color: #334155;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.modal-body {
  padding: 16px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-encounter {
  border: 1px solid #dbe2eb;
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}
.modal-enc-bar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13.5px;
}
.modal-enc-date {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.modal-enc-note {
  font-size: 12.5px;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 5px;
}
.modal-row {
  display: grid;
  grid-template-columns: 126px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.modal-row:last-child {
  border-bottom: none;
}
.modal-row.is-active {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--primary);
}
.modal-row.is-total {
  background: #f8fafc;
  border-top: 2px solid #cbd5e1;
}
.modal-row.is-total.is-active {
  background: #eff6ff;
}
.modal-row-type {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.modal-row-vs {
  font-size: 13.5px;
  line-height: 1.35;
}
.modal-row-vs .m-side {
  font-weight: 600;
  color: var(--text);
}
.modal-row-vs .m-vs {
  color: var(--muted);
  font-weight: 400;
  margin: 0 5px;
}
.modal-row-score {
  text-align: right;
  white-space: nowrap;
  font-family: Consolas, "Courier New", monospace;
}
.modal-row-score .ms-main {
  font-size: 16.5px;
  font-weight: 700;
}
.modal-row-score .ms-diff {
  font-size: 14px;
  font-weight: 700;
  margin-left: 5px;
}
@media (max-width: 600px) {
  .modal-row {
    grid-template-columns: 1fr auto;
  }
  .modal-row-type {
    grid-column: 1 / -1;
  }
}

/* Admin forms & sub-nav */
.admin-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.tab-group {
  display: flex;
  gap: 6px;
}
.tab-group a {
  padding: 7px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  background: #e2e8f0;
}
.tab-group a.active {
  background: var(--primary);
  color: #fff;
}

.match-form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
  align-items: end;
}
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-10 { grid-column: span 10; }
.col-12 { grid-column: span 12; }

.btn-success {
  background: #15803d;
  color: #fff;
  border-color: #15803d;
}
.btn-success:hover {
  background: #166534;
}
.status-switch {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.switch-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.switch-opt:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}
.scheduled-admin-card {
  border-color: #fdba74;
  background: #fffaf5;
}
.upcoming-time {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}
.badge-today {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Upcoming games matchup board */
.upcoming-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.upcoming-board-head {
  display: grid;
  grid-template-columns: 155px 1fr 220px;
  align-items: center;
  gap: 16px;
  padding: 9px 18px;
  background: #f1f5f9;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.uh-date { text-align: center; }
.uh-matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}
.uh-team-a { text-align: right; padding-right: 4px; }
.uh-team-b { text-align: left; padding-left: 4px; }
.uh-note { text-align: left; }

.upcoming-card {
  background: #ffffff;
  border: 1px solid #d5dce6;
  border-radius: 10px;
  overflow: hidden;
}
.uc-main-row {
  display: grid;
  grid-template-columns: 155px 1fr 220px;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
}
.badge-finished {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  background: #dcfce7;
  color: #15803d;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.uc-date {
  text-align: center;
  border-right: 1px solid #e2e8f0;
  padding-right: 14px;
}
.uc-date-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.uc-time-val {
  font-size: 17px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.uc-matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}
.uc-side {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.uc-side-a {
  justify-content: flex-end;
  text-align: right;
}
.uc-side-b {
  justify-content: flex-start;
  text-align: left;
}
.uc-side .team-players-stack .pl-line {
  font-size: 14.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.35;
  transition: background 0.12s, box-shadow 0.12s, color 0.12s;
}
.upcoming-card.hl-p1 .pl-1,
.upcoming-card.hl-p2 .pl-2,
.upcoming-card.hl-both .pl-1,
.upcoming-card.hl-both .pl-2 {
  background: #fef08a;
  color: #0f172a;
  box-shadow: inset 0 0 0 1px #eab308;
}
.uc-hl-trigger {
  cursor: pointer;
}
.uc-bd-item.uc-hl-trigger:hover .uc-bd-pill {
  background: #fef08a;
  border-color: #ca8a04;
  color: #0f172a;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.25);
}
.uc-num {
  min-width: 48px;
  font-size: 16px;
  padding: 5px 6px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
}
.uc-num.uc-winner {
  background: #dcfce7;
  border-color: #22c55e;
  color: #14532d;
}
.uc-vs-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
.vs-emblem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1px;
  line-height: 1;
  padding-right: 3px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(127, 29, 29, 0.55);
  transform: skewX(-6deg);
  user-select: none;
}
.score-emblem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 96px;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
  white-space: nowrap;
}
.score-emblem .se-win {
  color: #4ade80;
}
.score-emblem .se-sep {
  color: #94a3b8;
  font-size: 18px;
}
.uc-breakdown {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 9px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.uc-bd-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.uc-bd-lbl {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.uc-bd-pill {
  font-size: 14.5px;
  font-weight: 700;
  padding: 2px 9px;
}
.uc-note {
  border-left: 1px solid #e2e8f0;
  padding-left: 14px;
  font-size: 13.5px;
  color: #334155;
}
.uc-note-pill {
  display: inline-block;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 500;
}
.uc-note-empty {
  color: #94a3b8;
}

@media (max-width: 900px) {
  .upcoming-board-head { display: none; }
  .uc-main-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }
  .uc-date {
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    padding-right: 0;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  .uc-time-val, .badge-today, .badge-finished { margin-top: 0; }
  .uc-matchup {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .uc-side-a, .uc-side-b {
    justify-content: center;
    text-align: center;
  }
  .uc-note {
    border-left: none;
    border-top: 1px solid #e2e8f0;
    padding-left: 0;
    padding-top: 8px;
    text-align: center;
  }
}

.empty-upcoming {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14.5px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}
.score-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}
.time-24-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
}
.time-24-pair select {
  width: 100%;
  padding: 7px 4px;
  text-align: center;
  font-weight: 600;
}
.score-pair input {
  width: 100%;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}
.score-sep {
  font-weight: 700;
  color: var(--muted);
}
.live-preview {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.live-preview strong { font-size: 15px; }

.login-card {
  max-width: 390px;
  margin: 44px auto;
  padding: 26px 24px 24px 24px;
  border-top: 3px solid #d9a426;
}
.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.login-brand img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.18));
}
.login-card h1 {
  margin: 0 0 6px 0;
  font-size: 20px;
  text-align: center;
}
.login-sub {
  color: var(--muted);
  margin: 0 0 18px 0;
  font-size: 13px;
  text-align: center;
}
.login-card .field { margin-bottom: 12px; }

/* Role & permission matrix UI */
.role-tag {
  font-size: 12.5px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 10px;
}
.locked-match-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  color: #1e3a8a;
}
.perm-matrix-table th.perm-col-head {
  font-size: 12px;
  white-space: normal;
  line-height: 1.25;
  max-width: 115px;
  min-width: 90px;
}
.perm-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}
.perm-legend {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  font-size: 12.5px;
  color: #475569;
}
.perm-checks-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.perm-pill-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12.5px;
}
.perm-pill-check:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
}
.perm-pill-check input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.perm-pill-check span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.perm-pill-check small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.25;
}
@media (max-width: 900px) {
  .perm-legend, .perm-checks-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .col-2, .col-3, .col-4, .col-5, .col-6, .col-8, .col-10 { grid-column: span 12; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 10pt; }
  .topbar, .toolbar, .flashes, .no-print, .modal-backdrop { display: none !important; }
  .container { max-width: none; margin: 0; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; margin: 0; }
  .matrix-wrap { overflow: visible; border: none; }
  table.matrix { min-width: 0; width: 100%; font-size: 8.5pt; }
  table.matrix td { height: 34px; padding: 2px; }
}
