/* ==========================================================================
   School HRMS — design system ("glass / aurora")
   Dark-first; light theme via <html data-theme="light">.
   Also restyles the legacy class names (.card, .btn, .chip, .list-item,
   .badge-*, .sheet-overlay, .tab-btn, .empty-state…) that page scripts
   render, so converted pages keep working without JS changes.
   ========================================================================== */

/* ---------------- Tokens ---------------- */

:root {
  color-scheme: dark;

  --bg: #07060d;
  --ink: #ecebf5;
  --ink-2: #c9c7da;
  --muted: #9a98b3;
  --faint: #6c6a85;
  --line: rgba(255, 255, 255, .08);
  --line-soft: rgba(255, 255, 255, .05);
  --glass: rgba(255, 255, 255, .035);
  --glass-hi: rgba(255, 255, 255, .06);
  --glass-hover: rgba(255, 255, 255, .055);
  --glass-strong: linear-gradient(180deg, rgba(30, 27, 48, .92), rgba(18, 16, 30, .94));
  --glass-strong-solid: rgba(22, 20, 36, .94);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, .07);
  --field-bg: rgba(255, 255, 255, .04);
  --field-border: rgba(255, 255, 255, .10);
  --overlay: rgba(4, 3, 10, .62);

  --brand-1: #8b5cf6;
  --brand-2: #d946ef;
  --brand-3: #22d3ee;
  --brand-ink: #c4b5fd;
  --brand-grad: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --ring: 0 0 0 4px rgba(139, 92, 246, .20);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Plus Jakarta Sans", var(--font-sans);
  --font-mono: "JetBrains Mono", "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --card-pad: 22px;

  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .65);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 150ms;
  --t-med: 220ms;

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --aurora-opacity: .35;
  --grain-opacity: .045;

  /* Tinted text shades (light on dark) */
  --emerald-ink: #6ee7b7;
  --amber-ink: #fcd34d;
  --rose-ink: #fda4af;
  --sky-ink: #7dd3fc;
  --violet-ink: #c4b5fd;
  --fuchsia-ink: #f0abfc;
  --cyan-ink: #67e8f9;
  --indigo-ink: #a5b4fc;
  --slate-ink: #cbd5e1;

  /* Legacy aliases — inline styles and page scripts still reference these */
  --primary: var(--brand-1);
  --primary-dark: #7c3aed;
  --primary-light: rgba(139, 92, 246, .14);
  --success: var(--emerald-ink);
  --success-light: rgba(16, 185, 129, .12);
  --danger: var(--rose-ink);
  --danger-light: rgba(244, 63, 94, .12);
  --warning: var(--amber-ink);
  --warning-light: rgba(245, 158, 11, .12);
  --text: var(--ink);
  --text-muted: var(--muted);
  --border: var(--line);
  --card-bg: var(--glass-strong-solid);
  --radius: var(--r-lg);
  --radius-sm: var(--r-md);
  --shadow: none;
  --shadow-md: var(--shadow-lg);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f4fa;
  --ink: #1b1830;
  --ink-2: #3a3654;
  --muted: #5d5a73;
  --faint: #8d8aa3;
  --line: rgba(27, 24, 48, .09);
  --line-soft: rgba(27, 24, 48, .06);
  --glass: rgba(255, 255, 255, .85);
  --glass-hi: rgba(27, 24, 48, .04);
  --glass-hover: rgba(27, 24, 48, .035);
  --glass-strong: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(250, 249, 255, .97));
  --glass-strong-solid: rgba(255, 255, 255, .97);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, .9);
  --field-bg: rgba(255, 255, 255, .75);
  --field-border: rgba(27, 24, 48, .12);
  --overlay: rgba(27, 24, 48, .35);
  --brand-ink: #6d28d9;
  --shadow-lg: 0 24px 60px -24px rgba(40, 30, 90, .28);
  --aurora-opacity: .22;
  --grain-opacity: .03;

  --emerald-ink: #047857;
  --amber-ink: #b45309;
  --rose-ink: #be123c;
  --sky-ink: #0369a1;
  --violet-ink: #6d28d9;
  --fuchsia-ink: #a21caf;
  --cyan-ink: #0e7490;
  --indigo-ink: #4338ca;
  --slate-ink: #475569;
}

/* Tones: --t = rgb channels, --t-ink = readable text shade, --t-from/--t-to = orb gradient */
.tone-violet.tone-violet  { --t: 139 92 246;  --t-ink: var(--violet-ink);  --t-from: #a78bfa; --t-to: #7c3aed; }
.tone-fuchsia.tone-fuchsia { --t: 217 70 239;  --t-ink: var(--fuchsia-ink); --t-from: #f0abfc; --t-to: #c026d3; }
.tone-emerald.tone-emerald { --t: 16 185 129;  --t-ink: var(--emerald-ink); --t-from: #34d399; --t-to: #059669; }
.tone-amber.tone-amber   { --t: 245 158 11;  --t-ink: var(--amber-ink);   --t-from: #fbbf24; --t-to: #d97706; }
.tone-rose.tone-rose    { --t: 244 63 94;   --t-ink: var(--rose-ink);    --t-from: #fb7185; --t-to: #e11d48; }
.tone-sky.tone-sky     { --t: 14 165 233;  --t-ink: var(--sky-ink);     --t-from: #38bdf8; --t-to: #0284c7; }
.tone-cyan.tone-cyan    { --t: 34 211 238;  --t-ink: var(--cyan-ink);    --t-from: #67e8f9; --t-to: #0891b2; }
.tone-indigo.tone-indigo  { --t: 99 102 241;  --t-ink: var(--indigo-ink);  --t-from: #818cf8; --t-to: #4f46e5; }
.tone-slate.tone-slate   { --t: 100 116 139; --t-ink: var(--slate-ink);   --t-from: #94a3b8; --t-to: #475569; }

/* ---------------- Base ---------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0 0 4px;
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
  color: var(--ink);
}
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; }
img, svg { max-width: 100%; }
::selection { background: rgba(139, 92, 246, .35); }

.mono, code, kbd { font-family: var(--font-mono); font-size: .92em; }
.num, .mono, .stat-value, .amount, td, .tabular { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--brand-1); outline-offset: 2px; border-radius: 6px; }

/* Lucide icons */
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }
i[data-lucide] { display: inline-block; width: 18px; height: 18px; flex-shrink: 0; }

/* ---------------- Aurora + grain ---------------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.aurora .blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(120px);
  opacity: var(--aurora-opacity);
  will-change: transform;
  animation: aurora-drift 28s ease-in-out infinite alternate;
}
.aurora .blob-1 { background: radial-gradient(circle at center, var(--brand-1), transparent 65%); top: -25vmax; left: -15vmax; }
.aurora .blob-2 { background: radial-gradient(circle at center, var(--brand-2), transparent 65%); top: 10vmax; right: -25vmax; animation-delay: -9s; animation-duration: 34s; }
.aurora .blob-3 { background: radial-gradient(circle at center, var(--brand-3), transparent 65%); bottom: -35vmax; left: 20vmax; animation-delay: -17s; opacity: calc(var(--aurora-opacity) * .7); }

@keyframes aurora-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
  100% { transform: translate3d(-4vmax, 8vmax, 0) scale(.96); }
}

.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

/* ---------------- App shell ---------------- */

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-right: 1px solid var(--line);
  box-shadow: var(--highlight);
  transition: transform var(--t-med) var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  min-width: 0;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 8px 22px -6px rgba(139, 92, 246, .6);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { font-size: 11.5px; color: var(--muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 2px; scrollbar-width: thin; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group-label {
  padding: 0 12px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  margin-bottom: 2px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}
.nav-link:hover { background: var(--glass-hover); color: var(--ink); }
.nav-link.active {
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 10px 26px -10px rgba(217, 70, 239, .65), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.nav-link .nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
}

.sidebar-foot {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--glass-hi);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who-role { font-size: 11.5px; color: var(--muted); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-med) ease, visibility var(--t-med);
}

.app-main {
  margin-left: var(--sidebar-w);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background: rgba(7, 6, 13, .55);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.crumbs a:hover { color: var(--ink); }
.crumbs svg.lucide { width: 12px; height: 12px; opacity: .6; }
.topbar-h1 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 260px;
  height: 38px;
  padding: 0 10px 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease;
}
.search-trigger:hover { border-color: rgba(139, 92, 246, .45); }
.search-trigger span { flex: 1; text-align: left; }
kbd {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--glass-hi);
  color: var(--muted);
}

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--glass-hi);
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-fast) ease;
}
.icon-btn:hover { background: var(--glass-hover); color: var(--ink); }
.icon-btn:active { transform: scale(.96); }
.icon-btn .dot-count {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font: 600 10.5px/1 var(--font-mono);
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 0 0 2px var(--bg), 0 4px 12px -2px rgba(217, 70, 239, .6);
}
.icon-btn .dot-count[hidden] { display: none; }
.hamburger { display: none; }

/* Theme toggle swaps icons via CSS so lucide never has to re-render */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: inline-block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass-hi);
  cursor: pointer;
}
.avatar-btn svg.lucide { width: 14px; height: 14px; color: var(--muted); }

.app-content {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 48px;
  flex: 1;
}

/* Drawer below 1024px */
@media (max-width: 1023.98px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); background: var(--glass-strong); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  .app-main { margin-left: 0; }
  .hamburger { display: inline-grid; }
  .topbar { padding: 0 20px; }
  .app-content { padding: 24px 24px 40px; }
}
@media (max-width: 720px) {
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .avatar-btn { padding: 3px; }
  .avatar-btn .lucide-chevron-down { display: none; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-actions { gap: 6px; }
  .crumbs { display: none; }
  .icon-btn { width: 36px; height: 36px; }
  .app-content { padding: 16px 16px 32px; }
  :root { --card-pad: 18px; }
}

/* ---------------- Grid helpers ---------------- */

.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
@media (min-width: 640px) {
  .grid-2, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .col-span-2 { grid-column: span 2; }
}
@media (min-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stack > * + * { margin-top: 16px; }

/* ---------------- Page header ---------------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 28px;
  animation: rise var(--t-med) var(--ease) backwards;
}
.page-header-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.page-header-text { min-width: 0; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--brand-ink);
  margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-head);
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 600;
  letter-spacing: -.025em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 480px) {
  .page-header { margin-bottom: 20px; }
  .page-header .orb-lg { width: 44px; height: 44px; border-radius: 14px; }
  .page-actions { width: 100%; }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 14px;
}
.section-head:first-child { margin-top: 0; }
.section-title {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 28px 0 12px;
}
.section-head .section-title { margin: 0; }
.section-title:first-child { margin-top: 0; }

/* ---------------- Icon orb ---------------- */

.orb {
  --t: 139 92 246; --t-from: #a78bfa; --t-to: #7c3aed;
  position: relative;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(140deg, var(--t-from), var(--t-to));
  box-shadow: 0 10px 24px -8px rgb(var(--t) / .65), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.orb svg.lucide { width: 20px; height: 20px; stroke-width: 2; }
.orb-sm { width: 36px; height: 36px; border-radius: 12px; }
.orb-sm svg.lucide { width: 17px; height: 17px; }
.orb-lg { width: 56px; height: 56px; border-radius: 16px; }
.orb-lg svg.lucide { width: 26px; height: 26px; }

/* ---------------- Card ---------------- */

.card, .stat-card {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--line);
  box-shadow: var(--highlight);
  border-radius: var(--r-xl);
  padding: var(--card-pad);
  min-width: 0;
  animation: rise 360ms var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: transform var(--t-med) var(--ease), border-color var(--t-med) ease, background var(--t-med) ease;
}
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
a.card:hover, .card.hoverable:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .14); }
:root[data-theme="light"] .card { box-shadow: var(--highlight), 0 1px 2px rgba(27, 24, 48, .04), 0 12px 32px -18px rgba(40, 30, 90, .18); }

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.card-header-text { flex: 1; min-width: 0; }
.card-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
}
.card-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- Stat card ---------------- */

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 148px;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-top + div { margin-top: auto; }
.stat-card .stat-label { font-size: 13px; color: var(--muted); font-weight: 500; margin: 0; }
.stat-card .stat-value {
  font-family: var(--font-head);
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin-top: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--t-ink, var(--muted));
  background: rgb(var(--t, 255 255 255) / .12);
  border: 1px solid rgb(var(--t, 255 255 255) / .24);
  white-space: nowrap;
}
.trend-chip svg.lucide { width: 12px; height: 12px; }

/* ---------------- Buttons ---------------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font: 600 13.5px/1 var(--font-sans);
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: transform var(--t-fast) ease, box-shadow var(--t-med) ease, background var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease, opacity var(--t-fast);
}
.btn svg.lucide { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 8px 20px -8px rgba(217, 70, 239, .6), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 30px -10px rgba(217, 70, 239, .75), inset 0 1px 0 rgba(255, 255, 255, .25); transform: translateY(-1px); }

.btn-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .10);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .16); }
:root[data-theme="light"] .btn-secondary { background: rgba(255, 255, 255, .8); border-color: var(--field-border); }
:root[data-theme="light"] .btn-secondary:hover:not(:disabled) { background: #fff; border-color: rgba(27, 24, 48, .18); }

.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--glass-hover); }

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #fb7185, #e11d48);
  box-shadow: 0 8px 20px -8px rgba(244, 63, 94, .6), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.btn-danger:hover:not(:disabled) { box-shadow: 0 14px 28px -10px rgba(244, 63, 94, .75); transform: translateY(-1px); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-sm); gap: 6px; }
.btn-sm svg.lucide { width: 14px; height: 14px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 14.5px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-group .btn { flex: 1; }

/* Loading state: add .is-loading (UI.loading(btn, true)) */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--line); border-top-color: var(--ink); }

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 25;
  width: 56px; height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 26px;
  background: var(--brand-grad);
  box-shadow: 0 16px 36px -10px rgba(217, 70, 239, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform var(--t-fast) ease;
}
.fab:hover { transform: translateY(-2px); }

/* ---------------- Forms ---------------- */

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 400px) { .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; } }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
select,
textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--ink);
  font: 400 14px/1.4 var(--font-sans);
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, background var(--t-fast) ease;
  appearance: none;
  -webkit-appearance: none;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a98b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
select option { background: #16131f; color: #ecebf5; }
:root[data-theme="light"] select option { background: #fff; color: #1b1830; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: rgba(139, 92, 246, .35); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled, input[readonly] { opacity: .65; cursor: not-allowed; }
input[type="file"] { width: 100%; font-size: 13px; color: var(--muted); }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--field-border);
  background: var(--glass-hi);
  color: var(--ink);
  font: 600 12.5px var(--font-sans);
  cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand-1); cursor: pointer; }

.form-hint, .help-text { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Validation — server errors (.field-error / .is-invalid) and native :user-invalid */
.field-error, .invalid-feedback, .error-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--rose-ink);
  margin-top: 6px;
}
.is-invalid, input:user-invalid, select:user-invalid, textarea:user-invalid {
  border-color: rgba(244, 63, 94, .65) !important;
}
.is-invalid:focus, input:user-invalid:focus, select:user-invalid:focus, textarea:user-invalid:focus {
  box-shadow: 0 0 0 4px rgba(244, 63, 94, .18) !important;
}

/* Search field with leading icon (legacy .search-bar keeps its markup) */
.search-bar, .input-icon {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}
.search-bar > span, .search-bar > svg, .input-icon > svg {
  position: absolute;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
  font-size: 14px;
  line-height: 1;
}
.search-bar input, .input-icon input { padding-left: 40px !important; }

/* ---------------- Badges ---------------- */

.badge {
  --t: 100 116 139; --t-ink: var(--slate-ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  color: var(--t-ink);
  background: rgb(var(--t) / .12);
  border: 1px solid rgb(var(--t) / .28);
  text-transform: capitalize;
}
.badge-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.badge svg.lucide { width: 12px; height: 12px; }
.badge-success { --t: 16 185 129;  --t-ink: var(--emerald-ink); }
.badge-warning { --t: 245 158 11;  --t-ink: var(--amber-ink); }
.badge-danger  { --t: 244 63 94;   --t-ink: var(--rose-ink); }
.badge-info    { --t: 14 165 233;  --t-ink: var(--sky-ink); }
.badge-primary { --t: 139 92 246;  --t-ink: var(--violet-ink); }
.badge-neutral { --t: 100 116 139; --t-ink: var(--slate-ink); }

/* ---------------- Tables ---------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.card > .table-wrap.flush,
.card .table-flush {
  width: auto;
  margin: 0 calc(var(--card-pad) * -1) calc(var(--card-pad) * -1);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink-2);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast) ease; }
.table tbody tr:hover { background: var(--glass-hover); }
.table tr[data-href] { cursor: pointer; }
.card .table-flush th:first-child, .card .table-flush td:first-child,
.card > .table-wrap.flush th:first-child, .card > .table-wrap.flush td:first-child { padding-left: var(--card-pad); }
.card .table-flush th:last-child, .card .table-flush td:last-child,
.card > .table-wrap.flush th:last-child, .card > .table-wrap.flush td:last-child { padding-right: var(--card-pad); }
.table .num, .table th.num { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.table th.num { font-family: var(--font-sans); font-size: 11px; }
.nowrap { white-space: nowrap; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); font-weight: 500; }
.cell-user:hover .cell-title { color: var(--brand-ink); }
.amount-pos { color: var(--emerald-ink); font-weight: 600; }
.amount-neg { color: var(--rose-ink); font-weight: 600; }

/* Pagination / sort links as pills */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination a, .pagination span, .pagination button {
  min-width: 32px; height: 32px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font: 500 12.5px var(--font-mono);
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--glass-hi);
  cursor: pointer;
}
.pagination a:hover, .pagination button:hover { color: var(--ink); background: var(--glass-hover); }
.pagination .active, .pagination [aria-current="page"] { color: #fff; border-color: transparent; background: var(--brand-grad); }
th a.sort { display: inline-flex; align-items: center; gap: 4px; }
th a.sort:hover { color: var(--ink); }

/* ---------------- Lists (legacy .list-item rows) ---------------- */

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--highlight);
  cursor: pointer;
  animation: rise 320ms var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 30ms);
  transition: background var(--t-fast) ease, transform var(--t-fast) ease, border-color var(--t-fast) ease;
}
.list-item:hover { background: var(--glass-hover); border-color: rgba(255, 255, 255, .12); transform: translateY(-1px); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-meta { text-align: right; flex-shrink: 0; }
.list-item-meta .amount { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; color: var(--emerald-ink); }
.list-item-meta .date { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.avatar {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font: 600 13px var(--font-head);
  color: var(--violet-ink);
  background: linear-gradient(140deg, rgba(139, 92, 246, .22), rgba(217, 70, 239, .14));
  border: 1px solid rgba(139, 92, 246, .28);
}
.avatar-sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
.avatar-xs { width: 28px; height: 28px; border-radius: 999px; font-size: 11px; color: #fff; background: var(--brand-grad); border: none; }

/* Action tiles (quick links) */
.action-list { display: flex; flex-direction: column; gap: 4px; }
.action-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  margin: 0 -10px;
  border-radius: var(--r-lg);
  transition: background var(--t-fast) ease;
}
.action-tile:hover { background: var(--glass-hover); }
.action-tile-body { flex: 1; min-width: 0; }
.action-tile-title { font-weight: 600; font-size: 13.5px; }
.action-tile-sub { font-size: 12px; color: var(--muted); }
.action-tile > svg.lucide:last-child { color: var(--faint); width: 16px; height: 16px; transition: transform var(--t-fast) ease; }
.action-tile:hover > svg.lucide:last-child { transform: translateX(2px); color: var(--ink); }

/* ---------------- Tabs / segmented control / chips ---------------- */

.segmented, .tab-bar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: var(--glass-hi);
  border: 1px solid var(--line);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar, .tab-bar::-webkit-scrollbar { display: none; }
.segmented > *, .tab-bar > .tab-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: 600 12.5px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) ease, background var(--t-fast) ease, box-shadow var(--t-med) ease;
}
.segmented > *:hover, .tab-bar > .tab-btn:hover { color: var(--ink); }
.segmented > .active, .tab-bar > .tab-btn.active, .segmented > [aria-selected="true"] {
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 6px 16px -6px rgba(217, 70, 239, .6), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.tab-bar { display: flex; margin-bottom: 20px; }
.tab-bar > .tab-btn { flex: 1; justify-content: center; }
.tab-panel, [data-tab-panel] { display: none; }
.tab-panel.active, [data-tab-panel].active { display: block; animation: rise var(--t-med) var(--ease) backwards; }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass-hi);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) ease, background var(--t-fast) ease, border-color var(--t-fast) ease;
}
.chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, .16); }
.chip.active { color: #fff; border-color: transparent; background: var(--brand-grad); box-shadow: 0 6px 16px -6px rgba(217, 70, 239, .6); }
.segmented > .chip { border-radius: 10px; border: none; }
.segmented > .chip:not(.active) { background: transparent; box-shadow: none; }

/* ---------------- Alerts / toasts ---------------- */

.alert {
  --t: 14 165 233; --t-ink: var(--sky-ink);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: rgb(var(--t) / .10);
  border: 1px solid rgb(var(--t) / .28);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  color: var(--ink);
  animation: rise 320ms var(--ease) backwards;
}
.alert-success { --t: 16 185 129; --t-ink: var(--emerald-ink); }
.alert-warning { --t: 245 158 11; --t-ink: var(--amber-ink); }
.alert-error, .alert-danger { --t: 244 63 94; --t-ink: var(--rose-ink); }
.alert-info { --t: 14 165 233; --t-ink: var(--sky-ink); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--t-ink); font-size: 14px; }
.alert-text { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.alert-link { transition: transform var(--t-fast) ease, background var(--t-fast) ease; }
.alert-link:hover { transform: translateY(-1px); background: rgb(var(--t) / .14); }
.alert-link > svg.lucide:last-child { color: var(--t-ink); transition: transform var(--t-fast) ease; }
.alert-link:hover > svg.lucide:last-child { transform: translateX(3px); }

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  --t: 14 165 233; --t-ink: var(--sky-ink);
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  border: 1px solid rgb(var(--t) / .35);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .06), inset 3px 0 0 rgb(var(--t) / .9);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  font-size: 13.5px;
  color: var(--ink);
  animation: toast-in 260ms var(--ease) both;
}
.toast.leaving { animation: toast-out 220ms ease forwards; }
.toast > svg.lucide:first-child { color: var(--t-ink); margin-top: 1px; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { border: none; background: none; color: var(--muted); cursor: pointer; padding: 0; line-height: 0; }
.toast-close svg.lucide { width: 15px; height: 15px; }
.toast-success { --t: 16 185 129; --t-ink: var(--emerald-ink); }
.toast-warning { --t: 245 158 11; --t-ink: var(--amber-ink); }
.toast-error   { --t: 244 63 94;  --t-ink: var(--rose-ink); }
@keyframes toast-in  { from { opacity: 0; transform: translateX(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------------- Dropdowns ---------------- */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 240px;
  padding: 6px;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(.98);
  transform-origin: top right;
  transition: opacity var(--t-fast) ease, transform var(--t-fast) ease, visibility var(--t-fast);
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown-head .t { font-weight: 600; font-size: 13.5px; }
.dropdown-head .s { font-size: 12px; color: var(--muted); }
.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink-2);
  font: 500 13px var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--glass-hover); color: var(--ink); }
.dropdown-item svg.lucide { width: 16px; height: 16px; color: var(--muted); }
.dropdown-item.danger, .dropdown-item.danger svg.lucide { color: var(--rose-ink); }
.dropdown-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dropdown-empty { padding: 22px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }
.notif-menu { width: 320px; max-width: calc(100vw - 24px); }
@media (max-width: 480px) {
  .topbar .dropdown-menu { position: fixed; top: calc(var(--topbar-h) - 4px); left: 12px; right: 12px; width: auto; min-width: 0; max-width: none; }
}

/* ---------------- Modals (legacy .sheet-overlay / .sheet) ---------------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-med) ease, visibility var(--t-med);
}
.sheet-overlay.open { opacity: 1; visibility: visible; }
.sheet {
  position: relative;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 24px 24px 0 0;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .07);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  transform: translateY(24px);
  transition: transform var(--t-med) var(--ease);
}
.sheet-overlay.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 4px; margin: 0 auto 16px; border-radius: 999px; background: var(--line); }
.sheet h3 { font-size: 17px; }
@media (min-width: 720px) {
  .sheet-overlay { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: var(--r-xl); padding: 26px; transform: translateY(8px) scale(.98); }
  .sheet-handle { display: none; }
}

/* Command palette (search) */
.cmdk { align-items: flex-start; padding-top: 12vh; }
.cmdk .sheet { max-width: 560px; padding: 8px; border-radius: 20px; }
.cmdk-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.cmdk-input svg.lucide { color: var(--muted); }
.cmdk-input input { border: none !important; background: none !important; box-shadow: none !important; height: 48px !important; padding: 0 !important; font-size: 15px !important; }
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: 6px 0 2px; }
.cmdk-item.active { background: var(--glass-hover); color: var(--ink); }
.cmdk-item.active svg.lucide { color: var(--brand-ink); }
@media (max-width: 719.98px) { .cmdk { align-items: flex-start; padding: 12px; } .cmdk .sheet { border-radius: 20px; } }

/* ---------------- Empty states / loading ---------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .orb, .empty-state .empty-icon { margin-bottom: 16px; box-shadow: 0 0 0 8px rgb(var(--t, 139 92 246) / .08), 0 16px 44px -8px rgb(var(--t, 139 92 246) / .7), inset 0 1px 0 rgba(255, 255, 255, .28); }
.empty-state .empty-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: linear-gradient(140deg, rgba(139, 92, 246, .35), rgba(217, 70, 239, .25));
}
.empty-state .empty-title { font-family: var(--font-head); font-weight: 600; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.empty-state .empty-hint, .empty-state p { font-size: 13px; color: var(--muted); max-width: 340px; }
.empty-state .btn { margin-top: 16px; }

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--glass-hi);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
:root[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .8), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-orb { width: 44px; height: 44px; border-radius: 14px; }
.skel-line { height: 12px; }
.skel-line.lg { height: 26px; }
.skel-block { height: 220px; border-radius: var(--r-lg); }
.w-30 { width: 30%; } .w-40 { width: 40%; } .w-60 { width: 60%; } .w-80 { width: 80%; }

.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 0;
  font-size: 13px;
  color: var(--muted);
}
.spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brand-1);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Charts (inline SVG) ---------------- */

.chart-body { overflow-x: auto; }
.chart-body svg { display: block; width: 100%; height: auto; }
.chart-body path { transition: opacity var(--t-fast) ease; }
.chart-body path:hover { opacity: .8; }
.chart-bar-label { font: 500 11px var(--font-sans); fill: var(--muted); }
.chart-value-label { font: 600 11px var(--font-mono); fill: var(--ink-2); }
.chart-empty { padding: 32px 0; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------------- Page components ---------------- */

/* Standalone pages that don't use the app shell (access-denied screens) */
.container { max-width: 720px; margin: 0 auto; padding: 16px; }

/* Headline numbers in a row (fee/salary totals) */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.summary-strip .s-box { padding: 18px 20px; min-width: 0; }
.summary-strip .s-box + .s-box { border-left: 1px solid var(--line-soft); }
.summary-strip .s-box .v {
  font: 600 20px/1.2 var(--font-head);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-strip .s-box .l {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (max-width: 640px) {
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip .s-box:nth-child(3) { border-left: none; }
  .summary-strip .s-box:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .summary-strip .s-box { padding: 14px 16px; }
  .summary-strip .s-box .v { font-size: 17px; }
}
.v-success { color: var(--emerald-ink) !important; }
.v-danger  { color: var(--rose-ink) !important; }
.v-warning { color: var(--amber-ink) !important; }

/* Profile strip at the top of a detail page */
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card .avatar { width: 52px; height: 52px; border-radius: 16px; font-size: 17px; }
.profile-card .list-item-title { font-family: var(--font-head); font-size: 17px; letter-spacing: -.01em; }

/* Line rows inside a card (fee breakdown, quick collect, fee structure) */
.fee-row, .qc-row, .fs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.fee-row:first-child, .qc-row:first-child, .fs-row:first-child { padding-top: 0; }
.fee-row:last-child, .qc-row:last-child, .fs-row:last-child { border-bottom: none; padding-bottom: 0; }
.ft-name, .fs-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ft-nums { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.ft-actions { display: flex; gap: 6px; flex-shrink: 0; }
.fs-amt { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; color: var(--violet-ink); }

.fd-row, .sl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fd-nums, .sl-nums { font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; white-space: normal; }
.fd-nums b, .sl-nums b { color: var(--ink); font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; }

/* Key/value rows (expense detail) */
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.detail-row .label { color: var(--muted); flex-shrink: 0; }
.detail-row .value { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* Compact action buttons in rows */
.mini-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--field-border);
  background: var(--glass-hi);
  color: var(--ink);
  font: 600 12px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform var(--t-fast) ease, box-shadow var(--t-med) ease, background var(--t-fast) ease;
}
.mini-btn:hover { background: var(--glass-hover); }
.mini-btn.pay { color: #fff; border-color: transparent; background: var(--brand-grad); box-shadow: 0 6px 14px -6px rgba(217, 70, 239, .6); }
.mini-btn.pay:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -8px rgba(217, 70, 239, .7); }
.mini-btn.waive, .mini-btn.bonus { color: var(--amber-ink); border-color: rgba(245, 158, 11, .3); background: rgba(245, 158, 11, .12); }

.tx-del, .fs-del {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}
.tx-del:hover, .fs-del:hover { color: var(--rose-ink); background: rgba(244, 63, 94, .12); }
.tx-del svg.lucide, .fs-del svg.lucide { width: 16px; height: 16px; }

/* Tinted avatars for transaction rows */
.avatar.tone-emerald, .avatar.tone-amber, .avatar.tone-rose, .avatar.tone-sky {
  color: var(--t-ink);
  background: rgb(var(--t) / .14);
  border-color: rgb(var(--t) / .3);
}
.avatar svg.lucide { width: 18px; height: 18px; }

/* Month switcher */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; }
.month-nav .m-label { font: 600 15px var(--font-head); letter-spacing: -.01em; }

/* Tags (settings lists) */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag-list:empty { display: none; }
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, .28);
  background: rgba(139, 92, 246, .10);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
}
.tag-pill button {
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.tag-pill button:hover { color: var(--rose-ink); background: rgba(244, 63, 94, .14); }
.input-add { display: flex; gap: 8px; }
.input-add input { flex: 1; min-width: 0; }
.input-add .btn { flex-shrink: 0; }

/* User rows (settings) */
.user-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-row .list-item-body { min-width: 140px; }
.user-row .icon-btn { width: 34px; height: 34px; }
.user-row .icon-btn svg.lucide { width: 16px; height: 16px; }

.logo-preview {
  width: 72px; height: 72px;
  flex-shrink: 0;
  border-radius: 18px;
  object-fit: contain;
  background: var(--glass-hi);
  border: 1px dashed var(--field-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
img.logo-preview { background: #fff; padding: 6px; }
.logo-preview svg.lucide { width: 28px; height: 28px; }

/* Toggle row with a switch-styled checkbox */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; margin: 0; }
.switch { position: relative; width: 40px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100% !important; height: 100% !important; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--glass-hi);
  border: 1px solid var(--field-border);
  transition: background var(--t-fast) ease;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform var(--t-fast) var(--ease);
}
.switch input:checked + span { background: var(--brand-grad); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }

/* Attendance status */
.att-status-card { text-align: center; padding-top: 32px; padding-bottom: 28px; }
.att-status-card .empty-icon { margin: 0 auto 14px; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: linear-gradient(140deg, rgba(139, 92, 246, .35), rgba(217, 70, 239, .25)); }
.att-status-card .orb { margin: 0 auto 14px; }
.att-state { font: 600 18px var(--font-head); letter-spacing: -.01em; margin-bottom: 4px; }
.att-timer {
  margin: 14px 0 10px;
  font: 600 clamp(36px, 7vw, 52px)/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.att-sub { font-size: 13px; color: var(--muted); }
.att-location-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 460px;
  margin: 18px auto;
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--muted);
  background: var(--glass-hi);
  border: 1px solid var(--line);
}
.att-location-line.ok { color: var(--emerald-ink); background: rgba(16, 185, 129, .10); border-color: rgba(16, 185, 129, .28); font-weight: 500; }
.att-location-line.bad { color: var(--rose-ink); background: rgba(244, 63, 94, .10); border-color: rgba(244, 63, 94, .28); font-weight: 500; }
.att-status-card .btn-group, .att-status-card > .btn-block { max-width: 460px; margin-left: auto; margin-right: auto; }
.att-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.att-row:first-child { padding-top: 0; }
.att-row:last-child { border-bottom: none; padding-bottom: 0; }
.att-row-main { flex: 1; min-width: 0; }
.att-row-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.att-row-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.att-row-meta { flex-shrink: 0; text-align: right; font: 500 13px var(--font-mono); color: var(--ink-2); }

/* Enquiry follow-up hint */
.enq-followup { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; font-size: 11.5px; font-weight: 600; }
.enq-followup.overdue { color: var(--rose-ink); }
.enq-followup.upcoming { color: var(--muted); }

/* Reports */
.report-card { display: flex; flex-direction: column; }
.report-desc { font-size: 13px; color: var(--muted); margin-bottom: 18px; flex: 1; }

/* Filter toolbar above lists */
.toolbar { margin-bottom: 12px; }
.toolbar .search-bar { margin-bottom: 12px; }
.toolbar .chip-row { margin-bottom: 8px; }
.toolbar .chip-row:last-child { margin-bottom: 0; }

/* Receipt — a white "paper" document in both themes so it previews like the print */
.receipt-card {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 32px 28px;
  border-radius: var(--r-xl);
  background: #fff;
  color: #1b1830;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .08);
  animation: rise 360ms var(--ease) backwards;
}
.receipt-letterhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 18px; margin-bottom: 22px; border-bottom: 3px solid #8b5cf6; }
.receipt-letterhead .letterhead-logo-box { width: 60px; height: 60px; flex-shrink: 0; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.receipt-letterhead .letterhead-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.receipt-letterhead .letterhead-info { flex: 1; min-width: 0; text-align: right; }
.receipt-letterhead .school-name { font: 700 22px/1.2 var(--font-head); letter-spacing: -.02em; color: #1b1830; }
.receipt-letterhead .school-meta { font-size: 13px; color: #6b6880; margin-top: 4px; }
.receipt-title { text-align: center; font: 700 15px var(--font-sans); letter-spacing: .24em; color: #6d28d9; margin-bottom: 8px; }
.receipt-status { text-align: center; margin-bottom: 18px; }
.receipt-card .badge-success { --t-ink: #047857; }
.receipt-card .badge-warning { --t-ink: #b45309; }
.receipt-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; font-size: 14px; border-bottom: 1px solid rgba(27, 24, 48, .08); }
.receipt-row .label { color: #6b6880; }
.receipt-row .value { font-weight: 600; text-align: right; color: #1b1830; }
.receipt-amount { text-align: center; margin: 22px 0; padding: 22px; border-radius: 16px; background: linear-gradient(135deg, rgba(16, 185, 129, .10), rgba(34, 211, 238, .10)); border: 1px solid rgba(16, 185, 129, .25); }
.receipt-amount .amt { font: 700 36px/1.1 var(--font-head); letter-spacing: -.02em; color: #047857; font-variant-numeric: tabular-nums; }
.receipt-amount .lbl { font-size: 11px; font-weight: 600; letter-spacing: .18em; color: #6b6880; margin-bottom: 6px; }
.receipt-signature { text-align: right; margin-top: 34px; font-size: 13px; color: #6b6880; }
.receipt-signature .sig-line { border-top: 1px solid rgba(27, 24, 48, .25); width: 170px; margin: 30px 0 6px auto; }
@media (max-width: 480px) { .receipt-card { padding: 22px 18px; } .receipt-letterhead .school-name { font-size: 18px; } }
.receipt-actions { max-width: 640px; margin: 20px auto 0; display: flex; flex-wrap: wrap; gap: 10px; }
.receipt-actions .btn-group { flex: 1 1 180px; margin: 0; }
.wa-btn { color: #fff; background: linear-gradient(135deg, #34d399, #16a34a); box-shadow: 0 8px 20px -8px rgba(22, 163, 74, .6), inset 0 1px 0 rgba(255, 255, 255, .22); }
.wa-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(22, 163, 74, .7); }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; }
.auth-card .brand-mark { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px; }
.auth-card .brand-mark svg.lucide { width: 26px; height: 26px; }
.auth-title { text-align: center; font-size: 22px; letter-spacing: -.025em; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 4px 0 26px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 20px; font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.auth-corner { position: fixed; top: 16px; right: 16px; }

@media print {
  .receipt-card { box-shadow: none; max-width: none; border-radius: 0; padding: 0; }
  .receipt-actions { display: none !important; }
}

/* Lists that sit inside a card or modal render as flat rows instead of glass tiles */
.card .list-item, .sheet .list-item {
  margin: 0 -12px;
  padding: 11px 12px;
  border: none;
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.card .list-item:hover, .sheet .list-item:hover { background: var(--glass-hover); transform: none; }
.card .list-item + .list-item, .sheet .list-item + .list-item { margin-top: 2px; }
.card .list-item[style*="cursor:default"]:hover { background: transparent; }
.card > .loader, .card > div > .loader { padding: 28px 0; }
.card .empty-state { padding: 32px 12px; }
.exp-row .amount { color: var(--rose-ink); }

/* Settings user rows inside a card */
.card .user-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.card .user-row:first-child { padding-top: 0; }
.card .user-row:last-child { border-bottom: none; padding-bottom: 0; }

/* Search field icon before lucide swaps it in */
.search-bar > i, .input-icon > i { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.input-icon > svg.lucide, .search-bar > svg.lucide { width: 16px; height: 16px; }
.form-group .input-icon { margin-bottom: 0; }
.card .toolbar .search-bar input { background: var(--field-bg); }

/* Form layout */
.form-row > .form-group { min-width: 0; flex: 1; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.form-actions .btn-group { margin: 0 !important; flex-wrap: wrap; }
.form-actions .btn-group .btn { flex: 0 0 auto; }
.form-actions > .btn-primary { min-width: 180px; }
@media (max-width: 480px) {
  .form-actions > .btn, .form-actions > div, .form-actions .btn-group .btn { flex: 1 1 100%; }
}
.card > .form-group:last-child, .card > .form-row:last-child > .form-group { margin-bottom: 0; }
.card-note { font-size: 13px; color: var(--muted); margin: -8px 0 16px; }
.mb-16 { margin-bottom: 16px; }

/* Phones: compact stat cards, and card-header actions drop below the title instead of squeezing it */
@media (max-width: 640px) {
  .stat-card { min-height: 0; }
}
@media (max-width: 480px) {
  .card-header { flex-wrap: wrap; }
  .card-header .card-header-text { min-width: calc(100% - 52px); }
  .card-actions { width: 100%; }
}

/* ---------------- Utility ---------------- */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted, .muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
[hidden] { display: none !important; }

/* ---------------- Motion & print ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  .aurora .blob { animation: none; }
}

@media print {
  .aurora, .sidebar, .sidebar-backdrop, .topbar, .fab, .toast-stack, .no-print { display: none !important; }
  html, body { background: #fff !important; color: #000; }
  .app-main { margin: 0; }
  .app-content { max-width: none; padding: 0; }
  .card { backdrop-filter: none; background: #fff; border-color: #ddd; box-shadow: none; animation: none; }
}
