/* ============================================================
   AttendTrack – Main Stylesheet
   Design: Clean Corporate Teal | Typography: DM Sans + DM Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --primary:     #0891b2;
  --primary-dk:  #0e7490;
  --primary-lt:  #e0f2fe;
  --primary-xl:  #f0f9ff;
  --accent:      #f59e0b;
  --accent-lt:   #fef3c7;
  --success:     #10b981;
  --success-lt:  #d1fae5;
  --danger:      #ef4444;
  --danger-lt:   #fee2e2;
  --warning:     #f59e0b;
  --warning-lt:  #fef3c7;
  --info:        #6366f1;
  --info-lt:     #ede9fe;
  --txt:         #0f172a;
  --txt2:        #475569;
  --txt3:        #94a3b8;
  --ot:          #7c3aed;
  --ot-lt:       #ede9fe;
  --radius:      12px;
  --radius-lg:   18px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.06);
  --transition:  .2s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dk); }

img { max-width: 100%; display: block; }
code, pre { font-family: 'DM Mono', monospace; }

/* ── Auth Layout ── */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--txt);
}

.auth-brand {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 40%, #134e4a 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  top: -80px; right: -80px;
}

.auth-brand::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  bottom: -60px; left: -40px;
}

.auth-brand .logo-mark {
  width: 64px; height: 64px;
  background: rgba(255,255,255,.15);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 32px;
  border: 1px solid rgba(255,255,255,.2);
  backdrop-filter: blur(10px);
}

.auth-brand h1 {
  font-size: 2.8rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.auth-brand p {
  color: rgba(255,255,255,.75);
  font-size: 1.05rem;
  max-width: 340px;
  position: relative;
  z-index: 1;
}

.auth-features {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.85);
  font-size: .95rem;
}

.auth-feature-item span:first-child {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.12);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.auth-form-side {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  overflow-y: auto;
}

.auth-form-container {
  width: 100%;
  max-width: 400px;
}

.auth-form-container h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 6px;
}

.auth-form-container .subtitle {
  color: var(--txt2);
  margin-bottom: 36px;
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--txt2);
  margin-bottom: 6px;
}

.input-wrap {
  position: relative;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  color: var(--txt);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}

input.has-icon { padding-right: 44px; }
input.has-icon-left { padding-left: 44px; }

.input-icon {
  position: absolute;
  top: 50%; right: 14px;
  transform: translateY(-50%);
  color: var(--txt3);
  cursor: pointer;
  transition: color var(--transition);
  user-select: none;
  display: flex;
  align-items: center;
}

.input-icon:hover { color: var(--txt2); }
.input-icon-left {
  position: absolute;
  top: 50%; left: 14px;
  transform: translateY(-50%);
  color: var(--txt3);
  pointer-events: none;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dk); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(8,145,178,.35); }

.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

.btn-ot      { background: var(--ot);      color: #fff; }
.btn-ot:hover{ background: #6d28d9; color: #fff; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border2);
  color: var(--txt2);
}
.btn-outline:hover { background: var(--surface2); border-color: var(--primary); color: var(--primary); }

.btn-sm  { padding: 7px 14px; font-size: .85rem; border-radius: 8px; }
.btn-lg  { padding: 14px 28px; font-size: 1rem; }
.btn-full{ width: 100%; }
.btn-icon{ padding: 10px; border-radius: 10px; }

/* ── Alerts / Flash ── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-lt); color: #065f46; border-color: #a7f3d0; }
.alert-danger   { background: var(--danger-lt);  color: #991b1b; border-color: #fca5a5; }
.alert-warning  { background: var(--warning-lt); color: #92400e; border-color: #fcd34d; }
.alert-info     { background: var(--info-lt);    color: #3730a3; border-color: #c4b5fd; }

/* ── App Layout (Dashboard) ── */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  width: 230px;
  flex-shrink: 0;
}

.topbar .brand .icon {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-date {
  font-size: .875rem;
  color: var(--txt2);
  font-weight: 500;
  background: var(--surface2);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 10px;
  transition: background var(--transition);
  font-family: inherit;
}
.avatar-btn:hover { background: var(--surface2); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
}

.avatar-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--txt);
}

/* ── Sidebar ── */
.sidebar {
  background: var(--txt);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-item svg, .nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1e293b;
}

/* ── Main Content ── */
.main-content {
  padding: 32px;
  overflow-y: auto;
  background: var(--bg);
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--txt);
}

.page-header p {
  color: var(--txt2);
  margin-top: 4px;
  font-size: .9rem;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--primary-lt); }
.stat-icon.green  { background: var(--success-lt); }
.stat-icon.red    { background: var(--danger-lt); }
.stat-icon.purple { background: var(--ot-lt); }
.stat-icon.amber  { background: var(--accent-lt); }

.stat-body h3 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.1;
}

.stat-body p {
  font-size: .82rem;
  color: var(--txt3);
  margin-top: 2px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--txt);
}

.card-body { padding: 24px; }

/* ── Attendance Action Cards ── */
.attend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.attend-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
}

.attend-card .type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.type-badge.regular { background: var(--primary-lt); color: var(--primary-dk); }
.type-badge.ot      { background: var(--ot-lt); color: var(--ot); }

.attend-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.attend-card .time-display {
  font-family: 'DM Mono', monospace;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 4px;
}

.attend-card .time-display.ot-time { color: var(--ot); }
.attend-card .sub { font-size: .82rem; color: var(--txt3); margin-bottom: 16px; }

/* ── Geo/Photo Capture Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(10px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--txt3);
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--txt); }

.modal-body { padding: 24px; }

.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #0f172a;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

#camera-video, #camera-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#camera-canvas { display: none; }

.camera-captured-preview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.geo-info {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .85rem;
  color: var(--txt2);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.geo-info .geo-icon { font-size: 1.1rem; }
.geo-info.getting  { color: var(--txt3); }
.geo-info.got      { color: var(--success); }
.geo-info.failed   { color: var(--danger); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

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

thead tr { background: var(--surface2); }
thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--txt2);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td { padding: 13px 16px; color: var(--txt); vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: var(--success-lt); color: #065f46; }
.badge-red    { background: var(--danger-lt);  color: #991b1b; }
.badge-purple { background: var(--ot-lt);      color: var(--ot); }
.badge-amber  { background: var(--accent-lt);  color: #92400e; }
.badge-blue   { background: var(--primary-lt); color: var(--primary-dk); }
.badge-grey   { background: var(--border);     color: var(--txt2); }

/* ── Photo Thumbnail ── */
.photo-thumb {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: transform var(--transition), border-color var(--transition);
}
.photo-thumb:hover { transform: scale(1.1); border-color: var(--primary); }

/* ── Filters ── */
.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.filters select, .filters input { width: auto; padding: 9px 14px; font-size: .875rem; }

/* ── Profile ── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  border: 3px solid var(--primary-lt);
  position: relative;
}
.profile-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 16px 0;
}
.page-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--txt2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  display: none;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 90%; max-height: 90vh; border-radius: 8px; box-shadow: 0 25px 50px rgba(0,0,0,.5); }

/* ── Map Link ── */
.map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .8rem;
  color: var(--primary);
  font-weight: 500;
}

/* ── Clock display ── */
#live-clock {
  font-family: 'DM Mono', monospace;
  font-size: 2.5rem;
  font-weight: 500;
  color: var(--txt);
  letter-spacing: -.02em;
  line-height: 1;
}

#live-date {
  font-size: .9rem;
  color: var(--txt2);
  margin-top: 4px;
}

.clock-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 24px;
}

/* ── Admin ── */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

/* ── Search ── */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-wrap input { padding-left: 40px; }
.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
  z-index: 1;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE – MOBILE FIRST
   Breakpoints:
     ≤ 1024px  tablet
     ≤  768px  mobile (landscape)
     ≤  480px  mobile (portrait / small phones)
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 1024px) ── */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 220px 1fr;
  }

  .topbar .brand { width: 200px; }

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

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

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

  .main-content { padding: 24px; }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {

  /* Auth */
  .auth-wrapper {
    grid-template-columns: 1fr;
    background: var(--surface);
  }
  .auth-brand { display: none; }
  .auth-form-side {
    padding: 32px 20px 40px;
    min-height: 100vh;
    align-items: flex-start;
    padding-top: 48px;
  }
  .auth-form-container { max-width: 100%; }
  .auth-form-container h2 { font-size: 1.5rem; }

  /* App layout */
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr;
  }

  /* Sidebar — slides in over content */
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 500;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Sidebar overlay backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 56px;
    background: rgba(15,23,42,.45);
    z-index: 499;
  }
  .sidebar-backdrop.visible { display: block; }

  /* Topbar */
  .topbar { padding: 0 16px; height: 56px; }
  .topbar .brand { width: auto; font-size: 1rem; }
  .topbar-date { display: none; }
  .avatar-name { display: none; }

  /* Main content */
  .main-content {
    padding: 16px;
    padding-bottom: 32px;
  }

  /* Page header */
  .page-header { margin-bottom: 18px; }
  .page-header h1 { font-size: 1.25rem; }

  /* Stats grid — 2 columns on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }
  .stat-card { padding: 16px 14px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }
  .stat-body h3 { font-size: 1.4rem; }

  /* Attend cards — 1 column on mobile */
  .attend-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 18px;
  }
  .attend-card { padding: 18px; }
  .attend-card .time-display { font-size: 1.3rem; }

  /* Admin grid */
  .admin-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Cards */
  .card-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .card-header h2 { font-size: .95rem; }
  .card-body { padding: 16px; }

  /* Clock card */
  .clock-card { padding: 18px; margin-bottom: 16px; }
  #live-clock { font-size: 2rem; }

  /* Tables — horizontal scroll with minimum column widths */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  thead th { padding: 10px 12px; font-size: .75rem; }
  tbody td { padding: 10px 12px; font-size: .8rem; }

  /* Filters */
  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filters select,
  .filters input { width: 100%; }
  .filters .btn { width: 100%; justify-content: center; }
  .search-wrap { min-width: unset; }

  /* Modal — full screen on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 94vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(40px);
  }
  .modal-overlay.open .modal { transform: translateY(0); }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }

  /* Camera in modal */
  .camera-wrap { aspect-ratio: 4/3; }

  /* Modal actions — stack buttons */
  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }
  .modal-actions .btn { width: 100% !important; flex: unset !important; }

  /* Profile */
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
    gap: 16px;
  }

  /* Buttons in table — smaller */
  .btn-sm { padding: 6px 10px; font-size: .78rem; }

  /* Toast — full width at bottom */
  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 16px;
  }
  .toast { max-width: 100%; }

  /* Pagination */
  .pagination { flex-wrap: wrap; gap: 4px; }
  .page-btn { width: 32px; height: 32px; font-size: .8rem; }

  /* Divider spacing */
  .divider { margin: 16px 0; }
}

/* ── Small phones (≤ 480px) ── */
@media (max-width: 480px) {
  body { font-size: 14px; }

  /* Stats — still 2 cols but more compact */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; flex-direction: column; gap: 8px; }
  .stat-body h3 { font-size: 1.3rem; }
  .stat-body p { font-size: .75rem; }

  /* Admin grid — single column on very small screens */
  .admin-grid { grid-template-columns: 1fr; }

  /* Page header */
  .page-header h1 { font-size: 1.1rem; }

  /* Auth form padding */
  .auth-form-side { padding: 24px 16px 40px; }

  /* Buttons */
  .btn-lg { padding: 13px 20px; font-size: .95rem; }
  .btn    { font-size: 14px; }

  /* Clock */
  #live-clock { font-size: 1.75rem; }

  /* Form grid in modals — force single column */
  .modal [style*="grid-template-columns: 1fr 1fr"],
  .modal [style*="grid-template-columns:1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Card header actions wrap */
  .card-header { gap: 10px; }
  .card-header .btn { font-size: .8rem; padding: 7px 12px; }
}

/* ── Misc ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.text-muted { color: var(--txt3); font-size: .875rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.between { justify-content: space-between; }

.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
  display: none;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--txt3);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .95rem; }

/* Hamburger for mobile */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--txt2);
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .topbar-date { display: none; }
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 200;
  display: none;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--txt);
  font-size: .875rem;
  transition: background var(--transition);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); }

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--txt);
  color: #f1f5f9;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .3s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Print */
@media print {
  .sidebar, .topbar, .filters .btn, .no-print { display: none !important; }
  .app-layout { grid-template-columns: 1fr; }
  .main-content { padding: 0; }
}
