:root {
  --ink: #132d27;
  --ink-2: #1e493e;
  --evergreen: #1d725f;
  --evergreen-dark: #125647;
  --evergreen-soft: #e3f1e9;
  --sand: #f7f3eb;
  --paper: #fffdfa;
  --line: #e6ded1;
  --text: #1d2925;
  --muted: #6a746d;
  --sun: #dd9a34;
  --sun-soft: #fff0d8;
  --coral: #bc5945;
  --coral-soft: #fae7e2;
  --blue-soft: #e7eff0;
  --radius-lg: 20px;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(32, 50, 42, .08);
  --font-display: 'Sora', 'Trebuchet MS', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--sand); }
body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 15%, rgba(221, 154, 52, .12), transparent 21rem),
    radial-gradient(circle at 95% 38%, rgba(29, 114, 95, .10), transparent 23rem),
    var(--sand);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; color: var(--ink); font-family: var(--font-display); }
a { color: var(--evergreen-dark); }
[hidden] { display: none !important; }

/* Application masthead */
.app-header {
  position: relative;
  overflow: hidden;
  padding: 22px 24px 0;
  color: #fff;
  background: linear-gradient(116deg, #112f28 0%, #1b5a4c 57%, #164036 100%);
  box-shadow: 0 5px 24px rgba(16, 49, 41, .17);
}
.app-header::before,
.app-header::after {
  position: absolute;
  z-index: 0;
  border-radius: 999px;
  content: '';
  pointer-events: none;
}
.app-header::before {
  width: 320px;
  height: 320px;
  top: -220px;
  right: 9%;
  border: 1px solid rgba(255, 241, 211, .22);
  box-shadow: 0 0 0 42px rgba(255, 255, 255, .035), 0 0 0 85px rgba(255, 255, 255, .025);
}
.app-header::after {
  width: 210px;
  height: 210px;
  bottom: -170px;
  left: 37%;
  background: rgba(224, 157, 52, .16);
}
.header-inner, .tabs { position: relative; z-index: 1; }
.header-inner {
  display: flex;
  max-width: 1200px;
  min-height: 58px;
  margin: 0 auto;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; min-width: 0; gap: 12px; }
.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  object-fit: cover;
  border: 1px solid rgba(255, 244, 221, .62);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .19);
}
.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border: 1px solid rgba(255, 244, 221, .48);
  border-radius: 10px;
  color: #ffe0a4;
  background: rgba(255, 255, 255, .10);
  box-shadow: inset 0 1px rgba(255, 255, 255, .16);
  font-size: 16px;
  transform: rotate(45deg);
}
.brand h1 { color: #fff; font-size: clamp(18px, 2vw, 23px); letter-spacing: -.03em; }
.brand-sub { margin: 4px 0 0; color: rgba(239, 246, 240, .74); font-size: 12px; letter-spacing: .01em; }
.login-card .brand-logo { width: 54px; height: 54px; flex-basis: 54px; border-color: var(--line); box-shadow: 0 5px 15px rgba(30, 54, 43, .11); }
.student-header-logo { width: 31px; height: 31px; flex-basis: 31px; margin-right: 7px; vertical-align: middle; border-radius: 9px; }
.header-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; justify-content: flex-end; }
.notification-button { position: relative; display: inline-flex; width: 38px; height: 34px; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; color: #fff; background: rgba(255,255,255,.1); cursor: pointer; font-size: 17px; }
.notification-button:hover { background: rgba(255,255,255,.2); }
.notification-badge { position: absolute; top: -7px; right: -6px; min-width: 18px; height: 18px; padding: 1px 5px; border: 2px solid var(--ink); border-radius: 99px; color: #fff; background: #d85e48; font-size: 10px; font-weight: 800; line-height: 14px; }
.school-switcher { display: flex; gap: 7px; align-items: center; color: rgba(245, 250, 246, .86); font-size: 12px; font-weight: 750; }
.school-switcher select {
  min-width: 174px;
  max-width: 230px;
  padding: 8px 29px 8px 10px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 9px;
  outline: none;
  color: #18392f;
  background: #fffdf9;
  font-size: 13px;
  font-weight: 650;
}
.school-switcher select:focus { box-shadow: 0 0 0 3px rgba(255, 220, 147, .33); }
.tabs {
  display: flex;
  max-width: 1200px;
  margin: 18px auto 0;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  position: relative;
  flex: 0 0 auto;
  padding: 11px 18px 12px;
  border: 0;
  border-radius: 11px 11px 0 0;
  color: rgba(244, 250, 246, .72);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
  font-size: 13px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.tab-btn:hover { color: #fff; background: rgba(255, 255, 255, .09); }
.tab-btn.active { color: var(--ink); background: var(--sand); }
.tab-btn.active::after { position: absolute; right: 18px; bottom: 5px; left: 18px; height: 3px; border-radius: 9px; background: var(--sun); content: ''; }

/* Status, controls and shared surfaces */
.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 11px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 750;
}
.sync-ok { color: #17614f; background: #e8f5ed; }
.sync-warn { color: #85560c; background: var(--sun-soft); }
.sync-syncing { color: #275d65; background: var(--blue-soft); }
.btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 14px rgba(18, 50, 42, .14); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled, .status-btn:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }
.btn.primary { color: #fff; background: var(--ink); }
.btn.primary:hover { background: #0e241e; }
.btn.secondary { color: #fff; background: var(--evergreen); }
.btn.secondary:hover { background: var(--evergreen-dark); }
.btn.ghost { color: var(--ink); border-color: var(--line); background: rgba(255, 253, 249, .72); }
.app-header .btn.ghost, .student-header .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .36); background: rgba(255, 255, 255, .08); }
.btn.danger { color: #fff; background: var(--coral); }
.btn.small { min-height: 32px; padding: 6px 11px; border-radius: 9px; font-size: 12px; }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 44px; }
.tab-panel { display: none; animation: reveal .28s ease both; }
.tab-panel.active { display: block; }
@keyframes reveal { from { opacity: .2; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.panel {
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid rgba(221, 211, 196, .9);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 249, .92);
  box-shadow: var(--shadow);
}
.panel h2 { margin-bottom: 8px; font-size: 17px; letter-spacing: -.025em; }
.panel h2 + .footer-note { display: block; margin: -1px 0 16px; }
.footer-note { color: var(--muted); font-size: 12px; line-height: 1.55; }
.permission-fieldset {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
  margin: 3px 0 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf8f1;
}
.permission-fieldset legend { padding: 0 7px; color: var(--evergreen-dark); font-size: 12px; font-weight: 800; }
.permission-fieldset label, .school-choice { color: var(--text); font-size: 13px; font-weight: 650; }
.school-choice-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 2px; }
.school-choice { display: inline-flex; gap: 5px; align-items: center; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
input[type='checkbox'] { width: 15px; height: 15px; accent-color: var(--evergreen); }
.sheets-link { display: inline-flex; margin-top: 12px; color: var(--evergreen-dark); font-size: 13px; font-weight: 800; text-underline-offset: 3px; }

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  position: relative;
  min-height: 122px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--paper);
  box-shadow: 0 7px 17px rgba(43, 55, 48, .055);
}
.stat-card::after { position: absolute; top: 0; right: 0; width: 64px; height: 64px; border-radius: 0 0 0 64px; background: #e8efe9; content: ''; }
.stat-card.accent-present::after { background: var(--evergreen-soft); }
.stat-card.accent-absent::after { background: var(--coral-soft); }
.stat-card.accent-percent::after { background: var(--sun-soft); }
.stat-label { position: relative; z-index: 1; display: block; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .085em; text-transform: uppercase; }
.stat-value { position: relative; z-index: 1; color: var(--ink); font-family: var(--font-display); font-size: clamp(27px, 3.2vw, 35px); font-weight: 750; letter-spacing: -.055em; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr); gap: 18px; }
.panel-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.period-toggle { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f7f4ed; }
.period-btn { border: 0; border-radius: 7px; padding: 7px 10px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.period-btn.active { color: #fff; background: var(--evergreen); }
.chart-wrap { position: relative; min-height: 220px; height: 220px; }
.chart-wrap canvas { position: relative; z-index: 1; max-width: 100%; }
.chart-wrap .empty-note { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; }
.chart-wrap.empty .empty-note { display: flex; }
.chart-wrap.empty canvas { display: none; }
.count-validation { color: #a14a38; font-size: 12px; font-weight: 700; }
.count-validation.is-valid { color: var(--evergreen-dark); }
.activity-list { display: flex; max-height: 220px; margin: 0; padding: 0; list-style: none; flex-direction: column; gap: 6px; overflow-y: auto; }
.activity-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.activity-list li:last-child { border-bottom: 0; }
.activity-name { flex: 1; color: var(--text); font-weight: 650; }
.activity-time { color: var(--muted); font-size: 11px; }
.pill, .status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.pill { text-transform: uppercase; }
.pill.present, .status-pill.present { color: #14604e; background: var(--evergreen-soft); }
.pill.absent, .status-pill.absent { color: #963e2f; background: var(--coral-soft); }
.status-pill.not-marked { color: #69736d; background: #f0eee9; }

/* Data tables */
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 14px; border-bottom: 1px solid #eee8de; vertical-align: middle; text-align: left; }
th { position: sticky; z-index: 1; top: 0; color: #577067; background: #f1f5f0; font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #faf6ed; }
tbody tr:last-child td { border-bottom: 0; }
.empty-row { padding: 30px; color: var(--muted); text-align: center; }
.student-cell { display: flex; flex-direction: column; }
.student-name { color: var(--ink); font-weight: 750; }
.student-meta { margin-top: 2px; color: var(--muted); font-size: 11px; }
.actions-cell { white-space: nowrap; }
.sync-dot { display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; vertical-align: middle; }
.sync-dot.synced { background: var(--evergreen); box-shadow: 0 0 0 3px var(--evergreen-soft); }
.sync-dot.pending { background: var(--sun); box-shadow: 0 0 0 3px var(--sun-soft); }

/* Forms */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 2px 0 13px; }
.toolbar > label, .date-field, .report-toolbar label { display: flex; gap: 5px; flex-direction: column; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .025em; }
.search-input { min-width: min(100%, 225px); flex: 1 1 225px; }
.day-summary { margin: 0 0 14px; padding: 8px 11px; border-left: 3px solid var(--sun); color: var(--muted); background: #fbf5e9; font-size: 12px; }
input[type='text'], input[type='number'], input[type='date'], input[type='month'], input[type='email'], input[type='password'], select {
  min-height: 39px;
  padding: 9px 11px;
  border: 1px solid #dcd5c9;
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #fffefa;
  font-family: var(--font-body);
  font-size: 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input[type='email'], input[type='password'] { width: 100%; }
input::placeholder { color: #9ba199; }
input:focus, select:focus { border-color: var(--evergreen); background: #fff; box-shadow: 0 0 0 3px rgba(29, 114, 95, .14); }
.student-form { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(115px, 1fr)); gap: 11px; }
.form-actions { display: flex; grid-column: 1 / -1; gap: 10px; align-items: center; }
.date-range { display: flex; gap: 9px; align-items: flex-end; }
.date-range label { min-width: 132px; }
.report-toolbar { margin-top: 16px; margin-bottom: 0; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fbf8f1; }
.report-toolbar input, .report-toolbar select { min-width: 142px; }

.status-btn {
  min-height: 31px;
  margin: 2px 4px 2px 0;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  transition: transform .14s ease, filter .14s ease;
}
.status-btn:hover { filter: brightness(.95); transform: translateY(-1px); }
.present-btn { background: var(--evergreen); }
.absent-btn { background: var(--coral); }
.not-marked-btn { color: #5b625e; border-color: #d8d9d4; background: #f3f1eb; }
.status-btn.is-selected { outline: 2px solid rgba(17, 44, 36, .22); outline-offset: 1px; }
.not-marked-btn.is-selected { color: #3f4641; border-color: #9ba39d; background: #e5e5df; }
.icon-btn { width: 31px; height: 31px; margin-right: 4px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); cursor: pointer; font-size: 14px; transition: border-color .15s, background .15s, transform .15s; }
.icon-btn:hover { border-color: #b9c9bf; background: var(--evergreen-soft); transform: translateY(-1px); }
.icon-btn.danger { color: var(--coral); border-color: #efd0c9; }
.icon-btn.danger:hover { background: var(--coral-soft); }

/* Login and student portal */
.login-page, .student-portal-page { min-height: 100vh; }
.login-page { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid rgba(225, 215, 199, .94);
  border-radius: 22px;
  background: rgba(255, 253, 249, .94);
  box-shadow: 0 22px 54px rgba(28, 54, 46, .13);
}
.login-card .brand { margin-bottom: 8px; }
.login-card .brand h1 { color: var(--ink); font-size: 21px; }
.login-card .brand-mark { color: var(--evergreen); border-color: #bcd5ca; background: var(--evergreen-soft); }
.login-card .brand-sub { color: var(--muted); }
.login-card form { display: grid; gap: 15px; margin-top: 23px; }
.login-card label, .student-entry-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.login-card .btn { width: 100%; min-height: 43px; }
.login-card h2 { margin: 0; font-size: 18px; }
.form-help { margin: -7px 0 1px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.text-button { padding: 3px; border: 0; color: var(--evergreen-dark); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; text-align: center; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--ink); }
.login-error { margin: 0; color: #9d3526; font-size: 12px; font-weight: 650; }
.login-card .footer-note { display: block; margin: 20px 0 0; text-align: center; }

.student-portal-page { padding: 34px 20px; }
.student-portal-shell { max-width: 1080px; margin: auto; }
.student-entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.student-entry-grid .login-card { width: 100%; }
.student-entry-grid form { display: grid; gap: 14px; margin-top: 18px; }
.portal-message { grid-column: 1 / -1; margin: 0; padding: 13px 16px; border-radius: 12px; color: #31525b; background: var(--blue-soft); font-size: 13px; }
.portal-message.error { color: #943c2e; background: var(--coral-soft); }
.portal-message.success { color: #17604d; background: var(--evergreen-soft); }
.student-header { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; padding: 18px 20px; border-radius: var(--radius-lg); color: #fff; background: linear-gradient(115deg, var(--ink), var(--ink-2)); box-shadow: var(--shadow); }
.student-header strong { font-family: var(--font-display); }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.profile-details { display: grid; grid-template-columns: minmax(105px, max-content) 1fr; gap: 10px 18px; font-size: 13px; }
.profile-details dt { color: var(--muted); font-weight: 750; }
.profile-details dd { margin: 0; color: var(--text); font-weight: 600; }
.percentage-gauge { --percentage: 0%; position: relative; display: grid; width: 176px; height: 176px; margin: 12px auto 14px; border-radius: 50%; place-items: center; background: conic-gradient(var(--evergreen) var(--percentage), #e8e4db 0); box-shadow: inset 0 0 0 1px rgba(20, 66, 55, .06); }
.percentage-gauge::before { position: absolute; width: 130px; height: 130px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 1px var(--line); content: ''; }
.percentage-gauge span { position: relative; color: var(--ink); font-family: var(--font-display); font-size: 27px; font-weight: 800; }
.performance-text { color: var(--evergreen-dark); text-align: center; font-size: 13px; font-weight: 750; }
.student-stats { margin: 0 0 20px; }
.attendance-graphic { display: grid; gap: 14px; }
.attendance-graphic > div { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 12px; align-items: center; font-size: 12px; font-weight: 750; }
.attendance-track { height: 13px; overflow: hidden; border-radius: 999px; background: #ebe7df; }
.attendance-track i { display: block; height: 100%; border-radius: inherit; }
.present-bar { background: var(--evergreen); }
.absent-bar { background: var(--coral); }

/* Footer and feedback */
.app-footer { display: flex; max-width: 1200px; margin: 0 auto 34px; padding: 0 24px; gap: 13px; align-items: center; }
.toast-container { position: fixed; z-index: 1000; right: 20px; bottom: 20px; display: flex; max-width: min(360px, calc(100vw - 32px)); gap: 8px; flex-direction: column; }
.toast { padding: 13px 15px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 12px; color: #fff; background: var(--ink); box-shadow: 0 16px 32px rgba(16, 41, 34, .25); font-size: 13px; line-height: 1.4; opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--evergreen-dark); }
.toast-error { background: #9b3f30; }
.confirm-overlay { position: fixed; z-index: 1000; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(18, 40, 34, .48); backdrop-filter: blur(4px); }
.confirm-overlay.visible { display: flex; }
.confirm-box { width: min(100%, 390px); padding: 24px; border: 1px solid rgba(255, 255, 255, .5); border-radius: 18px; background: var(--paper); box-shadow: 0 22px 55px rgba(0, 0, 0, .2); }
.confirm-box p { margin: 0 0 19px; font-size: 14px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Permission presentation remains a convenience only; API permissions enforce access. */
body.read-only #markAllPresentBtn, body.read-only .status-btn, body.read-only #syncNowBtn, body.read-only #studentFormTitle, body.read-only #addStudentForm, body.read-only #studentsTable .actions-cell, body.read-only #exportDataBtn, body.read-only #importBtn { display: none; }
body.read-only .footer-note { font-size: 0; }
body.read-only .footer-note::after { content: 'Read-only account.'; color: var(--muted); font-size: 12px; font-weight: 750; }
body.students-read-only #studentFormTitle, body.students-read-only #addStudentForm, body.students-read-only #studentsTable .actions-cell { display: none; }

@media (max-width: 980px) {
  .header-inner { align-items: flex-start; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .student-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-header { padding: 17px 16px 0; }
  .header-inner { gap: 14px; align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .school-switcher { flex: 1 1 190px; }
  .school-switcher select { width: 100%; max-width: none; }
  .tabs { margin-top: 14px; margin-right: -16px; margin-left: -16px; padding: 0 16px; }
  .tab-btn { padding-right: 15px; padding-left: 15px; }
  .container { padding: 20px 16px 34px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid, .student-entry-grid { grid-template-columns: 1fr; }
  .student-header { align-items: flex-start; flex-direction: column; }
  .student-header > div:last-child { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
  .app-footer { padding: 0 16px; }
}
@media (max-width: 520px) {
  .brand h1 { font-size: 18px; }
  .brand-mark { width: 29px; height: 29px; flex-basis: 29px; }
  .header-actions { gap: 7px; }
  .sync-badge { order: 3; width: 100%; justify-content: center; }
  .panel { padding: 16px; border-radius: 16px; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { min-height: 102px; }
  .toolbar, .report-toolbar, .date-range { align-items: stretch; flex-direction: column; }
  .toolbar > *, .toolbar .btn, .date-range label, .report-toolbar input, .report-toolbar select { width: 100%; min-width: 0; }
  .student-form { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1; }
  .chart-wrap { min-height: 190px; height: 190px; }
  .login-page, .student-portal-page { padding: 16px; }
  .login-card { padding: 23px 20px; border-radius: 18px; }
  .profile-details { grid-template-columns: 1fr; gap: 3px; }
  .profile-details dd { margin-bottom: 8px; }
  .app-footer { align-items: flex-start; flex-direction: column; }
  .app-footer .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
