*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
  margin-right: 8px;
}

:root {
  --bg:        #0a0c0f;
  --surface:   #111418;
  --border:    #1e2330;
  --accent:    #00e5a0;
  --accent2:   #0077ff;
  --danger:    #ff3b5c;
  --text:      #e8eaf0;
  --muted:     #5a6070;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius:    12px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-mono); }

/* LAYOUT */
.shell {
  display: grid;
  grid-template-rows: 60px 1fr;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* HEADER */
header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 14px;
  position: sticky; top: 0; z-index: 50;
}
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }
header h1 { font-family: var(--font-head); font-size: 1.15rem; font-weight: 800; letter-spacing: -.5px; }
header h1 span { color: var(--accent); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#live-badge { font-size: .7rem; padding: 3px 10px; border-radius: 20px; background: #1a2a1a; color: var(--accent); border: 1px solid var(--accent); display: none; }
#live-badge.on { display: inline-block; }

/* SIDEBAR  */
nav {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 22px;
  font-size: .82rem; font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .2s;
  cursor: pointer;
}
nav a:hover, nav a.active {
  color: var(--text); border-left-color: var(--accent); background: rgba(0,229,160,.06);
}
nav a svg { flex-shrink: 0; }
.nav-label { font-size: .65rem; color: var(--muted); padding: 18px 22px 6px; text-transform: uppercase; letter-spacing: 1px; }

/* MAIN */
main { padding: 32px; overflow-y: auto; }

.section { display: none; }
.section.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

h2 { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.subtitle { color: var(--muted); font-size: .8rem; margin-bottom: 28px; }

/*  CAMERA  */
.cam-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 780px;
  aspect-ratio: 4/3;
  display: flex; align-items: center; justify-content: center;
}
.cam-wrap img { width: 100%; height: 100%; object-fit: cover; display: none; }
.cam-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted);
}
.cam-placeholder svg { opacity: .3; }
.cam-placeholder p { font-size: .85rem; }
.scan-line {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 2.4s linear infinite;
  display: none;
}
@keyframes scan { from{top:0} to{top:100%} }

.btn-row { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  padding: 10px 22px; border-radius: 8px; border: none;
  font-family: var(--font-mono); font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: all .2s; display: inline-flex; align-items: center; gap: 7px;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #00ffb0; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-ghost   { background: var(--border); color: var(--text); }
.btn-ghost:hover { background: #2a3040; }

/* ATTENDANCE TABLE  */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* ✅ Allow horizontal scroll on mobile instead of clipping */
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 860px;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead { background: #151820; }
th { padding: 12px 18px; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); white-space: nowrap; }
td { padding: 12px 18px; font-size: .82rem; border-top: 1px solid var(--border); white-space: nowrap; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.badge-name {
  background: rgba(0,229,160,.1); color: var(--accent);
  padding: 2px 10px; border-radius: 20px; font-size: .75rem; font-weight: 500;
}
.empty-state { text-align: center; color: var(--muted); padding: 48px; font-size: .85rem; }

.toolbar { display: flex; gap: 12px; margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.search-box {
  flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 14px; color: var(--text); font-family: var(--font-mono); font-size: .82rem;
  outline: none;
}
.search-box:focus { border-color: var(--accent); }

/* ── Delete button inside attendance table rows ── */
.del-att-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  padding: 5px 7px;
  display: inline-flex;
  align-items: center;
  transition: color .2s, border-color .2s, background .2s;
}
.del-att-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(255, 59, 92, 0.08);
}

/* Action column header alignment */
th.col-action { text-align: center; width: 60px; }
td.col-action { text-align: center; }

/* PERSONS  */
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; max-width: 860px; }
.person-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color .2s;
}
.person-card:hover { border-color: var(--accent); }
.person-card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #1a1d22; }
.person-card-footer { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; }
.person-card-footer span { font-size: .8rem; font-weight: 500; }
.del-btn {
  background: none; border: none; cursor: pointer; color: var(--muted);
  transition: color .2s; padding: 2px;
}
.del-btn:hover { color: var(--danger); }

/*  ADD PERSON FORM  */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; max-width: 480px; }
.form-group { margin-bottom: 18px; }
label { display: block; font-size: .75rem; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=file] {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; color: var(--text);
  font-family: var(--font-mono); font-size: .85rem; outline: none;
}
input[type=text]:focus { border-color: var(--accent); }
input[type=file] { cursor: pointer; padding: 8px 12px; }

/* TOAST */
#toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 20px;
  font-size: .82rem; min-width: 240px;
  transform: translateY(80px); opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: var(--accent); }
#toast.error   { border-color: var(--danger); }

/* STATS ROW  */
.stats { display: flex; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.stat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 24px; flex: 1; min-width: 140px;
}
.stat-box .val { font-family: var(--font-head); font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-box .lbl { font-size: .72rem; color: var(--muted); margin-top: 2px; }

@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  nav {
    display: flex;
    position: fixed;
    left: -220px;
    top: 60px;
    bottom: 0;
    width: 220px;
    z-index: 100;
    transition: left .3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
  nav.open { left: 0; }
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
    top: 60px;
  }
  .overlay.show { display: block; }
  .hamburger { display: flex; }

  /* Main padding tighter on mobile */
  main { padding: 16px; }

  /* Table: tighter cells so all 5 columns fit in scroll view */
  th, td { padding: 9px 8px; font-size: .72rem; }
  .badge-name { padding: 2px 6px; font-size: .68rem; }
  .del-att-btn { padding: 4px 5px; }

  /* Toolbar: stack search on its own line, buttons wrap */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .search-box { min-width: 100%; order: -1; }
  .toolbar .btn { padding: 8px 12px; font-size: .75rem; }

  /* Stats boxes smaller on mobile */
  .stat-box { padding: 14px 16px; }
  .stat-box .val { font-size: 1.5rem; }
}

@media (min-width: 641px) {
  .hamburger { display: none; }
  .overlay { display: none; }
}