*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1a2e4a;
  --navy-mid: #2c4a6e;
  --navy-light: #e8edf3;
  --accent: #c8850a;
  --accent-light: #fef3d7;
  --gray-50: #f7f8fa;
  --gray-100: #eaedf1;
  --gray-200: #d9dee6;
  --gray-300: #c4c9d4;
  --gray-500: #7a8394;
  --gray-700: #3d4553;
  --gray-900: #1a1e27;
  --green: #166534;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --red: #c0392b;
  --red-bg: #fdecea;
  --red-border: #fecaca;
  --yellow: #92400e;
  --yellow-bg: #fffbeb;
  --yellow-border: #fde68a;
  --blue: #1e40af;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 4px rgba(26,46,74,0.08), 0 2px 8px rgba(26,46,74,0.06);
  --shadow-md: 0 4px 16px rgba(26,46,74,0.12);
}

body {
  font-family: -apple-system, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-700);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ── */
.hidden { display: none !important; }

.page-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* ── Auth / Login ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--gray-50);
}

.auth-card {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--gray-100);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  width: 44px;
  height: 44px;
  background: var(--navy);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
}

.auth-card h1 { font-size: 1.25rem; font-weight: 700; color: var(--navy); }
.auth-card .auth-sub { font-size: 0.8rem; color: var(--gray-500); margin-top: 3px; margin-bottom: 1.5rem; }
.auth-error { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 0.6rem 0.75rem; font-size: 0.8rem; margin-bottom: 1rem; }

/* ── App Header ── */
.app-header {
  background: var(--navy);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.header-context {
  font-size: 0.75rem;
  opacity: 0.65;
  margin-top: 1px;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav-link {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.15); color: white; }

.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* ── Main Content ── */
.main-content { padding: 1.25rem; max-width: 960px; margin: 0 auto; }
.page-title { font-size: 1.25rem; font-weight: 700; color: var(--navy); margin-bottom: 1.25rem; }
.section-title { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-500); margin: 1.5rem 0 0.75rem; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 0.75rem; }
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--gray-900); }
.card-sub { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number],
input[type=tel], select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--gray-700);
  background: white;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--navy-mid); }
textarea { resize: vertical; min-height: 72px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { opacity: 0.9; }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-outline { background: white; color: var(--navy); border: 1px solid var(--navy); }
.btn-outline:hover { background: var(--navy-light); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover { background: var(--red-border); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.78rem; border-radius: 6px; }
.btn-icon { background: none; border: none; cursor: pointer; color: rgba(255,255,255,0.7); font-size: 0.8rem; font-family: inherit; padding: 0.35rem 0.5rem; border-radius: 6px; transition: color 0.15s; }
.btn-icon:hover { color: white; }

/* ── Chips / Badges ── */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chip-gray { background: var(--gray-100); color: var(--gray-700); }
.chip-blue { background: var(--blue-bg); color: var(--blue); }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-yellow { background: var(--yellow-bg); color: var(--yellow); }
.chip-accent { background: var(--accent-light); color: var(--accent); }

/* ── Chip toggle group (day/time picker buttons) ── */
.chip-toggle-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-toggle {
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-700);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip-toggle:hover { border-color: var(--blue); }
.chip-toggle.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-tile { background: white; border: 1px solid var(--gray-100); border-radius: var(--radius); padding: 0.875rem 1rem; text-align: center; }
.stat-num { font-size: 1.6rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.72rem; font-weight: 600; color: var(--gray-500); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Score display ── */
.score-row { display: flex; align-items: center; gap: 0.75rem; }
.score-box { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 0.5rem 0.875rem; font-size: 1.1rem; font-weight: 700; min-width: 48px; text-align: center; }
.score-box.winner { background: var(--navy-light); border-color: var(--navy); color: var(--navy); }
.score-vs { color: var(--gray-500); font-size: 0.75rem; font-weight: 600; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--gray-500); font-size: 0.875rem; }
.empty-state strong { display: block; font-size: 1rem; color: var(--gray-700); margin-bottom: 4px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 600px) {
  .modal-backdrop { align-items: center; padding: 1.5rem; }
}

.modal {
  background: white;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .modal { border-radius: 16px; }
}

.modal-title { font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.modal-actions .btn { flex: 1; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: white;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 300;
  transition: transform 0.25s ease;
  white-space: nowrap;
}

.toast.toast-show { transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--red); }
.toast.toast-success { background: var(--green); }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--gray-100); margin: 1rem 0; }

/* ── Inline row util ── */
.row { display: flex; align-items: center; gap: 0.75rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.flex-1 { flex: 1; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--red); }
.text-success { color: var(--green); }
.font-bold { font-weight: 700; }
