/* ==========================================================================
   Student List System — Design System & Responsive Stylesheet (v2)
   --------------------------------------------------------------------------
   Mobile-first. Works on phones (incl. iPhone notch / Dynamic Island), foldables,
   tablets & iPad (portrait + landscape), laptops, desktops and ultra-wide / 4K.

   Layout by viewport width
     < 600px        Phone      → bottom tab bar, cards, bottom-sheet modals
     600 – 1023px   Tablet     → compact icon rail sidebar, 2-col cards
     1024 – 1439px  Laptop     → full sidebar, data tables
     1440 – 1919px  Desktop    → wider content area
     >= 1920px      Large / 4K → scaled typography & spacing

   Notes
     • This file is CSS-only. JS toggles inline `display` on #mobile-bottom-nav,
       #auth-container and #main-app-container, so rules touching those elements
       are written to cooperate with inline styles (no !important "show" rules).
   ========================================================================== */

/* ==========================================================================
   1. DESIGN TOKENS
   ========================================================================== */
:root {
  color-scheme: light;

  /* Surfaces & borders */
  --bg-primary: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-secondary: #eef2f7;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --header-bg: rgba(255, 255, 255, 0.85);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Brand */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-text: #1e40af;

  /* Status colours */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #166534;

  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;

  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;

  --info: #0284c7;
  --info-bg: #e0f2fe;
  --info-text: #075985;

  --locked-bg: #f8fafc;
  --locked-border: #cbd5e1;

  /* Typography (Inter + Noto Sans Bengali fallback for Bangla names) */
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Noto Sans Bengali', 'SolaimanLipi', 'Helvetica Neue', Arial, sans-serif;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.12), 0 2px 6px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.25), 0 8px 16px -8px rgba(15, 23, 42, 0.15);
  --ring: 0 0 0 3px rgba(59, 130, 246, 0.25);

  /* Sizing */
  --touch-target: 44px;
  --header-h: 60px;
  --bottom-nav-h: 62px;
  --sidebar-w: 252px;
  --rail-w: 76px;
  --content-max: 1400px;
  --page-pad: 1rem;

  /* Safe areas (iPhone notch / home bar, foldables) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Select arrow (light) */
  --select-arrow: 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%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg-primary: #0b0f19;
  --bg-surface: #131b2e;
  --bg-surface-hover: #1b2640;
  --bg-secondary: #1b2640;
  --border-color: #2a3750;
  --border-focus: #60a5fa;
  --header-bg: rgba(19, 27, 46, 0.85);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a5f;
  --primary-text: #93c5fd;

  --success: #22c55e;
  --success-bg: #143823;
  --success-text: #86efac;

  --warning: #f59e0b;
  --warning-bg: #3d2c0d;
  --warning-text: #fde68a;

  --danger: #ef4444;
  --danger-bg: #3b181a;
  --danger-text: #fca5a5;

  --info: #38bdf8;
  --info-bg: #0c334e;
  --info-text: #bae6fd;

  --locked-bg: #0d1322;
  --locked-border: #233048;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 3px rgba(96, 165, 250, 0.3);

  --select-arrow: 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='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ==========================================================================
   2. BASE & RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  /* Propagates to the viewport – prevents horizontal scroll WITHOUT breaking sticky */
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  /* iOS rubber-band / pull-to-refresh friendliness */
  overscroll-behavior-y: none;
}

img, svg, video { max-width: 100%; height: auto; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { touch-action: manipulation; }

a { color: var(--primary); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-secondary);
  padding: 0.1em 0.4em;
  border-radius: 6px;
}

small { font-size: 0.8em; }

::selection { background: var(--primary-light); color: var(--primary-text); }

/* Lock page scroll while a modal is open (modern browsers; harmless elsewhere) */
body:has(.modal-backdrop[style*="display: flex"]) { overflow: hidden; }

.text-danger { color: var(--danger); }

/* ==========================================================================
   3. APP SHELL
   ========================================================================== */
#app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

/* ---------- Top header ---------- */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) max(var(--page-pad), var(--safe-right)) 0 max(var(--page-pad), var(--safe-left));
  background-color: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--primary);
  text-decoration: none;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-light), var(--bg-secondary));
  color: var(--primary-text);
  border-radius: 10px;
  font-size: 1.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
  min-width: 0;
}

/* ---------- Icon buttons ---------- */
.btn-icon {
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-icon:active { transform: scale(0.94); }

.btn-icon:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ---------- User badge & role tags ---------- */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.3rem 0.4rem 0.3rem 0.8rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

.user-badge > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 22ch;
}

.role-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.role-user        { background-color: var(--bg-surface); color: var(--text-secondary); border: 1px solid var(--border-color); }
.role-admin       { background-color: var(--warning-bg); color: var(--warning-text); }
.role-super-admin { background-color: var(--danger-bg);  color: var(--danger-text); }

/* ---------- App container (sidebar + content) ---------- */
.app-container {
  display: flex;
  flex: 1;
  position: relative;
  min-width: 0;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  flex: none;
  width: var(--sidebar-w);
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  align-self: flex-start;
  height: calc(100vh - var(--header-h) - var(--safe-top));
  height: calc(100dvh - var(--header-h) - var(--safe-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem calc(1rem + var(--safe-bottom));
  padding-left: max(0.75rem, var(--safe-left));
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  scrollbar-width: thin;
}

.nav-section-title {
  padding: 1rem 0.85rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: var(--touch-target);
  padding: 0.55rem 0.85rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.92rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-item > span:first-child { flex: none; font-size: 1.1rem; line-height: 1; }

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary-text);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.75rem;
  top: 22%;
  bottom: 22%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.nav-item-logout { color: var(--danger) !important; font-weight: 600; }
.nav-item-logout:hover {
  background-color: var(--danger-bg) !important;
  color: var(--danger-text) !important;
}

/* ---------- Main content ---------- */
.app-content {
  flex: 1 1 0;
  min-width: 0;                 /* lets wide tables scroll inside their wrapper instead of stretching the page */
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.25rem max(var(--page-pad), var(--safe-right)) calc(1.5rem + var(--safe-bottom)) max(var(--page-pad), var(--safe-left));
}

.view-panel { animation: viewIn 260ms ease-out; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Bottom nav (phones) ---------- */
.bottom-nav {
  display: none;   /* shown by JS (inline) after login, and only below 600px — see media queries */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background-color: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: var(--bottom-nav-h);
}

.bottom-nav-item {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.bottom-nav-item > span:first-child { font-size: 1.3rem; line-height: 1; }

.bottom-nav-item > span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav-item:active { background-color: var(--bg-surface-hover); }

.bottom-nav-item.active { color: var(--primary); font-weight: 700; }

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
}

.bottom-nav-logout { color: var(--danger) !important; font-weight: 600; }
.bottom-nav-logout:active { background-color: var(--danger-bg); }

/* ==========================================================================
   4. TYPOGRAPHY & PAGE HEADERS
   ========================================================================== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.page-header > div:first-child { min-width: 0; flex: 1 1 260px; }

.page-title {
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.page-subtitle {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==========================================================================
   5. BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--touch-target);
  padding: 0.5rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.btn:active { transform: scale(0.98); }

.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3); }

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) { background-color: var(--bg-surface-hover); border-color: var(--text-muted); }

.btn-danger { background-color: var(--danger); color: #ffffff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch-target);
  padding: 0.4rem 0.9rem;
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-logout:hover,
.btn-logout:focus-visible {
  background-color: var(--danger);
  color: #ffffff;
  outline: none;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}

.btn-sm { min-height: 38px; padding: 0.3rem 0.85rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ==========================================================================
   6. FORMS
   ========================================================================== */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  min-height: var(--touch-target);
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.75; }

.form-control:hover,
.form-select:hover { border-color: var(--text-muted); }

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.form-control:disabled,
.form-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--bg-secondary);
}

textarea.form-control {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.5;
}

.form-select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.4rem;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 16px;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
}

/* Input + inline button rows used in the sign-up / reset forms */
.form-group > div[style*="display:flex"] { align-items: stretch; }
.form-group > div[style*="display:flex"] > .form-control { flex: 1 1 auto; min-width: 0; }
.form-group > div[style*="display:flex"] > .btn { flex: none; }

/* ==========================================================================
   7. CARDS & FILTER BAR
   ========================================================================== */
.card {
  margin-bottom: 1.25rem;
  padding: 1.1rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-title {
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.filter-bar > div { min-width: 0; }
.filter-bar > div[style*="min-width"] { flex: 1 1 140px; }

.search-input-wrap {
  position: relative;
  flex: 1 1 220px;
}

/* ==========================================================================
   8. TABLES
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  /* Edge shadows that appear only when there is more content to scroll to */
  background-image:
    linear-gradient(to right, var(--bg-surface) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to left,  var(--bg-surface) 30%, rgba(255, 255, 255, 0)),
    radial-gradient(farthest-side at 0 50%,    rgba(15, 23, 42, 0.18), rgba(15, 23, 42, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, 0.18), rgba(15, 23, 42, 0));
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
  scrollbar-width: thin;
}

/* A table inside a card should not double its border */
.card > .table-responsive { border-radius: var(--radius-md); }

.table {
  width: 100%;
  min-width: 620px;           /* keeps columns readable; the wrapper scrolls on narrow screens */
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.table th {
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.table td > div[style*="display:flex"] { flex-wrap: wrap; }

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color var(--transition-fast); }
.table tbody tr:hover { background-color: var(--bg-surface-hover); }

/* Loading skeleton inside table cells shouldn't be squeezed */
.table td > .skeleton { min-width: 160px; }

/* ==========================================================================
   9. STUDENT CARDS (phone / tablet) & BADGES
   ========================================================================== */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: 0.9rem;
}

.student-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 1.1rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.student-card:active { transform: scale(0.99); }

.student-card-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.student-avatar {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: var(--primary-light);
  color: var(--primary-text);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 1.2rem;
  font-weight: 700;
}

.student-avatar img { width: 100%; height: 100%; object-fit: cover; }

.student-info { min-width: 0; }

.student-info h4 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.student-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.badge-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.locked-field-box {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--locked-bg);
  border: 1px dashed var(--locked-border);
  border-radius: var(--radius-md);
  text-align: center;
}

.locked-icon { margin-bottom: 0.25rem; font-size: 1.5rem; }

#students-pagination {
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ==========================================================================
   10. MODALS  (centered dialog ≥ 600px, bottom sheet on phones)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
  background-color: rgba(8, 12, 24, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overscroll-behavior: contain;
}

.modal-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms ease-out;
}

.modal-dialog-lg { max-width: 900px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes sheetIn {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

.modal-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-body {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   11. TOASTS & SKELETON
   ========================================================================== */
#toast-container {
  position: fixed;
  right: max(16px, var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 260px;
  max-width: 420px;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideUp 200ms ease-out;
}

.toast > span { min-width: 0; overflow-wrap: anywhere; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.toast-success { background-color: var(--success); }
.toast-error   { background-color: var(--danger); }
.toast-info    { background-color: var(--info); }
.toast-warning { background-color: var(--warning); color: #000; }

.skeleton {
  height: 20px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-surface-hover) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeletonPulse 1.5s infinite;
}

@keyframes skeletonPulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   12. AUTH SCREEN
   ========================================================================== */
.auth-wrapper {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  min-height: calc(100vh - var(--header-h) - var(--safe-top));
  min-height: calc(100dvh - var(--header-h) - var(--safe-top));
  place-items: center;                       /* `display:grid` is applied inline by JS */
  padding: 1.25rem max(1rem, var(--safe-right)) calc(1.25rem + var(--safe-bottom)) max(1rem, var(--safe-left));
  background:
    radial-gradient(60rem 30rem at 15% -10%, var(--primary-light), transparent 60%),
    radial-gradient(50rem 28rem at 110% 110%, var(--bg-secondary), transparent 60%),
    var(--bg-primary);
}

.auth-card {
  width: 100%;
  min-width: 0;
  max-width: 460px;
  padding: 1.5rem 1.25rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}

.auth-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  padding: 4px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.auth-tab {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 0.45rem 0.4rem;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-tab:hover { color: var(--text-primary); }

.auth-tab.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.auth-tab:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

/* ==========================================================================
   13. RESPONSIVE — PHONES  (< 600px: iPhone, Android, foldables)
   ========================================================================== */
@media (max-width: 599.98px) {
  :root { --header-h: 56px; }

  .brand { font-size: 0.98rem; }
  .brand-icon { width: 30px; height: 30px; font-size: 1rem; }
  .brand span { max-width: 34vw; }

  .header-actions { gap: 0.35rem; }
  .btn-icon { min-width: 40px; min-height: 40px; }
  .user-badge { padding: 0.2rem 0.3rem 0.2rem 0.6rem; font-size: 0.75rem; }
  .user-badge > span:first-child { max-width: 11ch; }

  /* Logout lives in the bottom tab bar on phones; hiding the header copy keeps the header uncluttered.
     !important is required because JS shows it with an inline display value. */
  .btn-logout { display: none !important; }

  /* Sidebar is replaced by the bottom tab bar (JS reveals it after login) */
  .app-sidebar { display: none !important; }

  .app-content {
    padding-top: 1rem;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 1.25rem);
  }

  /* Stack page-header actions full width for easy thumb reach */
  .page-header > .btn,
  .page-header > div[style*="display:flex"] { width: 100%; }
  .page-header > div[style*="display:flex"] > .btn { flex: 1 1 0; }

  .filter-bar { flex-direction: column; gap: 0.6rem; padding: 0.75rem; }
  .filter-bar > div,
  .filter-bar > div[style*="min-width"] { flex: 0 0 auto; width: 100%; min-width: 0; }

  /* Inline "input + button" rows wrap neatly on narrow screens */
  .form-group > div[style*="display:flex"] { flex-wrap: wrap; }
  .form-group > div[style*="display:flex"] > .btn { flex: 1 1 100%; }

  /* Bottom-sheet modals */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-dialog,
  .modal-dialog-lg {
    max-width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    animation: sheetIn 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .modal-header { position: relative; padding: 1.1rem 1rem 0.8rem; }
  .modal-header::before {            /* grab handle */
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    width: 38px;
    height: 4px;
    margin-left: -19px;
    border-radius: 4px;
    background: var(--border-color);
  }
  .modal-body { padding: 1rem; }
  .modal-footer {
    padding: 0.8rem 1rem calc(0.8rem + var(--safe-bottom));
    flex-direction: column-reverse;
  }
  .modal-footer > .btn { width: 100%; }

  /* Toasts span the width, above the bottom nav */
  #toast-container {
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
    max-width: none;
  }
  .toast { min-width: 0; max-width: none; width: 100%; }

  .auth-wrapper { align-items: start; padding-top: 1.25rem; width: 100%; min-width: 0; overflow-x: hidden; }
  .auth-card { width: 100%; min-width: 0; max-width: 100%; padding: 1.25rem 0.85rem; border-radius: 18px; }
  .auth-tab { font-size: 0.78rem; padding: 0.45rem 0.25rem; }

  .card { padding: 1rem; border-radius: var(--radius-md); }
  .student-card { padding: 1rem; }
}

/* Narrow phones (≤ 480px): compact tabs & role tag */
@media (max-width: 480px) {
  .user-badge > span:first-child { display: none; }
  .user-badge { padding-left: 0.3rem; }
  .auth-card { padding: 1.15rem 0.65rem; }
  .auth-tab { font-size: 0.74rem; padding: 0.4rem 0.15rem; }
}

/* Very small phones (≤ 380px: iPhone SE / mini, Galaxy Fold cover screen) */
@media (max-width: 380px) {
  html { font-size: 14px; }
  .auth-card { padding: 1rem 0.5rem; }
  .auth-tab { font-size: 0.70rem; padding: 0.35rem 0.1rem; }
  .bottom-nav-item { font-size: 0.62rem; }
  .bottom-nav-item > span:first-child { font-size: 1.2rem; }
}

/* ==========================================================================
   14. RESPONSIVE — TABLETS & iPad  (600px – 1023px)
   ========================================================================== */
@media (min-width: 600px) {
  :root { --page-pad: 1.5rem; }

  .bottom-nav { display: none !important; }

  .app-sidebar {
    width: var(--rail-w);
    padding: 0.75rem 0.5rem calc(0.75rem + var(--safe-bottom));
    padding-left: max(0.5rem, var(--safe-left));
    align-items: stretch;
  }

  /* Compact icon-only rail */
  .nav-text,
  .nav-section-title { display: none; }

  .nav-item {
    justify-content: center;
    min-height: 48px;
    padding: 0.7rem 0;
  }
  .nav-item > span:first-child { font-size: 1.3rem; }
  .nav-item.active::before { left: -0.5rem; }

  .sidebar-footer { padding-top: 0.75rem; }

  .app-content { padding-top: 1.5rem; }

  .auth-card { padding: 2rem 1.75rem; }
  .auth-tab { font-size: 0.88rem; }

  .modal-dialog { max-width: min(600px, 92vw); }
  .modal-dialog-lg { max-width: min(900px, 94vw); }
  .modal-footer > .btn { min-width: 110px; }
}

/* Large phones / small tablets (600–767px): icon-only logout keeps the header on one line */
@media (min-width: 600px) and (max-width: 767.98px) {
  .logout-btn-text { display: none; }
  .btn-logout { padding: 0.3rem 0.7rem; }
}

/* Student list: cards below 1024px, table from 1024px up */
.table-desktop-view { display: none !important; }
.cards-mobile-view  { display: grid !important; }

/* ==========================================================================
   15. RESPONSIVE — LAPTOP  (≥ 1024px: iPad landscape / Pro, laptops)
   ========================================================================== */
@media (min-width: 1024px) {
  :root { --page-pad: 2rem; }

  .app-sidebar {
    width: var(--sidebar-w);
    padding: 1rem 0.75rem calc(1rem + var(--safe-bottom));
    padding-left: max(0.75rem, var(--safe-left));
  }

  /* No !important here: inline `display:none` set by JS on role-gated headings must still win */
  .nav-text { display: inline; }
  .nav-section-title { display: block; }

  .nav-item { justify-content: flex-start; min-height: var(--touch-target); padding: 0.55rem 0.85rem; }
  .nav-item > span:first-child { font-size: 1.1rem; }
  .nav-item.active::before { left: -0.75rem; }

  .table-desktop-view { display: block !important; }
  .cards-mobile-view  { display: none !important; }

  .app-content { padding-top: 1.75rem; }
  .card { padding: 1.25rem; }
}

/* Mouse / trackpad only: hover lift on cards */
@media (hover: hover) and (pointer: fine) {
  .student-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
  }
}

/* ==========================================================================
   16. RESPONSIVE — DESKTOP & LARGE DISPLAYS
   ========================================================================== */
@media (min-width: 1440px) {
  :root { --content-max: 1600px; --sidebar-w: 270px; --page-pad: 2.5rem; }
  .table { font-size: 0.92rem; }
}

@media (min-width: 1920px) {
  html { font-size: 16px; }
  :root { --content-max: 1800px; --sidebar-w: 290px; --header-h: 68px; }
  .student-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
}

@media (min-width: 2560px) {
  html { font-size: 18px; }
  :root { --content-max: 2200px; --sidebar-w: 310px; --header-h: 72px; }
}

/* ==========================================================================
   17. DEVICE-SPECIFIC POLISH
   ========================================================================== */

/* Touch devices (phones + iPad, any width): prevent iOS focus-zoom & enlarge targets */
@media (pointer: coarse) {
  input, select, textarea,
  .form-control, .form-select { font-size: 16px; }

  .btn-sm { min-height: 42px; }
  .nav-item, .bottom-nav-item, .auth-tab { -webkit-user-select: none; user-select: none; }
  input[type="checkbox"], input[type="radio"] { width: 1.35rem; height: 1.35rem; }
}

/* Landscape phones / short viewports: reclaim vertical space */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --header-h: 48px; --bottom-nav-h: 50px; }
  .top-header { gap: 0.5rem; }
  .btn-icon, .btn-logout { min-height: 36px; }
  .app-content { padding-top: 0.75rem; }
  .page-header { margin-bottom: 0.75rem; }
  .bottom-nav-item { flex-direction: row; gap: 6px; font-size: 0.72rem; }
  .bottom-nav-item > span:first-child { font-size: 1.1rem; }
  .bottom-nav-item.active::before { left: 15%; right: 15%; }
  .modal-dialog, .modal-dialog-lg { max-height: 100vh; max-height: 100dvh; }
  .modal-backdrop { align-items: center; padding: max(0.5rem, var(--safe-top)) max(0.5rem, var(--safe-right)) max(0.5rem, var(--safe-bottom)) max(0.5rem, var(--safe-left)); }
  .modal-dialog, .modal-dialog-lg { border-radius: var(--radius-lg); border-bottom: 1px solid var(--border-color); }
  .auth-wrapper { align-items: start; }
}

/* High-contrast / forced colours */
@media (forced-colors: active) {
  .btn, .form-control, .form-select, .card, .student-card, .modal-dialog { border: 1px solid CanvasText; }
  .nav-item.active, .bottom-nav-item.active { outline: 2px solid Highlight; }
}

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

/* Print: content only */
@media print {
  .top-header, .app-sidebar, .bottom-nav, #toast-container, .modal-backdrop, .filter-bar, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .app-content { max-width: none; padding: 0; }
  .card, .table-responsive { box-shadow: none; border-color: #ccc; }
  .table { min-width: 0; }
}

/* ==========================================================================
   18. ANIMATED OTP INPUT  (6-digit verification code — see js/otp.js)
   Look & motion modelled on Otp.html, themed with the app's design tokens.
   ========================================================================== */
.otp-widget {
  --otp-brand: #6d5bd0;
  --otp-brand2: #9b8ce6;
  --otp-ok: #19b87a;
  --otp-ok2: #43e0a6;
  --otp-okline: #bfe9d8;
  --otp-tile-bg: var(--bg-surface, #ffffff);
  --otp-tile-border: var(--border-color, #e4e1f2);
  --otp-tile-shadow: 0 4px 14px rgba(109, 91, 208, 0.10);
  position: relative;
  width: 100%;
}
[data-theme="dark"] .otp-widget {
  --otp-brand: #a99cf5;
  --otp-brand2: #7a69dd;
  --otp-okline: #1f5f4b;
  --otp-tile-bg: var(--bg-secondary, #1a1730);
  --otp-tile-border: #34305a;
  --otp-tile-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.otp-stage {
  position: relative;
  height: var(--otp-idle, 84px);
  margin-top: 4px;
  transition: height 0.45s cubic-bezier(0.3, 0.9, 0.3, 1);
}
.otp-stage.busy { height: var(--otp-busy, 184px); }

/* The real <input>: invisible, covers the stage, receives keyboard / paste / autofill */
.otp-capture {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  cursor: text;
  font-size: 16px;               /* keeps iOS from zooming on focus */
  caret-color: transparent;
}
.otp-stage.busy .otp-capture { pointer-events: none; }

/* Digit tiles */
.otp-tile {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--otp-w, 44px);
  height: var(--otp-h, 52px);
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--otp-tile-bg);
  border: 1.5px solid var(--otp-tile-border);
  box-shadow: var(--otp-tile-shadow);
  color: var(--text-primary);
  font-size: calc(var(--otp-w, 44px) * 0.5);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  will-change: transform;
  transition: transform 0.8s cubic-bezier(0.3, 0.9, 0.3, 1), opacity 0.6s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.otp-tile.free { transition: opacity 0.25s, border-color 0.2s, box-shadow 0.2s; }   /* while JS drives the motion */
.otp-tile.filled { border-color: var(--otp-brand); }
.otp-tile.active { border-color: var(--otp-brand2); box-shadow: 0 0 0 4px rgba(109, 91, 208, 0.14), var(--otp-tile-shadow); }
.otp-tile.active:empty::after {
  content: "";
  width: 1.5px;
  height: calc(var(--otp-h, 52px) * 0.46);
  background: var(--otp-brand);
  animation: otp-blink 1s steps(2) infinite;
}
@keyframes otp-blink { 50% { opacity: 0; } }

.otp-widget.complete .otp-tile { border-color: var(--otp-ok); }
.otp-widget.error .otp-tile { border-color: var(--danger); color: var(--danger); }

/* Orbit path shown while tiles circle */
.otp-path {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 1.5px dashed var(--otp-brand2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.otp-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }

/* Verifying ring */
.otp-ring {
  position: relative;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--otp-tile-border);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.5s, transform 0.5s;
}
.otp-ring.on { opacity: 1; transform: none; }
.otp-ring.pop { animation: otp-ringpop 0.7s cubic-bezier(0.3, 1.5, 0.5, 1); }
.otp-ring.out { opacity: 0; transform: scale(0.55); transition: opacity 0.35s, transform 0.38s cubic-bezier(0.6, 0, 0.9, 0.4); }
@keyframes otp-ringpop {
  0%   { transform: scale(0.9); }
  50%  { transform: scale(1.1); box-shadow: 0 0 0 14px rgba(109, 91, 208, 0.12); }
  100% { transform: none; }
}
.otp-ring svg { position: absolute; inset: 11px; width: 70px; height: 70px; transform: rotate(-90deg); }
.otp-arc {
  transition: stroke-dashoffset 0.15s ease-out;
}
.otp-ring .otp-dot { position: absolute; inset: 0; border-radius: 50%; animation: otp-spin 2s linear infinite; }
.otp-ring .otp-dot::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--otp-brand2);
  box-shadow: 0 0 8px var(--otp-brand2);
}
@keyframes otp-spin { to { transform: rotate(360deg); } }
.otp-num {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--otp-tile-bg);
  border: 1px solid var(--otp-tile-border);
  color: var(--otp-brand);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* Success orb + check + badge */
.otp-orb {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
  background: radial-gradient(circle at 35% 30%, var(--otp-ok2), var(--otp-ok));
  box-shadow: 0 0 70px 24px rgba(25, 184, 122, 0.35);
  transition: opacity 0.6s, transform 0.7s cubic-bezier(0.3, 1.4, 0.4, 1), width 0.6s, height 0.6s, box-shadow 0.6s;
}
.otp-orb.on { opacity: 1; transform: none; animation: otp-pulse 1.6s ease-in-out infinite; }
.otp-orb.check {
  width: 60px;
  height: 60px;
  animation: none;
  box-shadow: 0 0 0 9px rgba(25, 184, 122, 0.14), 0 0 0 18px rgba(25, 184, 122, 0.07);
}
@keyframes otp-pulse { 50% { box-shadow: 0 0 90px 34px rgba(25, 184, 122, 0.42); } }
.otp-orb svg { width: 28px; height: 28px; opacity: 0; transition: opacity 0.3s 0.3s; }
.otp-orb.check svg { opacity: 1; }
.otp-orb path {
  stroke: #fff;
  stroke-width: 3.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}
.otp-orb.check path { animation: otp-draw 0.5s 0.35s forwards; }
@keyframes otp-draw { to { stroke-dashoffset: 0; } }

.otp-badge {
  position: absolute;
  left: 50%;
  top: calc(50% + 58px);
  padding: 5px 14px;
  border-radius: 99px;
  background: var(--otp-ok);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.4s 0.5s, transform 0.4s 0.5s;
}
.otp-badge.on { opacity: 1; transform: translate(-50%, 0); }

/* Celebration effects */
.otp-fx { position: absolute; left: 50%; top: 50%; pointer-events: none; border-radius: 50%; }
.otp-ripple { width: 84px; height: 84px; border: 2px solid var(--otp-ok2); }
.otp-spark { background: var(--otp-ok2); box-shadow: 0 0 8px var(--otp-ok2); }

/* Status line under the tiles */
.otp-status {
  min-height: 1.4em;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
  color: var(--text-muted);
}
.otp-status[data-kind="ok"]    { color: var(--otp-ok); font-weight: 600; }
.otp-status[data-kind="error"] { color: var(--danger-text);  font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .otp-tile, .otp-ring, .otp-orb, .otp-badge, .otp-stage { transition-duration: 0.01ms !important; }
  .otp-tile.active:empty::after { animation: none; }
}
