@font-face {
  font-family: "B Nazanin";
  src: url("/static/fonts/BNazanin.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "B Nazanin";
  src: url("/static/fonts/BNazanin-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #e8f0ef;
  --bg-deep: #0f3d3e;
  --ink: #122426;
  --muted: #5a7072;
  --surface: #f7fbfa;
  --line: #c5d6d4;
  --accent: #1f7a6c;
  --accent-2: #c45c26;
  --ok: #1b7f4c;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(15, 61, 62, 0.12);
  --radius: 18px;
  --font: "B Nazanin", "Nazanin", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(31, 122, 108, 0.18), transparent 55%),
    radial-gradient(900px 500px at -10% 20%, rgba(196, 92, 38, 0.12), transparent 50%),
    linear-gradient(180deg, #dce9e7 0%, var(--bg) 40%, #f3f7f6 100%);
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 20px 40px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 14px 8px 12px;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(232, 240, 239, 0.95), rgba(232, 240, 239, 0.75));
  border-radius: 0 0 16px 16px;
}

.topbar .brand { flex: 1; min-width: 0; }

.install-btn {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 14px;
  margin-inline-end: 2px;
  font-size: 0.85rem;
  border-radius: 12px;
}

.brand-mark {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--bg-deep);
  line-height: 1.1;
}

.brand-sub {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.icon-btn, .btn {
  font-family: inherit;
  border: 0;
  cursor: pointer;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.2rem;
}

.view { padding-top: 8px; }

/* ---- Home ---- */
.home-hero {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  padding: 32px 22px 28px;
  margin-bottom: 20px;
  color: #f7fffc;
  background:
    linear-gradient(155deg, #0a2f30 0%, #14524c 42%, #1f6b5f 78%, #2a7a68 100%);
  box-shadow: var(--shadow);
  text-align: center;
  isolation: isolate;
}

.home-hero-glow {
  position: absolute;
  inset: -20% -10% auto;
  height: 70%;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(196, 92, 38, 0.35), transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(120, 220, 200, 0.22), transparent 50%);
  animation: homeGlow 8s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none;
}

.home-hero-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background-image:
    linear-gradient(30deg, transparent 48%, rgba(255,255,255,0.35) 49%, rgba(255,255,255,0.35) 51%, transparent 52%),
    linear-gradient(-30deg, transparent 48%, rgba(255,255,255,0.2) 49%, rgba(255,255,255,0.2) 51%, transparent 52%);
  background-size: 28px 48px;
  z-index: 0;
  pointer-events: none;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), transparent 85%);
}

.home-kicker,
.home-title,
.home-lead,
.home-stats,
.home-cta {
  position: relative;
  z-index: 1;
}

.home-kicker {
  margin: 0 0 12px;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  opacity: 0.82;
  animation: homeRise 0.7s ease both;
}

.home-title {
  margin: 0;
  line-height: 1.15;
  animation: homeRise 0.8s 0.08s ease both;
}

.home-title-line {
  display: block;
  font-size: clamp(1.55rem, 6vw, 2rem);
  font-weight: 700;
}

.home-title-accent {
  display: block;
  margin-top: 4px;
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 700;
  color: #ffd7b8;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.home-lead {
  margin: 14px auto 0;
  max-width: 22rem;
  font-size: 1rem;
  line-height: 1.8;
  opacity: 0.9;
  animation: homeRise 0.85s 0.14s ease both;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 22px 0 18px;
  animation: homeRise 0.9s 0.2s ease both;
}

.home-stat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 12px 8px;
  backdrop-filter: blur(6px);
}

.home-stat strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}

.home-stat span {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  opacity: 0.85;
}

.home-cta {
  min-width: 180px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  animation: homeRise 0.95s 0.26s ease both;
}

.panel-pick-grid {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.panel-pick {
  font: inherit;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 18px;
  cursor: pointer;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(18, 36, 38, 0.06);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.panel-pick:active { transform: scale(0.985); }

.panel-pick strong {
  display: block;
  font-size: 1.25rem;
  color: var(--bg-deep);
  margin-bottom: 8px;
}

.panel-pick span {
  display: block;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.panel-pick em {
  display: inline-block;
  margin-top: 14px;
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
  background: #e7f2f0;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.panel-pick.employee em {
  color: var(--accent-2);
  background: #fff0e8;
}

.login-card {
  margin-top: 8px;
}

.login-hero {
  margin-bottom: 14px;
  padding-bottom: 24px;
}

.login-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.7;
}



.home-empty {
  line-height: 1.9;
}

.class-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.class-card-arrow {
  color: var(--accent);
  font-size: 1.1rem;
  opacity: 0.7;
}

.class-card {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.class-card:hover {
  border-color: #9cbcb8;
  box-shadow: 0 12px 28px rgba(18, 36, 38, 0.08);
}

@keyframes homeRise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes homeGlow {
  from { transform: translateY(0) scale(1); opacity: 0.85; }
  to { transform: translateY(8px) scale(1.05); opacity: 1; }
}

.hero-panel {
  background: linear-gradient(145deg, #0f3d3e 0%, #1a5a55 55%, #246b5f 100%);
  color: #f4fffc;
  border-radius: 28px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.hero-panel h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 700;
}

.hero-panel p {
  margin: 0;
  opacity: 0.85;
  line-height: 1.7;
  font-size: 0.95rem;
}

.grid { display: grid; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(18, 36, 38, 0.04);
}

.card.clickable { cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.card.clickable:active { transform: scale(0.985); }
.card.clickable:hover { border-color: #9cbcb8; }

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e7f2f0;
  color: var(--bg-deep);
  font-size: 0.78rem;
  font-weight: 600;
}

.chip.ok { background: #e4f6ec; color: var(--ok); }
.chip.warn { background: #fff4e5; color: var(--warn); }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
}

.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: #e7efee; color: var(--ink); }
.btn-accent { background: var(--accent-2); color: white; }
.btn-danger { background: #fbeaea; color: var(--danger); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.form-grid { display: grid; gap: 12px; }
label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}
input, textarea, select {
  font: inherit;
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
  padding: 10px 14px;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.45);
}

.student-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  background: #d9e8e5;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--bg-deep);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.student-name { margin: 0; font-weight: 700; font-size: 0.98rem; }
.student-code { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }

.camera-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #0b2425;
  aspect-ratio: 3 / 4;
  max-height: 48vh;
  width: min(100%, 320px);
  margin-inline: auto;
}

.camera-wrap.compact {
  max-height: 42vh;
  aspect-ratio: 4 / 5;
  width: min(100%, 280px);
  margin-inline: auto;
}

.camera-wrap video,
.camera-wrap canvas,
.camera-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 2px solid rgba(255,255,255,0.25);
  box-shadow: inset 0 0 0 999px rgba(0,0,0,0.18);
}

.camera-guide {
  position: absolute;
  top: 18%;
  left: 16%;
  right: 16%;
  bottom: 22%;
  border: 2px dashed rgba(255,255,255,0.65);
  border-radius: 50% / 42%;
  box-shadow: none;
}

.status-bar {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #e7f2f0;
  color: var(--bg-deep);
  font-weight: 700;
  text-align: center;
  font-size: 0.95rem;
}
.status-bar.ok { background: #e4f6ec; color: var(--ok); }
.status-bar.err { background: #fbeaea; color: var(--danger); }

.attend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.attend-head h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.attend-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.attend-actions .btn-main {
  grid-column: 1 / -1;
}

.last-match {
  margin-top: 8px;
  text-align: center;
  font-weight: 700;
  color: var(--ok);
  font-size: 0.95rem;
}

.roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.roster-item:last-child { border-bottom: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--bg-deep);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 30, 31, 0.45);
}
.modal-sheet {
  position: relative;
  width: min(100%, 560px);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 18px 28px;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

@media (min-width: 720px) {
  .modal { place-items: center; }
  .modal-sheet {
    border-radius: 24px;
    max-height: 80vh;
  }
}
