:root {
  --primary: #6D28D9;
  --primary-600: #5B21B6;
  --primary-050: #F3EEFF;
  --accent: #F59E0B;
  --accent-050: #FEF3E2;
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --text: #1A1C1E;
  --text-2: #6B7280;
  --success: #16A34A;
  --warning: #B45309;
  --danger: #DC2626;
  --live: #E11D48;
  --info: #2563EB;
  --border: #E7EAF0;
  --divider: #EEF0F4;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.08);
  --sidebar-w: 260px;
}

* { -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { text-decoration: none; }

/* ---------------- Layout ---------------- */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .2s ease;
}
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; }
.app-content { padding: 24px; }

.app-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px;
  font-weight: 700; font-size: 18px; color: var(--text);
}
.app-brand .brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.app-brand small { color: var(--accent); font-weight: 600; display: block; font-size: 11px; }

.sidebar-nav { padding: 8px 12px; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2); padding: 16px 12px 6px; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 500; margin-bottom: 2px;
  position: relative;
}
.sidebar-link i { font-size: 18px; width: 20px; text-align: center; }
.sidebar-link:hover { background: var(--bg); color: var(--text); }
.sidebar-link.active { background: var(--primary-050); color: var(--primary); font-weight: 600; }
.sidebar-link.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: var(--primary);
}

/* ---------------- Navbar ---------------- */
.app-navbar {
  position: sticky; top: 0; z-index: 1030;
  background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
}
.app-navbar .page-title { font-size: 18px; font-weight: 700; margin: 0; }
.app-navbar .breadcrumb { margin: 0; font-size: 12px; }
.breadcrumb-item, .breadcrumb-item a { color: var(--text-2); }
.breadcrumb-item.active { color: var(--primary); }

.admin-chip {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface);
}
.admin-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}

/* ---------------- Cards ---------------- */
.card {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); background: var(--surface);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--divider);
  font-weight: 600; padding: 16px 20px;
}
.card-body { padding: 20px; }

.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-card > div:not(.stat-icon) { min-width: 0; flex: 1 1 auto; }
.stat-card .stat-label { color: var(--text-2); font-size: 12px; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .stat-value { font-size: clamp(14px, 0.55vw + 8px, 17px); font-weight: 700; margin: 2px 0 0; line-height: 1.2; white-space: nowrap; }
@media (max-width: 575.98px) {
  .stat-card { padding: 14px; gap: 10px; }
  .stat-card .stat-icon { width: 42px; height: 42px; font-size: 17px; border-radius: 12px; }
  .stat-card .stat-value { font-size: 15px; }
  .stat-card .stat-label { font-size: 11px; }
}
.icon-primary { background: var(--primary-050); color: var(--primary); }
.icon-accent { background: var(--accent-050); color: var(--accent); }
.icon-success { background: #E7F6EC; color: var(--success); }
.icon-danger { background: #FDECEC; color: var(--danger); }
.icon-info { background: #E7EEFE; color: var(--info); }

/* ---------------- Buttons ---------------- */
.btn { border-radius: var(--r-sm); font-weight: 600; padding: 8px 16px; font-size: 13.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.96); color: #fff; }
.btn-outline-secondary { border-color: var(--border); color: var(--text-2); }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ---------------- Badges ---------------- */
.badge {
  font-weight: 600; padding: 5px 10px; border-radius: 999px; font-size: 11.5px;
  letter-spacing: .01em;
}
.badge-success { background: #E7F6EC; color: var(--success); }
.badge-danger { background: #FDECEC; color: var(--danger); }
.badge-warning { background: #FDF1E3; color: var(--warning); }
.badge-info { background: #E7EEFE; color: var(--info); }
.badge-primary { background: var(--primary-050); color: var(--primary); }
.badge-live { background: #FDE7EC; color: var(--live); }
.badge-muted { background: #EEF0F4; color: var(--text-2); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow: auto; border-radius: var(--r-lg); }
.table { margin: 0; color: var(--text); }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg); color: var(--text-2); font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--border); white-space: nowrap; padding: 12px 16px;
}
.table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.table tbody tr:hover { background: #FBFBFD; }
.table a.sort-link { color: var(--text-2); display: inline-flex; gap: 4px; align-items: center; }

/* ---------------- Forms ---------------- */
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.form-control, .form-select {
  border-radius: var(--r-sm); border-color: var(--border); padding: 10px 12px; font-size: 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050);
}
.input-group-text { background: var(--bg); border-color: var(--border); color: var(--text-2); border-radius: var(--r-sm); }

/* ---------------- Auth ---------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 100% 0%, var(--primary-050), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }

/* ---------------- Misc ---------------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.text-muted-2 { color: var(--text-2); }
.prize-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; background: var(--surface); }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
  .app-main { margin-left: 0; }
}

/* ---------------- Game calculator ---------------- */
.summary-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--divider);
}
.summary-row:last-child { border-bottom: 0; }
.summary-row > span:first-child { color: var(--text-2); font-size: 13px; }
.summary-value { font-weight: 700; transition: color .2s ease; }
.prize-line { transition: background .2s ease; }
@media (min-width: 992px) { .summary-card { position: sticky; top: 84px; } }

@keyframes valueFlash {
  0% { background-color: var(--accent-050); }
  100% { background-color: transparent; }
}
.value-flash { animation: valueFlash .6s ease; border-radius: 6px; }
input.value-flash { animation: valueFlash .6s ease; }

/* ---------------- Housie ticket grid ---------------- */
.housie-table { width: 100%; border-collapse: collapse; }
.housie-table td {
  width: 11.11%; height: 46px; text-align: center; vertical-align: middle;
  border: 1px solid var(--border); font-weight: 700; font-size: 15px;
}
.housie-table td.filled { background: var(--primary-050); color: var(--primary); }
.housie-table td.empty { background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 6px, #f3f4f6 6px, #f3f4f6 12px); }
