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

:root {
  --navy:     #0b1f35;
  --blue:     #2563eb;
  --blue-dk:  #1d4ed8;
  --accent:   #ef4444;
  --green:    #10b981;
  --gold:     #f59e0b;
  --bg:       #f0f4f8;
  --card:     #ffffff;
  --border:   #e2e8f0;
  --text:     #0f172a;
  --muted:    #64748b;
  --r:        14px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.07);
  --shadow-lg:0 4px 8px rgba(0,0,0,.06), 0 12px 40px rgba(0,0,0,.12);
  --tr:       .18s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Top nav ─────────────────────────────────────────────────── */
.topnav {
  background: linear-gradient(to right, #0b1f35 0%, #0f2d4a 100%);
  display: flex;
  align-items: center;
  padding: 0 40px;
  height: 80px;
  gap: 2px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 20px rgba(0,0,0,.28);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-right: 36px;
  text-decoration: none;
  color: #fff;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: .1px;
  flex-shrink: 0;
}
.topnav-brand .brand-logo {
  width: 52px; height: 52px;
  object-fit: contain; border-radius: 50%;
  background: #fff; padding: 2px; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25), 0 0 0 5px rgba(255,255,255,.07);
  transition: box-shadow var(--tr);
}
.topnav-brand:hover .brand-logo { box-shadow: 0 0 0 2px #fbbf24, 0 0 0 5px rgba(251,191,36,.2); }
.topnav-brand span { color: #fbbf24; letter-spacing: .2px; }

.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 0 18px; height: 80px;
  color: rgba(255,255,255,.5);
  text-decoration: none; font-size: .93rem; font-weight: 600;
  transition: color var(--tr), background var(--tr);
  border-bottom: 3px solid transparent;
  white-space: nowrap; letter-spacing: .1px;
}
.nav-link:hover { color: rgba(255,255,255,.9); background: rgba(255,255,255,.06); }
.nav-link.active { color: #fff; border-bottom-color: #fbbf24; }
.nav-link .ni { font-size: 1.05rem; }

/* ── Page wrapper ────────────────────────────────────────────── */
.page-wrapper { padding: 36px 40px; }

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 14px;
}
.page-header h1 {
  font-size: 1.6rem; font-weight: 800; color: var(--navy);
  letter-spacing: -.4px; line-height: 1.1;
}
.page-header p { color: var(--muted); font-size: .83rem; margin-top: 5px; }

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 18px; margin-bottom: 28px;
}
.stat-card {
  background: var(--card); border-radius: var(--r);
  padding: 22px 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 18px;
  border: 1px solid var(--border);
  transition: transform var(--tr), box-shadow var(--tr);
  cursor: default;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; flex-shrink: 0;
}
.ic-blue   { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.ic-green  { background: linear-gradient(135deg, #34d399, #059669); }
.ic-orange { background: linear-gradient(135deg, #fbbf24, #d97706); }
.ic-red    { background: linear-gradient(135deg, #f87171, #dc2626); }

.stat-value {
  font-size: 2rem; font-weight: 800; color: var(--navy);
  line-height: 1; letter-spacing: -.5px;
}
.stat-label {
  font-size: .7rem; color: var(--muted); font-weight: 700;
  margin-top: 5px; text-transform: uppercase; letter-spacing: .5px;
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--border);
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: linear-gradient(to bottom, #fafcff 0%, #fff 100%);
}
.card-header h2 { font-size: .98rem; font-weight: 700; color: var(--navy); }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input {
  padding: 8px 14px 8px 36px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .84rem; width: 230px; outline: none;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2394a3b8' stroke-width='2.5' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 11px center;
  transition: border-color var(--tr), box-shadow var(--tr), background var(--tr);
  font-family: inherit;
}
.search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background-color: #fff;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 9px; border: none;
  font-size: .84rem; font-weight: 600; cursor: pointer;
  transition: transform var(--tr), box-shadow var(--tr), filter var(--tr);
  white-space: nowrap; text-decoration: none; font-family: inherit;
  letter-spacing: .1px;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.btn:active { transform: none; box-shadow: none; }
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.btn-danger  { background: linear-gradient(135deg, #f87171, #dc2626); color: #fff; }
.btn-ghost   {
  background: #fff; color: var(--navy);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: #94a3b8; }
.btn-sm   { padding: 5px 12px; font-size: .78rem; }
.btn-icon { padding: 6px 9px; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  background: #f8fafc; color: var(--muted);
  font-size: .69rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; padding: 13px 16px;
  text-align: left; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background var(--tr); }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: #eff6ff !important; }
td { padding: 11px 16px; vertical-align: middle; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: .69rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.bg-green { background: #d1fae5; color: #065f46; }
.bg-red   { background: #fee2e2; color: #991b1b; }
.bg-blue  { background: #dbeafe; color: #1e40af; }
.bg-gray  { background: #f1f5f9; color: #475569; }

/* ── Toggle OUI/NON ──────────────────────────────────────────── */
.toggle-btn {
  cursor: pointer; padding: 4px 12px; border-radius: 20px;
  font-size: .69rem; font-weight: 700; text-transform: uppercase;
  border: none; min-width: 52px; text-align: center;
  transition: all var(--tr);
}
.toggle-btn:hover { transform: scale(1.06); }
.toggle-btn.oui { background: #d1fae5; color: #065f46; }
.toggle-btn.non { background: #f1f5f9; color: #94a3b8; }

/* ── Payment inputs ──────────────────────────────────────────── */
.pay-input {
  width: 72px; padding: 5px 7px;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .81rem; text-align: right; outline: none;
  background: #f8fafc; transition: all var(--tr); font-family: inherit;
}
.pay-input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.pay-input.dirty { border-color: var(--gold); background: #fffbeb; }
.pay-input.wide  { width: 110px; text-align: left; }

.save-row-btn {
  padding: 4px 12px; font-size: .75rem; border-radius: 7px;
  border: none; background: var(--green); color: #fff;
  cursor: pointer; font-weight: 600;
  opacity: 0; transition: opacity var(--tr);
}
.save-row-btn.show { opacity: 1; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(11,31,53,.5); backdrop-filter: blur(5px);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card); border-radius: 18px;
  box-shadow: 0 24px 80px rgba(11,31,53,.28);
  width: 660px; max-width: 95vw; max-height: 92vh; overflow-y: auto;
  animation: mIn .24s cubic-bezier(.34,1.56,.64,1);
  border: 1px solid var(--border);
}
@keyframes mIn { from { opacity:0; transform: scale(.93) translateY(-14px); } to { opacity:1; transform:none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafcff, #fff);
}
.modal-header h3 { font-size: 1.08rem; font-weight: 700; color: var(--navy); }
.modal-close {
  background: #f1f5f9; border: none; cursor: pointer;
  color: var(--muted); font-size: 1rem; padding: 6px 10px;
  border-radius: 8px; transition: all var(--tr); line-height: 1;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }
.modal-body   { padding: 24px 26px; }
.modal-footer {
  padding: 16px 26px 22px; display: flex; justify-content: flex-end;
  gap: 10px; border-top: 1px solid var(--border); background: #fafbfc;
}

/* ── Form ────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-size: .7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.form-control {
  padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: .875rem; outline: none; font-family: inherit;
  background: #fff; color: var(--text);
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 28px; right: 28px;
  display: flex; flex-direction: column; gap: 10px; z-index: 200;
}
.toast {
  padding: 13px 18px; border-radius: 12px;
  font-size: .84rem; font-weight: 600; color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  animation: tIn .22s cubic-bezier(.34,1.56,.64,1); max-width: 340px;
  display: flex; align-items: center; gap: 10px;
  border-left: 4px solid rgba(255,255,255,.35);
}
@keyframes tIn { from { opacity:0; transform: translateX(24px); } to { opacity:1; transform:none; } }
.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.info    { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* ── Belt badges ─────────────────────────────────────────────── */
.belt {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: .69rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.belt-blanche { background: #f8fafc; color: #475569; border: 1.5px solid #cbd5e1; }
.belt-jaune   { background: #fef3c7; color: #92400e; }
.belt-orange  { background: #ffedd5; color: #9a3412; }
.belt-verte   { background: #d1fae5; color: #065f46; }
.belt-bleue   { background: #dbeafe; color: #1e40af; }
.belt-marron  { background: #e7d4c3; color: #7c2d12; }
.belt-noire   { background: #1e293b; color: #f1f5f9; }

/* ── Export button (nav) ─────────────────────────────────────── */
.export-btn {
  margin-left: auto; padding: 8px 18px; border-radius: 9px;
  border: 1.5px solid rgba(251,191,36,.4);
  background: rgba(251,191,36,.1); color: #fbbf24;
  font-size: .88rem; font-weight: 700; cursor: pointer;
  transition: all var(--tr); white-space: nowrap; font-family: inherit;
  text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
}
.export-btn:hover {
  background: rgba(251,191,36,.22); border-color: #fbbf24; color: #fff;
  box-shadow: 0 2px 12px rgba(251,191,36,.25);
}
.export-btn svg { flex-shrink: 0; }

/* ── Logout button ───────────────────────────────────────────── */
.logout-btn {
  margin-left: auto; padding: 8px 18px; border-radius: 9px;
  border: 1.5px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.6);
  font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: all var(--tr); white-space: nowrap; font-family: inherit;
}
.logout-btn:hover { background: rgba(255,255,255,.13); color: #fff; border-color: rgba(255,255,255,.38); }

/* ── Mini presence bar ───────────────────────────────────────── */
.mini-bar-wrap {
  width: 46px; height: 5px; background: #e2e8f0;
  border-radius: 3px; overflow: hidden; display: inline-block;
  margin-right: 4px; vertical-align: middle;
}
.mini-bar { height: 100%; border-radius: 3px; transition: width .35s; }

/* ── Alert row ───────────────────────────────────────────────── */
.alert-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid #f1f5f9; font-size: .85rem;
}
.alert-row:last-child { border-bottom: none; }

/* ── Year bar ────────────────────────────────────────────────── */
.year-bar {
  background: linear-gradient(to bottom, #fff 0%, #fafbfd 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 32px; display: flex; align-items: center; gap: 8px;
  height: 46px; position: sticky; top: 62px; z-index: 40;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  flex-wrap: nowrap; overflow-x: auto;
}
.year-bar-label {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-right: 4px; white-space: nowrap; flex-shrink: 0;
}
.year-pill {
  padding: 5px 14px; border-radius: 20px;
  border: 1.5px solid var(--border); background: #f8fafc;
  color: var(--muted); font-size: .77rem; font-weight: 700;
  cursor: pointer; transition: all var(--tr);
  white-space: nowrap; flex-shrink: 0;
}
.year-pill:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
.year-pill.active {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 10px rgba(37,99,235,.35);
}
.year-pill.add-year { background: transparent; border-style: dashed; border-color: #cbd5e1; }
.year-pill.add-year:hover { border-color: var(--green); color: var(--green); background: #f0fdf4; }

.year-pill-group { display: inline-flex; align-items: center; gap: 2px; }
.year-pill-del {
  width: 17px; height: 17px; border-radius: 50%; border: none;
  background: transparent; color: var(--muted);
  font-size: .8rem; cursor: pointer; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: all var(--tr); flex-shrink: 0;
}
.year-pill-group:hover .year-pill-del { opacity: 1; }
.year-pill-del:hover { background: #fee2e2; color: #dc2626; }

/* ── Non-payant toggle (élèves) ──────────────────────────────── */
.np-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; border: none;
  font-size: .72rem; font-weight: 700; cursor: pointer;
  transition: all var(--tr);
}
.np-toggle.oui { background: #fef3c7; color: #92400e; }
.np-toggle.non { background: #f1f5f9; color: #94a3b8; }
.np-toggle:hover { filter: brightness(.92); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 700px) {
  .page-wrapper { padding: 18px 16px 90px 16px; /* espace pour la bottom nav */ }
  .form-grid { grid-template-columns: 1fr; }
  .topnav { padding: 0 16px; }
  .topnav .nav-link { display: none; } /* cacher les liens du haut sur mobile */
  .year-bar { padding: 0 16px; top: 62px; }
}

/* ── Bottom Navigation (mobile uniquement) ───────────────────── */
.bottom-nav {
  display: none;
}

@media (max-width: 700px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 68px;
    background: #0b1f35;
    border-top: 1px solid rgba(255,255,255,.1);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,.3);
    padding-bottom: env(safe-area-inset-bottom); /* iPhone notch */
  }

  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: rgba(255,255,255,.45);
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .2px;
    transition: color .2s, background .2s;
    padding: 8px 4px;
    border-radius: 0;
  }

  .bottom-nav a .bn-icon {
    font-size: 1.4rem;
    line-height: 1;
  }

  .bottom-nav a.active {
    color: #fbbf24;
    background: rgba(255,255,255,.05);
  }

  .bottom-nav a:hover {
    color: rgba(255,255,255,.75);
  }
}


/* ── Age category badges ─────────────────────────────────────── */
.cat-badge {
  display: inline-block; padding: 2px 9px;
  border-radius: 20px; font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.cat-petit  { background: #fce7f3; color: #9d174d; }
.cat-moyen  { background: #dbeafe; color: #1e40af; }
.cat-grand  { background: #d1fae5; color: #065f46; }

/* ── Cert badges ─────────────────────────────────────────────── */
.cert-ok       { background: #d1fae5; color: #065f46; }
.cert-expiring { background: #fef3c7; color: #92400e; }
.cert-expired  { background: #fee2e2; color: #991b1b; }

/* ── Sortable table headers ──────────────────────────────────── */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { background: #eff6ff; color: var(--blue); }
thead th.sort-asc::after  { content: ' ↑'; color: var(--blue); font-size: .8em; }
thead th.sort-desc::after { content: ' ↓'; color: var(--blue); font-size: .8em; }

/* ── Category filter bar ─────────────────────────────────────── */
.cat-filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: #fafbfd; align-items: center;
}
.cat-filter-label {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-right: 4px;
}
.cat-filter-btn {
  padding: 4px 13px; border-radius: 20px; border: 1.5px solid var(--border);
  background: #fff; font-size: .75rem; font-weight: 700; cursor: pointer;
  transition: all var(--tr); color: var(--muted); font-family: inherit;
}
.cat-filter-btn:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
.cat-filter-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Profile page ────────────────────────────────────────────── */
.profile-hero {
  background: linear-gradient(135deg, #0b1f35, #1a3a5c);
  color: #fff; border-radius: var(--r);
  padding: 32px 36px; margin-bottom: 24px;
  display: flex; align-items: center; gap: 28px;
  box-shadow: var(--shadow-lg);
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; flex-shrink: 0;
  border: 3px solid rgba(255,255,255,.25);
}
.profile-hero h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.3px; }
.profile-hero .profile-meta { font-size: .83rem; color: rgba(255,255,255,.65); margin-top: 6px; line-height: 1.6; }
.profile-hero .profile-belt { margin-top: 10px; }
.profile-info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px; margin-bottom: 22px;
}
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid #f1f5f9; font-size: .875rem;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); font-size: .73rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.info-value { color: var(--text); font-weight: 600; text-align: right; }
.presence-big-bar {
  height: 10px; border-radius: 5px; background: #e2e8f0;
  overflow: hidden; margin: 8px 0;
}
.presence-big-bar-fill { height: 100%; border-radius: 5px; transition: width .5s; }

/* ── Chart container ─────────────────────────────────────────── */
.chart-container { position: relative; height: 220px; padding: 16px 20px 0; }

/* ── Ranking table ───────────────────────────────────────────── */
.rank-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: .75rem; font-weight: 800;
}
.rank-gold   { background: #fef3c7; color: #92400e; }
.rank-silver { background: #f1f5f9; color: #475569; }
.rank-bronze { background: #ffedd5; color: #9a3412; }
.rank-other  { background: #f8fafc; color: #94a3b8; }

/* ── Student avatar initials ──────────────────────────────────── */
.student-av {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: .3px;
}
.av-blue   { background: #dbeafe; color: #1e40af; }
.av-green  { background: #d1fae5; color: #065f46; }
.av-pink   { background: #fce7f3; color: #9d174d; }
.av-orange { background: #ffedd5; color: #9a3412; }
.av-purple { background: #ede9fe; color: #5b21b6; }
.av-teal   { background: #ccfbf1; color: #134e4a; }
.av-amber  { background: #fef3c7; color: #92400e; }
.av-red    { background: #fee2e2; color: #991b1b; }

/* ── Alert tab panel (dashboard) ─────────────────────────────── */
.alert-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  background: #fafbfd;
}
.alert-tab-btn {
  flex: 1; padding: 13px 8px; font-size: .81rem; font-weight: 700;
  color: var(--muted); cursor: pointer; border: none; background: none;
  border-bottom: 2.5px solid transparent; margin-bottom: -2px;
  transition: color var(--tr), border-color var(--tr);
  font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.alert-tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.alert-tab-btn:hover:not(.active) { color: var(--navy); background: rgba(0,0,0,.025); }

/* ── Stat card context line ───────────────────────────────────── */
.stat-ctx {
  font-size: .71rem; color: var(--muted); margin-top: 7px;
  padding-top: 8px; border-top: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 5px;
}
.stat-ctx .ok  { color: var(--green); font-weight: 700; }
.stat-ctx .bad { color: var(--accent); font-weight: 700; }
.stat-ctx .warn { color: #f59e0b; font-weight: 700; }

/* ── Stat value color variants ────────────────────────────────── */
.sv-ok   { color: var(--green) !important; }
.sv-warn { color: #f59e0b !important; }
.sv-bad  { color: var(--accent) !important; }

/* ── Page banner (hero header per page) ──────────────────────── */
.page-banner {
  background: linear-gradient(135deg, #0b1f35 0%, #1a3a5c 100%);
  border-radius: var(--r); color: #fff;
  padding: 22px 34px; margin-bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(11,31,53,.22);
}
.page-banner-left {
  display: flex; align-items: center; gap: 18px; flex-shrink: 0;
}
.page-banner-logo {
  display: flex; align-items: center; flex-shrink: 0;
}
.page-banner-logo img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: contain;
  background: #fff; padding: 3px;
  box-shadow: 0 0 0 3px rgba(255,255,255,.25), 0 0 0 6px rgba(255,255,255,.08);
  transition: box-shadow var(--tr);
}
.page-banner-logo img:hover {
  box-shadow: 0 0 0 3px #fbbf24, 0 0 0 6px rgba(251,191,36,.2);
}
.page-banner-text h1 { font-size: 1.3rem; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.page-banner-text p  { color: rgba(255,255,255,.55); font-size: .82rem; margin-top: 4px; }
.page-banner-stats { display: flex; gap: 22px; align-items: center; }
.pbs-item { text-align: center; }
.pbs-val  { font-size: 1.6rem; font-weight: 900; letter-spacing: -.4px; display: block; }
.pbs-lbl  { font-size: .66rem; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .5px; margin-top: 1px; display: block; }
.pbs-div  { width: 1px; height: 36px; background: rgba(255,255,255,.14); flex-shrink: 0; }
@media (max-width: 768px) {
  .page-banner { flex-direction: column; align-items: flex-start; padding: 20px; }
  .page-banner-stats { flex-wrap: wrap; }
}

/* ── Better card variant with subtle header ──────────────────── */
.card-section-title {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  padding: 12px 22px 4px; border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-state .es-icon  { font-size: 2.2rem; margin-bottom: 10px; opacity: .35; display: block; }
.empty-state .es-title { font-size: .88rem; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.empty-state .es-sub   { font-size: .78rem; }

/* ── Success empty state ──────────────────────────────────────── */
.empty-ok {
  text-align: center; padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-ok .eo-icon  { font-size: 1.8rem; }
.empty-ok .eo-label { font-size: .88rem; font-weight: 700; color: var(--green); }
.empty-ok .eo-sub   { font-size: .76rem; color: var(--muted); }

/* ── Count badge (for nav) ────────────────────────────────────── */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: .65rem; font-weight: 800;
  background: var(--accent); color: #fff; line-height: 1;
}

/* ── Mini stats row ───────────────────────────────────────────── */
.mini-stats {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: #fafbfd;
}
.mini-stat {
  flex: 1; padding: 11px 14px; text-align: center;
  border-right: 1px solid var(--border);
}
.mini-stat:last-child { border-right: none; }
.mini-stat .msv { font-size: 1.05rem; font-weight: 800; color: var(--navy); }
.mini-stat .msl { font-size: .67rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }

/* ── Alert row (improved) ─────────────────────────────────────── */
.alert-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px; border-bottom: 1px solid #f1f5f9; font-size: .85rem;
  gap: 10px; transition: background var(--tr);
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: #f8faff; }
.alert-row .ar-name { font-weight: 700; font-size: .85rem; color: var(--text); }
.alert-row .ar-sub  { font-size: .74rem; color: var(--muted); margin-top: 1px; }
.alert-row .ar-action { font-size: .74rem; color: var(--blue); text-decoration: none; font-weight: 600; white-space: nowrap; padding: 4px 10px; border-radius: 6px; border: 1px solid #dbeafe; background: #eff6ff; transition: all var(--tr); }
.alert-row .ar-action:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .topnav, .year-bar, .toolbar, .search-input,
  .logout-btn, .btn, #toast-container,
  .pcell-edit, .save-row-btn, .modal-backdrop,
  .month-tabs, .legend, .pres-summary,
  .np-toggle, .toggle-btn, .rem-input { display: none !important; }
  body { background: #fff; }
  .page-wrapper { padding: 10px 16px; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .card-header { padding: 10px 14px; background: #fff; }
  .page-header { margin-bottom: 12px; }
  .page-header h1 { font-size: 1.2rem; }
  table { font-size: .78rem; }
  thead th { padding: 6px 8px; }
  td { padding: 5px 8px; }
  .pcell { box-shadow: none !important; cursor: default; }
  .pcell.editing .pcell-display { display: block !important; }
  .pcell.editing .pcell-edit    { display: none !important; }
}

/* ── Bulk action bar ─────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(90deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  animation: slideDown .2s ease;
}

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

.bulk-bar span {
  font-weight: 700;
  color: var(--blue);
  font-size: .88rem;
  margin-right: auto;
}

/* ── Selected row highlight ──────────────────────────────────── */
tr.row-selected {
  background: #eff6ff !important;
}
tr.row-selected td {
  border-color: #bfdbfe;
}

