/* ═══════════════════════════════════════════════════════
   DEMO SCHOOL — GLOBAL DESIGN SYSTEM
   "An Intelligent, Living Interface"
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,300&display=swap');

/* ───────────────────────────────────────────
   DESIGN TOKENS
─────────────────────────────────────────── */
:root {
  /* Brand */
  --navy:       #0f2847;
  --navy2:      #1a3a5c;
  --navy3:      #0b1e35;
  --gold:       #c9a84c;
  --gold2:      #e8c96a;
  --gold-soft:  rgba(201,168,76,0.12);

  /* Semantic */
  --primary:        var(--navy2);
  --primary-dark:   var(--navy);
  --primary-light:  #2d6a9f;
  --secondary:      #8b5cf6;
  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;

  /* Surface */
  --bg:       #f0f4f9;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --border2:  #cbd5e1;

  /* Text */
  --text-primary:   #0f2847;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;

  /* Sidebar */
  --sidebar-w:      240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h:       60px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(15,40,71,0.06);
  --shadow:    0 4px 16px rgba(15,40,71,0.10);
  --shadow-lg: 0 12px 40px rgba(15,40,71,0.14);

  /* Radii */
  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  /* Easing */
  --ease: cubic-bezier(0.22,1,0.36,1);
  --transition: all 0.25s var(--ease);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ═══════════════════════════════════════════════════════
   APP SHELL — SIDEBAR + TOPBAR + CONTENT
═══════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────
   LAYOUT WRAPPER
─────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ───────────────────────────────────────────
   SIDEBAR
─────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  overflow: hidden;          /* horizontal hidden to prevent brand text overflow */
  overflow-y: auto;          /* vertical scroll if content taller than viewport */
  z-index: 200;
  transition: width 0.3s var(--ease);
  scrollbar-width: none;     /* hide scrollbar on the sidebar itself */
}

.sidebar::-webkit-scrollbar { display: none; }

/* Subtle inner texture */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 140% 60% at 50% 0%, rgba(201,168,76,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 80% 40% at 10% 100%, rgba(255,255,255,0.02) 0%, transparent 50%);
  pointer-events: none;
}

/* Gold top bar */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(to right, var(--gold), var(--gold2), var(--gold));
}

/* Brand section */
.sidebar-brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 8px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(201,168,76,0.2), rgba(201,168,76,0.08));
  border: 1px solid rgba(201,168,76,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-brand-text {
  overflow: hidden;
}

.sidebar-school-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-tagline {
  font-size: 0.65rem;
  color: rgba(201,168,76,0.65);
  letter-spacing: 0.06em;
  white-space: nowrap;
  margin-top: 1px;
}

/* Nav section label */
.sidebar-section-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 12px 20px 6px;
  flex-shrink: 0;
}

/* Nav items */
.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px calc(60px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

/* Sidebar footer — anchored to the bottom of the sidebar absolutely */
.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--navy);
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  font-size: 0.855rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  margin-bottom: 2px;
}

.nav-item:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.06);
}

.nav-item.active {
  color: white;
  background: linear-gradient(135deg, rgba(201,168,76,0.18), rgba(201,168,76,0.08));
  font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(201,168,76,0.15);
}

/* Active left border */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(to bottom, var(--gold), var(--gold2));
}

/* Active glow */
.nav-item.active::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 60px;
  background: linear-gradient(to right, rgba(201,168,76,0.08), transparent);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.nav-item-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.nav-item:hover .nav-item-icon,
.nav-item.active .nav-item-icon { opacity: 1; }

.nav-item-label { flex: 1; }

.nav-badge {
  background: rgba(201,168,76,0.2);
  color: var(--gold2);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}

.sidebar-signature {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.38);
  letter-spacing: 0.05em;
  text-align: center;
  line-height: 1.5;
  font-style: italic;
}

.sidebar-signature span { color: rgba(201,168,76,0.45); font-style: normal; }

/* Hamburger: hidden on desktop, shown by mobile media query */
.topbar-hamburger { display: none; }

/* ───────────────────────────────────────────
   TOPBAR
─────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  box-shadow: 0 1px 0 rgba(15,40,71,0.05);
}

.topbar-page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.topbar-breadcrumb {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.topbar-breadcrumb span { color: var(--gold); }

.topbar-search {
  flex: 1;
  max-width: 360px;
  margin: 0 auto;
  position: relative;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  padding: 9px 16px 9px 36px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  margin-bottom: 0;
}

.topbar-search input:focus {
  border-color: var(--navy2);
  background: white;
  box-shadow: 0 0 0 3px rgba(26,58,92,0.07);
}

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

/* ── Global search results dropdown ── */
.global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}

.gs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.gs-item:last-child { border-bottom: none; }
.gs-item:hover { background: var(--bg); }

.gs-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

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

.gs-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.gs-empty {
  padding: 18px 16px;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
}

.gs-section-label {
  padding: 8px 14px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.gs-pay-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(16,185,129,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--success);
  margin-top: 1px;
}

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

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: all 0.2s var(--ease);
}

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

.notif-dd-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }

.notif-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(26,58,92,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--navy2);
  margin-top: 1px;
}

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

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

.notif-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.notif-empty {
  padding: 20px 16px;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}

.topbar-icon-btn:hover { background: var(--bg); color: var(--navy); }

.notif-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

/* Avatar + menu */
.topbar-avatar-wrap { position: relative; }

.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  letter-spacing: 0.05em;
  border: 2px solid transparent;
  transition: var(--transition);
}

.topbar-avatar:hover { border-color: var(--gold); transform: scale(1.05); }

.avatar-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 196px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: all 0.2s var(--ease);
  z-index: 300;
}

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

.avatar-dd-head {
  padding: 10px 12px 11px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.avatar-dd-name { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); }
.avatar-dd-role { font-size: 0.72rem; color: var(--text-secondary); margin-top: 1px; }

.avatar-dd-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.avatar-dd-item:hover { background: var(--bg); color: var(--navy); }
.avatar-dd-item.danger { color: var(--danger); }
.avatar-dd-item.danger:hover { background: #fef2f2; }

/* ───────────────────────────────────────────
   MAIN CONTENT
─────────────────────────────────────────── */
.main-content {
  grid-area: main;
  padding: 28px 32px 64px;
  overflow-x: hidden;
  animation: contentIn 0.45s var(--ease) both;
}

@keyframes contentIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Page header inside main */
.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 300;
}

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

/* ═══════════════════════════════════════════════════════
   CARD SYSTEM
═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.card h2,
.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Gold accent bar before card titles */
.card h2::before,
.card-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: linear-gradient(to bottom, var(--gold), var(--gold2));
  border-radius: 2px;
  flex-shrink: 0;
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 300;
  margin-top: 2px;
}

/* Glass card variant */
.card-glass {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255,255,255,0.8);
}

/* Stat card */
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 24px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease);
  position: relative;
  overflow: hidden;
}

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

.stat-card-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-card-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-card-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

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

/* ═══════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-xs);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.855rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--navy2) 0%, var(--navy) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(15,40,71,0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(15,40,71,0.3);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%);
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(201,168,76,0.3);
}

.btn-gold:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,168,76,0.4);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: white;
  border-color: var(--border2);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1.5px solid #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-success {
  background: #f0fdf4;
  color: var(--success);
  border: 1.5px solid #bbf7d0;
}

.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

/* Spinner inside button */
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════════════ */
form { width: 100%; }

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

form input,
form select,
form textarea {
  width: 100%;
  padding: 11px 14px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  margin-bottom: 14px;
}

form textarea { resize: vertical; min-height: 100px; }

form input:focus,
form select:focus,
form textarea:focus {
  border-color: var(--navy2);
  box-shadow: 0 0 0 3px rgba(26,58,92,0.08);
  background: white;
}

form input::placeholder,
form textarea::placeholder { color: var(--text-muted); }

form input:read-only,
form input:disabled,
form select:disabled {
  background: var(--bg);
  cursor: not-allowed;
  opacity: 0.7;
}

form button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--navy2) 0%, var(--navy) 100%);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 0;
  box-shadow: 0 2px 8px rgba(15,40,71,0.2);
}

form button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(15,40,71,0.28);
}

form button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ═══════════════════════════════════════════════════════
   TABLE SYSTEM
═══════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.87rem;
}

table th {
  padding: 11px 16px;
  text-align: left;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

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

table tbody tr { transition: background 0.15s; }

table tbody tr:hover { background: rgba(26,58,92,0.03); }

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

/* ═══════════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════════ */
.alert {
  padding: 13px 18px;
  border-radius: var(--radius-xs);
  margin-bottom: 20px;
  font-size: 0.875rem;
  line-height: 1.5;
  animation: alertIn 0.28s var(--ease);
  border-left: 3px solid;
}

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

.alert-success { background: #f0fdf4; color: #166534; border-color: var(--success); }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: var(--info); }

/* ═══════════════════════════════════════════════════════
   AUTOCOMPLETE / SEARCH
═══════════════════════════════════════════════════════ */
.autocomplete-container { position: relative; }

.search-input-large {
  width: 100% !important;
  padding: 13px 16px 13px 46px !important;
  background: white !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 0.9rem !important;
  color: var(--text-primary) !important;
  outline: none !important;
  transition: var(--transition) !important;
  box-shadow: var(--shadow-sm) !important;
  margin-bottom: 0 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.35-4.35'%3E%3C/path%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: 14px center !important;
  background-size: 18px 18px !important;
}

.search-input-large:focus {
  border-color: var(--navy2) !important;
  box-shadow: 0 0 0 3px rgba(26,58,92,0.08) !important;
}

.search-input-large::placeholder { color: var(--text-muted) !important; }

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border: 1.5px solid var(--navy2);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.autocomplete-item {
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected { background: var(--bg); }

.autocomplete-item .learner-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

.autocomplete-item .learner-details {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.autocomplete-no-results {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════
   BADGE SYSTEM
═══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gold    { background: rgba(201,168,76,0.15); color: var(--gold); }

/* ═══════════════════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ═══════════════════════════════════════════════════════
   SPINNER (global, in buttons / standalone)
═══════════════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-dark {
  border-color: rgba(15,40,71,0.15);
  border-top-color: var(--navy2);
}

/* ═══════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,40,71,0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  animation: fadeOverlay 0.2s ease;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal.hidden { display: none !important; }

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 560px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.1);
  animation: modalIn 0.3s var(--ease);
  position: relative;
}

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

.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ═══════════════════════════════════════════════════════
   SECTION DIVIDER
═══════════════════════════════════════════════════════ */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 20px;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider-text {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE (standalone — no sidebar)
═══════════════════════════════════════════════════════ */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — MOBILE-FIRST COMPLETE SYSTEM
═══════════════════════════════════════════════════════ */

/* ── Tablet: 1024px and below ── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  /* Slightly narrower sidebar */
  :root { --sidebar-w: 220px; }
}

/* ── Mobile: 768px and below ── */
@media (max-width: 768px) {

  /* ── Layout: sidebar slides off-canvas, content takes full width ── */
  :root {
    --topbar-h: 56px;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
      "topbar"
      "main";
    min-height: 100vh;
  }

  /* Sidebar: hidden off left edge by default */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;                     /* wider on mobile = easier touch targets */
    height: 100vh;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.32s var(--ease);
    box-shadow: none;
  }

  /* Sidebar open state */
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(15,40,71,0.35);
  }

  /* Backdrop overlay behind open sidebar */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,40,71,0.5);
    z-index: 399;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: backdropIn 0.25s ease;
  }

  @keyframes backdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  .sidebar-backdrop.visible { display: block; }

  /* ── Topbar: hamburger on the left ── */
  .topbar {
    padding: 0 16px;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  /* Show hamburger on mobile */
  .topbar-hamburger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-xs);
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    color: var(--text-secondary);
    transition: var(--transition);
  }

  .topbar-hamburger:hover { background: var(--bg); color: var(--navy); }

  .topbar-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: all 0.25s var(--ease);
    transform-origin: center;
  }

  /* Animated X when open */
  .topbar-hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .topbar-hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .topbar-hamburger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Hide search bar on small screens — save space */
  .topbar-search { display: none; }

  /* Hide sidebar footer on mobile — unreliable at bottom of small screens */
  .sidebar-footer { display: none; }

  /* Remove bottom padding that was reserved for the footer */
  .sidebar-nav { padding-bottom: 16px; }

  /* Page title in topbar shorter */
  .topbar-page-title {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
  }

  /* ── Main content ── */
  .main-content {
    padding: 20px 16px 72px;        /* bottom padding clears mobile browser chrome */
  }

  /* ── Page header ── */
  .page-title-row {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 12px;
  }

  .page-title { font-size: 1.55rem; }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 120px;
  }

  /* ── Cards ── */
  .card { padding: 20px; border-radius: var(--radius-sm); }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* ── Grid helpers ── */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 14px; }

  /* ── Tables: horizontal scroll wrapper ── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  table { min-width: 520px; }               /* prevents table from crushing */
  table th, table td { padding: 10px 12px; font-size: 0.82rem; }

  /* ── Buttons ── */
  .btn { font-size: 0.84rem; padding: 9px 14px; }

  /* ── Forms ── */
  form input, form select, form textarea { font-size: 0.9rem; padding: 10px 13px; }

  /* ── Modal ── */
  .modal { padding: 12px; align-items: flex-end; }

  .modal-content {
    padding: 24px 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 90vh;
    animation: modalSlideUp 0.3s var(--ease);
  }

  @keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ── Small phones: 480px and below ── */
@media (max-width: 480px) {
  .main-content { padding: 16px 12px 72px; }
  .card { padding: 16px; }
  .page-title { font-size: 1.35rem; }
  table th, table td { padding: 9px 10px; font-size: 0.80rem; }
}

/* ═══════════════════════════════════════════════════════
   PRINT STYLES — preserve receipt printing
═══════════════════════════════════════════════════════ */
@media print {
  @page { size: A4 portrait; margin: 0; }

  body { background: white; margin: 0; padding: 0; }

  .sidebar, .topbar, .no-print { display: none !important; }

  .app-shell {
    display: block;
    grid-template-areas: none;
    grid-template-columns: none;
  }

  .main-content { padding: 0; }

  .receipt-container {
    width: 210mm; height: 297mm;
    display: flex; flex-direction: column;
    page-break-after: always;
  }

  .receipt {
    width: 210mm; height: 148.5mm;
    padding: 10mm 12mm;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
    font-size: 10pt; line-height: 1.3;
    color: black !important;
    page-break-inside: avoid;
    position: relative; overflow: hidden;
    display: flex; flex-direction: column;
  }

  .receipt.receipt-with-custom-fee { padding: 8mm 12mm; }
  .receipt:first-child { border-bottom: 2px dashed #999; }
  .receipt * { color: black !important; }

  .receipt-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 6px; margin-bottom: 8px;
  }

  .receipt-header h1 { font-size: 14pt; font-weight: bold; margin: 0 0 2px; letter-spacing: 0.5px; }
  .receipt-header .motto { font-size: 8pt; font-style: italic; margin: 1px 0; }
  .receipt-header .contact { font-size: 8pt; margin: 1px 0; }

  .receipt-body { margin: 8px 0; flex: 1; display: flex; flex-direction: column; }
  .receipt-title { text-align: center; font-size: 11pt; font-weight: bold; text-decoration: underline; margin: 6px 0; }

  .info-section { margin-bottom: 8px; }
  .info-row { display: flex; margin-bottom: 3px; font-size: 9pt; }
  .info-label { width: 110px; font-weight: 600; }
  .info-value { flex: 1; border-bottom: 1px dotted #333; padding-bottom: 1px; }

  .fee-note-box { background: #f9fafb; border: 1px solid #d1d5db; padding: 5px 7px; border-radius: 3px; margin: 6px 0; font-size: 7.5pt; line-height: 1.2; }

  .payments-horizontal { margin: 8px 0; padding: 6px; background: #f9fafb; border: 1px solid #ddd; border-radius: 4px; }
  .payments-horizontal h3 { font-size: 9pt; font-weight: bold; margin: 0 0 5px; text-align: center; }

  .payment-items { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
  .payment-item { display: inline-block; padding: 3px 6px; background: white; border: 1px solid #ccc; border-radius: 3px; font-size: 8pt; white-space: nowrap; }
  .payment-item .date { font-weight: 600; color: #333; }
  .payment-item .amount { color: #059669; font-weight: bold; }

  .summary-section { margin-top: 8px; padding-top: 6px; border-top: 2px solid #000; }
  .summary-row { display: flex; justify-content: space-between; margin-bottom: 3px; font-size: 9pt; }
  .summary-row.total { font-size: 10pt; font-weight: bold; margin-top: 5px; padding-top: 5px; border-top: 1px solid #000; }

  .receipt-footer { margin-top: auto; padding-top: 6px; border-top: 1px solid #000; font-size: 7pt; text-align: center; line-height: 1.3; }
  .receipt-footer p { margin: 1px 0; }

  .signature-section { display: flex; justify-content: space-between; margin-top: 10px; margin-bottom: 6px; font-size: 8pt; }
  .signature-box { width: 45%; text-align: center; }
  .signature-line { border-top: 1px solid #000; margin-top: 20px; padding-top: 3px; }

  .receipt:first-child::after {
    content: "✂ CUT HERE ✂";
    position: absolute; bottom: -1px; left: 50%;
    transform: translateX(-50%);
    background: white; padding: 0 8px;
    font-size: 7pt; color: #666; letter-spacing: 1.5px;
  }
}
