/* =========================================================================
   GHA SMS — Design System
   Great Heights Academy — School Management System
   Royal Navy / Gold, Inter + Cormorant Garamond
   ========================================================================= */

:root {
  /* Brand */
  --navy-start: #065F46;
  --navy-end:   #022C22;
  --gold:       #FDE047;
  --gold-dark:  #A16207;
  --gold-light: #FEF9C3;

  /* Surfaces */
  --bg:      #F0F2F7;
  /* ... the rest stays exactly the same ... */

  /* Surfaces */
  --bg:      #F0F2F7;
  --card:    #ffffff;
  --border:  #E2E8F0;

  /* Text */
  --text:    #1A2B45;
  --muted:   #6B7A90;
  --on-navy: #EAF0F8;
  --on-navy-muted: #93A6C2;

  /* Status */
  --success:      #1E8E5A;
  --success-bg:   #E7F6EE;
  --danger:       #C43D3D;
  --danger-bg:    #FBEAEA;
  --warning:      #B8790C;
  --warning-bg:   #FBF1DE;
  --info:         #2563A8;
  --info-bg:      #E8F1FB;

  /* Shape & motion */
  --radius:     9px;
  --radius-sm:  6px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 2px rgba(15, 39, 68, 0.06);
  --shadow-md:  0 4px 16px rgba(15, 39, 68, 0.08);
  --shadow-lg:  0 12px 32px rgba(15, 39, 68, 0.14);
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);

  /* Type */
  --font-ui:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-head: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;
}

/* =========================================================================
   Reset
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: 0.2px;
}

h1 { font-size: 34px; line-height: 1.2; }
h2 { font-size: 27px; line-height: 1.25; }
h3 { font-size: 21px; line-height: 1.3; }
h4 { font-size: 17px; line-height: 1.35; font-family: var(--font-ui); font-weight: 600; }

p { margin: 0 0 12px; }

a { color: var(--navy-start); text-decoration: none; }
a:hover { color: var(--gold-dark); }

ul, ol { margin: 0; padding-left: 20px; }

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

svg { display: block; }

hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #9FB0C6; }

:focus-visible {
  outline: 2px solid var(--gold-dark);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* =========================================================================
   Utilities
   ========================================================================= */

.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold-dark);
}

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 6px; }
.gap-sm { gap: 10px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.flex-wrap { flex-wrap: wrap; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

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

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

.hide-mobile { display: initial; }
.show-mobile { display: none; }

@media (max-width: 780px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: initial !important; }
}

/* =========================================================================
   App Shell — Sidebar / Topbar / Content
   ========================================================================= */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-start) 0%, var(--navy-end) 100%);
  color: var(--on-navy);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s var(--ease);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .crest {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--gold);
  font-size: 16px;
  flex-shrink: 0;
}

img.sidebar-brand-logo,
.sidebar-brand img.crest {
  object-fit: cover;
  background: #fff;
}

.sidebar-brand .name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 18px;
  color: #fff;
  line-height: 1.2;
}

.sidebar-brand .name small {
  display: block;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--on-navy-muted);
  margin-top: 2px;
}

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

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--on-navy-muted);
  padding: 16px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--on-navy);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  position: relative;
}

.sidebar-link .ic {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--gold);
}

.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy-end);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.role-switcher {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.role-switcher .avatar { width: 32px; height: 32px; font-size: 13px; }

.role-switcher .who {
  flex: 1;
  min-width: 0;
}

.role-switcher .who .n {
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-switcher .who .r {
  color: var(--gold);
  font-size: 11px;
  text-transform: capitalize;
}

.role-switcher-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 14px;
  right: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 30;
}

.role-switch-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-transform: capitalize;
}
.role-switch-option:last-child { border-bottom: none; }
.role-switch-option:hover { background: var(--bg); }

/* Topbar
   Uses min-height rather than a fixed height, and both halves are allowed
   to shrink/wrap — a long page subtitle (several of this app's own pages
   have quite long ones) will otherwise either get clipped or visually
   overlap the page content below it on a narrow phone, since a FIXED
   height can't grow to fit wrapped text. */

.topbar {
  min-height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 22px; margin: 0; overflow-wrap: break-word; }
.topbar-title .sub { font-size: 12.5px; color: var(--muted); overflow-wrap: break-word; }

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

/* Topbar user menu — clickable name reveals Profile/Settings/Sign out;
   avatar is a separate click target reserved for a quick photo change. */
.topbar-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-avatar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  line-height: 0;
  transition: box-shadow 0.15s var(--ease);
}
.topbar-avatar-btn:hover { box-shadow: 0 0 0 2px var(--gold); border-radius: 50%; }
.topbar-name-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
}
.topbar-name-btn:hover { background: var(--bg); }
.topbar-name-btn svg { color: var(--muted); transition: transform 0.15s var(--ease); flex-shrink: 0; }
.topbar-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 60;
}
.topbar-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-ui);
}
.topbar-menu-item:last-child { border-bottom: none; }
.topbar-menu-item:hover { background: var(--bg); color: var(--text); }

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  padding: 28px 24px 60px;
}

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -280px; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 10px 16px; }
}

/* Very small phones — the 22px topbar title is still roomy enough next to
   the hamburger button and avatar on most phones, but a handful of this
   app's own page titles ("Question Bank", "Score Overview" + a long
   subtitle) are tight at 375px and below, so it steps down further. */
@media (max-width: 400px) {
  .topbar-title h1 { font-size: 18px; }
  .topbar-title .sub { font-size: 11.5px; }
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.05s var(--ease);
  line-height: 1.2;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, var(--navy-start), var(--navy-end));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: linear-gradient(180deg, #234573, var(--navy-end)); color: #fff; }

.btn-gold {
  background: var(--gold);
  color: var(--navy-end);
}
.btn-gold:hover { background: var(--gold-dark); color: #fff; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--navy-start); color: var(--navy-start); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

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

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; }

.btn[disabled], .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-group { display: inline-flex; border-radius: var(--radius); overflow: hidden; }
.btn-group .btn { border-radius: 0; border-right: 1px solid rgba(255,255,255,0.15); }
.btn-group .btn:last-child { border-right: none; }

/* =========================================================================
   Cards
   ========================================================================= */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

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

.card-header h3 { margin: 0; }
.card-header .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.card-body { padding: 22px; }
.card-body.tight { padding: 14px; }
.card-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

/* Several pages set grid-template-columns directly in a style="" attribute
   (e.g. Dashboard's "1fr 1.4fr 1fr" three-up layout) to get specific
   column-width ratios on desktop. An inline style always wins over this
   class's own auto-fit rule above, so those grids never collapsed on a
   narrow screen on their own — this forces every .card-grid back to a
   single column below 700px regardless of what its own inline style says. */
@media (max-width: 700px) {
  .card-grid { grid-template-columns: 1fr !important; }
}

/* Standalone icon-wrap — usable in any card, not just .stat-card. Same
   values as .stat-card .icon-wrap below, kept separate so that rule's
   specificity is untouched. Fixes every existing tile (Settings hub,
   Counselling landing, etc.) that was rendering these as unstyled,
   invisible wrappers because .icon-wrap alone was never actually defined
   outside the .stat-card context. */
.icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--gold-light);
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-wrap.navy { background: rgba(30,58,95,0.08); color: var(--navy-start); }
.icon-wrap.gold { background: var(--gold-light); color: var(--gold-dark); }
.icon-wrap.success { background: var(--success-bg); color: var(--success); }
.icon-wrap.warning { background: var(--warning-bg); color: var(--warning); }
.icon-wrap.danger { background: var(--danger-bg); color: var(--danger); }

/* Stat card */

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-card .icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--gold-light);
  color: var(--gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card .icon-wrap.navy { background: rgba(30,58,95,0.08); color: var(--navy-start); }
.stat-card .icon-wrap.success { background: var(--success-bg); color: var(--success); }
.stat-card .icon-wrap.warning { background: var(--warning-bg); color: var(--warning); }

.stat-card .value { font-family: var(--font-head); font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* =========================================================================
   Forms
   ========================================================================= */

.field { margin-bottom: 18px; }

label, .field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

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

.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

.input, .select, textarea.textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.input::placeholder, textarea::placeholder { color: #A6B0C3; }

.input:focus, .select:focus, textarea.textarea:focus {
  outline: none;
  border-color: var(--navy-start);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.input.has-error, .select.has-error, textarea.has-error {
  border-color: var(--danger);
}
.input.has-error:focus { box-shadow: 0 0 0 3px rgba(196, 61, 61, 0.1); }

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

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7A90' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.input-group { display: flex; }
.input-group .input { border-radius: 0; }
.input-group .input:first-child { border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius); }
.input-group .input:last-child { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.input-group-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.input-group-addon:first-child { border-radius: var(--radius) 0 0 var(--radius); border-right: none; }
.input-group-addon:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 700px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* Checkbox / Radio */

.check-row, .radio-row {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13.5px;
  padding: 2px 0;
}

.check-row input[type="checkbox"],
.radio-row input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--navy-start);
  cursor: pointer;
}

/* Toggle switch */

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.toggle .track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s var(--ease);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .track { background: var(--navy-start); }
.toggle input:checked + .track::before { transform: translateX(18px); }

/* File upload */

.file-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.file-drop:hover { border-color: var(--navy-start); background: #E9EEF6; }
.file-drop .ic { color: var(--muted); margin: 0 auto 8px; width: 30px; height: 30px; }
.file-drop .main { font-size: 13.5px; font-weight: 600; }
.file-drop .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Typeahead */

.typeahead { position: relative; }
.typeahead-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
}
.typeahead-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.typeahead-item:last-child { border-bottom: none; }
.typeahead-item:hover, .typeahead-item.active { background: var(--bg); }
.typeahead-item .name { font-size: 13.5px; font-weight: 600; }
.typeahead-item .meta { font-size: 11.5px; color: var(--muted); }
.typeahead-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.table thead th.sortable { cursor: pointer; user-select: none; }
table.table thead th.sortable:hover { color: var(--text); }

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

table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #FAFBFD; }

table.table.striped tbody tr:nth-child(even) { background: #FAFBFD; }

table.table.compact thead th { padding: 8px 10px; font-size: 10.5px; }
table.table.compact tbody td { padding: 5px 10px; }
table.table.compact .input { padding: 6px 10px; font-size: 12.5px; }

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

/* =========================================================================
   Badges / Pills / Avatars
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  line-height: 1.6;
  white-space: nowrap;
}

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

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gold    { background: var(--gold-light); color: var(--gold-dark); }
.badge-navy    { background: rgba(30,58,95,0.08); color: var(--navy-start); }
.badge-muted   { background: var(--bg); color: var(--muted); }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-start), var(--navy-end));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  font-family: var(--font-head);
}

.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

.avatar-group { display: flex; }
.avatar-group .avatar { border: 2px solid var(--card); margin-left: -10px; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* =========================================================================
   Alerts / Empty states
   ========================================================================= */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  border: 1px solid transparent;
}

.alert .ic { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }

.alert-success { background: var(--success-bg); color: #175E40; border-color: #C8E9D8; }
.alert-danger  { background: var(--danger-bg);  color: #8A2A2A; border-color: #F1CACA; }
.alert-warning { background: var(--warning-bg); color: #8A5A08; border-color: #F0DDA8; }
.alert-info    { background: var(--info-bg);    color: #1B4A79; border-color: #C7DEF3; }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty-state .ic {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  color: #C3CCDA;
}
.empty-state h4 { color: var(--text); margin-bottom: 6px; }
.empty-state p { max-width: 340px; margin: 0 auto 18px; font-size: 13.5px; }

/* =========================================================================
   Tabs / Breadcrumbs / Pagination
   ========================================================================= */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--navy-start); border-bottom-color: var(--gold); }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--navy-start); }
.breadcrumbs .sep { color: #C3CCDA; }
.breadcrumbs .current { color: var(--text); font-weight: 600; }

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.pagination .page-btn {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid transparent;
}
.pagination .page-btn:hover { background: var(--bg); }
.pagination .page-btn.active { background: var(--navy-start); color: #fff; }
.pagination .page-btn.disabled { opacity: 0.4; pointer-events: none; }

/* =========================================================================
   Modal
   ========================================================================= */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 39, 68, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; }
.modal-close { cursor: pointer; color: var(--muted); background: none; border: none; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* =========================================================================
   Login page (legacy single-panel card — kept for /forgot-password,
   /reset-password, and any other simple auth screens using .auth-shell/.auth-card)
   ========================================================================= */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy-start) 0%, var(--navy-end) 65%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-shell::before {
  content: '';
  position: absolute;
  width: 640px; height: 640px;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.18);
  top: -220px; right: -160px;
}
.auth-shell::after {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.14);
  bottom: -180px; left: -120px;
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 34px;
}

.auth-crest {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--gold-dark);
  font-size: 24px;
  margin: 0 auto 16px;
}

.auth-card h1 { text-align: center; font-size: 25px; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 26px; }

/* =========================================================================
   Loading / Spinner
   ========================================================================= */

.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.dark { border-color: rgba(30,58,95,0.2); border-top-color: var(--navy-start); }

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

.skeleton {
  background: linear-gradient(90deg, #E9ECF2 25%, #F3F5F8 37%, #E9ECF2 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* =========================================================================
   Grading scale / Report card print helpers
   ========================================================================= */

.grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12px;
  padding: 0 6px;
}
.grade-a { background: var(--success-bg); color: var(--success); }
.grade-b { background: var(--info-bg); color: var(--info); }
.grade-c { background: var(--gold-light); color: var(--gold-dark); }
.grade-d, .grade-e { background: var(--warning-bg); color: var(--warning); }
.grade-f { background: var(--danger-bg); color: var(--danger); }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell, .main-content { display: block !important; }
  .page { padding: 0 !important; }
  body { background: #fff !important; }
}

/* =========================================================================
   Noticeboard (dashboard feed)
   ========================================================================= */

.notice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.notice-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.notice-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.notice-card .body { padding: 12px 14px; }
.notice-card .date { font-size: 11.5px; color: var(--muted); }

/* =========================================================================
   Auth — split-screen login (Premium revision 2 — fixed height/icon bug)
   ========================================================================= */

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

.anim-in {
  opacity: 0;
  animation: authFadeUp 0.55s var(--ease) forwards;
}
.anim-d1 { animation-delay: 0.05s; }
.anim-d2 { animation-delay: 0.1s; }
.anim-d3 { animation-delay: 0.17s; }
.anim-d4 { animation-delay: 0.23s; }
.anim-d5 { animation-delay: 0.29s; }

@media (prefers-reduced-motion: reduce) {
  .anim-in { animation: none; opacity: 1; }
}

/* Locked to the viewport on desktop — this is the fix for the scroll bug.
   Both columns are forced to exactly 100vh, so neither can push the row
   taller than the screen. */
.auth-page {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Left — visual / branding panel */

.auth-visual {
  flex: 1 1 56%;
  position: relative;
  overflow: hidden;
  padding: 40px 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background: linear-gradient(160deg, var(--navy-start) 0%, var(--navy-end) 100%);
}

.auth-visual .bg-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.auth-visual .bg-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(212,175,55,0.14) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.5;
}

.auth-visual .bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, rgba(30,58,95,0.94) 0%, rgba(15,39,68,0.90) 60%, rgba(15,39,68,0.97) 100%);
}

.auth-visual .bg-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.16);
}
.auth-visual .bg-ring.r1 { width: 560px; height: 560px; top: -220px; right: -160px; }
.auth-visual .bg-ring.r2 { width: 340px; height: 340px; bottom: -140px; left: -90px; }

.auth-visual .layer {
  position: relative;
  z-index: 1;
}

.auth-visual .top-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-glass {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 8px 14px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn-glass svg { flex-shrink: 0; }
.btn-glass:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.35); color: #fff; transform: translateY(-1px); }
.btn-glass.gold { background: rgba(212,175,55,0.16); border-color: rgba(212,175,55,0.4); color: var(--gold); }
.btn-glass.gold:hover { background: rgba(212,175,55,0.26); color: var(--gold); }

.auth-visual .middle {
  margin: auto 0;
  padding: 30px 0;
  max-width: 420px;
}

.auth-visual .crest-lg {
  position: relative;
  width: 60px; height: 60px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.auth-visual .crest-lg-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.35);
}

.auth-visual .crest-lg-mark {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: rgba(212,175,55,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--gold);
  font-size: 24px;
}

.auth-visual h1 {
  color: #fff;
  font-size: 34px;
  margin-bottom: 10px;
}

.auth-visual .tagline {
  color: var(--on-navy-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 0;
}

.auth-divider-gold {
  width: 40px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), rgba(212,175,55,0));
  margin: 20px 0 10px;
}

.auth-caption {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--on-navy-muted);
}

.auth-visual .foot-note {
  font-size: 11.5px;
  color: var(--on-navy-muted);
}

/* Right — form panel */

.auth-form-panel {
  flex: 1 1 44%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.auth-form-panel .decor-blob {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,175,55,0.14) 0%, rgba(212,175,55,0) 70%);
  top: -90px;
  right: -90px;
  pointer-events: none;
}

.auth-form-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 396px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(15,39,68,0.05), 0 20px 40px -14px rgba(15,39,68,0.22);
  padding: 34px 34px;
}

.auth-form-inner {
  width: 100%;
  max-width: 380px;
}

.auth-form-inner .mobile-crest {
  display: none;
}

.auth-form-title {
  font-size: 24px;
  margin-top: 4px;
  margin-bottom: 8px;
  position: relative;
  display: inline-block;
}
.auth-form-title::after {
  content: '';
  position: absolute;
  left: 1px;
  bottom: -5px;
  width: 32px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), rgba(212,175,55,0));
}

.auth-form-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* Portal tabs (Staff / Student) */

.portal-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}

.portal-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 8px;
  border-radius: calc(var(--radius) - 3px);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.portal-tab svg { flex-shrink: 0; }

.portal-tab.active {
  background: var(--card);
  color: var(--navy-start);
  box-shadow: var(--shadow-sm);
}

/* Password field with show/hide toggle */

.password-field { position: relative; }
.password-field .input { padding-right: 44px; }

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 8px;
  display: flex;
  border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--text); background: var(--bg); }
.password-toggle svg { flex-shrink: 0; }

/* Icon-prefixed inputs (username / password) */

.icon-field { position: relative; }
.icon-field .field-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  pointer-events: none;
  transition: color 0.15s var(--ease);
}
.icon-field .field-icon svg { flex-shrink: 0; }
.icon-field .input { padding-left: 40px; }
.icon-field.password-field .input { padding-right: 44px; }

/* Gold-accented focus state, scoped to the auth form only */
.auth-form-card .input:focus {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.16);
}
.auth-form-card .icon-field:focus-within .field-icon {
  color: var(--gold-dark);
}

.forgot-row {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 16px;
}
.forgot-row a { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.forgot-row a:hover { color: var(--navy-start); }

/* Submit button — subtle shimmer sweep on hover */
.auth-submit {
  position: relative;
  overflow: hidden;
}
.auth-submit::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(212,175,55,0.35), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s var(--ease);
}
.auth-submit:hover::after { left: 130%; }

.auth-secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 16px;
}
.auth-secure-note svg { flex-shrink: 0; }

@media (max-width: 900px) {
  .auth-page { height: auto; min-height: 100vh; overflow: visible; }
  .auth-visual { display: none; }
  .auth-form-panel { flex: 1 1 100%; padding: 32px 22px; overflow: visible; }
  .auth-form-inner .mobile-crest { display: block; text-align: center; margin-bottom: 20px; }
}

@media (max-height: 700px) and (min-width: 901px) {
  .auth-visual { padding: 28px 40px; }
  .auth-visual .crest-lg { width: 50px; height: 50px; margin-bottom: 14px; }
  .auth-visual .crest-lg-mark { font-size: 20px; }
  .auth-visual h1 { font-size: 28px; margin-bottom: 8px; }
  .auth-divider-gold { margin: 14px 0 8px; }
  .auth-form-card { padding: 26px 30px; }
}
