/* ---------------------------------------------------------------
   School ERP — light, airy design system. No JS framework required.
   ------------------------------------------------------------- */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-muted: #fbfbfe;
  --border: #eaecf1;
  --border-strong: #dde0e8;
  --text: #1f2430;
  --text-muted: #6b7180;
  --text-faint: #9aa0ae;
  --primary: #4f63ff;
  --primary-soft: #eef0ff;
  --primary-strong: #3c4feb;
  --success: #17a673;
  --success-soft: #e9f9f2;
  --warning: #d98c1a;
  --warning-soft: #fdf3e2;
  --danger: #e0435c;
  --danger-soft: #fdeaee;
  --info: #3aa0d1;
  --info-soft: #eaf6fc;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.04);
  --shadow: 0 4px 16px rgba(20, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(20, 24, 40, 0.10);
  --sidebar-w: 248px;
  --sidebar-collapsed-w: 68px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 600; margin: 0 0 4px; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; color: var(--text-muted); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: visible;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
}
.sidebar-inner {
  width: var(--sidebar-w);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---------- Sidebar collapse toggle ---------- */
.sidebar-toggle {
  position: fixed;
  top: 90px;
  left: calc(var(--sidebar-w) - 14px);
  z-index: 45;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 10px rgba(20, 24, 40, 0.14);
  color: var(--text-muted);
  transition: left 0.2s ease, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar-toggle:hover { color: var(--primary-strong); background: rgba(255, 255, 255, 0.8); box-shadow: 0 3px 12px rgba(20, 24, 40, 0.18); }
.sidebar-toggle-icon { width: 15px; height: 15px; transition: transform 0.2s ease; }

:root[data-sidebar-collapsed="1"] .sidebar { width: var(--sidebar-collapsed-w); }
:root[data-sidebar-collapsed="1"] .sidebar-inner { width: var(--sidebar-collapsed-w); }
:root[data-sidebar-collapsed="1"] .sidebar-toggle { left: calc(var(--sidebar-collapsed-w) - 14px); }
:root[data-sidebar-collapsed="1"] .sidebar-toggle-icon { transform: rotate(180deg); }

.sidebar-brand {
  padding: 31px 0 31px 21px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--surface);
  margin-bottom: 8px;
  overflow: hidden;
}
.sidebar-brand-link { display: flex; align-items: center; }
.sidebar-brand-link:hover { text-decoration: none; }
.sidebar-brand-logo {
  width: 216px;
  max-width: 216px;
  height: auto;
  display: block;
  flex-shrink: 0;
}

/* ---------- Nav link icon + label ---------- */
.nav-link-icon {
  display: flex; align-items: center; justify-content: center;
  width: 20px; flex-shrink: 0;
}
.nav-link-icon-svg { width: 17px; height: 17px; }
.nav-link-label { white-space: nowrap; }

:root[data-sidebar-collapsed="1"] .nav-group-label { visibility: hidden; }
:root[data-sidebar-collapsed="1"] .nav-link-label { display: none; }
:root[data-sidebar-collapsed="1"] .nav-link { justify-content: center; padding-left: 10px; padding-right: 10px; }
:root[data-sidebar-collapsed="1"] .nav-link.active { padding-left: 10px; }

.nav-group { padding: 2px 12px 4px; }
.nav-group-label {
  font-size: 12.5px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 -12px 4px; padding: 6px 22px 6px;
}
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  color: #4b5468; font-size: 13.5px; font-weight: 500;
  margin-bottom: 1px;
}
.nav-link:hover { background: var(--surface-muted); color: var(--primary-strong); text-decoration: none; }
.nav-link.active {
  background: var(--primary-soft); color: var(--primary-strong); font-weight: 700;
  padding-left: 16px;
  position: relative; z-index: 1;
  box-shadow: var(--shadow-sm);
  scroll-margin: 60px;
}
.nav-link.active::before {
  content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 3px;
  border-radius: 999px; background: var(--primary);
}
.nav-link .icon { width: 16px; text-align: center; opacity: 0.85; font-size: 13px; }

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

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 248, 251, 0.85);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }

.topbar-datetime {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-faint); white-space: nowrap;
}
.topbar-date { font-weight: 700; }
.topbar-time { font-weight: 700; font-variant-numeric: tabular-nums; }

.user-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--surface-muted); border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.user-pill:hover, .user-pill.open { background: var(--primary-soft); border-color: var(--border); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
}
.user-pill-text { display: flex; flex-direction: column; line-height: 1.25; }
.user-pill-name { font-weight: 600; color: var(--text); font-size: 13.5px; }
.user-role-tag { font-size: 11px; color: var(--text-faint); font-weight: 500; }
.user-pill-chevron { width: 15px; height: 15px; color: var(--text-faint); transition: transform 0.15s; flex-shrink: 0; }
.user-pill.open .user-pill-chevron { transform: rotate(180deg); }

.user-pill-wrap { position: relative; }
.user-pill-menu {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
  min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.user-pill.open + .user-pill-menu { display: block; }
.user-pill-menu a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: var(--text);
}
.user-pill-menu a:hover { background: var(--surface-muted); text-decoration: none; }
.user-pill-menu svg { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }

.logout-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid transparent; font-size: 13px; font-weight: 700;
  transition: background 0.15s, border-color 0.15s;
}
.logout-pill:hover { background: #fbdde3; border-color: rgba(224, 67, 92, 0.3); text-decoration: none; }
.logout-pill svg { width: 15px; height: 15px; flex-shrink: 0; }

@media (max-width: 640px) {
  .topbar-datetime { display: none; }
  .user-pill-text { display: none; }
}

.content { padding: 14px 24px 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-header h2, .card-header h3 { margin: 0; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent-primary .stat-value { color: var(--primary-strong); }
.stat-card.accent-success .stat-value { color: var(--success); }
.stat-card.accent-warning .stat-value { color: var(--warning); }
.stat-card.accent-danger .stat-value { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-muted); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbdde3; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"],
select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; color: var(--text); background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.help-text { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
table.data-table th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-faint); background: var(--surface-muted); padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-muted); }
.table-empty { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-primary { background: var(--primary-soft); color: var(--primary-strong); border-color: transparent; }

/* ---------- Alerts / flash ---------- */
.alert { padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: #0d7a56; border-color: #cdf0e2; }
.alert-error { background: var(--danger-soft); color: #b3283f; border-color: #f7ccd5; }
.alert-info { background: var(--info-soft); color: #256f92; border-color: #cdeaf7; }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin: 24px 0 10px; }
.section-title:first-child { margin-top: 0; }
.dash-hero + .section-title { margin-top: 0; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-faint); }
.empty-state .icon { font-size: 32px; margin-bottom: 10px; opacity: 0.5; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.progress-track { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- Attendance grid ---------- */
.roster-list { display: flex; flex-direction: column; gap: 6px; }
.roster-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.roster-row .student-name { font-weight: 600; font-size: 13.5px; }
.roster-row .student-meta { font-size: 12px; color: var(--text-faint); }
.status-pills { display: flex; gap: 4px; }
.status-pill {
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
}
.status-pill.selected.status-present { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-pill.selected.status-absent { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.status-pill.selected.status-late { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.status-pill.selected.status-leave { background: var(--info-soft); color: var(--info); border-color: transparent; }
.status-pill.selected.status-done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-pill.selected.status-pending { background: var(--surface-muted); color: var(--text-muted); border-color: var(--border-strong); }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #eef0ff 0%, #f7f8fb 45%);
}
.login-card {
  width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 36px 32px;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-logo .logo-dot { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #8b7bff); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.login-logo .logo-text { font-weight: 700; font-size: 15px; }
.login-card h1 { font-size: 19px; margin-bottom: 2px; }
.login-card .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }

/* ---------- Login (split layout) ---------- */
.login-shell--split {
  padding: 0; align-items: stretch; justify-content: stretch;
  background:
    radial-gradient(circle at 10% 12%, rgba(124,107,255,0.20) 0%, transparent 38%),
    radial-gradient(circle at 34% 88%, rgba(23,166,115,0.16) 0%, transparent 42%),
    radial-gradient(circle at 96% 30%, rgba(255,138,107,0.16) 0%, transparent 38%),
    radial-gradient(circle at 66% 96%, rgba(79,99,255,0.14) 0%, transparent 42%),
    #fbfbff;
}
.login-panel-left {
  flex: 1 1 50%; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.login-left-accent {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: 0; filter: blur(2px);
}
.login-left-accent--a {
  top: -90px; left: -90px; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(124,107,255,0.28) 0%, rgba(124,107,255,0) 70%);
}
.login-left-accent--b {
  bottom: -110px; left: 10px; width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(23,166,115,0.22) 0%, rgba(23,166,115,0) 70%);
}
.login-left-accent--c {
  top: 40%; right: -80px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,138,107,0.20) 0%, rgba(255,138,107,0) 70%);
}
.login-card--split {
  width: 100%; max-width: 430px; position: relative; z-index: 1;
  background: rgba(255,255,255,0.82); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 28px;
  padding: 40px 36px;
  box-shadow: 0 24px 60px rgba(48,54,113,0.14), 0 2px 8px rgba(48,54,113,0.06);
}
.login-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--primary-strong);
  background: var(--primary-soft); padding: 5px 12px; border-radius: 999px;
  margin-bottom: 14px; letter-spacing: 0.02em;
}
.login-eyebrow svg { width: 12px; height: 12px; flex-shrink: 0; }
.login-logo--split { margin-bottom: 20px; }
.login-logo-img { max-width: 200px; height: auto; display: block; }
.login-card--split h1 { font-size: 26px; font-weight: 800; margin-bottom: 22px; letter-spacing: -0.01em; }
.login-card--split .btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7d6bff 100%);
  box-shadow: 0 12px 24px rgba(79,99,255,0.28);
  border: none; transition: transform 0.15s, box-shadow 0.15s;
}
.login-card--split .btn-primary:hover {
  transform: translateY(-1px); box-shadow: 0 14px 28px rgba(79,99,255,0.34);
}
.login-input-wrap { position: relative; }
.login-input-wrap svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-faint); pointer-events: none;
}
.login-input-wrap input { padding-left: 38px; background: rgba(255,255,255,0.9); }
.login-card--split input:focus {
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.login-row-between {
  display: flex; align-items: center; justify-content: space-between; margin: -2px 0 20px;
}
.switch-label { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--text); margin-bottom: 0; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background 0.15s; }
.switch-track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.forgot-link { font-size: 13px; font-weight: 500; }

.login-panel-right {
  flex: 1 1 50%; position: relative; overflow: hidden;
  background: #dcebe3;
  border-radius: 28px;
  margin: 16px 16px 16px 0;
  padding: 44px 40px;
}
.login-panel-right-inner {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.login-right-text { align-self: flex-start; text-align: left; max-width: 600px; position: relative; z-index: 2; }
.login-quote {
  color: var(--primary); font-size: 19px; line-height: 1.45; font-weight: 800;
  margin: 0 0 10px; letter-spacing: -0.01em; white-space: normal;
}
.login-tagline {
  font-size: 15px; font-weight: 600; color: #5f6a8a;
  margin: 0; letter-spacing: -0.005em;
}

.login-illustration {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; object-position: center bottom;
  z-index: 0; pointer-events: none;
}

@keyframes login-floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

@media (max-width: 1320px) {
  .login-quote { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .login-illustration { animation: none; }
}

@media (max-width: 900px) {
  .login-panel-right { display: none; }
  .login-panel-left { flex: 1 1 100%; }
}

/* ---------- Timetable grid ---------- */
.timetable-grid { display: grid; grid-template-columns: 90px repeat(6, 1fr); gap: 6px; }
.tt-cell { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px; background: var(--surface); min-height: 54px; }
.tt-head { background: var(--surface-muted); font-weight: 700; font-size: 11px; text-align: center; color: var(--text-faint); text-transform: uppercase; }
.tt-cell .subj { font-weight: 700; color: var(--text); }
.tt-cell .teacher { color: var(--text-faint); font-size: 11px; }

.mobile-nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border-strong); color: var(--text);
  cursor: pointer; flex-shrink: 0; margin-right: 4px;
}
.mobile-nav-toggle:hover { background: var(--surface-muted); }
.mobile-nav-toggle svg { width: 18px; height: 18px; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 39;
  background: rgba(20, 24, 40, 0.45);
}

@media (max-width: 900px) {
  .sidebar { position: fixed; top: 0; left: -260px; z-index: 40; transition: left 0.2s; width: var(--sidebar-w); height: 100vh; }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: none; }
  .content { padding: 16px; }
  .mobile-nav-toggle { display: flex; }
  .sidebar-backdrop.open { display: block; }
  body.mobile-nav-open { overflow: hidden; }
  .dash-hero-sub { display: block; margin-top: 4px; }

  /* The desktop collapse-to-icon-rail feature is desktop-only — never let
     a collapsed state carried over via localStorage shrink the slide-out
     mobile menu to an unusable icon strip. */
  .sidebar-inner { width: var(--sidebar-w) !important; }
  .nav-group-label { visibility: visible !important; }
  .nav-link-label { display: inline !important; }
  .nav-link { justify-content: flex-start !important; }
}

/* ---------- Dashboard hero ---------- */
.dash-hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.dash-hero h1 { font-size: 24px; margin: 0 0 2px; }
.dash-hero-sub { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.dash-hero-roles { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Widget grid (clickable analytics cards) ---------- */
.widget-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
  margin-bottom: 24px;
}
.widget-card {
  text-align: left; cursor: pointer; font-family: inherit;
  background: linear-gradient(160deg, var(--surface) 0%, #f4f5f9 100%);
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 12px 18px 14px; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex; flex-direction: column; gap: 7px;
}
.widget-card:hover, .widget-card:focus-visible {
  transform: translateY(-2px); box-shadow: var(--shadow); border-left-color: var(--primary);
  outline: none;
}
.widget-card:active { transform: translateY(0); }
.widget-card.accent-primary { border-left-color: var(--primary); background: linear-gradient(160deg, var(--surface) 0%, var(--primary-soft) 100%); }
.widget-card.accent-success { border-left-color: var(--success); background: linear-gradient(160deg, var(--surface) 0%, var(--success-soft) 100%); }
.widget-card.accent-warning { border-left-color: var(--warning); background: linear-gradient(160deg, var(--surface) 0%, var(--warning-soft) 100%); }
.widget-card.accent-danger { border-left-color: var(--danger); background: linear-gradient(160deg, var(--surface) 0%, var(--danger-soft) 100%); }
.widget-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.widget-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary-strong); flex-shrink: 0;
}
.widget-icon-svg { width: 14px; height: 14px; }
.modal-header .widget-icon { width: 30px; height: 30px; }
.modal-header .widget-icon-svg { width: 16px; height: 16px; }
.modal-header > div:first-child { display: flex; align-items: center; gap: 10px; }
.widget-card.accent-success .widget-icon { background: var(--success-soft); color: var(--success); }
.widget-card.accent-warning .widget-icon { background: var(--warning-soft); color: var(--warning); }
.widget-card.accent-danger .widget-icon { background: var(--danger-soft); color: var(--danger); }
.widget-expand {
  display: block; text-align: right; margin-top: 2px;
  font-size: 11px; font-weight: 600; color: var(--text-faint); opacity: 0; transition: opacity 0.15s;
}
.widget-card:hover .widget-expand, .widget-card:focus-visible .widget-expand { opacity: 1; color: var(--primary); }
.widget-label { font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: 0.03em; }
.widget-value { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; color: #0a0c11; }
.widget-sub { font-size: 12px; color: #12151d; margin-top: auto; padding-top: 6px; }

/* ---------- Modal ---------- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  align-items: center; justify-content: center; padding: 24px;
}
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 24, 40, 0.45); backdrop-filter: blur(1px); }
.modal-dialog {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-pop 0.15s ease-out;
}
@keyframes modal-pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-weight: 700; font-size: 15px; margin-left: 8px; }
.modal-close {
  background: none; border: none; font-size: 22px; line-height: 1; color: var(--text-faint);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-muted); color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-headline { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.modal-headline-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.modal-headline-sub { font-size: 13px; color: var(--text-muted); }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
body.modal-open { overflow: hidden; }

@media (max-width: 640px) {
  .widget-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .modal { padding: 10px; }
}

/* ---------- Parent portal ---------- */
.portal-body { background: var(--bg); min-height: 100vh; }
.portal-topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.portal-topbar-inner {
  max-width: 900px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px;
}
.portal-logo { height: 34px; width: auto; }
.portal-child-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.portal-child-switch select {
  padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; background: var(--surface);
}
.portal-logout { margin-left: auto; font-size: 12.5px; color: var(--text-faint); }
.portal-tabs {
  max-width: 900px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px;
  overflow-x: auto; scrollbar-width: none;
  /* On mobile the tab strip is often wider than the screen; without this
     it just cuts off the last tab with no hint there's more to scroll to. */
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.portal-tabs::-webkit-scrollbar { display: none; }
.portal-tab {
  padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.portal-tab:hover { color: var(--text); text-decoration: none; }
.portal-tab.active { color: var(--primary-strong); border-bottom-color: var(--primary); }
.portal-content { max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; }
.portal-h1 { font-size: 22px; margin-bottom: 2px; }
.portal-sub { color: var(--text-muted); margin: 0 0 6px; }

@media (max-width: 640px) {
  .portal-topbar-inner { padding: 12px 16px; }
  .portal-content { padding: 20px 16px 48px; }
}

/* ---------- Dashboard trend charts ---------- */
.trend-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 24px;
}
.trend-card--wide { grid-column: 1 / -1; }
.trend-card-head { margin-bottom: 4px; }
.trend-card-head h3 { font-size: 14px; margin-bottom: 2px; }
.trend-card-head p { font-size: 12px; margin: 0; }

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 9.5px; fill: var(--text-faint); font-family: inherit; }
.chart-line { stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.chart-bar-value { font-size: 10.5px; font-weight: 700; fill: var(--text); font-family: inherit; }

.funnel-chart { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; }
.funnel-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-track { background: var(--surface-muted); border-radius: 999px; height: 14px; overflow: hidden; }
.funnel-fill { display: block; height: 100%; border-radius: 999px; min-width: 6px; transition: width 0.3s ease; }
.funnel-count { font-size: 12.5px; font-weight: 700; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .trend-grid { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 96px 1fr 36px; }
}

/* ---------- Settings tabs (school setup) ---------- */
.settings-tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0 22px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.settings-tab {
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); text-decoration: none; }
.settings-tab.active { color: var(--primary-strong); border-bottom-color: var(--primary); }

/* ---------- Role management (collapsible permission matrix) ---------- */
.role-card summary::-webkit-details-marker { display: none; }
.role-card summary::marker { content: ""; }
.role-card[open] summary { border-bottom: 1px solid var(--border); }

/* ---------- Clickable cards (e.g. Reports index) — need their own
   hover affordance since plain .card gives no visual hint it's a link. */
.card-link { display: block; transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease; }
.card-link:hover { box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,0.08)); border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }

/* ---------- Sidebar profile (moved off the top row, pinned to sidebar bottom) ---------- */
.sidebar-profile-wrap { position: relative; flex-shrink: 0; border-top: 1px solid var(--border); padding: 8px; }
.sidebar-profile {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px; border: none; background: none; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left; font-family: inherit;
}
.sidebar-profile:hover { background: var(--surface-muted); }
.sidebar-profile .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-profile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sidebar-profile-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-profile-email { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-profile-chevron { width: 15px; height: 15px; color: var(--text-faint); flex-shrink: 0; transition: transform 0.15s ease; }
.sidebar-profile-wrap.open .sidebar-profile-chevron { transform: rotate(180deg); }
:root[data-sidebar-collapsed="1"] .sidebar-profile-text,
:root[data-sidebar-collapsed="1"] .sidebar-profile-chevron { display: none; }
:root[data-sidebar-collapsed="1"] .sidebar-profile { justify-content: center; }

.profile-card {
  display: none;
  position: absolute; left: 8px; bottom: calc(100% + 6px);
  width: 300px; max-width: calc(100vw - 32px);
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 12px 32px rgba(20, 24, 40, 0.18); border: 1px solid var(--border);
  z-index: 60;
}
.sidebar-profile-wrap.open .profile-card { display: block; }
.profile-card-hero {
  background: linear-gradient(135deg, #6366f1, #7c8cf5);
  padding: 22px 20px 18px; text-align: center; color: #fff;
}
.profile-card-avatar {
  width: 58px; height: 58px; margin: 0 auto 10px; border-radius: 50%;
  background: rgba(255,255,255,0.18); border: 2px solid rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
}
.profile-card-avatar svg { width: 28px; height: 28px; }
.profile-card-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.profile-card-email { font-size: 12.5px; opacity: 0.9; margin-bottom: 10px; word-break: break-all; }
.profile-card-status {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  background: rgba(255,255,255,0.92); color: var(--success, #15803d); padding: 3px 12px; border-radius: 999px;
}
.profile-card-body { padding: 14px 18px 16px; }
.profile-field { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.profile-field:last-of-type { border-bottom: none; }
.profile-field-label {
  display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 3px;
}
.profile-field-label svg { width: 13px; height: 13px; flex-shrink: 0; }
.profile-field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--text); }
.profile-field-action { font-size: 12.5px; font-weight: 600; color: var(--primary-strong); text-decoration: underline; flex-shrink: 0; }
.profile-action-btn {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px;
  background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; font-size: 13.5px;
  border-radius: var(--radius-sm); text-decoration: none;
}
.profile-action-btn:hover { text-decoration: none; filter: brightness(0.97); }
.profile-action-btn svg { width: 16px; height: 16px; }
.profile-card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-muted);
}
.profile-logout-link { font-size: 13.5px; font-weight: 600; color: var(--text); }
.profile-logout-link:hover { text-decoration: none; color: var(--danger); }
.profile-logout-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--danger-soft, #fee2e2); color: var(--danger, #dc2626);
  display: flex; align-items: center; justify-content: center;
}
.profile-logout-btn:hover { filter: brightness(0.96); }
.profile-logout-btn svg { width: 16px; height: 16px; }

@media (max-width: 900px) {
  .sidebar-profile-wrap { display: block; }
}

/* ---------- Floating "ASK" widget ---------- */
.ask-widget { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.ask-trigger {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; font-family: inherit; padding: 0;
}
.ask-trigger-icon {
  position: relative; width: 48px; height: 48px; border-radius: 16px;
  background: linear-gradient(155deg, #6b7bff 0%, #3c4feb 100%);
  box-shadow: 0 10px 24px rgba(60, 79, 235, 0.35);
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow 0.15s ease;
  animation: ask-heartbeat 5s ease-in-out infinite;
  transform-origin: center;
}
.ask-trigger-icon svg { width: 27px; height: 27px; }
.ask-trigger:hover .ask-trigger-icon { box-shadow: 0 14px 30px rgba(60, 79, 235, 0.42); }
.ask-trigger-dot {
  position: absolute; top: -3px; right: -3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--success); border: 3px solid var(--surface);
}
.ask-trigger-label {
  font-size: 12.5px; font-weight: 700; color: var(--primary-strong);
  background: var(--surface); border: 1px solid var(--primary-soft);
  padding: 3px 12px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.ask-widget.open .ask-trigger { display: none; }

/* Whole-icon "heartbeat" — expand/compress the entire bubble every 5s.
   A scale on a 48px block reads unmistakably, unlike the sub-pixel eye
   squash this replaced, which was too small to notice on a real screen. */
@keyframes ask-heartbeat {
  0%, 60%, 100% { transform: scale(1); }
  70% { transform: scale(1.18); }
  78% { transform: scale(0.94); }
  86% { transform: scale(1.08); }
  93% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .ask-trigger-icon { animation: none; } }

.ask-panel {
  display: none; flex-direction: column;
  width: 360px; max-width: calc(100vw - 32px); height: 480px; max-height: calc(100vh - 120px);
  background: var(--surface); border-radius: 18px; overflow: hidden;
  box-shadow: 0 20px 48px rgba(20, 24, 40, 0.22); border: 1px solid var(--border);
}
.ask-widget.open .ask-panel { display: flex; }

.ask-panel-header {
  display: flex; align-items: center; gap: 12px; padding: 16px 16px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, #e4e8ff 100%);
  flex-shrink: 0;
}
.ask-panel-bot {
  width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(155deg, #6b7bff 0%, #3c4feb 100%);
  display: flex; align-items: center; justify-content: center;
}
.ask-panel-bot svg { width: 24px; height: 24px; }
.ask-panel-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ask-panel-title strong { font-size: 13.5px; color: var(--primary-strong); letter-spacing: 0.03em; }
.ask-panel-title span { font-size: 12px; color: var(--text-muted); }
.ask-panel-close {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: rgba(255,255,255,0.6); border: none; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--primary-strong);
  display: flex; align-items: center; justify-content: center;
}
.ask-panel-close:hover { background: rgba(255,255,255,0.9); }

.ask-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ask-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px 9px; background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.ask-tab svg { width: 17px; height: 17px; }
.ask-tab:hover { color: var(--text); }
.ask-tab.active { color: var(--primary-strong); border-bottom-color: var(--primary); }

.ask-content { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.ask-empty { text-align: center; padding: 32px 12px; color: var(--text-faint); }
.ask-empty svg { width: 34px; height: 34px; margin-bottom: 10px; opacity: 0.6; }
.ask-empty p { font-size: 13px; margin: 0; line-height: 1.5; color: var(--text-faint); }

.ask-howto-item {
  display: block; padding: 11px 12px; border-radius: var(--radius-sm); margin-bottom: 6px;
  border: 1px solid var(--border); color: var(--text);
}
.ask-howto-item:hover { background: var(--surface-muted); text-decoration: none; border-color: var(--border-strong); }
.ask-howto-item strong { display: block; font-size: 13px; margin-bottom: 2px; }
.ask-howto-item span { display: block; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.ask-results { display: flex; flex-direction: column; gap: 6px; }
.ask-result-item {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text);
}
.ask-result-item:hover { background: var(--surface-muted); text-decoration: none; border-color: var(--primary); }
.ask-result-type {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--primary-strong); background: var(--primary-soft); padding: 1px 7px; border-radius: 999px; margin-bottom: 4px;
}
.ask-result-item strong { display: block; font-size: 13px; }
.ask-result-meta { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.ask-footer { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ask-footer input {
  flex: 1; border: 1px solid var(--border-strong); border-radius: 999px; padding: 9px 16px;
  font-size: 13px; font-family: inherit; outline: none;
}
.ask-footer input:focus { border-color: var(--primary); }
.ask-footer button {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; border: none; cursor: pointer;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
}
.ask-footer button svg { width: 16px; height: 16px; }
.ask-footer button:hover { background: var(--primary-strong); }

@media (max-width: 480px) {
  .ask-widget { right: 14px; bottom: 14px; }
  .ask-panel { width: calc(100vw - 28px); }
}
