/* ===========================================================
   Face Attend — Web UI design system
   White canvas, Sociovia green #34B233, Fraunces + Manrope + JetBrains Mono
   =========================================================== */
:root {
  --canvas: #FAFAF8;
  --surface: #FFFFFF;
  --quiet: #F3F3F0;
  --line: #E7E7E4;
  --line-strong: #D4D4D0;
  --ink: #0A0A0B;
  --pen: #2E2E30;
  --muted: #6B6E76;
  --soft: #A5A8B0;
  --brand: #34B233;
  --brand-hover: #2A9A2A;
  --brand-deep: #1F7A20;
  --brand-soft: #ECFBEC;
  --brand-fill: #F5FDF5;
  --warn: #B45309;
  --warnSoft: #FEF3C7;
  --danger: #9A1F1F;
  --dangerSoft: #FEE7E7;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* Grain overlay (super subtle) */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.025 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* Type helpers */
.serif { font-family: 'Fraunces', serif; letter-spacing: -0.025em; }
.serif-italic { font-family: 'Fraunces'; font-style: italic; letter-spacing: -0.02em; }
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.muted { color: var(--muted); }
.pen   { color: var(--pen); }

.h1 {
  font-family: 'Fraunces';
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.98;
  font-size: clamp(32px, 4.4vw, 52px);
  margin: 10px 0 0;
  font-variation-settings: 'opsz' 144;
}
.h1 em, .h1 .italic { font-style: italic; color: var(--brand-deep); }
.h2 {
  font-family: 'Fraunces';
  font-weight: 400;
  letter-spacing: -0.025em;
  font-size: 22px;
  margin: 0;
  font-variation-settings: 'opsz' 96;
}
.kicker { max-width: 640px; color: var(--muted); margin-top: 10px; line-height: 1.55; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.eyebrow-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--brand); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 24px;
  background: rgba(250, 250, 248, 0.88);
  backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--ink);
  display: inline-block; position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; bottom: 5px; right: 5px;
  width: 6px; height: 6px; border-radius: 999px; background: var(--brand);
  box-shadow: 0 0 0 2px var(--ink);
}
.brand-mark.small { width: 20px; height: 20px; border-radius: 6px; }
.brand-mark.small::after { bottom: 3px; right: 3px; width: 4px; height: 4px; }
.brand-text { display: inline-flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-weight: 800; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

.tabs { display: flex; gap: 2px; margin-left: 10px; }
.tab {
  padding: 7px 13px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  font-family: 'Manrope'; font-weight: 500; font-size: 13.5px;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .1s ease;
}
.tab:hover { color: var(--ink); background: var(--quiet); }
.tab.active {
  color: var(--ink); background: var(--surface); border-color: var(--line);
  box-shadow: 0 1px 2px rgba(10,10,11,0.05);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Dots + pills + status chips */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12px; color: var(--muted);
}
.pill-label { font-weight: 500; color: var(--ink); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 999px; background: var(--soft); }
.dot-green { background: var(--brand); box-shadow: 0 0 0 3px rgba(52,178,51,.18); }
.dot-amber { background: var(--warn); box-shadow: 0 0 0 3px rgba(180,83,9,.16); }
.dot-red   { background: var(--danger); box-shadow: 0 0 0 3px rgba(154,31,31,.18); }
.dot-gray  { background: var(--soft); }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 11.5px; color: var(--muted);
}

/* Main container */
.page { max-width: 1240px; margin: 0 auto; padding: 32px 24px 60px; position: relative; z-index: 2; }

.view { display: none; }
.view.active { display: block; animation: viewIn .4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}

.hero { margin-bottom: 24px; }

/* Grid helpers */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stats-grid { margin-bottom: 20px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(10,10,11,0.03);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.card:hover { border-color: var(--line-strong); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.card-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }

/* Stat tile */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 14px;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(10,10,11,.14); }
.stat.brand { background: var(--brand-fill); border-color: rgba(52,178,51,.25); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat-value {
  font-family: 'Fraunces'; font-weight: 400;
  font-variation-settings: 'opsz' 96;
  font-size: 38px; letter-spacing: -0.03em; line-height: 1;
  color: var(--ink); margin-top: 8px;
}
.stat.brand .stat-value { color: var(--brand-deep); }
.stat-foot { font-size: 11.5px; color: var(--muted); margin-top: 8px; font-family: 'JetBrains Mono'; letter-spacing: 0.02em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: 'Manrope'; font-weight: 500; font-size: 13.5px;
  cursor: pointer; text-decoration: none;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  box-shadow: 0 1px 2px rgba(10,10,11,.03);
}
.btn:hover { background: var(--quiet); border-color: #C0C0BC; box-shadow: 0 2px 4px rgba(10,10,11,.05); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(52,178,51,.24);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; box-shadow: 0 4px 10px rgba(52,178,51,.24); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--quiet); color: var(--ink); box-shadow: none; }
.btn-danger { color: var(--danger); border-color: #E6BEBE; background: var(--surface); }
.btn-danger:hover { background: var(--dangerSoft); color: var(--danger); }

/* Form controls */
.field { margin-bottom: 12px; }
.field-label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-family: 'Manrope'; font-size: 14px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(10,10,11,.02) inset;
}
.input::placeholder { color: var(--soft); }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(52,178,51,.14); }
.input-sm { padding: 7px 10px; font-size: 13px; width: 220px; }

.actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: 6px; cursor: pointer; }
.hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

/* Editorial numbered list */
.editorial-list { counter-reset: item; margin: 0; padding: 0; list-style: none; }
.editorial-list > li {
  counter-increment: item;
  padding: 14px 0 14px 52px;
  border-top: 1px solid var(--line);
  position: relative;
  font-size: 14px; line-height: 1.55;
}
.editorial-list > li:first-child { border-top: none; }
.editorial-list > li::before {
  content: counter(item, decimal-leading-zero);
  position: absolute; left: 0; top: 13px;
  font-family: 'Fraunces'; font-size: 22px; color: var(--brand); line-height: 1;
}

/* Video + overlay */
.video-wrap {
  position: relative;
  border-radius: 12px; overflow: hidden;
  background: #0A0A0B; aspect-ratio: 4 / 3; margin: 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
}
video, canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.overlay { position: absolute; inset: 0; pointer-events: none; background: transparent; }
.video-badge {
  position: absolute; top: 10px; right: 10px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px;
  font-family: 'JetBrains Mono'; backdrop-filter: blur(4px);
  letter-spacing: .04em;
}

/* Progress bar */
.progress-wrap { margin-top: 14px; }
.progress {
  height: 8px; border-radius: 999px; background: var(--quiet); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .25s ease;
}

/* Students list (train tab) */
.students-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.student-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
  transition: border-color .15s ease, transform .1s ease;
}
.student-row:hover { border-color: var(--line-strong); }
.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--ink); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.student-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.student-name { font-weight: 600; line-height: 1.1; }
.student-id { font-size: 11.5px; color: var(--muted); font-family: 'JetBrains Mono'; }
.student-row .count {
  font-family: 'JetBrains Mono'; font-size: 12px; color: var(--muted); margin-right: 6px;
}
.empty {
  padding: 18px; text-align: center; color: var(--muted); font-style: italic;
}

/* Log pre */
.log {
  margin: 12px 0 0;
  padding: 12px; border-radius: 10px;
  background: #0A0A0B; color: #D4D4D0;
  font-family: 'JetBrains Mono'; font-size: 12px;
  min-height: 120px; max-height: 300px; overflow: auto;
  white-space: pre-wrap; line-height: 1.45;
  border: 1px solid #19191B;
}

/* Live detections list (recognize tab) */
.live-list { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow: auto; }
.live-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--brand-fill); border: 1px solid rgba(52,178,51,.25);
  animation: popin .25s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.live-row.unknown { background: var(--quiet); border-color: var(--line); }
.live-name { font-weight: 600; }
.live-conf { font-family: 'JetBrains Mono'; font-size: 12px; color: var(--muted); margin-left: auto; }
@keyframes popin {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data thead th {
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--quiet);
}
table.data tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
table.data tbody tr:hover td { background: var(--brand-fill); }
table.data .mono { color: var(--pen); }

/* Reveal animations */
@keyframes rise { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.reveal   { animation: rise .55s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.reveal-1 { animation: rise .55s cubic-bezier(0.2, 0.7, 0.2, 1) .06s both; }
.reveal-2 { animation: rise .55s cubic-bezier(0.2, 0.7, 0.2, 1) .12s both; }
.reveal-3 { animation: rise .55s cubic-bezier(0.2, 0.7, 0.2, 1) .20s both; }
.reveal-4 { animation: rise .55s cubic-bezier(0.2, 0.7, 0.2, 1) .28s both; }

/* Footer */
.footer {
  max-width: 1240px; margin: 0 auto; padding: 16px 24px 32px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--line);
}
.footer-left { display: flex; align-items: center; gap: 10px; }
.footer-left .brand-mark { display: inline-block; }

/* Toast */
#toasts {
  position: fixed; bottom: 24px; right: 24px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 24px -8px rgba(10,10,11,.18);
  font-size: 13px; min-width: 220px; max-width: 360px;
  animation: popin .3s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.toast.success { border-color: rgba(52,178,51,.3); }
.toast.error { border-color: #E6BEBE; }
.toast .label { font-weight: 700; color: var(--ink); }
.toast .body { color: var(--muted); margin-top: 2px; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ===========================================================
   Responsive — tablet / mobile
   =========================================================== */

/* Tablet (≤ 960px): still-wide 2-col becomes 1-col (already in base) */

/* Phones (≤ 720px) */
@media (max-width: 720px) {
  .topbar {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .brand-text { max-width: 110px; }
  .brand-sub { display: none; }
  .brand-title { font-size: 13px; }

  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: 0;
    flex: 1 1 auto;
    min-width: 0;
    gap: 1px;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 6px 10px;
    font-size: 12.5px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .topbar-right { gap: 6px; }
  .pill { padding: 3px 8px; }
  .pill-label { display: none; }

  .page { padding: 20px 14px 48px; }
  .hero { margin-bottom: 18px; }
  .h1 { font-size: clamp(26px, 8vw, 36px); line-height: 1.03; }
  .h2 { font-size: 18px; }
  .kicker { font-size: 14px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px 10px; }
  .stat-value { font-size: 28px; }
  .stat-foot { font-size: 10.5px; margin-top: 4px; }

  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 16px; border-radius: 14px; }
  .card-head { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

  .video-wrap { max-width: 100%; }
  .video-badge { top: 8px; right: 8px; padding: 3px 8px; font-size: 11px; }

  .actions { flex-wrap: wrap; }
  .actions > * { flex: 1 1 auto; min-width: 120px; }
  .btn { padding: 10px 14px; font-size: 14px; }  /* bigger touch targets */

  .input, .input-sm { width: 100%; font-size: 16px; }  /* 16px avoids iOS zoom */

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 16px 14px 28px;
    text-align: left;
  }
  .footer-left { flex-wrap: wrap; }

  .editorial-list > li { padding: 12px 0 12px 44px; font-size: 13.5px; }
  .editorial-list > li::before { font-size: 18px; top: 11px; }

  .log { font-size: 11.5px; max-height: 200px; }

  .live-list, .students-list { max-height: 320px; }
  .student-row { padding: 8px 10px; gap: 10px; }
  .avatar { width: 32px; height: 32px; font-size: 13px; }

  #toasts { bottom: 12px; right: 12px; left: 12px; }
  .toast { min-width: 0; }
}

/* Very small (≤ 400px) */
@media (max-width: 400px) {
  .brand-text { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
  .page { padding: 16px 12px 40px; }
}

/* Landscape phone (short height) */
@media (max-height: 500px) and (max-width: 900px) {
  .hero { margin-bottom: 10px; }
  .h1 { font-size: 24px; }
  .kicker { font-size: 13px; }
}

/* Prefers reduced motion — turn off reveal animations */
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-1, .reveal-2, .reveal-3, .reveal-4,
  .view, .live-row, .toast {
    animation: none !important;
  }
  * { transition: none !important; }
}
