* {
  box-sizing: border-box;
}

:root {
  --primary: #7c2334;
  --primary-dark: #5f1725;
  --secondary: #475467;
  --secondary-dark: #344054;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --success: #067647;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 12px 28px rgba(16, 24, 40, 0.08);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 35, 52, 0.08), transparent 25%),
    radial-gradient(circle at top right, rgba(71, 84, 103, 0.08), transparent 25%),
    linear-gradient(180deg, #ffffff 0%, #f5f7fb 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* Public nav */
.public-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.88);
  border-bottom: 1px solid rgba(228,231,236,0.8);
}

.public-nav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  height: 46px;
  width: auto;
  border-radius: 10px;
}

.brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.public-nav-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--secondary);
  background: transparent;
}

.nav-link:hover,
.nav-link.active {
  background: #f2f4f7;
}

.nav-link-accent {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

/* Public layout */
.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 22px 40px;
}

.hero-v2 {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 34px;
  background:
    linear-gradient(135deg, rgba(124,35,52,0.94), rgba(95,23,37,0.95)),
    linear-gradient(180deg, #7c2334, #5f1725);
  color: white;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.hero-v2::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  right: -80px;
  top: -80px;
  background: rgba(255,255,255,0.08);
}

.hero-v2-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 22px;
}

.hero-top-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-title-wrap h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.hero-title-wrap p {
  margin: 14px 0 0;
  color: rgba(255,255,255,0.88);
  max-width: 760px;
  line-height: 1.6;
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.hero-stat {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  padding: 16px;
}

.hero-stat-label {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.82);
}

.hero-stat-value {
  margin-top: 6px;
  font-size: 1.7rem;
  font-weight: 800;
}

/* Generic cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}

.card h2,
.card h3 {
  margin: 0 0 12px;
  letter-spacing: -0.03em;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.small-muted,
.subtext {
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.5;
}

/* Buttons */
.btn,
button {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover,
button:hover {
  transform: translateY(-1px);
  opacity: 0.97;
}

.btn,
button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: white;
}

.btn-light {
  background: white;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.25);
}

.btn-danger {
  background: linear-gradient(135deg, #d92d20, var(--danger));
  color: white;
}

/* Filters */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 22px;
}

.filter-stack {
  display: grid;
  gap: 18px;
}

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--secondary);
  border: 1px solid #eaecf0;
  font-weight: 800;
  font-size: 0.9rem;
}

.pill-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

tbody tr:hover td {
  background: #fcfcfd;
}

/* Front-end panels */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.result-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 8px 22px rgba(16,24,40,0.05);
}

.result-card h3 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.schedule-grid {
  display: grid;
  gap: 18px;
}

.schedule-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 8px 20px rgba(16,24,40,0.05);
}

.schedule-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}

.schedule-event-title {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.schedule-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #ecfdf3;
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 800;
}

.event-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.medal-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.medal-box {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.medal-box.gold { border-left: 5px solid #d4a72c; }
.medal-box.silver { border-left: 5px solid #98a2b3; }
.medal-box.bronze { border-left: 5px solid #b56a3a; }

.medal-label {
  font-size: 0.88rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--secondary);
}

/* Forms */
.stack {
  display: grid;
  gap: 14px;
}

.grid-2,
.grid-3,
.grid-form {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfcfe;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(124,35,52,0.45);
  box-shadow: 0 0 0 4px rgba(124,35,52,0.10);
  background: white;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

/* Notices */
.notice {
  background: #ecfdf3;
  color: var(--success);
  border: 1px solid #abefc6;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-weight: 700;
}

.notice.error {
  background: #fef3f2;
  color: var(--danger);
  border-color: #fecdca;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 500px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.login-logo {
  max-height: 80px;
  width: auto;
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.login-card p {
  text-align: center;
  color: var(--muted);
}

/* Admin V2 layout */
.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  background: var(--bg);
}

.admin-sidebar {
  background: linear-gradient(180deg, #111827 0%, #182230 100%);
  color: white;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-sidebar-top {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 20px;
}

.sidebar-logo {
  max-height: 56px;
  margin-bottom: 14px;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.sidebar-role {
  color: rgba(255,255,255,0.72);
  margin-top: 6px;
  font-size: 0.92rem;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.sidebar-link {
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(255,255,255,0.88);
  font-weight: 700;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(255,255,255,0.10);
  color: white;
}

.sidebar-link-danger {
  color: #fecaca;
}

.dashboard-main {
  padding: 26px;
}

.dashboard-topbar {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.dashboard-topbar h1 {
  margin: 0 0 6px;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.dashboard-topbar p {
  margin: 0;
  color: var(--muted);
}

.dashboard-userbox {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  min-width: 220px;
}

.dashboard-user-name {
  font-weight: 800;
}

.dashboard-user-role {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.92rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

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

.kpi-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.kpi-value {
  margin-top: 8px;
  font-size: 1.9rem;
  font-weight: 800;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.quick-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.quick-card h3 {
  margin: 0 0 10px;
}

.quick-card p {
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.55;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  background: rgba(255,255,255,0.7);
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Responsive */
@media (max-width: 1080px) {
  .dashboard-grid,
  .quick-grid,
  .kpi-grid,
  .hero-stats,
  .grid-2,
  .grid-3,
  .grid-form,
  .medal-row {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    height: auto;
    position: relative;
  }
}

@media (max-width: 760px) {
  .public-nav-inner,
  .app-shell,
  .dashboard-main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero-v2,
  .card,
  .dashboard-topbar,
  .quick-card,
  .kpi-card,
  .schedule-card,
  .login-card {
    padding: 18px;
    border-radius: 20px;
  }

  .dashboard-grid,
  .quick-grid,
  .kpi-grid,
  .hero-stats,
  .grid-2,
  .grid-3,
  .grid-form,
  .medal-row {
    grid-template-columns: 1fr;
  }

  .hero-top-row,
  .dashboard-topbar,
  .public-nav-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .public-nav-links,
  .hero-actions {
    width: 100%;
  }

  .btn,
  button {
    width: 100%;
  }

  .brand-name {
    font-size: 0.98rem;
  }
}

@media print {
  .public-nav,
  .site-footer,
  .hero-actions,
  .btn,
  button {
    display: none !important;
  }

  body {
    background: white;
  }

  .hero-v2,
  .card,
  .schedule-card,
  .result-card {
    box-shadow: none;
    border: 1px solid #d0d5dd;
  }
}

/* --- Admin V2 enhancements --- */

.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.dashboard-main {
  min-width: 0;
}

.admin-panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
  margin-bottom: 24px;
}

.admin-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.admin-card h2,
.admin-card h3 {
  margin-top: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.action-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.action-card h3 {
  margin: 0 0 10px;
}

.action-card p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.form-section {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form > * {
  flex: 1 1 180px;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f2f4f7;
  border: 1px solid #eaecf0;
  color: var(--secondary);
  font-size: 0.82rem;
  font-weight: 800;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.role-super_admin { background: #fdf2fa; color: #c11574; }
.role-admin { background: #eff8ff; color: #175cd3; }
.role-scorekeeper { background: #ecfdf3; color: #067647; }
.role-referee { background: #fff7ed; color: #b54708; }

.preview-panel {
  background: linear-gradient(135deg, rgba(124,35,52,0.08), rgba(71,84,103,0.06));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
}

.preview-banner {
  border-radius: 20px;
  padding: 22px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 65%, black));
  color: white;
}

.preview-banner h3 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.preview-banner p {
  margin: 0;
  color: rgba(255,255,255,0.88);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 1080px) {
  .admin-panel-grid,
  .action-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: relative;
    height: auto;
  }
}

.announcement-card {
  background: linear-gradient(135deg, rgba(124,35,52,0.08), rgba(71,84,103,0.05));
  border: 1px solid var(--line);
}
.schedule-badge {
  background: #ecfdf3;
  color: #067647;
}

.hero-stat {
  min-height: 95px;
}