/* ============================================================================
   Class Attendance System · Unified design system
   ----------------------------------------------------------------------------
   One stylesheet for every page (landing, login, dashboard, leaves, admin).
   Mobile-first, responsive, dark UI with brand-blue accents.
   ============================================================================ */

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
  --bg:            #0b1220;
  --bg-elev:       #11192b;
  --bg-card:       #161f37;
  --bg-card-hi:    #1c2748;
  --line:          #233055;
  --line-soft:     #1a2444;
  --ink:           #e5ecff;
  --ink-soft:      #94a3c8;
  --ink-mute:      #6f7da4;

  --brand:         #2563eb;
  --brand-hi:      #3b82f6;
  --brand-soft:    rgba(37, 99, 235, 0.14);
  --accent:        #38bdf8;
  --good:          #16a34a;
  --good-soft:     rgba(22, 163, 74, 0.14);
  --warn:          #f59e0b;
  --warn-soft:     rgba(245, 158, 11, 0.14);
  --bad:           #ef4444;
  --bad-soft:      rgba(239, 68, 68, 0.14);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.20);
  --shadow:     0 4px 18px rgba(0,0,0,0.25);
  --shadow-lg:  0 10px 36px rgba(0,0,0,0.32);

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
}

/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a   { color: inherit; text-decoration: none; transition: color var(--transition); }
img { max-width: 100%; display: block; }
input, select, button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
::selection { background: var(--brand); color: white; }
:focus-visible { outline: 2px solid var(--brand-hi); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.hidden  { display: none !important; }

/* ── Layout helpers ───────────────────────────────────────────────────── */
.wrap { width: min(1200px, 100% - 2rem); margin: 0 auto; }
.row  { display: flex; gap: 1rem; align-items: center; }
.row.between { justify-content: space-between; }
.col  { display: flex; flex-direction: column; gap: 1rem; }
.spacer { flex: 1; }
.muted  { color: var(--ink-soft); }
.dim    { color: var(--ink-mute); }
.mono   { font-family: var(--font-mono); font-size: .82em; letter-spacing: .02em; }

/* ── Top bar (every authenticated page) ──────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  padding: 0.85rem 0;
}
.topbar .wrap { display: flex; align-items: center; gap: 1rem; }
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; letter-spacing: -0.01em; font-size: 1rem;
}
.brand .logo {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: 7px; display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
.topnav { display: flex; gap: 0.25rem; margin-left: auto; align-items: center; }
.topnav a {
  padding: 0.45rem 0.85rem; border-radius: var(--r-sm);
  color: var(--ink-soft); font-size: 0.92rem; font-weight: 500;
  transition: var(--transition);
}
.topnav a:hover { background: var(--bg-card); color: var(--ink); }
.topnav a.active { background: var(--brand-soft); color: var(--brand-hi); }
.user-chip {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.4rem 0.7rem 0.4rem 0.5rem;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r); font-size: 0.85rem;
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center; font-weight: 700; font-size: 0.7rem;
}

/* ── Hamburger (mobile) ───────────────────────────────────────────────── */
.menu-btn {
  display: none; width: 36px; height: 36px;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg-card); padding: 0;
  align-items: center; justify-content: center;
}
.menu-btn span,
.menu-btn span::before,
.menu-btn span::after {
  content: ''; display: block; width: 16px; height: 2px;
  background: var(--ink); border-radius: 2px;
  transition: var(--transition);
}
.menu-btn span { position: relative; }
.menu-btn span::before { position: absolute; top: -5px; left: 0; }
.menu-btn span::after  { position: absolute; top:  5px; left: 0; }

@media (max-width: 880px) {
  .menu-btn { display: inline-flex; }
  .topnav {
    position: fixed; inset: 56px 0 auto 0;
    flex-direction: column; gap: 0;
    background: var(--bg-elev); border-bottom: 1px solid var(--line);
    padding: 1rem;
    transform: translateY(-110%); transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .topnav.open { transform: translateY(0); }
  .topnav a { padding: 0.85rem 1rem; width: 100%; }
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.6rem 1.05rem; border-radius: var(--r-sm);
  font-weight: 600; font-size: 0.92rem;
  background: var(--bg-card); color: var(--ink);
  border: 1px solid var(--line);
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg-card-hi); border-color: var(--brand); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary  { background: var(--brand); border-color: var(--brand); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--brand-hi); border-color: var(--brand-hi); }
.btn.good     { background: var(--good); border-color: var(--good); color: white; }
.btn.good:hover:not(:disabled){ filter: brightness(1.1); }
.btn.bad      { background: var(--bad); border-color: var(--bad); color: white; }
.btn.bad:hover:not(:disabled) { filter: brightness(1.1); }
.btn.ghost    { background: transparent; border-color: var(--line); }
.btn.sm       { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
.btn.lg       { padding: 0.85rem 1.4rem; font-size: 1rem; }
.btn.block    { width: 100%; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label {
  font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.field input, .field select, .field textarea {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 0.65rem 0.85rem;
  font-size: 0.95rem; color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.field-hint { font-size: 0.75rem; color: var(--ink-mute); margin-top: 0.15rem; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
}
.card.tight { padding: 1rem 1.1rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.card-header h2 {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.5rem;
}

/* ── Stats grid ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.1rem 1.2rem;
  position: relative; overflow: hidden;
  transition: var(--transition);
}
.stat:hover { border-color: var(--brand); transform: translateY(-2px); }
.stat::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--brand);
}
.stat.good::before { background: var(--good); }
.stat.warn::before { background: var(--warn); }
.stat.bad::before  { background: var(--bad); }
.stat .k {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 0.4rem;
}
.stat .v { font-size: 1.85rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat .delta { font-size: 0.78rem; color: var(--ink-mute); margin-top: 0.25rem; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-sm); border: 1px solid var(--line); }
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.9rem;
}
thead { background: var(--bg-elev); }
th {
  text-align: left; padding: 0.7rem 0.9rem;
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line-soft);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hi); }
.table-empty { text-align: center; padding: 2rem 1rem; color: var(--ink-mute); font-style: italic; }

/* ── Pills / badges ──────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.6rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid currentColor;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good); background: var(--good-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad  { color: var(--bad);  background: var(--bad-soft); }
.pill.brand{ color: var(--brand-hi); background: var(--brand-soft); }
.pill.mute { color: var(--ink-mute); background: var(--bg-elev); border-color: var(--line); }

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--r-sm);
  font-size: 0.88rem; border: 1px solid currentColor;
  display: flex; gap: 0.55rem; align-items: flex-start;
}
.alert.error { color: var(--bad); background: var(--bad-soft); }
.alert.success { color: var(--good); background: var(--good-soft); }
.alert.warn { color: var(--warn); background: var(--warn-soft); }
.alert.info { color: var(--brand-hi); background: var(--brand-soft); }

/* ── Login layout ────────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 2rem 1rem;
  background: radial-gradient(circle at 30% 20%, rgba(37, 99, 235, 0.12) 0%, transparent 60%),
              radial-gradient(circle at 70% 80%, rgba(56, 189, 248, 0.08) 0%, transparent 50%),
              var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 2rem 1.85rem;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand { margin-bottom: 1.5rem; font-size: 1.05rem; }
.auth-card h1 {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.4rem;
}
.auth-card p.lede { color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 1.5rem; }
.auth-card .field + .field { margin-top: 0.85rem; }
.auth-card .btn { margin-top: 1.25rem; }

/* ── Landing / hero (index.html) ─────────────────────────────────────── */
.landing-hero {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 4rem 1.5rem;
  background: radial-gradient(circle at 30% 20%, rgba(37, 99, 235, 0.18) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(56, 189, 248, 0.12) 0%, transparent 50%),
              var(--bg);
  text-align: center;
}
.landing-hero h1 {
  font-size: clamp(2.3rem, 5vw, 3.6rem);
  font-weight: 800; letter-spacing: -0.025em; line-height: 1.05;
  margin-bottom: 1rem;
}
.landing-hero h1 .accent {
  background: linear-gradient(135deg, var(--brand-hi) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.landing-hero .lede {
  font-size: 1.1rem; color: var(--ink-soft);
  max-width: 56ch; margin: 0 auto 2rem;
}
.landing-cta { display: flex; gap: 0.85rem; justify-content: center; flex-wrap: wrap; }
.landing-features {
  margin-top: 4rem;
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  max-width: 920px; width: 100%;
  text-align: left;
}
.landing-feature {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.25rem;
}
.landing-feature .ic {
  width: 36px; height: 36px;
  background: var(--brand-soft); color: var(--brand-hi);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  margin-bottom: 0.6rem; font-size: 1.1rem;
}
.landing-feature h3 { font-size: 0.98rem; font-weight: 700; margin-bottom: 0.35rem; }
.landing-feature p  { font-size: 0.86rem; color: var(--ink-soft); }

/* ── Page header / section header ─────────────────────────────────────── */
.page-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1.5rem;
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header .sub { color: var(--ink-soft); font-size: 0.92rem; margin-top: 0.2rem; }

/* ── Punch panel (student dashboard) ─────────────────────────────────── */
.punch-panel {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(56, 189, 248, 0.05));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.punch-panel.live {
  border-color: var(--good);
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.10), rgba(56, 189, 248, 0.04));
}
.punch-panel h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; }
.punch-panel .meta { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 1rem; }
.punch-panel .actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.65);
  animation: pulse 1.6s infinite;
  margin-right: 0.45rem;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(22, 163, 74, 0.65); }
  70%  { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0   rgba(22, 163, 74, 0); }
}

/* ── Active sessions list ────────────────────────────────────────────── */
.sessions-list { display: grid; gap: 0.75rem; }
.session-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.session-row .name { font-weight: 600; }
.session-row .meta { color: var(--ink-soft); font-size: 0.85rem; }

/* ── Tabs ────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab {
  padding: 0.6rem 0.95rem;
  background: none; color: var(--ink-soft); font-size: 0.92rem;
  border-bottom: 2px solid transparent; transition: var(--transition);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-hi); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.7);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 1rem; z-index: 100;
}
.modal {
  width: 100%; max-width: 540px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.5rem 1.6rem;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

/* ── PWA install banner ──────────────────────────────────────────────── */
.install-banner {
  position: fixed; bottom: 1rem; left: 1rem; right: 1rem; z-index: 60;
  background: var(--bg-card); border: 1px solid var(--brand);
  border-radius: var(--r); padding: 0.85rem 1rem;
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
  box-shadow: var(--shadow-lg);
  max-width: 480px; margin-left: auto; margin-right: auto;
}
.install-banner .ic {
  width: 32px; height: 32px;
  background: var(--brand-soft); color: var(--brand-hi);
  border-radius: 50%; display: grid; place-items: center;
}
.install-banner .text { flex: 1; font-size: 0.88rem; }
.install-banner .text strong { display: block; }
.install-banner .text small { color: var(--ink-soft); }

/* ── Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 2rem 0;
  margin-top: 3rem;
  font-size: 0.82rem;
  color: var(--ink-mute);
}
.site-footer .wrap {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}

/* ── Responsive: small screens ───────────────────────────────────────── */
@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stat .v { font-size: 1.55rem; }
  .auth-card { padding: 1.5rem 1.25rem; }
  .punch-panel { padding: 1.25rem; }
  th, td { padding: 0.55rem 0.7rem; font-size: 0.84rem; }
}

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
