/* ============================================================
   Syntax SaaS — Design System
   Professional dashboard theme (Indigo / Blue primary)
   ============================================================ */

:root {
  --indigo: #4f46e5;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --indigo-800: #3730a3;
  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --blue: #2563eb;
  --blue-50: #eff6ff;

  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e6e9f2;
  --border-strong: #d5dae8;

  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --gray-bg: #f1f5f9;
  --purple-bg: #f3e8ff;
  --purple: #7e22ce;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 10px 26px -16px rgba(15, 23, 42, 0.25);
  --shadow-lg: 0 18px 50px -18px rgba(30, 27, 75, 0.38);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.18);
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; letter-spacing: -0.01em; color: #0f172a; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { display: block; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--indigo), var(--blue));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.8);
}
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.brand-name span { color: var(--indigo); }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: -2px; }

.hamburger {
  display: none;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: #fff;
  align-items: center; justify-content: center; color: var(--text);
}

.role-switch {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; margin-left: auto; overflow-x: auto; scrollbar-width: none;
}
.role-switch::-webkit-scrollbar { display: none; }
.role-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; white-space: nowrap;
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 7px;
  transition: all 0.18s ease;
}
.role-btn:hover { color: var(--text); background: rgba(79, 70, 229, 0.06); }
.role-btn.active {
  background: #fff; color: var(--indigo-700);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.role-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.7; }

.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; border: 1px solid transparent; padding: 9px 15px;
  font-weight: 600; font-size: 13.5px; line-height: 1;
  transition: transform 0.12s ease, background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--indigo); color: #fff; box-shadow: 0 10px 20px -12px rgba(79, 70, 229, 0.9); }
.btn-primary:hover { background: var(--indigo-700); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg); border-color: var(--muted-2); }
.btn-soft { background: var(--indigo-50); color: var(--indigo-700); }
.btn-soft:hover { background: var(--indigo-100); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #166534; }
.btn-red { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-red:hover { background: var(--red-bg); }
.btn-amber { background: #fff; color: var(--amber); border-color: #fde68a; }
.btn-amber:hover { background: var(--amber-bg); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--muted); display: grid; place-items: center;
  transition: all 0.16s ease;
}
.icon-btn:hover { color: var(--indigo); border-color: var(--indigo-100); background: var(--indigo-50); }
.icon-btn.danger:hover { color: var(--red); border-color: #fecaca; background: var(--red-bg); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------------- Layout ---------------- */
.app-root { min-height: calc(100vh - var(--topbar-h)); }
.page { padding: 26px; max-width: 1280px; margin: 0 auto; animation: fadeUp 0.35s ease both; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseRing { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); } 70% { box-shadow: 0 0 0 14px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--indigo); }

/* ---------------- Cards & grid ---------------- */
.grid { display: grid; gap: 18px; }
.stats-grid { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card-pad-0 { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-head h3 { font-size: 16px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 20px; }

.stat { position: relative; overflow: hidden; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--indigo-50); color: var(--indigo);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-icon.blue { background: var(--blue-50); color: var(--blue); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin-top: 14px; }
.stat-label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat-delta { font-size: 12.5px; font-weight: 600; margin-top: 10px; display: inline-flex; align-items: center; gap: 5px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta .muted { color: var(--muted); font-weight: 500; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-grace { background: var(--amber-bg); color: var(--amber); }
.badge-expired { background: var(--red-bg); color: var(--red); }
.badge-locked { background: var(--gray-bg); color: #475569; }
.badge-info { background: var(--indigo-50); color: var(--indigo-700); }
.badge-grade { min-width: 34px; justify-content: center; }
.g-A { background: var(--green-bg); color: var(--green); }
.g-B { background: var(--blue-50); color: var(--blue); }
.g-C { background: var(--indigo-50); color: var(--indigo-700); }
.g-D { background: var(--amber-bg); color: var(--amber); }
.g-F { background: var(--red-bg); color: var(--red); }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 620px; }
table.data thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 700; padding: 12px 20px; background: #fbfcfe;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data tbody td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background 0.14s ease; }
table.data tbody tr:hover { background: #fafbff; }
.cell-strong { font-weight: 600; color: #0f172a; }
.cell-muted { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.avatar-cell { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--indigo), var(--blue));
}

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.field label { font-size: 13px; font-weight: 600; color: #334155; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: #fff; outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--indigo); box-shadow: var(--ring); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }
.input-group { display: flex; gap: 10px; flex-wrap: wrap; }
.input-group > .field { flex: 1 1 180px; margin-bottom: 0; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .field { margin-bottom: 0; min-width: 190px; flex: 1 1 190px; }

.trait-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin-top: 8px; }
.trait-row { display: contents; align-items: center; border-bottom: 1px solid var(--border); padding: 6px 0; }
.trait-row .cell-muted { font-size: 13px; color: var(--muted); }
.trait-row select { width: 150px; max-width: 100%; padding: 8px 10px; font-size: 13px; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 48px; height: 27px; border-radius: 999px; background: #cbd5e1;
  position: relative; transition: background 0.2s ease; flex-shrink: 0;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease; box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-track { background: var(--indigo); }
.switch input:checked + .switch-track::after { transform: translateX(21px); }
.switch-text { font-size: 13.5px; }
.switch-text strong { display: block; font-weight: 600; }
.switch-text small { color: var(--muted); }

/* ---------------- Sidebar layout ---------------- */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: 264px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  padding: 18px 14px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidebar-brand { padding: 6px 10px 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.sidebar-brand .name { font-weight: 700; font-size: 14.5px; }
.sidebar-brand .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); font-weight: 700; padding: 14px 12px 6px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #475569; font-weight: 600; font-size: 14px; border: 1px solid transparent;
  transition: all 0.16s ease; text-align: left; background: none; width: 100%;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--indigo-700); }
.nav-item.active { background: linear-gradient(135deg, var(--indigo), var(--blue)); color: #fff; box-shadow: 0 12px 22px -14px rgba(79, 70, 229, 0.95); }
.nav-item .nav-badge { margin-left: auto; font-size: 11px; background: var(--red-bg); color: var(--red); padding: 2px 8px; border-radius: 999px; }
.nav-item.active .nav-badge { background: rgba(255, 255, 255, 0.25); color: #fff; }

.content { flex: 1; min-width: 0; padding: 26px; }
.content-inner { max-width: 1120px; margin: 0 auto; animation: fadeUp 0.3s ease both; }

.sidebar-backdrop {
  display: none; position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgba(15, 23, 42, 0.45); z-index: 45; animation: fadeIn 0.2s ease;
}

/* ---------------- Toolbar / segmented ---------------- */
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: 4px; gap: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: 8px; transition: all 0.16s ease;
}
.segmented button.active { background: #fff; color: var(--indigo-700); box-shadow: var(--shadow-sm); }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(3px);
  z-index: 100; display: grid; place-items: center; padding: 20px; animation: fadeIn 0.2s ease;
}
.modal {
  width: 100%; max-width: 520px; background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); animation: pop 0.24s ease both; max-height: 92vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 24px 6px; }
.modal-head h3 { font-size: 18px; }
.modal-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 24px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; flex-wrap: wrap; }
.modal-foot .spacer { margin-right: auto; }
.close-x { border: 0; background: var(--bg); color: var(--muted); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.close-x:hover { background: var(--red-bg); color: var(--red); }

/* ---------------- Toast ---------------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 36px)); }
.toast {
  display: flex; align-items: flex-start; gap: 11px; background: #0f172a; color: #e2e8f0;
  padding: 13px 15px; border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop 0.25s ease both;
  border-left: 4px solid var(--indigo);
}
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast.info { border-left-color: #38bdf8; }
.toast .t-title { font-weight: 700; font-size: 13.5px; color: #fff; }
.toast .t-msg { font-size: 12.5px; color: #cbd5e1; margin-top: 2px; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ---------------- Lock screen ---------------- */
.lock-wrap {
  min-height: calc(100vh - var(--topbar-h)); display: grid; place-items: center; padding: 30px 20px;
  background:
    radial-gradient(900px 480px at 15% -10%, rgba(79, 70, 229, 0.16), transparent 60%),
    radial-gradient(800px 420px at 100% 0%, rgba(37, 99, 235, 0.14), transparent 55%),
    var(--bg);
}
.lock-card {
  width: 100%; max-width: 640px; background: #fff; border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop 0.35s ease both;
}
.lock-banner {
  background: linear-gradient(135deg, #b91c1c, #dc2626); color: #fff; padding: 30px 30px 28px;
  position: relative; overflow: hidden;
}
.lock-banner::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.09);
}
.lock-icon {
  width: 62px; height: 62px; border-radius: 18px; background: rgba(255, 255, 255, 0.16);
  display: grid; place-items: center; margin-bottom: 18px; border: 1px solid rgba(255, 255, 255, 0.25);
}
.lock-icon svg { width: 30px; height: 30px; }
.lock-banner h1 { color: #fff; font-size: 23px; letter-spacing: -0.02em; }
.lock-banner p { color: rgba(255, 255, 255, 0.92); font-size: 14px; margin-top: 10px; max-width: 520px; }
.lock-body { padding: 28px 30px 30px; }
.lock-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.lock-meta > div { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; }
.lock-meta .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.lock-meta .v { font-weight: 700; margin-top: 5px; font-size: 15px; }
.renew-btn {
  width: 100%; justify-content: center; padding: 15px; font-size: 15px; border-radius: 12px;
  background: linear-gradient(135deg, var(--indigo), var(--blue)); color: #fff; border: 0;
  box-shadow: 0 18px 34px -16px rgba(79, 70, 229, 0.95);
}
.renew-btn:hover { filter: brightness(1.05); }
.pay-methods { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pay-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; font-weight: 600; }

/* ---------------- Result card ---------------- */
.result-shell { max-width: 900px; margin: 0 auto; }
.report {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.report-head {
  display: flex; align-items: center; gap: 18px; padding: 22px 26px;
  background: linear-gradient(135deg, #eef2ff, #eff6ff); border-bottom: 3px solid var(--indigo);
}
.report-logo {
  width: 74px; height: 74px; border-radius: 16px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--blue)); color: #fff;
  display: grid; place-items: center; box-shadow: 0 12px 24px -12px rgba(79, 70, 229, 0.9);
}
.report-logo svg { width: 38px; height: 38px; }
.report-school h2 { font-size: 20px; letter-spacing: -0.02em; }
.report-school .addr { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.report-school .tag { font-size: 11.5px; font-weight: 700; color: var(--indigo-700); margin-top: 6px; letter-spacing: 0.05em; text-transform: uppercase; }
.report-body { padding: 24px 26px; }
.report-title { text-align: center; margin-bottom: 20px; }
.report-title h3 { font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--indigo-700); }
.report-title p { color: var(--muted); font-size: 13px; margin-top: 3px; }

.bio { display: grid; grid-template-columns: 96px 1fr; gap: 18px; margin-bottom: 22px; }
.bio-photo {
  width: 96px; height: 110px; border-radius: 12px; background: var(--bg); border: 2px dashed var(--border-strong);
  display: grid; place-items: center; color: var(--muted-2);
}
.bio-photo svg { width: 34px; height: 34px; }
.bio-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; align-content: start; }
.bio-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--border-strong); padding-bottom: 6px; font-size: 13.5px; }
.bio-row .k { color: var(--muted); font-weight: 600; }
.bio-row .v { font-weight: 600; text-align: right; }

.result-shell h4.section {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: #334155;
  margin: 24px 0 12px; display: flex; align-items: center; gap: 8px;
}
.result-shell h4.section::after { content: ""; flex: 1; height: 1px; background: var(--border); }

table.report-table { width: 100%; border-collapse: collapse; font-size: 13.5px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.report-table th { background: #f8faff; text-align: left; padding: 10px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--border); }
table.report-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.report-table tr:last-child td { border-bottom: 0; }
table.report-table tfoot td { font-weight: 700; background: #f8faff; border-top: 2px solid var(--border-strong); }
.traits-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; }
.trait { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--border-strong); padding-bottom: 6px; font-size: 13.5px; }
.trait .rating { font-weight: 700; color: var(--indigo-700); }

.remarks { background: #f8faff; border: 1px solid var(--border); border-left: 4px solid var(--indigo); border-radius: 10px; padding: 14px 16px; font-size: 13.5px; color: #334155; }
.sign-row { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 30px; }
.sign { text-align: center; }
.sign .line { border-top: 1.5px solid #94a3b8; margin-bottom: 7px; height: 34px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; }
.sign .sig-name { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 19px; color: var(--indigo-700); }
.sign .role { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

.result-actions { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 16px; flex-wrap: wrap; }

.login-wrap { min-height: calc(100vh - var(--topbar-h)); display: grid; place-items: center; padding: 34px 20px; background:
    radial-gradient(900px 460px at 10% -10%, rgba(79, 70, 229, 0.14), transparent 60%),
    radial-gradient(760px 400px at 100% 0%, rgba(37, 99, 235, 0.12), transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 430px; background: #fff; border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 32px; animation: pop 0.3s ease both; }
.login-logo { width: 58px; height: 58px; border-radius: 16px; background: linear-gradient(135deg, var(--indigo), var(--blue)); color: #fff; display: grid; place-items: center; margin-bottom: 18px; box-shadow: 0 14px 26px -14px rgba(79, 70, 229, 0.95); }
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 22px; }
.pin-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
.demo-note { margin-top: 18px; background: var(--indigo-50); border: 1px dashed var(--indigo-100); color: var(--indigo-700); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; }
.demo-note strong { font-weight: 700; }

/* ---------------- Auth gateway ---------------- */
.topbar-auth-note {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.topbar-auth-note svg { width: 16px; height: 16px; color: var(--indigo); }

.user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--blue)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  box-shadow: 0 8px 16px -10px rgba(79, 70, 229, 0.9);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta span { font-weight: 700; font-size: 13.5px; }
.user-meta small { color: var(--muted); font-size: 12px; }

.auth-card { max-width: 470px; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.auth-brand .login-logo { margin-bottom: 0; }
.auth-brand h1 { font-size: 20px; }
.auth-brand .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.auth-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 13px;
  padding: 5px; margin-bottom: 22px;
}
.auth-tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 10px 6px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all 0.16s ease;
}
.auth-tab svg { width: 18px; height: 18px; }
.auth-tab:hover { color: var(--indigo-700); background: rgba(79, 70, 229, 0.06); }
.auth-tab.active { background: #fff; color: var(--indigo-700); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.label-short { display: none; }

.notice-block {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--amber-bg); border: 1px solid #fde68a;
  border-radius: 12px; padding: 14px 16px;
}
.notice-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center;
  background: rgba(180, 83, 9, 0.12); color: var(--amber);
}
.notice-icon svg { width: 20px; height: 20px; }
.notice-title { font-weight: 700; color: #92400e; font-size: 14px; }
.notice-text { color: #a16207; font-size: 13px; margin-top: 3px; }

/* ---------------- Misc components ---------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--muted-2); }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.progress { height: 8px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--indigo), var(--blue)); transition: width 0.4s ease; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; }
.mini-title { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 50;
    transform: translateX(-100%); transition: transform 0.26s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .page, .content { padding: 18px; }
  .brand-sub { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-3 { grid-template-columns: 1fr; }
  .stat-value { font-size: 24px; }
  .stat-icon { width: 38px; height: 38px; }
  .lock-meta { grid-template-columns: 1fr; }
  .bio { grid-template-columns: 1fr; }
  .bio-photo { margin: 0 auto; }
  .bio-grid, .traits-grid, .sign-row { grid-template-columns: 1fr; }
  .report-head { flex-direction: column; text-align: center; }
  .role-btn .label-full { display: none; }
  .top-actions .btn span { display: none; }
  .user-meta small { display: none; }
  .auth-tab { font-size: 11px; padding: 9px 4px; }
  .auth-tab svg { width: 16px; height: 16px; }
}
@media (max-width: 460px) {
  .stats-grid { grid-template-columns: 1fr; }
  .brand-name { font-size: 15px; }
  .role-switch { padding: 3px; }
  .role-btn { padding: 7px 10px; }
}

/* ---------------- Print (report card) ---------------- */
@media print {
  .topbar, .result-actions, .toast-root, .modal-backdrop { display: none !important; }
  body { background: #fff; }
  .app-root { padding: 0; }
  .page, .content { padding: 0; max-width: 100%; }
  .report { border: 1px solid #cbd5e1; box-shadow: none; border-radius: 0; }
  .report-head { background: #eef2ff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report, table.report-table { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 12mm; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ============================================================
   Student Enrollment & Lifecycle Management
   ============================================================ */
.code, code {
  font-family: "SFMono-Regular", "JetBrains Mono", "Consolas", ui-monospace, monospace;
  font-size: 0.86em;
  letter-spacing: 0.02em;
}
code {
  background: var(--indigo-50); color: var(--indigo-700); padding: 2px 7px;
  border-radius: 6px; font-weight: 600;
}
.cell-muted.code { color: var(--muted); background: none; padding: 0; }

.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.stat-card .stat-value { line-height: 1.1; }
.stat-card .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.badge-muted { background: var(--gray-bg); color: var(--muted); }

.input-inline { display: flex; gap: 8px; align-items: center; }
.input-inline .input { flex: 1; }

.genbanner {
  display: flex; gap: 10px; align-items: center; margin-bottom: 16px; padding: 11px 14px;
  background: var(--indigo-50); border: 1px solid var(--indigo-100); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--indigo-800);
}
.genbanner svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--indigo); }

.field-err { display: none; color: var(--red); font-size: 12px; margin-top: 5px; font-weight: 500; }
.field.has-error .field-err { display: block; }
.field.has-error .input, .field.has-error .select { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }

.profile-hero {
  display: flex; gap: 14px; align-items: center; padding: 16px;
  background: linear-gradient(135deg, var(--indigo-50), #fff); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 16px;
}
.profile-avatar {
  width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #3b82f6); color: #fff; font-weight: 800; font-size: 20px;
  flex-shrink: 0;
}
.profile-name { font-size: 18px; font-weight: 800; color: #0f172a; }
.profile-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.profile-id { text-align: right; }
.profile-id .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.profile-id .v { font-weight: 700; color: var(--indigo-700); margin-top: 3px; }

.cred-box {
  border: 1px dashed var(--indigo-100); background: #fbfcff; border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 8px;
}
.cred-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; color: var(--indigo-800); margin-bottom: 10px; }
.cred-head svg { width: 16px; height: 16px; }
.cred-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid #eef1f8; }
.cred-row:last-of-type { border-bottom: 0; }
.cred-row span { color: var(--muted); }
.cred-box .btn { margin-top: 12px; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.profile-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; background: var(--bg); border-radius: var(--radius-sm); }
.profile-item.span-2 { grid-column: 1 / -1; }
.profile-item .k { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.profile-item .v { font-weight: 600; font-size: 13.5px; color: #0f172a; }

.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini-stat { text-align: center; padding: 12px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.mini-stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.mini-stat .v { font-size: 19px; font-weight: 800; color: var(--indigo-700); margin-top: 4px; }

.history-table td, .history-table th { white-space: nowrap; }

@media (max-width: 720px) {
  .profile-grid, .mini-stats { grid-template-columns: 1fr 1fr; }
  .profile-hero { flex-wrap: wrap; }
  .profile-id { text-align: left; width: 100%; }
}

/* ============ Flexible subject tag input ============ */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  min-height: 44px;
}
.tag-input:focus-within { border-color: var(--indigo-500); box-shadow: 0 0 0 3px var(--indigo-50); }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--indigo-50);
  color: var(--indigo-700);
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--indigo-100);
}
.tag-x {
  display: inline-flex;
  border: none;
  background: transparent;
  color: var(--indigo-700);
  cursor: pointer;
  padding: 0;
  opacity: .65;
  line-height: 1;
}
.tag-x:hover { opacity: 1; }
.tag-entry {
  flex: 1;
  min-width: 130px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  color: var(--indigo-950);
  padding: 2px 0;
}
.tag-entry:focus { outline: none; }
.tag-entry::placeholder { color: var(--muted); }

/* ============ Bank transfer payment modal ============ */
.bank-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 6px;
  background: var(--bg);
}
.bank-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--indigo-50);
  color: var(--indigo-800);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.bank-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--indigo-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bank-inner { padding: 6px 16px 12px; }
.bank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.bank-row:last-child { border-bottom: none; }
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 22px 12px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.upload-zone:hover { border-color: var(--indigo-400); background: var(--indigo-50); }

/* ============ Pending payment banner ============ */
.pending-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1.5px solid #fde68a;
  background: var(--amber-bg);
  margin-bottom: 18px;
}
.pending-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.pending-banner-title { font-weight: 800; font-size: 14.5px; color: #92400e; }
.pending-banner-text { font-size: 13px; color: #92400e; opacity: .95; margin-top: 3px; }
.pending-banner .list-row {
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}

/* Approved assessment banner (green) */
.pending-banner.approved-banner {
  border-color: #bbf7d0;
  background: var(--green-bg);
}
.pending-banner.approved-banner .pending-banner-icon {
  background: #fff;
  color: var(--green);
}
.pending-banner.approved-banner .pending-banner-title,
.pending-banner.approved-banner .pending-banner-text {
  color: #166534;
}

/* ============ Extra button / badge helpers ============ */
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: transparent; }
.btn-danger:hover { background: #fecaca; }

/* ============ Class curriculum / add-class modal ============ */
.field-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ============ Lock screen bank transfer ============ */
.divider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 6px 0;
}
.divider-row::before, .divider-row::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.bank-btn { background: linear-gradient(135deg, #0e7490, #0891b2); color: #fff; }
.bank-btn:hover { opacity: .92; }
.bank-mini {
  margin-top: 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  padding: 14px 16px;
  text-align: left;
}
.bank-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 6px;
}
.bank-mini-head span { color: var(--green); font-size: 12px; }
.bank-mini-col {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13.5px;
  color: var(--indigo-950);
}
.bank-mini-col span { color: var(--muted); font-size: 12.5px; }
.renew-btn + .divider-row { margin-top: 16px; }

/* ============ Searchable class picker (Teacher Score Entry) ============ */
.class-field { position: relative; }
.class-combo {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
.class-field.open .class-combo,
.class-field.has-query .class-combo { display: block; }
.combo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--indigo-950);
  padding: 9px 12px;
  border-radius: 8px;
}
.combo-item:hover { background: var(--bg); }
.combo-item.active { background: var(--indigo-50); color: var(--indigo-700); }
.combo-current {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--indigo);
  font-weight: 800;
}
.combo-empty { padding: 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* ============ Lock screen — bank transfer only ============ */
.pay-method-label {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--indigo-700);
  margin-bottom: 10px;
}
.bank-card-lg { border-color: #c7d2fe; box-shadow: var(--shadow); }
.bank-verified {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--green);
}

/* ============ Report card principal field ============ */
.result-actions { align-items: flex-end; flex-wrap: wrap; }
.principal-field { margin: 0 auto 0 0; min-width: 230px; flex: 0 1 260px; text-align: left; }
.principal-field label { display: flex; gap: 6px; align-items: baseline; }
@media (max-width: 720px) {
  .principal-field { flex: 1 1 100%; margin: 0 0 4px; }
}

/* ============================================================
   CROSS-DEVICE COMPATIBILITY LAYER
   - Large laptop / desktop: spacious multi-column layouts
   - Tablet & mobile: responsive stacking, drawer navigation,
     sheet modals and horizontally scrollable data tables
   - Touch: comfortable 44px tap targets and mobile-friendly inputs
   ============================================================ */

/* ---------- Universal interaction niceties ---------- */
* { -webkit-tap-highlight-color: transparent; }
button, .btn, .icon-btn, .nav-item, .combo-item, .auth-tab, .role-btn, .tag-x, .close-x {
  touch-action: manipulation;
}
svg { flex-shrink: 0; }

/* Safe-area aware chrome (notched phones / tablets) */
.topbar {
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
}
.toast-root {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
}
.login-wrap, .lock-wrap {
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(30px, env(safe-area-inset-bottom));
}

/* ---------- Tooltips for action buttons ---------- */
.app-tip {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  transform: translate(-50%, -100%);
  background: #0f172a;
  color: #f8fafc;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.12s ease both;
  max-width: 260px;
}
.app-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #0f172a;
}

/* ---------- Large laptop / desktop optimisation ---------- */
@media (min-width: 1440px) {
  body { font-size: 15.5px; }
  .page { max-width: 1440px; padding: 32px; }
  .content { padding: 32px; }
  .content-inner { max-width: 1320px; }
  .sidebar { width: 288px; }
  .grid { gap: 22px; }
  .card { padding: 24px; }
  .stat-value { font-size: 32px; }
  table.data { min-width: 0; }
  table.data thead th, table.data tbody td { padding-left: 24px; padding-right: 24px; }
  .two-col { grid-template-columns: 1.7fr 1fr; }
}
@media (min-width: 1800px) {
  .page { max-width: 1640px; }
  .content-inner { max-width: 1480px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 24px; }
}
/* Hover feedback only where a real pointer exists */
@media (hover: hover) and (pointer: fine) {
  .stat { transition: box-shadow 0.2s ease, transform 0.2s ease; }
  .stat:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
  .nav-item:hover { transform: translateX(2px); }
  .btn:hover { transform: translateY(-1px); }
  .card-head .icon-btn:hover svg, .row-actions .icon-btn:hover svg { transform: scale(1.08); }
  .icon-btn svg { transition: transform 0.14s ease; }
}

/* ---------- Tablet & mobile stacking ---------- */
@media (max-width: 1024px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar {
    width: min(86vw, 320px);
    max-width: 86vw;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-lg);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .sidebar-backdrop { backdrop-filter: blur(1px); }
  .brand-sub { display: none; }
}
body.nav-open { overflow: hidden; }

@media (max-width: 720px) {
  .input-group { flex-direction: column; }
  .input-group > .field { flex: 1 1 auto; }
  .toolbar { gap: 10px; }
  .toolbar .field { flex: 1 1 100%; min-width: 0; }
  .page-head { gap: 12px; }
  .page-head h1 { font-size: 21px; }
  .result-actions { justify-content: stretch; }
  .result-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 640px) {
  .topbar { gap: 10px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .page, .content { padding: 14px; }
  .card { padding: 16px; border-radius: 14px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .card-pad-0 .card-head { padding: 14px 16px; }
  table.data thead th, table.data tbody td { padding: 11px 14px; font-size: 13.5px; }
  .stat-value { font-size: 26px; }
  .user-avatar { width: 34px; height: 34px; }
  .role-btn { padding: 8px 11px; }
  /* Mobile-friendly inputs: 16px prevents iOS auto-zoom */
  .input, .select, textarea.input, .tag-entry { font-size: 16px; }
}
@media (max-width: 420px) {
  .stats-grid, .mini-stats, .profile-grid { grid-template-columns: 1fr; }
  .auth-tabs { grid-template-columns: repeat(2, 1fr); }
  .auth-tab { font-size: 12px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .page-head-actions { width: 100%; }
  .page-head-actions .btn { flex: 1 1 auto; }
}

/* ---------- Sheet modals on small screens ---------- */
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: end; }
  .modal {
    max-width: 100%;
    border-radius: 22px 22px 0 0;
    max-height: 94vh;
    max-height: 94dvh;
    animation: sheetUp 0.28s cubic-bezier(0.22, 0.61, 0.36, 1) both;
  }
  .modal-head { padding: 20px 18px 4px; }
  .modal-body { padding: 14px 18px 8px; }
  .modal-foot {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  }
  .close-x { width: 40px; height: 40px; }
}
@keyframes sheetUp {
  from { transform: translateY(100%); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

/* ---------- Horizontally scrollable data tables ---------- */
.table-wrap {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
  /* Freeze the first (identity) column so it stays visible while scrolling */
  table.data.sticky-col th:first-child,
  table.data.sticky-col td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 1px 0 0 var(--border);
  }
  table.data.sticky-col thead th:first-child { background: #fbfcfe; z-index: 3; }
  table.data.sticky-col tbody tr:hover td:first-child { background: #fafbff; }

  /* Broadsheet: freeze the student name column, drop the row-number column */
  table.data.broadsheet th.col-idx,
  table.data.broadsheet td.col-idx { display: none; }
  table.data.broadsheet td.col-name,
  table.data.broadsheet th.col-name {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 1px 0 0 var(--border);
  }
  table.data.broadsheet thead th.col-name { background: #fbfcfe; z-index: 3; }

  /* Report card keeps its own scroll container on small screens */
  table.report-table { min-width: 540px; }
  .report-body { padding: 18px 16px; }
  .report-head { padding: 18px; }
}

/* ---------- Touch-friendly tap targets ---------- */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .nav-item { min-height: 50px; }
  .close-x { width: 42px; height: 42px; }
  .input, .select, textarea.input { min-height: 46px; }
  .tag-input { min-height: 50px; }
  .tag-x { padding: 6px; margin: -6px; }
  .auth-tab { min-height: 56px; }
  .combo-item { min-height: 46px; }
  .score-input {
    min-height: 44px !important;
    max-width: 92px !important;
    font-size: 16px;
    text-align: center;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Teacher result entry — mode tabs + bulk upload view
   ============================================================ */
.seg-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: var(--gray-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 18px;
}
.seg-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.seg-tab svg { width: 16px; height: 16px; }
.seg-tab:hover { color: var(--text); }
.seg-tab.active {
  background: #fff;
  color: var(--indigo-700);
  box-shadow: var(--shadow-sm);
}

.upload-drop {
  display: block;
  text-align: center;
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 30px 22px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.upload-drop:hover { border-color: var(--indigo); background: var(--indigo-50); }
.upload-drop .stat-icon { display: inline-flex; }

.upload-steps { display: grid; gap: 10px; margin-top: 18px; }
.upload-step { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; color: var(--text); }
.upload-step .n {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--indigo-50);
  color: var(--indigo-700);
  font-weight: 700;
  font-size: 12px;
}
.upload-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

@media (max-width: 640px) {
  .seg-tabs { display: flex; width: 100%; }
  .seg-tab { flex: 1 1 0; justify-content: center; }
  .upload-actions .btn { flex: 1 1 100%; }
}
@media (pointer: coarse) {
  .seg-tab { min-height: 44px; }
}

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 4px; }

/* ===================== Global page loader ===================== */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(246, 247, 252, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.page-loader.show { display: flex; opacity: 1; visibility: visible; }
.page-loader.hide { opacity: 0; visibility: hidden; }
.page-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 34px;
  background: #ffffff;
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  animation: page-loader-pop 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes page-loader-pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.page-loader-spinner { width: 52px; height: 52px; }
.page-loader-track { stroke: #e2e8f0; }
.page-loader-dash {
  stroke: linear-gradient(135deg, #4f46e5, #06b6d4);
  stroke: url(#loaderGrad);
  stroke: #4f46e5;
  stroke-dasharray: 1 200;
  animation: page-loader-spin 0.7s linear infinite;
  transform-origin: 25px 25px;
  transform-box: fill-box;
}
.page-loader-dash { stroke: #4f46e5; }
@keyframes page-loader-spin {
  to { transform: rotate(360deg); }
}
.page-loader-text {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.02em;
}
