/* ============================================================
   DrivePlanner — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-50: #EFF6FF;
  --brand-100: #DBEAFE;
  --brand-200: #BFDBFE;
  --brand-300: #93C5FD;
  --brand-400: #60A5FA;
  --brand-500: #3B82F6;
  --brand-600: #2563EB;
  --brand-700: #1D4ED8;
  --brand-800: #1E40AF;
  --brand-900: #1E3A8A;

  /* Neutrals (Slate) */
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Semantic */
  --color-success: #10B981;
  --color-success-bg: #ECFDF5;
  --color-success-border: #A7F3D0;
  --color-warning: #F59E0B;
  --color-warning-bg: #FFFBEB;
  --color-warning-border: #FDE68A;
  --color-danger: #EF4444;
  --color-danger-bg: #FEF2F2;
  --color-danger-border: #FECACA;
  --color-info: #3B82F6;
  --color-info-bg: #EFF6FF;
  --color-info-border: #BFDBFE;
  --color-purple: #8B5CF6;
  --color-purple-bg: #F5F3FF;
  --color-orange: #F97316;
  --color-orange-bg: #FFF7ED;

  /* Surfaces */
  --bg-page: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-input: #FFFFFF;

  /* Sidebar */
  --sidebar-bg: #0F172A;
  --sidebar-bg-active: rgba(59, 130, 246, .15);
  --sidebar-bg-hover: rgba(255, 255, 255, .06);
  --sidebar-text: rgba(255, 255, 255, .65);
  --sidebar-text-active: #FFFFFF;
  --sidebar-accent: #3B82F6;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-on-brand: #FFFFFF;

  /* Borders */
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow: 0 4px 6px rgba(0, 0, 0, .07), 0 2px 4px rgba(0, 0, 0, .05);
  --shadow-md: 0 10px 15px rgba(0, 0, 0, .10), 0 4px 6px rgba(0, 0, 0, .05);
  --shadow-lg: 0 20px 25px rgba(0, 0, 0, .10), 0 8px 10px rgba(0, 0, 0, .04);
  --shadow-xl: 0 25px 50px rgba(0, 0, 0, .18);

  /* Transitions */
  --t-fast: 120ms ease;
  --t: 200ms ease;
  --t-slow: 300ms ease;

  /* Z-index layers */
  --z-sidebar: 100;
  --z-topbar: 90;
  --z-dropdown: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ── Dark Mode ──────────────────────────────────────────────── */
html[data-theme="dark"] {
  /* Surfaces */
  --bg-page: #0F172A;
  --bg-card: #1E293B;
  --bg-input: #1E293B;

  /* Neutrals — slate scale inverted */
  --gray-50: #1E293B;
  --gray-100: #334155;
  --gray-200: #475569;
  --gray-300: #64748B;
  --gray-400: #94A3B8;
  --gray-500: #CBD5E1;

  /* Typography */
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #64748B;

  /* Borders */
  --border: #334155;
  --border-strong: #475569;

  /* Brand light tone — tinted for dark bg */
  --brand-50: rgba(37, 99, 235, .18);

  /* Semantic backgrounds — tinted, not solid */
  --color-success-bg: rgba(16, 185, 129, .14);
  --color-success-border: rgba(16, 185, 129, .28);
  --color-warning-bg: rgba(245, 158, 11, .14);
  --color-warning-border: rgba(245, 158, 11, .28);
  --color-danger-bg: rgba(239, 68, 68, .14);
  --color-danger-border: rgba(239, 68, 68, .28);
  --color-info-bg: rgba(59, 130, 246, .14);
  --color-info-border: rgba(59, 130, 246, .28);
  --color-purple-bg: rgba(139, 92, 246, .14);
  --color-orange-bg: rgba(249, 115, 22, .14);

  /* Shadows — stronger on dark */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .55), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 6px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .35);
  --shadow-md: 0 10px 15px rgba(0, 0, 0, .55), 0 4px 6px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 25px rgba(0, 0, 0, .6), 0 8px 10px rgba(0, 0, 0, .45);
}

/* Component-level dark overrides for hardcoded colours */
html[data-theme="dark"] .cal-day.holiday {
  background: rgba(249, 115, 22, .1);
}

html[data-theme="dark"] .cal-day.today {
  background: rgba(37, 99, 235, .18);
}

/* Badge text — light tones for dark backgrounds */
html[data-theme="dark"] .badge-blue {
  color: #93C5FD;
}

html[data-theme="dark"] .badge-green {
  color: #6EE7B7;
}

html[data-theme="dark"] .badge-gray {
  color: #94A3B8;
}

html[data-theme="dark"] .badge-red {
  color: #FCA5A5;
}

html[data-theme="dark"] .badge-orange {
  color: #FDBA74;
}

html[data-theme="dark"] .cal-day.weekend {
  background: transparent;
}

html[data-theme="dark"] .cal-day:hover {
  background: rgba(255, 255, 255, .04);
}

html[data-theme="dark"] .cal-day.other-month {
  background: rgba(0, 0, 0, .25);
}

html[data-theme="dark"] .cal-day.today .day-num {
  background: var(--brand-600);
}

html[data-theme="dark"] .progress-track {
  background: var(--gray-100);
}

html[data-theme="dark"] .skeleton {
  background: var(--gray-100);
}

html[data-theme="dark"] .table thead th {
  background: var(--gray-50);
}

html[data-theme="dark"] .table tbody tr:hover {
  background: rgba(255, 255, 255, .03);
}

html[data-theme="dark"] .table tbody tr {
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .auth-form-side {
  background: var(--bg-card);
}

html[data-theme="dark"] .auth-brand {
  background: var(--gray-900);
}

html[data-theme="dark"] .sc-own-car-note {
  background: rgba(245, 158, 11, .1);
  border-color: rgba(245, 158, 11, .25);
  color: #FCD34D;
}

html[data-theme="dark"] .danger-zone-card {
  border-color: var(--color-danger-border);
}

html[data-theme="dark"] .danger-zone-header {
  background: var(--color-danger-bg);
}

html[data-theme="dark"] .delete-confirm-input-wrap {
  background: var(--gray-50);
  border-color: var(--border);
}

html[data-theme="dark"] .legal-draft-notice {
  background: rgba(245, 158, 11, .1);
  border-color: rgba(245, 158, 11, .25);
  color: #FCD34D;
}

html[data-theme="dark"] ::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

html[data-theme="dark"] select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Smooth transition when switching themes */
html[data-theme-animating] *,
html[data-theme-animating] *::before,
html[data-theme-animating] *::after {
  transition: background-color 220ms ease, border-color 220ms ease, color 180ms ease,
    box-shadow 220ms ease !important;
}

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul {
  list-style: none;
}

/* ── Typography ─────────────────────────────────────────────── */
h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.5px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.3px;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}

h5 {
  font-size: .9375rem;
  font-weight: 600;
}

p {
  color: var(--text-secondary);
}

small {
  font-size: .8125rem;
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Impersonation banner ────────────────────────────────────── */
#impersonate-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--z-sidebar) + 10);
  background: #6D28D9;
  color: #fff;
  padding: 0 24px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

#impersonate-bar svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .8;
}

#impersonate-bar .impersonate-back {
  margin-left: auto;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .15);
  transition: background var(--t-fast);
  white-space: nowrap;
}

#impersonate-bar .impersonate-back:hover {
  background: rgba(255, 255, 255, .25);
}

body.impersonating .app-layout {
  padding-top: 40px;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  transition: width var(--t-slow), transform var(--t-slow);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--brand-600);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .25);
}

.sidebar-logo-icon svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

/* DrivePlanner logo icon — sidebar size */
.nav-logo-img {
  height: 32px;
  width: 32px;
  display: block;
  flex-shrink: 0;
}

.sidebar-logo-name {
  font-size: .9375rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.015em;
  white-space: nowrap;
  transition: opacity var(--t-base), width var(--t-base);
}

.auth-logo-img {
  height: 96px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

/* Admin badge next to logo in sidebar (replaces old sidebar-logo-text) */
.sidebar-logo-admin-badge {
  font-size: .6875rem;
  font-weight: 700;
  color: var(--brand-400);
  background: rgba(37, 99, 235, .18);
  border: 1px solid rgba(96, 165, 250, .3);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  align-self: center;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
}

.nav-section-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .3);
  padding: 14px 10px 6px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
  text-decoration: none;
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--sidebar-accent);
  border-radius: 0 3px 3px 0;
}

.nav-item .badge-count {
  margin-left: auto;
  background: var(--brand-600);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-version {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, .2);
  font-size: .7rem;
  letter-spacing: .04em;
  user-select: none;
}

.sidebar-version svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .4;
}

/* ── Sidebar collapse row & button ──────────────────────────── */
.sidebar-collapse-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 6px 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: rgba(255, 255, 255, .4);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
}

.sidebar-collapse-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-collapse-btn .icon-expand {
  display: none;
}

/* nav-label wraps the text inside every nav-item */
.nav-label {
  transition: opacity var(--t-base);
  white-space: nowrap;
}

.sidebar-logo-admin-badge,
.sidebar-user-info,
.nav-section-label {
  transition: opacity var(--t-base);
}

/* ── Collapsed state (desktop only) ─────────────────────────── */
.app-layout.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.app-layout.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.app-layout.sidebar-collapsed .nav-item {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}

.app-layout.sidebar-collapsed .sidebar-logo {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

.app-layout.sidebar-collapsed .sidebar-version {
  justify-content: center;
}

.app-layout.sidebar-collapsed .sidebar-collapse-row {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-layout.sidebar-collapsed .sidebar-collapse-btn .icon-collapse {
  display: none;
}

.app-layout.sidebar-collapsed .sidebar-collapse-btn .icon-expand {
  display: block;
}

.app-layout.sidebar-collapsed .nav-label,
.app-layout.sidebar-collapsed .sidebar-logo-admin-badge,
.app-layout.sidebar-collapsed .sidebar-logo-name,
.app-layout.sidebar-collapsed .nav-section-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Badge becomes a corner indicator, removed from flex flow so icon stays centred */
.app-layout.sidebar-collapsed .nav-item .badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  margin-left: 0;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: .5625rem;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Badge inside buttons (filter tabs etc.) */
.btn .badge-count {
  margin-left: 4px;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--t-slow);
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  box-shadow: var(--shadow-xs);
}

/* Left zone */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shown only on mobile — desktop title lives in the topbar */
.page-heading-mobile {
  display: none;
}

/* Centre zone: search */
.topbar-center {
  flex: 0 0 340px;
  position: relative;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: text;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.topbar-search:focus-within {
  border-color: var(--brand-400);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.topbar-search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.topbar-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: .875rem;
  color: var(--text-primary);
  min-width: 0;
}

.topbar-search-input::placeholder {
  color: var(--text-muted);
}

.topbar-search-kbd {
  font-size: .6875rem;
  font-family: inherit;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  background: var(--bg-card);
  white-space: nowrap;
  flex-shrink: 0;
  pointer-events: none;
}

.topbar-search:focus-within .topbar-search-kbd {
  display: none;
}

.topbar-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.topbar-search-section {
  padding: 7px 14px 5px;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.topbar-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: .875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .1s;
}

.topbar-search-item:hover {
  background: var(--brand-50);
  color: var(--brand-700);
}

.topbar-search-item-name {
  font-weight: 600;
  font-size: .875rem;
}

.topbar-search-item-sub {
  font-size: .75rem;
  color: var(--text-muted);
}

.topbar-search-empty {
  padding: 14px;
  font-size: .875rem;
  color: var(--text-muted);
  text-align: center;
}

/* Right zone */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}

.topbar-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
  padding-right: 10px;
  border-right: 1px solid var(--border);
}

.topbar-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}

.topbar-icon-btn:hover {
  background: var(--gray-50);
  color: var(--text-primary);
  border-color: var(--gray-300);
}

.topbar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: .625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-card);
}

/* User menu button */
.topbar-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
  flex-shrink: 0;
}

.topbar-user:hover,
.topbar-user.open {
  background: var(--gray-50);
  border-color: var(--border);
}

.topbar-user-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-user-chevron {
  color: var(--text-muted);
  transition: transform .2s;
  flex-shrink: 0;
}

.topbar-user.open .topbar-user-chevron {
  transform: rotate(180deg);
}

/* Dropdown panel */
.topbar-dropdown {
  position: fixed;
  top: 68px;
  right: 8px;
  width: 210px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  transition: opacity .15s, transform .15s, visibility .15s;
}

.topbar-user.open .topbar-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Round first/last children so hover backgrounds respect border-radius
   (replaces the removed overflow:hidden) */
.topbar-dd-header {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.topbar-dropdown> :last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.topbar-dd-header {
  padding: 12px 14px 10px;
}

.topbar-dd-name {
  font-weight: 700;
  font-size: .9375rem;
  color: var(--text-primary);
}

.topbar-dd-role {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: capitalize;
}

.topbar-dd-divider {
  height: 1px;
  background: var(--border);
}

.topbar-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: .875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .1s, color .1s;
}

.topbar-dd-item:hover {
  background: var(--gray-50);
  color: var(--text-primary);
}

.topbar-dd-danger {
  color: var(--color-danger);
}

.topbar-dd-danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.topbar-dd-toggle {
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
}

.topbar-dd-toggle:hover {
  background: var(--gray-50);
  color: var(--text-primary);
}

/* Backward compat — pages that still use old .topbar-actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-icon svg {
  width: 17px;
  height: 17px;
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}

.menu-toggle:hover {
  background: var(--gray-100);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.page-content {
  flex: 1;
  padding: 28px;
  width: 100%;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: .875rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.card-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header h3 {
  font-size: .9375rem;
  font-weight: 600;
  flex: 1;
}

.card-body {
  padding: 22px;
}

.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow var(--t), transform var(--t);
  box-shadow: var(--shadow-xs);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card-clickable {
  cursor: pointer;
}

.stat-card-clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
}

.stat-card-clickable:active {
  transform: scale(0.97);
  transition-duration: 80ms;
}

.stat-card-caret {
  margin-left: auto;
  padding-left: 10px;
  flex-shrink: 0;
  align-self: center;
  color: var(--text-muted);
  opacity: 0.25;
  transition: opacity 200ms, color 200ms;
}

@keyframes caretNudge {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(10px);
  }
}

.stat-card-clickable:hover .stat-card-caret {
  opacity: 1;
  color: var(--brand-600);
  animation: caretNudge 900ms ease-in-out infinite;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-icon.blue {
  background: var(--brand-50);
  color: var(--brand-600);
}

.stat-icon.green {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.stat-icon.orange {
  background: var(--color-orange-bg);
  color: var(--color-orange);
}

.stat-icon.purple {
  background: var(--color-purple-bg);
  color: var(--color-purple);
}

.stat-icon.red {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-label {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-change {
  font-size: .75rem;
  margin-top: 6px;
  font-weight: 500;
}

.stat-change.up {
  color: var(--color-success);
}

.stat-change.down {
  color: var(--color-danger);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.btn svg {
  width: 15px;
  height: 15px;
  min-width: 15px;
  min-height: 15px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.6rem 10px;
  font-size: .8125rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: .9375rem;
}

.btn-xl {
  padding: 14px 30px;
  font-size: 1rem;
}

.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .2), 0 0 0 0 rgba(37, 99, 235, 0);
}

.btn-primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
  box-shadow: 0 4px 12px rgba(16, 185, 129, .3);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
  border-color: #DC2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
}

.btn-warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: #fff;
}

.btn-warning:hover {
  background: #D97706;
  border-color: #D97706;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.btn-outline-primary {
  background: transparent;
  color: var(--brand-600);
  border-color: var(--brand-300);
}

.btn-outline-primary:hover {
  background: var(--brand-50);
  border-color: var(--brand-600);
}

/* Loading state */
.btn.loading {
  pointer-events: none;
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  opacity: 1;
  color: rgba(255, 255, 255, .8);
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-primary);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.5;
}

.form-control-sm {
  padding: 6px 10px;
  font-size: .8125rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

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

.form-control:disabled {
  background: var(--gray-100);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}

.form-control.is-valid {
  border-color: var(--color-success);
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-error {
  font-size: .75rem;
  color: var(--color-danger);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input with icon */
.input-wrap {
  position: relative;
}

.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrap .form-control {
  padding-left: 40px;
}

.input-wrap .input-icon-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
}

.input-wrap .input-icon-right:hover {
  color: var(--text-primary);
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-600);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check label {
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--t-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  left: 3px;
  top: 3px;
  transition: transform var(--t-fast);
  box-shadow: var(--shadow-xs);
}

.toggle input:checked+.toggle-slider {
  background: var(--brand-600);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(18px);
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.table thead th {
  padding: 11px 16px;
  background: var(--gray-50);
  font-weight: 600;
  font-size: .8125rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ── County / day toggle buttons ────────────────────────────── */
.county-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.county-btn {
  padding: 5px 13px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
  user-select: none;
}

.county-btn:hover {
  border-color: var(--brand-400);
  color: var(--brand-700);
}

.county-btn.selected {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge svg {
  width: 11px;
  height: 11px;
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-blue {
  background: var(--brand-50);
  color: var(--brand-700);
}

.badge-green {
  background: var(--color-success-bg);
  color: #065F46;
}

.badge-red {
  background: var(--color-danger-bg);
  color: #991B1B;
}

.badge-orange {
  background: var(--color-orange-bg);
  color: #9A3412;
}

.badge-purple {
  background: var(--color-purple-bg);
  color: #5B21B6;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: #92400E;
}

/* ── Avatar ──────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--brand-100);
  color: var(--brand-700);
}

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

.avatar-xs {
  width: 28px;
  height: 28px;
  font-size: .6875rem;
}

.avatar-sm {
  width: 34px;
  height: 34px;
  font-size: .75rem;
}

.avatar-md {
  width: 42px;
  height: 42px;
  font-size: .875rem;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.125rem;
}

.avatar-xl {
  width: 80px;
  height: 80px;
  font-size: 1.5rem;
}

.avatar-green {
  background: var(--color-success-bg);
  color: #065F46;
}

.avatar-orange {
  background: var(--color-orange-bg);
  color: #9A3412;
}

.avatar-purple {
  background: var(--color-purple-bg);
  color: #5B21B6;
}

/* ── Progress bar ────────────────────────────────────────────── */
.progress-wrap {
  width: 100%;
}

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: .8125rem;
}

.progress-track {
  height: 7px;
  background: var(--gray-100);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand-600);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

.progress-fill.green {
  background: var(--color-success);
}

.progress-fill.orange {
  background: var(--color-warning);
}

.progress-fill.red {
  background: var(--color-danger);
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(.96) translateY(10px);
  transition: transform var(--t-slow);
  z-index: var(--z-modal);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-sm {
  max-width: 380px;
}

.modal-md {
  max-width: 635px;
}

.modal-lg {
  max-width: 700px;
}

.modal-xl {
  max-width: 900px;
}

.modal-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  flex: 1;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-body-scroll {
  max-height: 58vh;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  width: calc(100vw - 48px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--gray-900);
  color: #fff;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform .35s cubic-bezier(.2, 0, 0, 1.2), opacity .35s;
  opacity: 0;
  font-size: .875rem;
  line-height: 1.5;
  border-left: 3px solid var(--brand-500);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.toast-success {
  border-color: var(--color-success);
}

.toast.toast-error {
  border-color: var(--color-danger);
}

.toast.toast-warning {
  border-color: var(--color-warning);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-icon.success {
  color: var(--color-success);
}

.toast-icon.error {
  color: var(--color-danger);
}

.toast-icon.warning {
  color: var(--color-warning);
}

.toast-icon.info {
  color: var(--brand-400);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: .875rem;
}

.toast-msg {
  font-size: .8125rem;
  color: rgba(255, 255, 255, .7);
  margin-top: 1px;
}

.toast-close {
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, .4);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--t-fast);
  white-space: nowrap;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-600);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform var(--t);
}

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

.tab-btn.active {
  color: var(--brand-600);
  font-weight: 600;
}

.tab-btn.active::after {
  transform: scaleX(1);
}

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: var(--z-dropdown);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(.97);
  transition: opacity var(--t), transform var(--t);
  padding: 6px;
}

.dropdown-menu.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}

.dropdown-item:hover {
  background: var(--gray-50);
  color: var(--text-primary);
  text-decoration: none;
}

.dropdown-item.danger:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.dropdown-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 0;
}

/* ── Calendar: view toggle ───────────────────────────────────── */
.cal-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.cal-view-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: .8125rem;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.cal-view-btn.active {
  background: var(--brand-600);
  color: #fff;
}

.cal-view-btn:not(.active):hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.cal-panel-hidden {
  display: none;
}

/* ── Calendar: list view ─────────────────────────────────────── */
.cal-list-section {
  padding: 8px 18px;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.cal-list-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: .9375rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.cal-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

.cal-list-row:last-child {
  border-bottom: none;
}

.cal-list-row:hover {
  background: var(--brand-50);
}

.cal-list-date {
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.cal-list-dow {
  display: block;
  font-size: .625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cal-list-d {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.cal-list-mon {
  display: block;
  font-size: .625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cal-list-today {
  background: var(--brand-600);
  color: #fff !important;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.cal-list-stripe {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}

.cal-list-stripe.edt_lesson {
  background: #1D4ED8;
}

.cal-list-stripe.standard_lesson {
  background: #065F46;
}

.cal-list-stripe.pre_test {
  background: #B45309;
}

.cal-list-stripe.car_hire {
  background: #6D28D9;
}

.cal-list-stripe.cancelled {
  background: var(--gray-300);
}

.cal-ev-slot-stripe {
  background: var(--gray-400);
}

.cal-list-slot-row {
  background: var(--gray-50);
}

.cal-list-slot-row:hover {
  background: #CCFBF1;
}

/* Slot area grid in create-slot modals */
.slot-areas-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slot-area-group-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.slot-area-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.slot-area-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8125rem;
  cursor: pointer;
  padding: 3px 8px 3px 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background .15s, border-color .15s;
}

.slot-area-check:hover {
  background: var(--brand-50);
  border-color: var(--brand-300);
}

.slot-area-check input[type=checkbox] {
  accent-color: var(--brand-600);
  width: 14px;
  height: 14px;
  margin: 0;
}

.cal-list-body {
  flex: 1;
  min-width: 0;
}

.cal-list-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.cal-list-name {
  font-weight: 600;
  font-size: .9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-list-time {
  font-size: .8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.cal-list-bottom {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* ── Calendar: legend swatch ─────────────────────────────────── */
.cal-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.cal-swatch.edt_lesson {
  background: #BFDBFE;
}

.cal-swatch.standard_lesson {
  background: #A7F3D0;
}

.cal-swatch.pre_test {
  background: #FDE68A;
}

.cal-swatch.car_hire {
  background: #DDD6FE;
}

/* ── Calendar: mobile bar layout (Epic-style) ───────────────── */
.cal-bars {
  display: none;
  /* shown by mobile.css */
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding: 0 1px;
}

.cal-bar-row {
  display: flex;
  gap: 2px;
}

.cal-bar {
  height: 5px;
  border-radius: 3px;
  min-width: 0;
  cursor: pointer;
  transition: opacity .15s;
}

.cal-bar:hover {
  opacity: .7;
}

.cal-bar.edt_lesson {
  background: #3B82F6;
}

.cal-bar.standard_lesson {
  background: #10B981;
}

.cal-bar.pre_test {
  background: #F59E0B;
}

.cal-bar.car_hire {
  background: #8B5CF6;
}

.cal-bar.cancelled {
  background: var(--gray-300);
}

.cal-bar.cal-ev-slot-bar {
  background: var(--gray-400);
  opacity: .75;
}

.cal-bar-more {
  font-size: .5rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1px;
}

/* ── Calendar ────────────────────────────────────────────────── */
.cal-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}

.cal-nav {
  display: flex;
  gap: 6px;
}

.cal-month-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-dow {
  text-align: center;
  padding: 10px 4px 8px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.cal-day {
  min-height: 90px;
  padding: 8px 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
  position: relative;
  vertical-align: top;
}

.cal-day:nth-child(7n) {
  border-right: none;
}

.cal-day:hover {
  background: var(--brand-50);
}

.cal-day.other-month {
  background: var(--gray-50);
}

.cal-day.other-month .day-num {
  color: var(--gray-300);
}

.cal-day.today {
  background: var(--brand-50);
}

.cal-day.today .day-num {
  background: var(--brand-600);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-day.holiday {
  background: #FFF7ED;
}

.cal-day.weekend .day-num {
  color: var(--text-muted);
}

.day-header {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}

.day-num {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.cal-holiday-badge {
  font-size: .5625rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: #FEF3C7;
  color: #92400E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.cal-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-event {
  display: block;
  font-size: .6875rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: filter var(--t-fast);
}

.cal-event:hover {
  filter: brightness(.92);
}

.cal-event.edt_lesson {
  background: #BFDBFE;
  color: #1D4ED8;
}

.cal-event.standard_lesson {
  background: #A7F3D0;
  color: #065F46;
}

.cal-event.pre_test {
  background: #FDE68A;
  color: #B45309;
}

.cal-event.car_hire {
  background: #DDD6FE;
  color: #6D28D9;
}

.cal-event.cancelled {
  background: var(--gray-100);
  color: var(--gray-500);
  text-decoration: line-through;
}

.cal-event.ev-past,
.cal-bar.ev-past,
.cal-list-row.ev-past {
  opacity: 0.45;
}

.cal-list-row.not-own {
  border-left: 3px solid var(--brand-600);
  padding-left: 15px;
}

.cal-event.cal-ev-slot {
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px dashed var(--gray-400);
}

.cal-event.not-own {
  border-left: 10px solid var(--brand-600);
}

.cal-event.more {
  background: none;
  color: var(--brand-600);
  font-weight: 600;
}

.cal-more-btn {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cal-event.has-reschedule {
  outline: 2px solid #F59E0B;
  outline-offset: -2px;
}

.cal-resched-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #EF4444;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.cal-more-btn:hover {
  color: var(--brand-700);
}

.day-view-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

.day-view-row:last-child {
  border-bottom: none;
}

.day-view-row:hover {
  background: var(--gray-50);
}

.past-reminder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.past-reminder-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.past-reminder-info {
  flex: 1;
  min-width: 0;
}

.past-reminder-info .font-semi {
  margin-bottom: 4px;
}

.day-view-time {
  min-width: 44px;
  text-align: center;
}

/* ── Registration Step 3 — pre-check questions ───────────────── */
.reg-question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.reg-question-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: .9375rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.reg-question-title svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--brand-600);
}

.reg-question-desc {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.reg-option-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .9rem;
}

.reg-option-label input[type="radio"] {
  flex-shrink: 0;
}

.reg-info-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--brand-50);
  border-left: 3px solid var(--brand-400);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: .8125rem;
  color: var(--brand-800);
}

.reg-info-note svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.reg-own-car-box {
  margin-top: 16px;
  padding: 16px;
  background: var(--color-warning-bg);
  border: 1px solid #FCD34D;
  border-radius: var(--radius-md);
}

.reg-own-car-legal {
  font-size: .8125rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.6;
}

/* Legal modals — T&C / Privacy Policy */
.legal-draft-notice {
  background: var(--color-warning-bg);
  border: 1px solid #FCD34D;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .8125rem;
  margin-bottom: 20px;
}

.legal-effective {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-body-scroll h4 {
  font-size: .9375rem;
  font-weight: 600;
  margin: 20px 0 6px;
  color: var(--text-primary);
}

.modal-body-scroll p,
.modal-body-scroll li {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.modal-body-scroll ul {
  padding-left: 20px;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-body-scroll h4:first-of-type {
  margin-top: 0;
}

/* ── Auth pages (login / register) ───────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-brand {
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 60%, #1D4ED8 100%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: rgba(59, 130, 246, .08);
  border-radius: 50%;
  top: -200px;
  right: -200px;
}

.auth-brand::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: rgba(59, 130, 246, .06);
  border-radius: 50%;
  bottom: -150px;
  left: -100px;
}

.auth-brand-inner {
  position: relative;
  z-index: 1;
}

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.auth-brand-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--brand-600);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .25);
}

.auth-brand-logo-icon svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

.auth-brand-logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.5px;
}

.auth-brand-logo-text span {
  color: var(--brand-400);
}

.auth-brand h1 {
  font-size: 2.25rem;
  color: #fff;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 18px;
  letter-spacing: -.5px;
}

.auth-brand p {
  color: rgba(255, 255, 255, .6);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 380px;
}

.auth-brand-features {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, .75);
  font-size: .9375rem;
}

.auth-brand-feature-icon {
  width: 34px;
  height: 34px;
  background: rgba(59, 130, 246, .2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-brand-feature-icon svg {
  width: 17px;
  height: 17px;
  color: var(--brand-300);
}

.auth-form-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 60px;
  background: #fff;
  overflow-y: auto;
}

.auth-form-box {
  width: 100%;
  max-width: 420px;
}

.auth-form-box h2 {
  margin-bottom: 6px;
}

.auth-form-box>p {
  margin-bottom: 32px;
}

/* Role selector */
.role-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.role-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
  text-align: center;
}

.role-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.role-card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  transition: background var(--t);
}

.role-card-icon svg {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  transition: color var(--t);
}

.role-card-title {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text-secondary);
}

.role-card-desc {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.role-card:has(input:checked) {
  border-color: var(--brand-600);
  background: var(--brand-50);
}

.role-card:has(input:checked) .role-card-icon {
  background: var(--brand-100);
}

.role-card:has(input:checked) .role-card-icon svg {
  color: var(--brand-700);
}

.role-card:has(input:checked) .role-card-title {
  color: var(--brand-700);
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.0625rem;
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: .875rem;
  max-width: 300px;
  margin: 0 auto 20px;
}

/* ── Alert banners ───────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 20px;
  border: 1px solid;
}

.alert svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-info {
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
  color: #1E40AF;
}

.alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: #065F46;
}

.alert-warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: #92400E;
}

.alert-danger {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: #991B1B;
}

/* ── Search bar ──────────────────────────────────────────────── */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-bar svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  font-size: .875rem;
  color: var(--text-primary);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .1);
}

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: .8125rem;
  margin: 20px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Skeleton loading ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.wide {
  width: 80%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-avatar {
  border-radius: 50%;
}

/* ── Floating action button ──────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .4);
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  z-index: 50;
}

.fab:hover {
  background: var(--brand-700);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(37, 99, 235, .5);
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* ── Utilities ───────────────────────────────────────────────── */
.d-flex {
  display: flex;
}

.d-grid {
  display: grid;
}

.d-none {
  display: none;
}

.flex-1 {
  flex: 1;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.gap-5 {
  gap: 20px;
}

.gap-6 {
  gap: 24px;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.p-0 {
  padding: 0;
}

.text-sm {
  font-size: .875rem;
}

.text-xs {
  font-size: .75rem;
}

.font-medium {
  font-weight: 500;
}

.font-semi {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

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

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

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

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

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

.text-brand {
  color: var(--brand-600);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

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

.rounded-full {
  border-radius: 9999px;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.min-w-0 {
  min-width: 0;
}

/* ── Admin: Instructor mobile cards ─────────────────────────── */
.instr-mobile-card {
  display: none;
}

.instr-mobile-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.instr-mobile-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.instr-mobile-actions .btn svg {
  width: 15px;
  height: 15px;
}

/* ── Admin: Student list ─────────────────────────────────────── */
#students-list {
  overflow-x: auto;
}

.stud-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 200px 100px 100px 100px 240px;
  column-gap: 16px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

.stud-header-row {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.stud-data-row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.stud-data-row:last-child {
  border-bottom: none;
}

.stud-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
}

.stud-actions .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  flex-shrink: 0;
}

.stud-actions .btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.stud-edt {
  min-width: 80px;
}

.stud-edt-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

/* ── Admin: Instructor list ──────────────────────────────────── */
.instr-grid {
  display: grid;
  grid-template-columns: 1fr 80px 90px 115px 68px 105px 100px 310px;
  column-gap: 16px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

#instructors-list {
  overflow-x: auto;
}

.instr-header-row {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.instr-col-head {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.instr-col-head-right {
  text-align: right;
}

.instr-data-row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.instr-data-row:last-child {
  border-bottom: none;
}

.instr-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ── Student Card Modal ──────────────────────────────────────── */
.sc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 640px) {
  .sc-grid {
    grid-template-columns: 1fr;
  }
}

.sc-section-title {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sc-info-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sc-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: .875rem;
}

.sc-info-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.sc-info-value {
  text-align: right;
  word-break: break-word;
}

#sc-payments-list {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.sc-payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.sc-payment-row:last-child {
  border-bottom: none;
}

.sc-payment-summary {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sc-own-car-note {
  margin-top: 10px;
  padding: 10px 12px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  font-size: .8125rem;
  color: #92400E;
  line-height: 1.5;
}

/* ── Danger Zone ─────────────────────────────────────────────── */
.danger-zone-card {
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
}

.danger-zone-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: var(--color-danger-bg);
  border-bottom: 1px solid var(--color-danger-border);
  font-weight: 700;
  font-size: .9375rem;
  color: #991B1B;
}

.danger-zone-body {
  padding: 20px 22px;
}

.danger-zone-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.danger-zone-item-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.danger-zone-item-desc {
  font-size: .875rem;
  color: var(--text-muted);
}

.delete-consequences-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.delete-consequences-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .875rem;
}

.delete-consequences-list li svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.delete-confirm-input-wrap {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.delete-confirm-label {
  display: block;
  font-size: .875rem;
  margin-bottom: 10px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn .3s ease;
}

.animate-scale-in {
  animation: scaleIn .25s ease;
}

.animate-slide-up {
  animation: slideUp .35s ease;
}

/* Stagger children */
.stagger>* {
  animation: fadeIn .3s ease both;
}

.stagger>*:nth-child(1) {
  animation-delay: .05s;
}

.stagger>*:nth-child(2) {
  animation-delay: .10s;
}

.stagger>*:nth-child(3) {
  animation-delay: .15s;
}

.stagger>*:nth-child(4) {
  animation-delay: .20s;
}

.stagger>*:nth-child(5) {
  animation-delay: .25s;
}

.stagger>*:nth-child(6) {
  animation-delay: .30s;
}

/* ── Subscription billing toggle ─────────────────────────────────────── */
.sub-billing-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.sub-billing-toggle {
  display: flex;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.sub-billing-btn {
  border: none;
  background: none;
  padding: 6px 20px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  white-space: nowrap;
}

.sub-billing-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

.sub-billing-save {
  display: inline-block;
  font-size: .6875rem;
  font-weight: 700;
  color: var(--color-success);
  background: var(--color-success-bg);
  border-radius: 4px;
  padding: 2px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Subscription plan cards ─────────────────────────────────────────── */
.sub-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.sub-plan-card.is-current {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}

.sub-plan-badge {
  margin-bottom: 12px;
}

.sub-plan-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.sub-plan-price-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: 4px;
}

.sub-plan-price-cur {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-600);
}

.sub-plan-price-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-600);
  line-height: 1;
  transition: opacity 120ms ease, transform 120ms ease;
}

.sub-plan-price-per {
  font-size: .875rem;
  color: var(--text-muted);
  margin-left: 2px;
}

.sub-plan-annual-note {
  font-size: .75rem;
  color: var(--text-muted);
  min-height: 1.25em;
  margin-bottom: 8px;
}

.sub-plan-desc {
  font-size: .875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.sub-plan-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 16px;
}

.sub-plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sub-plan-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
}

.sub-plan-btn-full {
  width: 100%;
  justify-content: center;
}

.sub-plan-btn-disabled {
  pointer-events: none;
  opacity: .6;
}

/* ── Mobile bottom navigation ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, .07);
  display: none;
  /* activated by mobile.css */
  align-items: center;
  /* height = usable 68px + iPhone home-indicator safe area */
  height: calc(68px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .625rem;
  font-weight: 500;
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
  transition: color 150ms ease;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.bottom-nav-item.active {
  color: var(--brand-600);
}

.bottom-nav-label {
  line-height: 1;
}

.bottom-nav-icon-wrap {
  position: relative;
  display: inline-flex;
}

.bottom-nav-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--color-danger);
  color: #fff;
  font-size: .5625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  border: 2px solid var(--bg-card);
}

/* Centre "Schedule" button — larger and elevated */
.bottom-nav-item.bottom-nav-center {
  flex: 1.2;
}

.bottom-nav-center-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, .42);
  transform: translateY(-16px);
  flex-shrink: 0;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.bottom-nav-center-btn svg {
  width: 26px;
  height: 26px;
}

.bottom-nav-item.bottom-nav-center:active .bottom-nav-center-btn {
  transform: translateY(-16px) scale(.91);
  box-shadow: 0 2px 6px rgba(37, 99, 235, .32);
}

.bottom-nav-item.bottom-nav-center.active .bottom-nav-center-btn {
  background: var(--brand-700);
}

.bottom-nav-item.bottom-nav-center .bottom-nav-label {
  margin-top: -10px;
}

/* ── Instructor: Student list (div grid) ─────────────────────── */
#student-list {
  overflow-x: auto;
}

.istud-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 90px 140px 105px 100px 196px;
  column-gap: 20px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

.istud-header-row {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.istud-data-row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.istud-data-row:last-child {
  border-bottom: none;
}

.istud-mobile-card {
  display: none;
}

/* ── Instructor: Resources list (div grid) ────────────────────── */
.res-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 110px minmax(160px, 1fr) 90px;
  column-gap: 20px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

.res-grid-partner {
  grid-template-columns: minmax(200px, 1fr) 110px minmax(160px, 1fr) 130px 90px;
}

.res-header-row {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.res-data-row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.res-data-row:last-child {
  border-bottom: none;
}

.res-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.res-mobile-card {
  display: none;
}

/* ── Admin: Student mobile card ──────────────────────────────── */
.stud-mobile-card {
  display: none;
}

/* ── Instructor: Invite Codes list (div grid) ─────────────────── */
#codes-list {
  overflow-x: auto;
}

.inv-grid {
  display: grid;
  grid-template-columns: 150px 90px 110px 190px minmax(120px, 1fr) 200px;
  column-gap: 16px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

.inv-header-row {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.inv-data-row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.inv-data-row:last-child {
  border-bottom: none;
}

.inv-code-text {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--brand-700);
}

.inv-mobile-card {
  display: none;
}

.inv-mobile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ── My Progress page ────────────────────────────────────────── */
.prog-hero-card {
  margin-bottom: 24px;
}

.prog-hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
}

.prog-hero-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.prog-hero-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--brand-700);
}

.prog-hero-value.complete {
  color: var(--color-success);
}

.prog-hero-unit {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-muted);
}

.prog-hero-track {
  height: 12px;
  margin-bottom: 12px;
  border-radius: 99px;
}

.prog-hero-fill {
  border-radius: 99px;
}

.prog-complete-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-success);
  font-weight: 600;
}

.prog-pct-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--brand-600);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.prog-pct-circle.complete {
  background: var(--color-success);
}

.prog-pct-num {
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1;
}

.prog-pct-label {
  font-size: .625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .8;
}

.prog-stats {
  margin-bottom: 24px;
}

.no-edt-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.no-edt-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--brand-100);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.no-edt-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.no-edt-desc {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.prog-test-card {
  margin-bottom: 24px;
}

.prog-test-hint {
  margin-bottom: 16px;
}

.prog-test-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.prog-test-date-group {
  margin: 0;
  flex: 1;
  min-width: 180px;
}

.prog-test-passed {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-success);
}

.prog-test-title {
  font-size: 1.125rem;
}

.prog-page-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}

.prog-table-wrap {
  border: none;
  border-radius: 0;
}

.prog-empty {
  padding: 16px 0;
}

.prog-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prog-breakdown-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.prog-breakdown-track {
  height: 6px;
}

.prog-test-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--color-success);
  font-weight: 600;
}

/* ── Learner dashboard layout ─────────────────────────────────── */
.learner-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

/* Icon-only button variant */
.btn-icon {
  padding: 6px;
  aspect-ratio: 1;
  justify-content: center;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}



/* ── My Progress: Lesson History grid ─────────────────────── */
.lesson-list {
  overflow-x: auto;
}

.lesson-header-row {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.lesson-data-row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.lesson-data-row:last-child {
  border-bottom: none;
}

/* EDT-only columns: Date | Time | Duration | Status */
.lesson-grid-edt {
  display: grid;
  grid-template-columns: 130px 100px 90px 110px;
  column-gap: 16px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

/* All-lessons columns: Date | Time | Type | Duration | Status */
.lesson-grid-all {
  display: grid;
  grid-template-columns: 130px 90px minmax(100px, 1fr) 90px 110px;
  column-gap: 16px;
  padding-left: 22px;
  padding-right: 22px;
  align-items: center;
}

.lesson-mobile-card {
  display: none;
}


/* ── Learner: Upcoming lesson rows ────────────────────────── */
.card-body-flush {
  padding: 0;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.upcoming-item:last-child {
  border-bottom: none;
}

.upcoming-date-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--brand-50);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.upcoming-date-month {
  font-size: .6875rem;
  font-weight: 700;
  color: var(--brand-600);
  text-transform: uppercase;
}

.upcoming-date-day {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--brand-700);
  line-height: 1;
}

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


/* ── Topbar: notification dropdown ────────────────────────── */
.topbar-notif-wrap {
  position: relative;
}

.topbar-notif-dropdown {
  position: fixed;
  top: 68px;
  right: 8px;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
}

.topbar-notif-hdr {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.topbar-notif-dropdown> :last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.topbar-notif-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.topbar-notif-hdr-title {
  font-weight: 700;
  font-size: .875rem;
  color: var(--text-primary);
}

.topbar-notif-mark-all {
  font-size: .75rem;
  font-weight: 500;
  color: var(--brand-600);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.topbar-notif-mark-all:hover {
  text-decoration: underline;
}

.topbar-notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: .875rem;
}

/* Must come after the ".topbar-notif-dropdown> :last-child" rule above and
   match its specificity (two class-level selectors) so this wins the cascade
   tie via source order — that rule sets overflow:hidden for corner-rounding
   on whatever the last child is, which silently disabled scrolling here
   whenever there were enough notifications to make this the last child. */
.topbar-notif-dropdown > .topbar-notif-list {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
}

.topbar-notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.topbar-notif-item:last-child {
  border-bottom: none;
}

.topbar-notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
  flex-shrink: 0;
  margin-top: 5px;
}

.topbar-notif-dot-orange {
  background: var(--color-warning, #F59E0B);
}

.topbar-notif-item-link {
  text-decoration: none;
  color: inherit;
  display: flex;
}

.topbar-notif-item-link:hover {
  background: var(--gray-50);
}

.topbar-notif-body {
  flex: 1;
  min-width: 0;
}

.topbar-notif-item-title {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.topbar-notif-item-msg {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 4px;
}

.topbar-notif-item-time {
  font-size: .6875rem;
  color: var(--text-muted);
}

/* ── Notify Student modal (WhatsApp / Copy) ──────────────────── */
.notify-student-hdr {
  margin-bottom: 4px;
}

.notify-email-sent {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 10px;
  background: rgba(16, 185, 129, .1);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--success);
  font-weight: 500;
}

.notify-email-sent svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.notify-msg-area {
  font-size: .875rem;
  font-family: inherit;
  resize: vertical;
  background: var(--gray-50);
  color: var(--text-primary);
  line-height: 1.6;
}

.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast);
  white-space: nowrap;
}

.btn-wa:hover {
  background: #1aaa54;
  color: #fff;
}

.btn-wa svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.btn-wa-disabled {
  opacity: .4;
  pointer-events: none;
}

/* ── Calendar Export Dropdown ──────────────────────────────── */
.cal-export-wrap {
  position: relative;
}

.cal-export-dropdown {
  position: fixed;
  top: 68px;
  right: 8px;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  padding: 6px;
  z-index: 200;
  opacity: 0;
  transform: scale(0.95) translateY(-6px);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity .15s ease-out, transform .15s ease-out;
}

.cal-export-dropdown.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* ── Dropdown caret arrow ─────────────────────────────────────────────────
   A rotated square whose top two edges (NW + NE of the diamond) show the
   dropdown border colour, and whose fill matches the dropdown background.
   This makes the caret look like a notch cut into the dropdown's top border.
   --arrow-x is set via JS to the horizontal centre of the trigger button. */
.topbar-dropdown::before,
.topbar-notif-dropdown::before,
.cal-export-dropdown::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right-color: transparent;
  border-bottom-color: transparent;
  top: -6px;
  left: clamp(14px, var(--arrow-x, calc(100% - 22px)), calc(100% - 14px));
  transform: translateX(-50%) rotate(45deg);
  z-index: 3;
  pointer-events: none;
}

.cal-export-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-primary);
  font: inherit;
  font-size: .875rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast);
}

.cal-export-item:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.cal-export-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.cal-export-item-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cal-export-item-label {
  font-weight: 500;
  line-height: 1.3;
}

.cal-export-item-desc {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.cal-export-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ── ICS Import page ──────────────────────────────────────────────────── */
.ics-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.ics-bulk-bar select {
  width: auto;
  flex: 1;
  min-width: 160px;
}

.ics-event-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.ics-event-row:last-child {
  border-bottom: none;
}

.ics-event-row .ics-row-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.ics-event-meta {
  flex: 1;
  min-width: 0;
}

.ics-event-row select {
  width: auto;
  flex-shrink: 0;
  min-width: 150px;
}

/* ── Partnership calendar bar colours ───────────────────────────────── */
.cal-bar.partner-0 {
  background: #2563EB;
}

.cal-bar.partner-1 {
  background: #7C3AED;
}

.cal-bar.partner-2 {
  background: #059669;
}

.cal-bar.partner-3 {
  background: #D97706;
}

.cal-bar.partner-4 {
  background: #DC2626;
}

/* ── Partner dot (student list instructor indicator) ─────────────────── */
.partner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ── Student grid with instructor column ─────────────────────────────── */
.istud-grid-partner {
  grid-template-columns: minmax(150px, 0.8fr) minmax(120px, 0.6fr) 105px 200px 105px 100px 196px;
}

/* ── Partnership management page ─────────────────────────────────────── */
.partnership-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.partnership-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary-light, #EFF6FF);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.partnership-icon svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.partner-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 150ms;
}

.partner-member-row:last-child {
  border-bottom: none;
}

.partner-member-row:hover {
  background: var(--bg-hover);
}

.partner-member-pending {
  opacity: .75;
}

.partner-color-bar {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.partner-member-info {
  flex: 1;
  min-width: 0;
}

.partner-member-info .font-semi {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-gray {
  background: var(--bg-muted, #E2E8F0);
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .partnership-grid {
    grid-template-columns: 1fr;
  }

  .istud-grid-partner {
    grid-template-columns: 1fr 1fr 80px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   HELP & SUPPORT PAGES
   ═══════════════════════════════════════════════════════════════ */

.help-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #2563EB 0%, #1d4ed8 100%);
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 28px;
  color: #fff;
}

.help-hero-icon {
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, .15);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.help-hero-icon svg {
  color: #fff;
}

.help-hero-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.help-hero-sub {
  font-size: .9375rem;
  opacity: .82;
}

.help-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 20px;
  padding: 3px 12px 3px 8px;
  font-size: .8125rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10px;
}

.help-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.help-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color var(--t-base), color var(--t-base), background var(--t-base);
}

.help-quick-link:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-ghost);
}

.help-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.help-accordion {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--t-base);
}

.help-accordion[open] {
  box-shadow: var(--shadow-sm);
}

.help-accordion-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-base);
}

.help-accordion-summary::-webkit-details-marker {
  display: none;
}

.help-accordion-summary:hover {
  background: var(--bg-subtle);
}

.help-accordion-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary-ghost);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}

.help-accordion-label {
  flex: 1;
  font-weight: 600;
  font-size: .9375rem;
  color: var(--text-primary);
}

.help-accordion-count {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.help-accordion-chevron {
  color: var(--text-muted);
  transition: transform var(--t-base);
  flex-shrink: 0;
}

.help-accordion[open] .help-accordion-chevron {
  transform: rotate(180deg);
}

.help-accordion-body {
  border-top: 1px solid var(--border);
  padding: 6px 0 8px;
}

.help-item {
  padding: 16px 20px 16px 66px;
  border-bottom: 1px solid var(--border-subtle, #f1f5f9);
}

.help-item:last-child {
  border-bottom: none;
}

.help-item h4 {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.help-item p {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.help-item p:last-child {
  margin-bottom: 0;
}

.help-item ul {
  margin: 6px 0 8px 0;
  padding-left: 18px;
}

.help-item ul li {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2px;
}

.help-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--primary-ghost);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: .8125rem;
  color: var(--primary);
  line-height: 1.6;
}

.help-tip svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.help-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.help-switch-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.help-switch-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.help-switch-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.help-switch-card-icon.green {
  background: #dcfce7;
  color: #16a34a;
}

.help-switch-card-icon.blue {
  background: var(--primary-ghost);
  color: var(--primary);
}

[data-theme="dark"] .help-switch-card-icon.green {
  background: rgba(22, 163, 74, .15);
  color: #4ade80;
}

.help-switch-card-body {
  flex: 1;
  min-width: 0;
}

.help-switch-card-title {
  font-weight: 700;
  font-size: .9375rem;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.help-switch-card-sub {
  font-size: .8125rem;
  color: var(--text-secondary);
}

.help-switch-card-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

.help-support-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.help-support-card-icon {
  width: 48px;
  height: 48px;
  background: #fef3c7;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #d97706;
}

[data-theme="dark"] .help-support-card-icon {
  background: rgba(217, 119, 6, .15);
  color: #fbbf24;
}

.help-support-card-body {
  flex: 1;
}

.help-support-card-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.help-support-card-sub {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.help-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 20px;
  transition: color var(--t-base);
}

.help-back-link:hover {
  color: var(--primary);
}

/* ── PWA iOS install modal ─────────────────────────────────────────────────── */
.pwa-ios-steps {
  margin: 0 0 16px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text-primary);
  font-size: .9375rem;
  line-height: 1.5;
}

.pwa-ios-share-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  color: var(--brand-600);
}

.pwa-ios-note {
  margin: 0;
  font-size: .8125rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .help-hero {
    padding: 20px;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .help-hero-icon {
    display: none;
  }

  .help-item {
    padding-left: 20px;
  }

  .help-bottom-grid {
    grid-template-columns: 1fr;
  }

  .help-support-card {
    flex-direction: column;
    align-items: flex-start;
  }
}