/* ==========================================================================
   DROPBOX TRACKER — ENTERPRISE DESIGN SYSTEM
   Mobile-first. Shell: bottom tab bar (< 992px) / fixed sidebar (>= 992px)
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root,
[data-bs-theme="light"] {
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f0f4f2;
  --surface: #ffffff;
  --surface-2: #f6faf8;
  --surface-3: #e8f1ec;
  --border: #d4e2db;
  --border-strong: #bacdc4;

  --text: #081d16;
  --text-2: #2f4b41;
  --text-3: #567367;

  --brand: #059669;
  --brand-600: #047857;
  --brand-text: #047857;
  --brand-soft: #e5f7ee;
  --brand-ring: rgba(5, 150, 105, 0.22);

  --success: #059669;  --success-soft: #e5f7ee;  --success-fill: #10b981;
  --warning: #b45309;  --warning-soft: #fffbeb;  --warning-fill: #f59e0b;
  --danger:  #c22525;  --danger-soft:  #fdf2f2;  --danger-fill:  #ef4444;
  --info:    #0d9488;  --info-soft:    #e6faf7;  --info-fill:    #14b8a6;
  --violet:  #6366f1;  --violet-soft:  #eef2ff;  --violet-fill:  #8b5cf6;
  --neutral: #374151;  --neutral-soft: #f3f4f6;

  --shadow-xs: 0 1px 2px rgba(8, 29, 22, 0.05);
  --shadow-sm: 0 1px 3px rgba(8, 29, 22, 0.07), 0 1px 2px rgba(8, 29, 22, 0.04);
  --shadow-md: 0 8px 24px -8px rgba(8, 29, 22, 0.14);
  --shadow-lg: 0 24px 48px -12px rgba(8, 29, 22, 0.22);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-w: 260px;
  --topbar-h: 60px;
  --bottomnav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --sidebar-bg: #06231c;
  --sidebar-text: #a8c6bc;
  --sidebar-text-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(255, 255, 255, 0.12);
  --sidebar-border: rgba(255, 255, 255, 0.09);
}

[data-bs-theme="dark"] {
  --bg: #06130f;
  --surface: #0a1b15;
  --surface-2: #0e241d;
  --surface-3: #133027;
  --border: #1a3e34;
  --border-strong: #255447;

  --text: #e7f5ef;
  --text-2: #a2c4b7;
  --text-3: #759a8c;

  --brand: #10b981;
  --brand-600: #34d399;
  --brand-text: #6ee7b7;
  --brand-soft: rgba(16, 185, 129, 0.16);
  --brand-ring: rgba(16, 185, 129, 0.32);

  --success: #34d399;  --success-soft: rgba(52, 211, 153, 0.14);  --success-fill: #10b981;
  --warning: #fbbf24;  --warning-soft: rgba(251, 191, 36, 0.14);  --warning-fill: #f59e0b;
  --danger:  #f87171;  --danger-soft:  rgba(248, 113, 113, 0.14); --danger-fill:  #ef4444;
  --info:    #2dd4bf;  --info-soft:    rgba(45, 212, 191, 0.14);  --info-fill:    #14b8a6;
  --violet:  #a78bfa;  --violet-soft:  rgba(167, 139, 250, 0.16); --violet-fill:  #8b5cf6;
  --neutral: #9ca3af;  --neutral-soft: rgba(156, 163, 175, 0.12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);

  --sidebar-bg: #051510;
  --sidebar-border: rgba(255, 255, 255, 0.07);
}

/* ---------- 2. Bootstrap bridge ---------- */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-font-sans-serif: var(--font-sans);
  --bs-font-monospace: var(--font-mono);
  --bs-body-font-family: var(--font-sans);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-secondary-color: var(--text-3);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-link-color: var(--brand-text);
  --bs-link-hover-color: var(--brand-600);
  --bs-link-color-rgb: 5, 150, 105;
  --bs-emphasis-color: var(--text);
  --bs-heading-color: var(--text);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -0.015em; }
a { text-decoration: none; }
.text-muted { color: var(--text-3) !important; }
.text-main { color: var(--text) !important; }
.mono, .font-monospace { font-family: var(--font-mono) !important; font-feature-settings: "zero" 0; }
.tnum { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-font-size: 14px;
  --bs-btn-padding-x: 16px;
  --bs-btn-padding-y: 9px;
  --bs-btn-border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { --bs-btn-padding-x: 12px; --bs-btn-padding-y: 6px; --bs-btn-font-size: 13px; --bs-btn-border-radius: 8px; gap: 6px; }
.btn-lg { --bs-btn-padding-y: 13px; --bs-btn-font-size: 15px; --bs-btn-border-radius: 12px; }
.btn:focus-visible { box-shadow: 0 0 0 4px var(--brand-ring) !important; }

.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-600); --bs-btn-active-border-color: var(--brand-600);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(5, 150, 105, .3), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.btn-success {
  --bs-btn-bg: #059669; --bs-btn-border-color: #059669;
  --bs-btn-hover-bg: #047857; --bs-btn-hover-border-color: #047857;
  --bs-btn-active-bg: #047857; --bs-btn-disabled-bg: #059669; --bs-btn-disabled-border-color: #059669;
}
.btn-danger {
  --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626;
  --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c;
}
.btn-warning {
  --bs-btn-bg: #f59e0b; --bs-btn-border-color: #f59e0b; --bs-btn-color: #1f1300;
  --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706; --bs-btn-hover-color: #1f1300;
}
.btn-light, .btn-ghost {
  --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border-strong); --bs-btn-color: var(--text);
  --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--border-strong); --bs-btn-hover-color: var(--text);
  --bs-btn-active-bg: var(--surface-3); --bs-btn-active-border-color: var(--border-strong); --bs-btn-active-color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn-soft {
  --bs-btn-bg: var(--brand-soft); --bs-btn-border-color: transparent; --bs-btn-color: var(--brand-text);
  --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-border-color: var(--brand-ring); --bs-btn-hover-color: var(--brand-text);
  --bs-btn-active-bg: var(--brand-soft); --bs-btn-active-color: var(--brand-text);
}
.btn-soft-danger {
  --bs-btn-bg: var(--danger-soft); --bs-btn-border-color: transparent; --bs-btn-color: var(--danger);
  --bs-btn-hover-bg: var(--danger-soft); --bs-btn-hover-border-color: var(--danger); --bs-btn-hover-color: var(--danger);
}
.btn-soft-success {
  --bs-btn-bg: var(--success-soft); --bs-btn-border-color: transparent; --bs-btn-color: var(--success);
  --bs-btn-hover-bg: var(--success-soft); --bs-btn-hover-border-color: var(--success); --bs-btn-hover-color: var(--success);
}
.btn-soft-warning {
  --bs-btn-bg: var(--warning-soft); --bs-btn-border-color: transparent; --bs-btn-color: var(--warning);
  --bs-btn-hover-bg: var(--warning-soft); --bs-btn-hover-border-color: var(--warning); --bs-btn-hover-color: var(--warning);
}
.btn-locked {
  --bs-btn-bg: var(--surface-3); --bs-btn-border-color: var(--border-strong); --bs-btn-color: var(--text-2);
  --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-border-color: var(--border-strong); --bs-btn-hover-color: var(--text);
  --bs-btn-active-bg: var(--surface-3); --bs-btn-active-color: var(--text);
}
.btn-icon {
  --bs-btn-padding-x: 0; --bs-btn-padding-y: 0;
  width: 38px; height: 38px; flex: 0 0 auto;
}
.btn-icon.btn-sm { width: 34px; height: 34px; }

/* Forms */
.form-control, .form-select {
  min-height: 44px;
  border-radius: 10px;
  border-color: var(--border-strong);
  background-color: var(--surface);
  color: var(--text);
  font-size: 14.5px;
}
.form-control-sm, .form-select-sm { min-height: 36px; font-size: 13px; border-radius: 8px; }
.form-control::placeholder { color: var(--text-3); opacity: .85; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
  background-color: var(--surface);
  color: var(--text);
}
.form-label { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.form-text { color: var(--text-3); font-size: 12.5px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-3); border-radius: 10px; }

/* Alerts */
.alert { border-radius: var(--radius); border-width: 1px; font-size: 13.5px; }
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert-danger  { background: var(--danger-soft);  border-color: transparent; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.alert-info    { background: var(--info-soft);    border-color: transparent; color: var(--info); }

/* ---------- 3. App shell ---------- */
.app-shell { min-height: 100vh; display: flex; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* Sidebar (desktop) */
.app-sidebar { display: none; }

@media (min-width: 992px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1030;
    border-right: 1px solid var(--sidebar-border);
  }
  .app-main { margin-left: var(--sidebar-w); }
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand .brand-title { color: #fff; }
.sidebar-brand .brand-subtitle { color: rgba(255, 255, 255, .55); }

.sidebar-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255, 255, 255, .4); padding: 18px 22px 8px;
}
.sidebar-nav { padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-link i { font-size: 17px; width: 20px; text-align: center; opacity: .9; }
.sidebar-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.sidebar-link.active { background: var(--sidebar-active); color: var(--sidebar-text-strong); }
.sidebar-link.active::before {
  content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: #10b981;
}
.sidebar-link.active i { color: #6ee7b7; }

.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid var(--sidebar-border); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px;
  background: rgba(255, 255, 255, .04); color: #fff;
}
.sidebar-user .user-name { font-size: 13px; font-weight: 700; color: #fff; line-height: 1.25; }
.sidebar-user .user-role { font-size: 11px; color: rgba(255, 255, 255, .55); }
.sidebar-user .btn-icon { --bs-btn-color: rgba(255,255,255,.7); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: rgba(255,255,255,.08); --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; }

/* Brand */
.brand-emblem {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, #10b981 0%, #047857 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 4px 10px -2px rgba(5, 150, 105, .45);
}
.brand-emblem.lg { width: 52px; height: 52px; flex-basis: 52px; border-radius: 14px; font-size: 24px; }
.brand-title { font-size: 15px; font-weight: 800; line-height: 1.15; color: var(--text); letter-spacing: -0.01em; }
.brand-subtitle { font-size: 10.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 8px;
  padding: 4px 7px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.brand-logo-img {
  height: 24px;
  width: auto;
  object-fit: contain;
  display: block;
}
.brand-logo-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 12px;
  padding: 6px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}
.brand-logo-img-lg {
  height: 32px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* Topbar */
.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 15px; font-weight: 700; color: var(--text); min-width: 0; }
.topbar-title small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
@media (min-width: 992px) {
  .app-topbar { padding: 0 32px; }
  .topbar-brand { display: none !important; }
}
@media (max-width: 991.98px) {
  .topbar-title { display: none; }
}

.avatar {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-text);
  font-size: 13px; font-weight: 800; letter-spacing: .02em;
  border: 1px solid var(--border);
}
.avatar.lg { width: 48px; height: 48px; flex-basis: 48px; font-size: 16px; }
.avatar.on-dark { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .12); }

.avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; }
.avatar-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-ring); }

/* Theme switch */
.theme-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px;
}
.theme-switch button {
  border: 0; background: transparent; color: var(--text-3);
  width: 30px; height: 28px; border-radius: 999px; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-switch.on-dark { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); }
.theme-switch.on-dark button { color: rgba(255,255,255,.55); }
.theme-switch.on-dark button.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; }

/* Page area */
.app-page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--bottomnav-h) + var(--safe-b) + 24px);
}
body.has-dock .app-page { padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 96px); }
@media (min-width: 768px) { .app-page { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 992px) {
  .app-page, body.has-dock .app-page { padding: 28px 32px 40px; }
}

.app-footer {
  display: none;
  padding: 18px 32px; font-size: 12px; color: var(--text-3);
  border-top: 1px solid var(--border);
}
@media (min-width: 992px) { .app-footer { display: flex; justify-content: space-between; gap: 12px; } }

/* Bottom navigation (mobile) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--bottomnav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px -12px rgba(14, 22, 40, .18);
}
@media (min-width: 992px) { .bottom-nav { display: none; } }
.bottom-nav-item {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; font-weight: 700; letter-spacing: .01em;
  background: none; border: 0; padding: 6px 2px;
  position: relative;
}
.bottom-nav-item i {
  font-size: 19px; line-height: 1;
  width: 52px; height: 28px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s;
}
.bottom-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav-item.active { color: var(--brand-text); }
.bottom-nav-item.active i { background: var(--brand-soft); color: var(--brand-text); }

/* Account sheet (offcanvas bottom) */
.offcanvas.account-sheet {
  height: auto; max-height: 85vh;
  border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--text);
  border: 0;
  padding-bottom: var(--safe-b);
}
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 10px auto 4px; }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-list a, .sheet-list button {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 4px; color: var(--text); font-weight: 600; font-size: 15px;
  border: 0; background: none; border-bottom: 1px solid var(--border); text-align: left;
}
.sheet-list li:last-child a { border-bottom: 0; }
.sheet-list .sheet-ico {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-2); font-size: 16px;
}
.sheet-list .text-danger .sheet-ico { background: var(--danger-soft); color: var(--danger); }

/* Dropdowns */
.dropdown-menu {
  --bs-dropdown-bg: var(--surface);
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-link-color: var(--text);
  --bs-dropdown-link-hover-bg: var(--surface-2);
  --bs-dropdown-link-active-bg: var(--brand-soft);
  --bs-dropdown-link-active-color: var(--brand-text);
  border-radius: 14px; padding: 6px;
  box-shadow: var(--shadow-lg);
}
.dropdown-item { border-radius: 8px; padding: 9px 12px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }

/* ---------- 4. Page header ---------- */
.page-head { margin-bottom: 20px; }
.page-head-row { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 768px) {
  .page-head-row { flex-direction: row; align-items: flex-end; justify-content: space-between; }
}
.page-eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.page-title {
  font-size: clamp(1.3rem, 1.05rem + 1.1vw, 1.75rem);
  font-weight: 800; line-height: 1.2; margin: 0 0 4px;
  letter-spacing: -0.025em;
  word-break: break-word;
}
.page-subtitle { color: var(--text-2); font-size: 14px; margin: 0; max-width: 720px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 767.98px) {
  .page-actions.stack-mobile { display: grid; grid-template-columns: 1fr 1fr; }
  .page-actions.stack-mobile > .btn:only-child,
  .page-actions.stack-mobile > .btn.span-2 { grid-column: span 2; }
}

.crumbs {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 13px; color: var(--text-3); margin-bottom: 12px;
}
.crumbs a { color: var(--text-2); font-weight: 600; }
.crumbs a:hover { color: var(--brand-text); }
.crumbs .sep { opacity: .5; font-size: 11px; }
.crumbs .current { color: var(--text); font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 700; color: var(--brand-text);
  margin-bottom: 10px;
}

/* ---------- 5. Surfaces ---------- */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.surface + .surface, .section-gap { margin-top: 16px; }
@media (min-width: 992px) { .surface + .surface, .section-gap { margin-top: 20px; } }
.surface-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 0;
}
.surface-head.bordered { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.surface-title {
  font-size: 15.5px; font-weight: 750; font-weight: 700; margin: 0;
  display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em;
}
.surface-title .title-ico {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-text); font-size: 15px;
}
.surface-sub { font-size: 12.5px; color: var(--text-3); margin: 4px 0 0; }
.surface-body { padding: 16px; }
.surface-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
@media (min-width: 768px) {
  .surface-head { padding: 20px 22px 0; }
  .surface-head.bordered { padding-bottom: 16px; }
  .surface-body { padding: 20px 22px; }
  .surface-foot { padding: 14px 22px; }
}

/* Hero card (school banner / circle banner) */
.hero-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #062b22 0%, #0d5442 55%, #157960 100%);
  color: #fff;
  padding: 20px;
  box-shadow: var(--shadow-md);
}
.hero-card::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  border-radius: 50%; background: radial-gradient(circle, rgba(52, 211, 153, .22) 0%, transparent 70%);
  pointer-events: none;
}
[data-bs-theme="dark"] .hero-card { background: linear-gradient(135deg, #051a14 0%, #0a3328 65%, #0f4d3c 100%); }
.hero-card .page-title, .hero-card h1 { color: #fff; }
.hero-card .page-subtitle { color: rgba(255,255,255,.78); }
.hero-card .pill { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.18); }
.hero-card .pill.pill-success { background: rgba(16,185,129,.25); color: #d1fae5; border-color: rgba(16,185,129,.4); }
.hero-card .pill.pill-warning { background: rgba(245,158,11,.25); color: #fff3d6; border-color: rgba(245,158,11,.45); }
.hero-card .btn-light { --bs-btn-bg: rgba(255,255,255,.12); --bs-btn-border-color: rgba(255,255,255,.22); --bs-btn-color: #fff; --bs-btn-hover-bg: rgba(255,255,255,.2); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: rgba(255,255,255,.3); --bs-btn-active-bg: rgba(255,255,255,.24); --bs-btn-active-color: #fff; box-shadow: none; }
@media (min-width: 768px) { .hero-card { padding: 28px; } }

.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 18px;
}
.hero-stat {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 10px 12px;
}
.hero-stat .v { font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-stat .l { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.7); margin-top: 2px; }
.hero-progress { margin-top: 16px; }
.hero-progress .track { height: 8px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.hero-progress .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #34d399, #10b981); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.hero-progress .meta { display: flex; justify-content: space-between; font-size: 12.5px; color: rgba(255,255,255,.8); margin-bottom: 6px; font-weight: 600; }
.hero-progress .meta strong { color: #fff; }

/* ---------- 6. KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 1200px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
}
@media (min-width: 768px) { .kpi { padding: 18px 20px; } }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12px; font-weight: 700; color: var(--text-2); line-height: 1.3; }
.kpi-icon {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.kpi-value {
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem);
  font-weight: 800; line-height: 1.05; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--text);
  overflow-wrap: anywhere;
}
.kpi-value .of { font-size: .55em; font-weight: 700; color: var(--text-3); }
.kpi-foot { font-size: 12px; color: var(--text-3); line-height: 1.35; }
.kpi-foot strong { color: var(--text-2); }

.tone-brand   { background: var(--brand-soft);   color: var(--brand-text); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger  { background: var(--danger-soft);  color: var(--danger); }
.tone-info    { background: var(--info-soft);    color: var(--info); }
.tone-violet  { background: var(--violet-soft);  color: var(--violet); }
.tone-neutral { background: var(--neutral-soft); color: var(--neutral); }

/* Mini stat strip (inside cards) */
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-cell { border-radius: 10px; padding: 8px 10px; text-align: center; }
.stat-cell .v { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-cell .l { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }

/* ---------- 7. Progress ---------- */
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex: 1 1 auto; min-width: 48px; }
.meter.sm { height: 6px; }
.meter.lg { height: 12px; }
.meter-fill { height: 100%; border-radius: 99px; background: var(--success-fill); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.meter-fill.warn { background: var(--warning-fill); }
.meter-fill.brand { background: var(--brand); }
.meter-fill.low { background: var(--danger-fill); }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-pct { font-size: 12.5px; font-weight: 700; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.ring {
  --p: 0; --size: 112px; --thick: 11px; --ring-color: var(--success-fill);
  width: var(--size); height: var(--size); flex: 0 0 var(--size); border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center; position: relative;
}
.ring::before { content: ""; position: absolute; inset: var(--thick); border-radius: 50%; background: var(--surface); }
.ring > * { position: relative; text-align: center; }
.ring .ring-val { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -0.02em; }
.ring .ring-lbl { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-top: 3px; }

.progress-panel { display: flex; align-items: center; gap: 18px; }
.progress-panel .legend { display: grid; gap: 10px; flex: 1 1 auto; min-width: 0; }
.legend-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); }
.legend-item .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.legend-item strong { font-variant-numeric: tabular-nums; color: var(--text); font-size: 15px; }

/* ---------- 8. Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.5; white-space: nowrap;
  border: 1px solid transparent;
}
.pill i { font-size: 11px; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger  { background: var(--danger-soft);  color: var(--danger); }
.pill-info    { background: var(--info-soft);    color: var(--info); }
.pill-brand   { background: var(--brand-soft);   color: var(--brand-text); }
.pill-violet  { background: var(--violet-soft);  color: var(--violet); }
.pill-neutral { background: var(--neutral-soft); color: var(--neutral); }
.pill-solid-success { background: #059669; color: #fff; }
.pill-mono { font-family: var(--font-mono); font-weight: 600; letter-spacing: 0; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

.badge { font-weight: 700; border-radius: 6px; }

/* ---------- 9. Toolbar / search / segmented ---------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 768px) { .toolbar { flex-direction: row; align-items: center; } }
.toolbar .grow { flex: 1 1 auto; min-width: 0; }

.search-field { position: relative; }
.search-field > i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 15px; pointer-events: none;
}
.search-field .form-control { padding-left: 40px; }
.search-field .clear-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-3); width: 32px; height: 32px; border-radius: 8px;
  display: none; align-items: center; justify-content: center;
}
.search-field.has-value .clear-btn { display: inline-flex; }

.segmented {
  display: flex; padding: 4px; gap: 4px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 1 0 auto; border: 0; background: transparent;
  padding: 7px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button .count {
  font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px;
  background: var(--surface); color: var(--text-3); font-variant-numeric: tabular-nums;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button.active .count { background: var(--brand-soft); color: var(--brand-text); }

/* Radio-based segmented option + class toggles (status options modal) */
.segmented label { display: flex; }
.segmented .scope-opt {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  padding: 8px 12px; border-radius: 9px; cursor: pointer; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--text-2);
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented .btn-check:checked + .scope-opt { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .btn-check:focus-visible + .scope-opt { box-shadow: 0 0 0 3px var(--brand-ring); }
.class-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.class-toggle {
  display: flex; align-items: center; justify-content: center;
  height: 40px; border-radius: 10px; cursor: pointer; user-select: none;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 700; font-size: 13.5px; color: var(--text-2);
  transition: all .15s;
}
.class-toggle:hover { border-color: var(--brand); color: var(--brand-text); }
.btn-check:checked + .class-toggle { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-check:focus-visible + .class-toggle { box-shadow: 0 0 0 3px var(--brand-ring); }

.chip-scroll {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px;
}
.chip-scroll::-webkit-scrollbar { display: none; }
@media (min-width: 768px) { .chip-scroll { margin: 0; padding: 2px 0; flex-wrap: wrap; } }
.chip {
  flex: 0 0 auto; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand-text); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .count { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 600; }

.sticky-tools {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); z-index: 1010;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  margin: 0 -16px; padding: 10px 16px;
}
@media (min-width: 768px) { .sticky-tools { margin: 0 -24px; padding: 12px 24px; } }
@media (min-width: 992px) { .sticky-tools { margin: 0 -32px; padding: 12px 32px; } }

.result-count { font-size: 12.5px; color: var(--text-3); font-weight: 600; white-space: nowrap; }
.result-count strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- 10. Data tables ---------- */
.data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
  width: 100%; margin: 0; border-collapse: separate; border-spacing: 0;
  font-size: 13.5px; color: var(--text);
}
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3);
  padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  text-align: left;
}
.data-table tbody td {
  padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
  background: var(--surface);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tfoot td {
  padding: 13px 14px; background: var(--surface-2); font-weight: 800;
  border-top: 1px solid var(--border-strong);
}
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.data-table .center { text-align: center; }
.data-table .end { text-align: right; }
.data-table .idx { color: var(--text-3); font-size: 12px; width: 44px; font-variant-numeric: tabular-nums; }
.data-table .cell-title { font-weight: 700; color: var(--text); }
.data-table .cell-sub { font-size: 12px; color: var(--text-3); }
.data-table a.cell-title:hover { color: var(--brand-text); }
.surface > .data-table-wrap:first-child .data-table thead th:first-child { border-top-left-radius: var(--radius-lg); }
.surface > .data-table-wrap:first-child .data-table thead th:last-child { border-top-right-radius: var(--radius-lg); }
.surface > .data-table-wrap { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.surface > .data-table-wrap:only-child { border-radius: var(--radius-lg); }
.surface-head + .data-table-wrap { margin-top: 16px; border-top: 1px solid var(--border); }

.action-group { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* Stacked tables on phones: each row becomes a card, cells show data-label */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tfoot, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tbody tr, .table-stack tfoot tr {
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
    background: var(--surface);
  }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack tbody tr:hover td { background: transparent; }
  .table-stack td, .table-stack tfoot td {
    padding: 0 !important; border: 0 !important; background: transparent !important;
    text-align: left !important; min-width: 0;
  }
  .table-stack td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-3); margin-bottom: 2px;
  }
  .table-stack td.stack-full { grid-column: 1 / -1; }
  .table-stack td.stack-hide { display: none; }
  .table-stack td.stack-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .table-stack td.stack-head::before { display: none; }
  .table-stack .action-group { width: 100%; justify-content: stretch; }
  .table-stack .action-group > .btn { flex: 1 1 auto; }
  .table-stack tfoot tr { background: var(--surface-2); }
  .table-stack.stack-3 tbody tr, .table-stack.stack-3 tfoot tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Class-wise strip (school entry page): one compact scrollable row of tiles */
.class-strip-card { padding: 12px 0 12px; }
.class-strip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px 10px; }
.class-strip {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 2px 14px 4px; scrollbar-width: thin;
}
.class-strip::-webkit-scrollbar { height: 6px; }
.class-strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
.class-tile {
  flex: 0 0 132px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 9px 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); transition: border-color .15s, background .15s, box-shadow .15s;
}
.class-tile:hover { border-color: var(--brand); }
.class-tile.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand-ring); }
.class-tile .ct-top, .class-tile .ct-nums { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.class-tile .ct-name { font-size: 13px; font-weight: 800; }
.class-tile .ct-pct { font-size: 11.5px; font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }
.class-tile .ct-nums { font-size: 12px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.class-tile .ct-nums .pill { padding: 1px 7px; font-size: 11px; }
.class-tile .meter { min-width: 0; }
@media (min-width: 768px) {
  .class-strip-head { padding: 0 18px 10px; }
  .class-strip { padding: 2px 18px 4px; }
}
@media print { .class-strip-card { display: none !important; } }

/* Sections that collapse on phones but are always open from md up */
@media (min-width: 768px) { .collapse-md-show.collapse:not(.show) { display: block; } }
[data-bs-toggle="collapse"] .when-open { display: none; }
[data-bs-toggle="collapse"]:not(.collapsed) .when-open { display: inline; }
[data-bs-toggle="collapse"]:not(.collapsed) .when-collapsed { display: none; }
[data-bs-toggle="collapse"] .bi-chevron-down { transition: transform .2s; }
[data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down { transform: rotate(180deg); }
.min-w-0 { min-width: 0; }

/* ---------- 11. Distribution bars ---------- */
.dist-list { display: grid; gap: 14px; }
@media (min-width: 992px) { .dist-list.two-col { grid-template-columns: 1fr 1fr; column-gap: 32px; } }
.dist-row .dist-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.dist-row .dist-name { font-size: 13.5px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-row .dist-val { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dist-row .dist-val small { font-weight: 600; color: var(--text-3); margin-left: 6px; }
.dist-row .meter-fill { background: var(--brand); }
.dist-row.is-pending .meter-fill { background: var(--warning-fill); }
.dist-row.is-pending .dist-name { color: var(--warning); }

/* ---------- 12. Student cards (mobile entry) ---------- */
.st-list { display: grid; gap: 12px; }
.st-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden; position: relative;
  transition: border-color .2s, box-shadow .2s;
}
.st-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--warning-fill); transition: background .25s;
}
.st-card.is-updated::before { background: var(--success-fill); }
.st-card-body { padding: 14px 14px 12px 18px; }
.st-head { display: flex; align-items: flex-start; gap: 12px; }
.st-avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: .02em;
  background: var(--brand-soft); color: var(--brand-text);
}
.st-name { font-size: 15.5px; font-weight: 750; font-weight: 700; color: var(--text); line-height: 1.3; margin: 0; word-break: break-word; }
.st-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.st-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  margin-top: 12px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 10px;
  font-size: 12.5px;
}
.st-details .k { display: block; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.st-details .v { color: var(--text); font-weight: 600; word-break: break-word; }
.st-details .full { grid-column: 1 / -1; }
.st-details a.v { color: var(--brand-text); }
.st-entry {
  padding: 12px 14px 14px 18px; border-top: 1px dashed var(--border-strong);
  background: linear-gradient(to bottom, var(--surface), var(--surface-2));
}
.st-entry-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 8px;
}

/* Status select (primary data-entry control) */
.status-select {
  min-height: 48px;
  font-size: 15px; font-weight: 600;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background-color: var(--surface);
  color: var(--text);
  padding: 10px 40px 10px 14px;
  transition: border-color .15s, box-shadow .15s, background-color .3s;
}
.status-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); outline: none; }
.status-select.is-empty { border-color: var(--warning-fill); border-style: dashed; color: var(--text-2); }
.status-select.saved-success { border-color: var(--success-fill) !important; background-color: var(--success-soft) !important; }
.status-select:disabled { opacity: .75; background-color: var(--surface-2); }
.status-select.is-saving { opacity: .6; }
@media (min-width: 768px) { .status-select { min-height: 42px; font-size: 14px; } }

/* Desktop student table */
.data-table .status-select { min-width: 260px; }

/* School cards (CLRC mobile) */
.sch-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 14px; }
.sch-card + .sch-card { margin-top: 12px; }
.sch-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sch-card-name { font-size: 15px; font-weight: 700; margin: 8px 0 12px; line-height: 1.35; }
.sch-card-actions { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; margin-top: 14px; }

/* ---------- 13. Action dock (sticky finalize bar on mobile) ---------- */
.action-dock { display: flex; align-items: center; gap: 12px; }
@media (max-width: 991.98px) {
  .action-dock.dock-mobile {
    position: fixed; left: 12px; right: 12px;
    bottom: calc(var(--bottomnav-h) + var(--safe-b) + 10px);
    z-index: 1025;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 10px 10px 10px 14px;
    box-shadow: var(--shadow-lg);
  }
  .action-dock.dock-mobile .btn { flex: 0 0 auto; }
  .action-dock .dock-info { display: flex !important; }
}
.dock-info { display: none; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.dock-info .t { font-size: 12.5px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.dock-info .s { font-size: 11.5px; color: var(--text-3); }
.dock-info .meter { margin-top: 5px; }

/* ---------- 14. Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .ico {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: var(--surface-3); color: var(--text-3);
}
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.empty-state p { font-size: 13.5px; color: var(--text-3); margin: 0; }
.no-results { display: none; }
.no-results.show { display: block; }

/* ---------- 15. Modals (bottom sheet on phones) ---------- */
.modal-content {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 20px; }
.modal-header .modal-title { font-size: 16.5px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-backdrop.show { opacity: .55; }
.modal-ico {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  margin-bottom: 14px;
}
.app-dialog .modal-body { padding: 24px 22px 8px; }
.app-dialog .modal-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.app-dialog .dialog-msg { color: var(--text-2); font-size: 14px; white-space: pre-line; margin: 0; }
.app-dialog .modal-footer { border-top: 0; padding: 18px 22px 22px; }
.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px; }
.summary-box .row-kv { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.summary-box .row-kv:last-child { border-bottom: 0; }
.summary-box .row-kv strong { font-variant-numeric: tabular-nums; font-size: 15px; }

@media (max-width: 575.98px) {
  .modal-dialog.modal-dialog-centered, .modal-dialog.sheet {
    margin: 0; max-width: none; min-height: 100%;
    display: flex; align-items: flex-end;
  }
  .modal.fade .modal-dialog.modal-dialog-centered, .modal.fade .modal-dialog.sheet { transform: translateY(40px); }
  .modal.show .modal-dialog.modal-dialog-centered, .modal.show .modal-dialog.sheet { transform: none; }
  .modal-dialog-centered .modal-content, .modal-dialog.sheet .modal-content {
    border-radius: 22px 22px 0 0; border-bottom: 0; width: 100%;
    padding-bottom: var(--safe-b);
    max-height: 92vh; overflow-y: auto;
  }
  .modal-dialog-centered .modal-content::before, .modal-dialog.sheet .modal-content::before {
    content: ""; display: block; width: 40px; height: 4px; border-radius: 4px;
    background: var(--border-strong); margin: 10px auto 0;
  }
  .modal-footer { flex-wrap: nowrap; }
  .modal-footer > .btn { flex: 1 1 0; }
}

/* ---------- 16. Toasts ---------- */
#toast-container {
  position: fixed; z-index: 2000;
  top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
@media (min-width: 768px) { #toast-container { left: auto; right: 24px; top: 24px; align-items: flex-end; } }
.toast-msg {
  pointer-events: auto;
  width: 100%; max-width: 420px;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 600; line-height: 1.4;
  animation: toastIn .32s cubic-bezier(.16, 1, .3, 1);
  transition: opacity .25s, transform .25s;
}
.toast-msg .t-ico { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.toast-msg .t-text { padding-top: 3px; flex: 1 1 auto; min-width: 0; }
.toast-msg.hide { opacity: 0; transform: translateY(-8px); }
.toast-success .t-ico { background: var(--success-soft); color: var(--success); }
.toast-error .t-ico   { background: var(--danger-soft);  color: var(--danger); }
.toast-info .t-ico    { background: var(--info-soft);    color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- 17. Pagination ---------- */
.pagination { --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--border); --bs-pagination-color: var(--text-2);
  --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-hover-color: var(--text); --bs-pagination-hover-border-color: var(--border);
  --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand);
  --bs-pagination-border-radius: 8px; gap: 4px; }
.pagination .page-link { border-radius: 8px !important; font-weight: 700; font-size: 13px; min-width: 36px; text-align: center; }

/* ---------- 18. List links (export page etc.) ---------- */
.link-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.link-card + .link-card { margin-top: 10px; }
.link-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); color: var(--text); }
.link-card:active { transform: scale(.995); }
.link-card .lc-ico { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.link-card .lc-title { font-weight: 700; font-size: 14.5px; }
.link-card .lc-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.link-card .lc-go { margin-left: auto; color: var(--text-3); font-size: 18px; flex: 0 0 auto; }

/* ---------- 19. Auth (login) ---------- */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: flex; background: var(--bg); }
.auth-aside { display: none; }
@media (min-width: 992px) {
  .auth-aside {
    display: flex; flex-direction: column; justify-content: space-between;
    flex: 0 0 46%; max-width: 640px;
    padding: 48px;
    color: #fff; position: relative; overflow: hidden;
    background:
      radial-gradient(1200px 600px at -10% -20%, rgba(16, 185, 129, .42), transparent 60%),
      radial-gradient(800px 500px at 120% 120%, rgba(45, 212, 191, .28), transparent 60%),
      linear-gradient(160deg, #06231c 0%, #0d4436 55%, #125e4c 100%);
  }
  .auth-aside::after {
    content: ""; position: absolute; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
    background-size: 36px 36px; mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
    pointer-events: none;
  }
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside h2 { color: #fff; font-size: 34px; font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 14px; }
.auth-aside p.lead-text { color: rgba(255,255,255,.78); font-size: 15px; max-width: 440px; }
.auth-feature { display: flex; gap: 14px; align-items: flex-start; }
.auth-feature + .auth-feature { margin-top: 18px; }
.auth-feature .f-ico { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #a7f3d0; }
.auth-feature .f-t { font-weight: 700; font-size: 14.5px; color: #fff; }
.auth-feature .f-s { font-size: 13px; color: rgba(255,255,255,.65); }

.auth-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.auth-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.auth-center { flex: 1 1 auto; display: flex; align-items: flex-start; justify-content: center; padding: 8px 20px 32px; }
@media (min-width: 576px) { .auth-center { align-items: center; } }
.auth-card { width: 100%; max-width: 420px; }
@media (min-width: 576px) {
  .auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-md); padding: 32px; }
}
.auth-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 6px; }
.auth-card .auth-sub { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.auth-mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
@media (min-width: 992px) { .auth-mobile-brand { display: none; } }
.auth-input { min-height: 50px; font-size: 15px; border-radius: 12px; }
.auth-input-group { position: relative; }
.auth-input-group > i.lead-ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 16px; pointer-events: none; z-index: 2; }
.auth-input-group .form-control, .auth-input-group .form-select { padding-left: 44px; }
.auth-input-group .pass-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); z-index: 2; border: 0; background: none; color: var(--text-3); width: 40px; height: 40px; border-radius: 10px; }
.auth-input-group .pass-toggle:hover { color: var(--text); background: var(--surface-2); }
.auth-input-group .form-control.has-toggle { padding-right: 48px; }
.auth-foot { font-size: 12px; color: var(--text-3); text-align: center; padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); }
.hint-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: 12.5px; font-weight: 500; }
.hint-box code { color: inherit; font-weight: 700; background: rgba(255,255,255,.4); padding: 1px 6px; border-radius: 5px; }
[data-bs-theme="dark"] .hint-box code { background: rgba(0,0,0,.25); }

/* ---------- 20. Misc utilities ---------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.gap-section { display: grid; gap: 16px; }
@media (min-width: 992px) { .gap-section { gap: 20px; } }
.text-success-c { color: var(--success) !important; }
.text-warning-c { color: var(--warning) !important; }
.text-brand { color: var(--brand-text) !important; }
.fw-800 { font-weight: 800 !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.visually-hidden-focusable:focus { position: fixed !important; top: 8px; left: 8px; z-index: 3000; background: var(--surface); padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow-md); }
.scroll-mt { scroll-margin-top: calc(var(--topbar-h) + 80px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Legacy class names still referenced in some markup */
.table-custom { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* ==========================================================================
   OFFICIAL PRINT / PDF STYLESHEET
   ========================================================================== */
@media print {
  @page { size: A4 landscape; margin: 8mm 6mm; }

  body {
    background: #ffffff !important; color: #000000 !important; font-size: 11px !important;
    -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important;
  }

  .app-sidebar, .app-topbar, .bottom-nav, .app-footer, .action-dock, .sticky-tools,
  #toast-container, .d-print-none, .crumbs, .back-link, .btn, .modal, .offcanvas,
  input, select.status-select, .segmented, .chip-scroll {
    display: none !important;
  }

  .app-main { margin: 0 !important; }
  .app-page { padding: 0 !important; max-width: none !important; }

  .st-list, .st-card, .d-block.d-md-none { display: none !important; }

  .d-none.d-md-block, .d-print-block, .data-table-wrap { display: block !important; overflow: visible !important; }

  .surface, .hero-card, .kpi { box-shadow: none !important; border: 1px solid #94a3b8 !important; border-radius: 0 !important; background: #fff !important; color: #000 !important; }
  .hero-card * { color: #000 !important; }

  .data-table { width: 100% !important; border-collapse: collapse !important; font-size: 10.5px !important; }
  .data-table th, .data-table td { border: 1px solid #333 !important; padding: 5px 6px !important; color: #000 !important; background: transparent !important; position: static !important; }
  .data-table th { background-color: #f1f5f9 !important; font-weight: 800 !important; font-size: 9.5px !important; }
  .data-table tr { page-break-inside: avoid !important; }
  thead { display: table-header-group !important; }
}
