@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,700;1,500&family=Plus+Jakarta+Sans:wght@400;500;600&display=swap');

:root {
  --br-dark: #412402;
  --br-brown: #6B3A1F;
  --br-gold: #EF9F27;
  --br-gold-light: #FAC775;
  --br-cream: #FDF8F2;
  --br-cream-dark: #F5EAD8;
  --br-green: #2D5016;
  --br-green-light: #5A8A2E;
  --br-green-pale: #EAF3DE;
  --br-text: #1A0F05;
  --br-muted: #7A5C3D;
  --br-border: rgba(65,36,2,0.12);
  --br-shadow: 0 4px 24px rgba(65,36,2,0.08);
  --br-shadow-md: 0 8px 32px rgba(65,36,2,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--br-cream);
  color: var(--br-text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* TOPBAR */
.topbar {
  background: var(--br-dark);
  color: var(--br-gold-light);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo { display: flex; align-items: center; gap: 10px; }
.topbar-logo span { font-family: var(--font-display); font-size: 16px; font-weight: 500; color: var(--br-gold-light); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-time { font-size: 18px; font-weight: 500; font-family: monospace; color: #fff; }
.topbar-user { font-size: 13px; color: rgba(250,199,117,0.7); }

/* NAV (BOTTOM) */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--br-dark);
  display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(250,199,117,0.5);
  font-size: 10px;
  text-decoration: none;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  transition: color .2s;
}
.nav-item.active, .nav-item:hover { color: var(--br-gold-light); }
.nav-item svg { width: 22px; height: 22px; }

/* CARDS */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--br-border);
  padding: 1.25rem;
  box-shadow: var(--br-shadow);
}
.card-sm { padding: .875rem 1rem; border-radius: var(--radius-sm); }

/* MAIN CONTENT */
.main-content {
  padding: 1rem;
  padding-bottom: 80px;
  max-width: 480px;
  margin: 0 auto;
}

/* PAGE TITLE */
.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--br-dark);
  margin-bottom: .25rem;
}
.page-sub { font-size: 13px; color: var(--br-muted); margin-bottom: 1.25rem; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: .75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: transform .15s, opacity .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--br-dark); color: var(--br-gold-light); }
.btn-primary:hover { background: var(--br-brown); }
.btn-gold { background: var(--br-gold); color: var(--br-dark); }
.btn-gold:hover { opacity: .9; }
.btn-outline { background: transparent; color: var(--br-dark); border: 1.5px solid var(--br-dark); }
.btn-success { background: var(--br-green); color: #fff; }
.btn-danger { background: #C0392B; color: #fff; }
.btn-full { width: 100%; }
.btn-lg { padding: 1rem 1.5rem; font-size: 15px; border-radius: var(--radius); }

/* FORM */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--br-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.form-control {
  width: 100%; padding: .75rem 1rem;
  border: 1.5px solid var(--br-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px; color: var(--br-text);
  background: #fff;
  transition: border-color .2s;
  outline: none;
}
.form-control:focus { border-color: var(--br-gold); }
select.form-control { cursor: pointer; }

/* STATUS BADGES */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge-success { background: var(--br-green-pale); color: var(--br-green); }
.badge-danger { background: #FDEDEC; color: #C0392B; }
.badge-warning { background: #FEF9E7; color: #B7770D; }
.badge-info { background: #EBF5FB; color: #1A5276; }
.badge-gray { background: #F2F3F4; color: #626567; }

/* DIVIDER */
.divider { border: none; border-top: 1px solid var(--br-border); margin: 1rem 0; }

/* STAT CARD */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.25rem; }
.stat-card {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: .875rem 1rem;
  border: 1px solid var(--br-border);
}
.stat-label { font-size: 11px; color: var(--br-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--br-dark); line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--br-muted); }

/* ALERT */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 1rem;
  border-left: 3px solid;
}
.alert-success { background: var(--br-green-pale); color: var(--br-green); border-color: var(--br-green-light); }
.alert-danger { background: #FDEDEC; color: #922B21; border-color: #E74C3C; }
.alert-warning { background: #FEF9E7; color: #7D6608; border-color: var(--br-gold); }
.alert-info { background: #EBF5FB; color: #1A5276; border-color: #2980B9; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem;
  width: 100%; max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-handle { width: 40px; height: 4px; background: var(--br-border); border-radius: 2px; margin: 0 auto 1.25rem; }
.modal-hidden { display: none; }

/* CAMERA BOX */
.camera-box {
  width: 100%; aspect-ratio: 4/3;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  margin-bottom: 1rem;
}
.camera-box video, .camera-box canvas { width: 100%; height: 100%; object-fit: cover; }
.camera-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.face-guide {
  width: 180px; height: 220px;
  border: 3px solid var(--br-gold);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
}

/* TIMER */
.timer-display {
  font-size: 42px;
  font-weight: 600;
  color: var(--br-dark);
  text-align: center;
  font-family: monospace;
  letter-spacing: 2px;
  margin: .5rem 0;
}

/* LOCATION STATUS */
.location-bar {
  display: flex; align-items: center; gap: 8px;
  padding: .625rem .875rem;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
}
.location-ok { background: var(--br-green-pale); color: var(--br-green); }
.location-err { background: #FDEDEC; color: #922B21; }
.location-wait { background: #FEF9E7; color: #7D6608; }

/* TABLE */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--br-border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--br-dark); color: var(--br-gold-light); padding: .75rem 1rem; text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--br-border); }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--br-cream); }

/* TABS */
.tabs { display: flex; gap: 4px; background: var(--br-cream-dark); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 1.25rem; }
.tab-btn {
  flex: 1; padding: .5rem; border: none; cursor: pointer;
  border-radius: 6px; font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  background: transparent; color: var(--br-muted);
  transition: all .2s;
}
.tab-btn.active { background: #fff; color: var(--br-dark); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* SPINNER */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--br-border);
  border-top-color: var(--br-gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* AVATAR */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.avatar-gold { background: var(--br-gold-light); color: var(--br-dark); }
.avatar-green { background: var(--br-green-pale); color: var(--br-green); }
.avatar-blue { background: #D6EAF8; color: #1A5276; }

/* TOAST */
.toast-container { position: fixed; top: 70px; right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--br-dark); color: var(--br-gold-light);
  padding: .75rem 1.25rem; border-radius: var(--radius-sm);
  font-size: 13px; max-width: 280px;
  animation: slideIn .3s ease;
  box-shadow: var(--br-shadow-md);
}
.toast.error { background: #922B21; color: #fff; }
.toast.success { background: var(--br-green); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* RESPONSIVE */
@media (min-width: 768px) {
  .main-content { padding: 1.5rem; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ADMIN SIDEBAR (desktop) */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px; background: var(--br-dark); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; padding: 1.5rem 0;
  display: none;
}
@media (min-width: 900px) { .admin-sidebar { display: flex; flex-direction: column; } }
.sidebar-logo { padding: 0 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 1rem; }
.sidebar-logo h2 { font-family: var(--font-display); font-size: 18px; color: var(--br-gold-light); }
.sidebar-logo p { font-size: 11px; color: rgba(250,199,117,.5); }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: .75rem 1.25rem;
  color: rgba(250,199,117,.6);
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: all .2s;
}
.sidebar-link:hover, .sidebar-link.active { color: var(--br-gold-light); background: rgba(255,255,255,.06); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.admin-main { flex: 1; padding: 2rem; background: var(--br-cream); min-height: 100vh; }
