:root {
  --bg: #eaf1f7;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --text: #172033;
  --muted: #617089;
  --line: #dfe7ef;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --accent: #f59e0b;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 22px 55px rgba(23, 32, 51, 0.14);
  --radius: 8px;
}

body[data-theme="dark"] {
  --bg: #121722;
  --surface: #1b2330;
  --surface-2: #222d3d;
  --text: #edf4ff;
  --muted: #a8b4c5;
  --line: #344055;
  --brand: #2dd4bf;
  --brand-2: #60a5fa;
  --accent: #fbbf24;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

body[data-theme="default"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #334155;
  --brand-2: #0f766e;
}

* { box-sizing: border-box;}
html,
body,
#app {
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
}
#app {
  position: fixed;
  inset: 0;
  overflow: auto;
}
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, .12), transparent 34%),
    radial-gradient(circle at bottom right, rgba(37, 99, 235, .10), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; }
button {
  border: 0;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
button:hover { transform: translateY(-1px); }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .12), transparent 34%),
    linear-gradient(315deg, rgba(37, 99, 235, .12), transparent 36%),
    var(--bg);
}
.auth-card {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  overflow: hidden;
}
.auth-brand {
  padding: 44px;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: white;
}
.auth-brand h1 { font-size: 42px; margin: 0 0 18px; line-height: 1.04; }
.auth-brand p { line-height: 1.7; opacity: .94; }
.auth-panel { padding: 34px; }
.tabs, .inline-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.tab, .chip {
  background: var(--surface-2);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.tab.active, .chip.active {
  background: var(--text);
  color: var(--surface);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.export-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.check-row input {
  width: auto;
}
label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.primary, .secondary, .danger, .ghost {
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 12px;
  font-weight: 800;
}
.primary { background: linear-gradient(135deg, var(--brand), #14b8a6); color: white; box-shadow: 0 10px 26px rgba(15, 118, 110, .25); }
.secondary { background: linear-gradient(135deg, var(--brand-2), #38bdf8); color: white; }
.danger { background: var(--danger); color: white; }
.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.link-btn { color: var(--brand-2); background: transparent; padding: 8px 0; font-weight: 800; }
.app-shell {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  display: block;
  overflow-x: hidden;
}
.sidebar {
  background: color-mix(in srgb, var(--surface) 92%, var(--brand) 8%);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  height: 100dvh;
  overflow-y: auto;
  z-index: 6;
}
.logo { font-size: 24px; font-weight: 900; margin: 4px 8px 26px; }
.logo {
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 18%, transparent), color-mix(in srgb, var(--brand-2) 14%, transparent));
}
.sidebar-head {
  display: block;
}
.icon-btn.menu-toggle,
.icon-btn.menu-close,
.mobile-menu-tools,
.mobile-menu-backdrop {
  display: none;
}
.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  margin-bottom: 6px;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 800;
}
.nav-btn.active, .nav-btn:hover {
  background: color-mix(in srgb, var(--brand-2) 12%, var(--surface));
  color: var(--text);
  transform: translateX(3px);
}
.main {
  min-width: 0;
  max-width: 100%;
  margin-left: 260px;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(14px);
}
.top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.top-title {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(23, 32, 51, .05);
}
.institute-card {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(23, 32, 51, .06);
}
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px;
  margin-bottom: 22px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand) 14%, transparent), transparent 50%),
    var(--surface);
  box-shadow: 0 18px 38px rgba(23, 32, 51, .1);
}
.dashboard-hero > div:first-child {
  display: grid;
  gap: 5px;
}
.dashboard-hero strong {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}
.hero-clock {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  justify-content: center;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  font-weight: 900;
}
.institute-card strong { font-size: 20px; }
.small { color: var(--muted); font-size: 13px; }
.danger-text { color: var(--danger); font-weight: 800; }
.top-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.top-actions select,
.top-actions button { width: auto; flex: 0 0 auto; }
.top-follow-button {
  position: relative;
}
.top-follow-button span {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 950;
}
.follow-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 13, 23, .45);
  display: flex;
  justify-content: flex-end;
}
.follow-drawer {
  width: min(380px, 92vw);
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 46px rgba(8, 13, 23, .22);
  overflow: hidden;
}
.follow-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.follow-drawer-head h3 {
  margin: 2px 0 0;
}
.follow-drawer-list {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}
.follow-drawer-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  cursor: pointer;
}
.follow-drawer-card strong,
.follow-drawer-card span,
.follow-drawer-card time {
  display: block;
}
.follow-drawer-card span,
.follow-drawer-card time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.follow-drawer-card .actions {
  justify-content: flex-end;
}
.side-follow-alert {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(23, 32, 51, .08);
}
.side-follow-head {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
}
.side-follow-head span {
  color: #b45309;
  font-size: 12px;
  font-weight: 950;
}
.side-follow-head strong {
  font-size: 16px;
}
.side-follow-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}
.side-follow-item {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.top-follow-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.top-follow-text span {
  color: #b45309;
  font-size: 12px;
  font-weight: 950;
}
.top-follow-text strong,
.top-follow-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-follow-text strong {
  font-size: 14px;
}
.top-follow-text small {
  color: var(--muted);
  font-weight: 800;
}
.side-follow-alert .actions {
  justify-content: flex-end;
}
.side-follow-alert .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}
.class-assign-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.class-assign-panel h3 {
  margin: 0 0 4px;
}
.class-assign-actions {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
.class-assign-actions button,
.mobile-menu-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.class-schedule-wrap {
  overflow-x: auto;
}
.follow-alert-panel {
  display: grid;
  gap: 13px;
  padding: 16px;
  margin-bottom: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 14px 30px rgba(23, 32, 51, .08);
}
.follow-alert-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.follow-alert-head h3 {
  margin: 0 0 3px;
}
.follow-alert-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.follow-alert-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}
.follow-alert-card > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.follow-alert-card strong,
.follow-alert-card span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.follow-alert-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.follow-alert-time {
  font-weight: 900;
  white-space: nowrap;
}
.content {
  width: 100%;
  max-width: 100%;
  padding: 24px;
  overflow-x: hidden;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card {
  min-height: 135px;
  padding: 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 16px 34px rgba(23, 32, 51, .10);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.stat-card:after {
  content: "";
  position: absolute;
  right: -32px;
  top: -32px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-2) 18%, transparent);
}
.stat-card h3 { margin: 0; color: var(--muted); font-size: 14px; }
.stat-card .num { font-size: 40px; line-height: 1; margin-top: 18px; font-weight: 950; }
.stat-card p { margin: 12px 0 0; }
.stat-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--brand-2) 40%, var(--line));
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title h2 { margin: 0; font-size: 28px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 14px 30px rgba(23, 32, 51, .07);
  margin-bottom: 18px;
  max-width: 100%;
  overflow-x: auto;
}
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.staff-grid {
  align-items: start;
}
.staff-grid .panel {
  height: 100%;
}
.staff-grid .actions {
  align-items: center;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}
.toolbar .field { min-width: 190px; }
.wide-search {
  width: min(520px, 100%);
  min-width: min(360px, 100%);
}
.records-panel {
  margin-top: 18px;
}
.records-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
}
.records-head h3 { margin: 0; }
.attendance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.attendance-summary > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.attendance-calendar {
  display: grid;
  gap: 14px;
}
.attendance-calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.attendance-calendar-head strong {
  font-size: 20px;
}
.attendance-calendar-head button:first-child .ui-icon {
  transform: rotate(180deg);
}
.attendance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.attendance-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.attendance-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.attendance-legend .present { background: #16a34a; }
.attendance-legend .absent { background: #dc2626; }
.attendance-legend .empty-day { background: #cbd5e1; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.calendar-weekday {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.calendar-day {
  min-height: 72px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e2e8f0;
  color: #334155;
}
.calendar-day strong {
  font-size: 18px;
}
.calendar-day span {
  font-size: 11px;
  font-weight: 900;
}
.calendar-day.present {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}
.calendar-day.absent {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}
.calendar-day.not-marked {
  background: #e2e8f0;
  color: #475569;
}
.calendar-day.blank {
  visibility: hidden;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  overflow: hidden;
}
th, td {
  padding: 13px 11px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr {
  transition: background .16s ease, transform .16s ease;
}
tbody tr:hover {
  background: color-mix(in srgb, var(--brand-2) 7%, transparent);
}
th { color: var(--muted); font-size: 13px; }
td.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.cell-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 900;
}
.ui-icon {
  width: 20px;
  height: 20px;
  display: block;
}
.nav-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}
.nav-icon .ui-icon {
  width: 21px;
  height: 21px;
}
.fab .ui-icon {
  width: 28px;
  height: 28px;
}
.stat-popup {
  display: grid;
  gap: 6px;
  padding: 18px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.stat-popup .num {
  font-size: 44px;
  font-weight: 950;
}
.payment-preview {
  display: grid;
  gap: 16px;
}
.payment-student {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 10%, transparent), var(--surface-2));
}
.payment-student .small {
  flex-basis: 100%;
}
.payment-student strong {
  font-size: 24px;
}
.payment-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.payment-cards article {
  display: grid;
  gap: 8px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.payment-cards span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.payment-cards strong {
  font-size: 22px;
}
.payment-cards .highlight {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
  background: color-mix(in srgb, var(--brand) 11%, var(--surface));
}
.payment-cards .balance {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--brand-2) 42%, var(--line));
  background: color-mix(in srgb, var(--brand-2) 10%, var(--surface));
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.user-card {
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(23, 32, 51, .07);
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: color-mix(in srgb, var(--brand-2) 12%, var(--surface));
  color: var(--brand-2);
}
.badge.warn { color: #b45309; background: #fef3c7; }
.badge.good { color: #15803d; background: #dcfce7; }
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.fab-stack {
  position: fixed;
  right: 26px;
  bottom: 26px;
  display: flex;
  gap: 12px;
  z-index: 8;
}
.fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  color: white;
  background: var(--brand);
  box-shadow: 0 18px 40px rgba(15, 118, 110, .32);
}
.fab:hover {
  transform: translateY(-4px) scale(1.04);
}
.fab.calendar { background: var(--brand-2); }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 13, 23, .54);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}
.modal {
  width: min(780px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 22px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 22px; }
.print-subtitle { margin: -4px 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions.full { grid-column: 1 / -1; }
.toast {
  position: fixed;
  right: 22px;
  top: 20px;
  z-index: 50;
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  background: var(--text);
  color: var(--surface);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}
.hide { display: none !important; }
@media (max-width: 1020px) {
  .app-shell { display: block; }
  .main { margin-left: 0; }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .logo { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .auth-card { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .content, .topbar { padding: 14px; }
  .topbar {
    align-items: center;
    flex-direction: row;
  }
  .top-actions { display: none; }
  .menu-toggle {
    display: inline-grid;
    flex: 0 0 auto;
  }
  .top-title {
    max-width: calc(100vw - 92px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dashboard-hero { align-items: stretch; flex-direction: column; padding: 18px; }
  .dashboard-hero strong { font-size: 26px; }
  .hero-clock { min-width: 0; width: 100%; }
  .form-grid, .stats { grid-template-columns: 1fr; }
  .stats { gap: 12px; }
  .stat-card { min-height: 112px; padding: 18px; }
  .stat-card .num { font-size: 34px; }
  .export-grid { grid-template-columns: 1fr; }
  .toolbar .field,
  .toolbar button,
  .modal-actions button {
    width: 100%;
  }
  .inline-tabs {
    width: 100%;
  }
  .inline-tabs .chip {
    flex: 1 1 auto;
  }
  .auth-brand, .auth-panel { padding: 24px; }
  .auth-brand h1 { font-size: 32px; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 320px);
    height: 100dvh;
    z-index: 31;
    display: block;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 18px 0 46px rgba(8, 13, 23, .22);
  }
  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }
  .sidebar-head .logo {
    flex: 1;
    margin: 0;
  }
  .menu-close {
    display: inline-grid;
    flex: 0 0 auto;
  }
  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(8, 13, 23, .48);
  }
  body.mobile-menu-open .mobile-menu-backdrop {
    display: block;
  }
  .mobile-menu-tools {
    display: grid;
    gap: 10px;
    padding-top: 14px;
    margin-top: 12px;
    border-top: 1px solid var(--line);
  }
  .mobile-menu-tools select,
  .mobile-menu-tools button {
    width: 100%;
  }
  .nav-btn {
    margin-bottom: 8px;
  }
  .class-assign-panel {
    align-items: stretch;
    flex-direction: column;
  }
  .class-assign-actions {
    display: flex;
  }
  .class-assign-actions button {
    width: 100%;
  }
  .follow-alert-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .follow-alert-card .actions {
    justify-content: flex-end;
  }
  .calendar-grid {
    gap: 5px;
  }
  .calendar-day {
    min-height: 58px;
    padding: 6px 3px;
  }
  .calendar-day strong {
    font-size: 15px;
  }
  .calendar-day span {
    font-size: 9px;
  }
  .payment-cards {
    grid-template-columns: 1fr;
  }
  .payment-student strong {
    font-size: 21px;
  }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .records-head { align-items: stretch; flex-direction: column; }
  .fab-stack { right: 15px; bottom: 15px; }
}

@media print {
  body {
    background: #fff;
    color: #111;
  }
  .sidebar,
  .topbar,
  .fab-stack,
  .toolbar,
  .modal-head .icon-btn,
  .modal-actions,
  button {
    display: none !important;
  }
  .app-shell {
    display: block;
  }
  body.print-transactions .app-shell,
  body.print-transactions .toast {
    display: none !important;
  }
  .content,
  .modal {
    padding: 0;
    box-shadow: none;
    border: 0;
    width: 100%;
    max-height: none;
    overflow: visible;
  }
  .modal-backdrop {
    position: static;
    display: block;
    background: #fff;
    padding: 0;
  }
  .panel,
  .stat-card {
    box-shadow: none;
    border: 1px solid #bbb;
    break-inside: avoid;
  }
  table {
    font-size: 12px;
  }
  th,
  td {
    border: 1px solid #bbb;
  }
}
