:root {
  --bg: #eef7f6;
  --bg-2: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f766e;
  --primary-2: #14b8a6;
  --primary-dark: #134e4a;
  --blue: #2563eb;
  --warning: #f59e0b;
  --danger: #dc2626;
  --safe: #16a34a;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  --soft-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 288px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.2), transparent 36rem),
    radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.14), transparent 30rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 42px;
  border: 1px solid rgba(15, 118, 110, 0.13);
  border-radius: 42px;
  pointer-events: none;
}
.login-hero {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 900px;
}
.login-logo { width: 134px; height: 134px; }
.login-hero h1 {
  font-size: clamp(48px, 7vw, 92px);
  margin: 8px 0;
  letter-spacing: -0.07em;
  line-height: 0.92;
}
.tagline {
  color: var(--muted);
  font-size: clamp(18px, 2vw, 24px);
  max-width: 780px;
  line-height: 1.5;
}
.login-card {
  width: min(460px, 100%);
  padding: 32px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  justify-self: end;
}
.glass {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
}
.login-card label, .form-grid label, .filters label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 16px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: white;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.14);
}

.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, #082f2c 0%, #0f766e 50%, #1e3a8a 100%);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: 16px 0 40px rgba(15, 23, 42, 0.18);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; padding: 6px 6px 14px; }
.brand img { width: 54px; height: 54px; filter: drop-shadow(0 8px 18px rgba(0,0,0,.18)); }
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: rgba(255,255,255,.72); font-size: 12px; }
.nav-list { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  border: 0;
  color: rgba(255,255,255,.8);
  background: transparent;
  padding: 13px 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  text-align: left;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.16); color: white; }
.nav-item span { width: 24px; text-align: center; }
.sidebar-footer {
  margin-top: auto;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.status-dot { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.status-dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.18); }
.sidebar-footer small { color: rgba(255,255,255,.7); }

.main-content { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: rgba(238, 247, 246, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}
.topbar-title h2, .section-header h1, .hero-panel h1 { margin: 0; letter-spacing: -0.03em; }
.topbar-title h2 { font-size: 28px; }
.topbar-actions, .button-row, .hero-actions, .form-actions, .modal-actions, .template-buttons { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-btn {
  width: 42px; height: 42px; border: 0; border-radius: 14px; background: white; box-shadow: var(--soft-shadow);
}
#menuBtn { display: none; }

.view { display: none; padding: 24px 28px 46px; }
.view.active-view { display: block; }
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.section-header p { color: var(--muted); max-width: 840px; line-height: 1.55; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: .12em;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.hero-panel {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .96), rgba(30, 58, 138, .95)),
    url("assets/logo.svg") right 32px center/180px no-repeat;
  color: white;
  border-radius: 32px;
  padding: clamp(24px, 4vw, 44px);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}
.hero-panel .eyebrow { color: #99f6e4; }
.hero-panel h1 { max-width: 900px; font-size: clamp(32px, 4vw, 58px); line-height: 1.02; }
.hero-panel p { max-width: 780px; color: rgba(255,255,255,.78); font-size: 17px; line-height: 1.6; }

.card {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: var(--radius-xl);
  box-shadow: var(--soft-shadow);
  padding: 20px;
}
.card.flat { box-shadow: none; border-radius: var(--radius); }
.table-card { padding: 0; overflow: hidden; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.card-header.compact { align-items: center; }
.card-header h3, .card-header h2 { margin: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border: 1px solid rgba(226, 232, 240, .94);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--soft-shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -22px; bottom: -22px;
  width: 96px; height: 96px;
  border-radius: 50%;
  background: rgba(20,184,166,.12);
}
.stat-icon { font-size: 28px; margin-bottom: 10px; }
.stat-value { font-size: 34px; font-weight: 900; letter-spacing: -0.05em; }
.stat-label { color: var(--muted); font-weight: 700; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 11px 15px;
  color: var(--text);
  background: white;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .07);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: 42px;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: white; }
.btn.light { background: #ecfeff; color: #155e75; }
.btn.ghost { background: rgba(255,255,255,.7); box-shadow: none; border: 1px solid rgba(203,213,225,.9); }
.btn.danger { background: linear-gradient(135deg, #dc2626, #f97316); color: white; }
.btn.danger.ghost { background: #fff1f2; color: #b91c1c; }
.btn.small { padding: 7px 10px; min-height: 32px; border-radius: 10px; font-size: 12px; }
.btn.wide { width: 100%; margin: 8px 0 12px; }
.file-btn input { display: none; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.pill.safe { background: #dcfce7; color: #166534; }
.pill.warning { background: #fef3c7; color: #92400e; }
.pill.danger { background: #fee2e2; color: #991b1b; }
.pill.info { background: #dbeafe; color: #1d4ed8; }
.pill.neutral { background: #f1f5f9; color: #475569; }

.activity-list { display: grid; gap: 10px; }
.activity-list.tall { max-height: 560px; overflow: auto; padding-right: 4px; }
.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #f8fafc;
}
.activity-icon {
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: white;
  box-shadow: inset 0 0 0 1px #e2e8f0;
}
.activity-item h4 { margin: 0 0 3px; font-size: 14px; }
.activity-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.activity-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty-state {
  padding: 22px;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
th { background: #f8fafc; color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
td { font-size: 14px; }
.student-cell { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #ccfbf1, #dbeafe);
  color: #115e59;
  font-weight: 900;
}
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid label { margin: 0; }
.form-grid .full { grid-column: 1 / -1; }
.compact-form { gap: 12px; }
.compact-form input, .compact-form select, .compact-form textarea { padding: 10px 12px; }

.scanner-card { min-height: 360px; }
.scanner-box {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 16px;
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, #f8fafc, #ecfeff);
  border: 1px solid #dbeafe;
}
.qr-frame {
  width: 130px; height: 130px;
  border-radius: 28px;
  display: grid; place-items: center;
  font-size: 70px;
  color: var(--primary);
  border: 8px solid white;
  box-shadow: inset 0 0 0 3px #0f766e, var(--soft-shadow);
  background: white;
}
.scan-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; width: 100%; }
.scan-result { width: 100%; }
.profile-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: white;
  text-align: left;
}

.bar-list { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 7px; }
.bar-row-top { display: flex; justify-content: space-between; color: #334155; font-weight: 900; font-size: 14px; }
.bar-track { height: 12px; border-radius: 999px; overflow: hidden; background: #e2e8f0; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--blue)); min-width: 4%; }
.printable-report {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 18px;
  line-height: 1.6;
  background: #f8fafc;
}

.notice-box {
  display: grid;
  gap: 12px;
  color: #334155;
  line-height: 1.65;
}
.notice-box h4 { margin: 10px 0 0; }
.notice-box p { margin: 0; }

.modal {
  border: 0;
  padding: 0;
  border-radius: 28px;
  max-width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: transparent;
}
.modal::backdrop { background: rgba(15,23,42,.55); backdrop-filter: blur(8px); }
.modal-card {
  background: white;
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px;
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.profile-modal { width: min(760px, calc(100vw - 32px)); }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.profile-field { padding: 13px; border: 1px solid #e2e8f0; border-radius: 16px; background: #f8fafc; }
.profile-field span { display: block; font-size: 11px; color: var(--muted); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.profile-field strong { overflow-wrap: anywhere; }
.modal-actions { justify-content: flex-end; padding-top: 18px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: none;
  background: #0f172a;
  color: white;
  padding: 13px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 40px));
}
.toast.show { display: block; animation: toastIn .25s ease both; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-screen { grid-template-columns: 1fr; }
  .login-card { justify-self: start; }
}
@media (max-width: 940px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-104%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  #menuBtn { display: inline-grid; }
  .topbar { padding: 14px 16px; }
  .topbar-actions { display: none; }
  .view { padding: 18px 16px 36px; }
  .section-header, .hero-panel { flex-direction: column; }
  .two-col, .filters { grid-template-columns: 1fr; }
  .scan-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .login-screen { padding: 24px; }
  .login-screen::before { inset: 14px; border-radius: 28px; }
  .login-hero { display: grid; }
  .login-logo { width: 92px; height: 92px; }
  .login-card { padding: 22px; }
  .stats-grid, .form-grid, .profile-grid { grid-template-columns: 1fr; }
  .button-row, .hero-actions, .template-buttons { width: 100%; }
  .button-row .btn, .hero-actions .btn, .stacked-mobile .btn { width: 100%; }
  .hero-panel { background-image: linear-gradient(135deg, rgba(15, 118, 110, .96), rgba(30, 58, 138, .95)); }
  .activity-item { grid-template-columns: auto 1fr; }
  .activity-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 940px) {
  .main-content { padding-bottom: 88px; }
  .mobile-tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    box-shadow: 0 18px 60px rgba(15, 23, 42, 0.18);
  }
  .mobile-tab {
    border: 0;
    border-radius: 18px;
    background: transparent;
    color: #64748b;
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 2px;
    font-weight: 900;
  }
  .mobile-tab span { font-size: 20px; line-height: 1; }
  .mobile-tab small { font-size: 10px; }
  .mobile-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
  }
  .mobile-tab.hidden { display: none; }
  .mobile-tabbar:has(.mobile-tab.hidden) { grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); }
}

@media (max-width: 640px) {
  body { background-attachment: fixed; }
  .topbar-title h2 { font-size: 22px; }
  .card, .stat-card { border-radius: 22px; }
  .hero-panel { border-radius: 26px; }
  .modal, .modal-card, .profile-modal {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 22px;
  }
  input, select, textarea { min-height: 46px; }
  th, td { padding: 12px; }
}

@media (max-width: 720px) {
  .table-card { background: transparent; border: 0; box-shadow: none; padding: 0; }
  .table-responsive { overflow: visible; }
  table { min-width: 0; border-collapse: separate; border-spacing: 0 12px; }
  thead { display: none; }
  tbody, tr, td { display: block; width: 100%; }
  tr {
    background: white;
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 22px;
    padding: 12px;
    box-shadow: var(--soft-shadow);
  }
  td {
    border-bottom: 0;
    padding: 10px 8px;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    align-items: start;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
  }
  td[data-label="Learner"] { grid-template-columns: 1fr; }
  td[data-label="Learner"]::before { display: none; }
  td[data-label="Actions"] .table-actions { justify-content: flex-start; }
}

@media print {
  body { background: white; }
  .sidebar, .topbar, .section-header, .stats-grid, .grid:not(:has(.printable-report)), .btn, .modal { display: none !important; }
  .app-shell { display: block; }
  .view { display: block !important; padding: 0; }
  .view:not(#reports) { display: none !important; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .printable-report { border: 0; background: white; }
}
