/* ============================================================
   SCHOLA — School Management System
   Design language: Editorial / Refined / Warm
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..900;1,9..144,300..900&family=Inter+Tight:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Palette — warm editorial */
  --paper: #f5f1ea;
  --paper-deep: #ebe5d9;
  --ink: #1a1d24;
  --ink-soft: #3a3f4a;
  --ink-muted: #6b7280;
  --rule: #d9d2c2;
  --rule-soft: #e6dfce;
  --terracotta: #c0532f;
  --terracotta-deep: #9b3f1f;
  --sage: #5e7c5e;
  --gold: #b08043;
  --cream: #faf7f0;
  --white: #ffffff;
  --danger: #a83232;
  --success: #4a7c4a;
  --warning: #c98a2b;

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', Menlo, monospace;

  /* Spacing */
  --gutter: 1.5rem;
  --radius: 4px;
  --radius-lg: 8px;

  --shadow-sm: 0 1px 2px rgba(26,29,36,0.04), 0 1px 3px rgba(26,29,36,0.06);
  --shadow-md: 0 4px 12px rgba(26,29,36,0.06), 0 2px 4px rgba(26,29,36,0.04);
  --shadow-lg: 0 12px 32px rgba(26,29,36,0.10), 0 4px 8px rgba(26,29,36,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ============================================================
   LAYOUT — sidebar + main
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: var(--cream);
  padding: 2rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #000;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a2e36; border-radius: 3px; }

.brand {
  padding: 0 1.75rem 1.75rem;
  border-bottom: 1px solid #2a2e36;
  margin-bottom: 1.5rem;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: -0.02em;
  font-style: italic;
  color: var(--paper);
  line-height: 1;
}

.brand-mark::after {
  content: '.';
  color: var(--terracotta);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 0.5rem;
}

.nav-group {
  padding: 0 1rem;
  margin-bottom: 1.25rem;
}

.nav-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6b7280;
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  color: #b8bcc7;
  font-size: 0.875rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: #22262e;
  color: var(--paper);
}

.nav-item.active {
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}

.nav-item.active .nav-icon { color: var(--terracotta); }

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: inherit;
}

/* MAIN */

.main {
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2.5rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}

.crumb {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  width: 280px;
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  font-size: 0.85rem;
  color: var(--ink);
}

.search-box svg { color: var(--ink-muted); flex-shrink: 0; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 100px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--terracotta);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.75rem;
  font-family: var(--font-display);
}

.user-chip-name {
  font-size: 0.8rem;
  font-weight: 500;
}

/* CONTENT */

.content {
  padding: 2.5rem;
  flex: 1;
  max-width: 1500px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.75rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-title em {
  font-style: italic;
  color: var(--terracotta);
  font-weight: 300;
}

.page-subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 0.5rem;
}

.page-actions { display: flex; gap: 0.6rem; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: #000; }

.btn-accent {
  background: var(--terracotta);
  color: var(--paper);
}
.btn-accent:hover { background: var(--terracotta-deep); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
.btn-ghost:hover { background: var(--cream); border-color: var(--ink); }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }

.btn-icon {
  padding: 0.5rem;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule-soft);
}

.card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.card-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.4rem;
}

/* Stats Grid (Dashboard) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--terracotta);
}

.stat:nth-child(2)::before { background: var(--sage); }
.stat:nth-child(3)::before { background: var(--gold); }
.stat:nth-child(4)::before { background: var(--ink); }

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.03em;
}

.stat-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-meta .up { color: var(--success); font-weight: 600; }
.stat-meta .down { color: var(--danger); font-weight: 600; }

/* Two-column grid for dashboard */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* Tables */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule-soft);
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-input {
  padding: 0.45rem 0.75rem;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 0.82rem;
  outline: none;
  min-width: 180px;
}

.filter-input:focus { border-color: var(--ink); }

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--cream);
  border-bottom: 1px solid var(--rule);
}

th {
  text-align: left;
  padding: 0.85rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}

td {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.88rem;
  color: var(--ink-soft);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--cream); }

.cell-primary { color: var(--ink); font-weight: 500; }
.cell-mono { font-family: var(--font-mono); font-size: 0.8rem; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 100px;
  font-weight: 500;
}

.badge-active { background: rgba(74,124,74,0.12); color: var(--success); }
.badge-pending { background: rgba(201,138,43,0.12); color: var(--warning); }
.badge-inactive { background: rgba(168,50,50,0.10); color: var(--danger); }
.badge-info { background: rgba(26,29,36,0.06); color: var(--ink-soft); }
.badge-accent { background: rgba(192,83,47,0.10); color: var(--terracotta); }

/* Action buttons in table */
.row-actions { display: flex; gap: 0.4rem; }
.row-action {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border-radius: var(--radius);
  color: var(--ink-muted);
  transition: all 0.15s;
}
.row-action:hover { background: var(--cream); color: var(--ink); }
.row-action.danger:hover { color: var(--danger); }

/* Forms / Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,29,36,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--rule);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--rule);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.modal-body { padding: 2rem; }
.modal-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.form-row { margin-bottom: 1.25rem; }
.form-row.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--ink);
}

textarea { resize: vertical; min-height: 80px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--terracotta);
  font-weight: 500;
}
.tab:hover:not(.active) { color: var(--ink); }

/* Empty state */
.empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--ink-muted);
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  font-style: italic;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.85rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transform: translateY(120%);
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toast.show { transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Activity feed */
.activity-item {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--terracotta);
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.activity-text { font-size: 0.85rem; flex: 1; }
.activity-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

/* Login page */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-art {
  background: var(--ink);
  color: var(--paper);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-art::before {
  content: '';
  position: absolute;
  top: -200px; right: -200px;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--terracotta) 0%, transparent 60%);
  opacity: 0.4;
}

.login-art-content { position: relative; z-index: 1; }

.login-quote {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-style: italic;
  max-width: 480px;
}

.login-quote em { color: var(--terracotta); font-style: normal; font-weight: 500; }

.login-attr {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(245,241,234,0.5);
  margin-top: 1.5rem;
}

.login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: var(--paper);
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 2.5rem;
}

/* Calendar */
.calendar {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.calendar-month {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar-day-name {
  padding: 0.6rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--cream);
}

.calendar-day {
  aspect-ratio: 1.2;
  padding: 0.5rem;
  border-bottom: 1px solid var(--rule-soft);
  border-right: 1px solid var(--rule-soft);
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.calendar-day:hover { background: var(--cream); }
.calendar-day.today {
  font-weight: 700;
  color: var(--terracotta);
}
.calendar-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 6px; left: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--terracotta);
}

.calendar-day.muted { color: var(--ink-muted); opacity: 0.4; }

/* Detail / profile views */
.detail-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

.detail-key {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
}

.detail-value { font-size: 0.95rem; margin-bottom: 1rem; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content > * { animation: fadeIn 0.4s ease both; }
.content > *:nth-child(2) { animation-delay: 0.05s; }
.content > *:nth-child(3) { animation-delay: 0.1s; }

/* Loading */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--rule);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MOBILE NAVIGATION — hamburger + off-canvas drawer
   Hidden on desktop (>768px); rendered/visible on mobile only.
   ============================================================ */

.menu-toggle {
  display: none;                 /* hidden by default; shown in mobile media query */
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
  flex-shrink: 0;
}

.menu-toggle:hover { background: var(--paper-2); }
.menu-toggle:active { transform: scale(0.96); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 36, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  animation: fadeIn 0.2s ease;
}

.sidebar-backdrop.active { display: block; }

.brand-close {
  display: none;                 /* shown only inside mobile drawer */
  background: none;
  border: none;
  color: rgba(245, 241, 234, 0.6);
  cursor: pointer;
  padding: 0.5rem;
  margin-left: auto;
}
.brand-close:hover { color: var(--paper); }

/* Lock body scroll when the drawer is open. */
body.sidebar-open { overflow: hidden; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   1280  — slightly tighter desktop
   1024  — tablet landscape: narrower sidebar, simpler grids
   768   — mobile: off-canvas sidebar, hamburger, stacked layouts
   480   — small phones: maximum compaction
   ============================================================ */

@media (max-width: 1280px) {
  .content { padding: 2rem; }
  .topbar  { padding: 1rem 2rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .app { grid-template-columns: 220px 1fr; }
  .sidebar { padding: 1.5rem 0; }
  .brand { padding: 0 1.25rem 1.25rem; }
  .nav-group { padding: 0 0.75rem; }
  .nav-item { padding: 0.55rem 0.75rem; font-size: 0.85rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 2.25rem; }
  .search-box { min-width: 0; max-width: 200px; }
  .modal { max-width: 90vw; }
}

/* -------- MOBILE (≤768px) -------- */
@media (max-width: 768px) {

  /* Single column; sidebar becomes a drawer. */
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100dvh;              /* dvh handles mobile browser chrome correctly */
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .brand-close { display: inline-flex; align-items: center; }
  .brand { display: flex; align-items: flex-start; }

  /* Topbar: show hamburger, hide search + user name. */
  .menu-toggle { display: inline-flex; }
  .topbar {
    padding: 0.875rem 1rem;
    gap: 0.75rem;
  }
  .crumb { font-size: 0.65rem; flex: 1; min-width: 0;
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { gap: 0.5rem; }
  .search-box { display: none; }
  .user-chip-name { display: none; }
  .user-chip { padding: 0; background: transparent; border: none; }

  /* Content: trim padding hard. */
  .content { padding: 1.25rem 1rem; }

  /* Page header: stack title and actions. */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .page-title { font-size: 1.85rem; line-height: 1.1; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }

  /* Grids collapse to single column. */
  .stat-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .stat-card { padding: 1.25rem; }
  .stat-value { font-size: 2rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Cards: tighter padding. */
  .card { padding: 1.25rem; }
  .card-body { padding: 1.25rem; }
  .card-header { padding: 1rem 1.25rem; }

  /* Tables: scroll horizontally on overflow rather than crushing columns.
     Wrap any <table> in <div class="table-wrap"> in your markup. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
  th, td { padding: 0.75rem 0.85rem; font-size: 0.85rem; }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .toolbar-filters {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .toolbar-filters > * { flex: 1; min-width: 140px; }

  /* Modal: full-screen sheet on mobile. */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 95dvh;
    border-radius: 16px 16px 0 0;
    animation: slideUp 0.25s ease;
  }
  .modal-header { padding: 1.25rem 1.5rem; }
  .modal-body { padding: 1.5rem; }
  .modal-footer { padding: 1rem 1.5rem; flex-direction: column-reverse; gap: 0.5rem; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Forms: full-width inputs, single column. */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-input, .form-select, .form-textarea { font-size: 16px; }  /* prevents iOS zoom */

  /* Login: stack the editorial split. */
  .login-shell { grid-template-columns: 1fr; }
  .login-art {
    display: flex;
    padding: 2rem 1.5rem;
    min-height: 200px;
  }
  .login-art-content:nth-child(2) { display: none; }   /* hide the long quote on phones */
  .login-form { padding: 2rem 1.5rem; }
  .login-title { font-size: 1.85rem; }
  .login-card { max-width: 100%; }

  /* Tabs: scroll horizontally if too many. */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* Calendar: shrink cells and font. */
  .calendar-grid { gap: 1px; }
  .calendar-day {
    min-height: 64px;
    padding: 0.4rem;
    font-size: 0.8rem;
  }
  .calendar-day-num { font-size: 0.85rem; }
  .calendar-event {
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
  }

  /* Timetable: horizontal scroll (it's a wide grid by nature). */
  .timetable-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .timetable { min-width: 720px; }

  /* Activity feed and similar lists. */
  .activity-item { padding: 0.85rem 1rem; font-size: 0.85rem; }
  .activity-item-time { font-size: 0.7rem; }

  /* Toast: anchor to bottom on mobile, full width with safe-area. */
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    max-width: none;
  }

  /* Badge sizes nudge down. */
  .badge { font-size: 0.65rem; padding: 0.2rem 0.55rem; }

  /* Eyebrow/labels stay readable. */
  .eyebrow { font-size: 0.65rem; }

  /* Hide heavy decorative pieces in cards. */
  .card-decor, .stat-decor { display: none; }
}

/* -------- SMALL PHONES (≤480px) -------- */
@media (max-width: 480px) {
  .content { padding: 1rem 0.75rem; }
  .topbar  { padding: 0.75rem; }
  .crumb   { font-size: 0.6rem; }

  .page-title { font-size: 1.6rem; }

  .card, .stat-card { padding: 1rem; }
  .card-body { padding: 1rem; }
  .stat-value { font-size: 1.75rem; }

  .modal-body { padding: 1rem; }
  .modal-header { padding: 1rem; }
  .modal-footer { padding: 1rem; }

  th, td { padding: 0.6rem 0.7rem; font-size: 0.8rem; }

  .calendar-day { min-height: 52px; padding: 0.3rem; font-size: 0.75rem; }
  .calendar-day-num { font-size: 0.75rem; }

  /* On very small screens, keep the user avatar but drop the bell badge if any. */
  .btn { padding: 0.55rem 0.85rem; font-size: 0.85rem; }
  .btn-primary { padding: 0.6rem 0.9rem; }
}

/* -------- TOUCH-FIRST AFFORDANCES -------- */
/* Anything pointer-coarse (most touchscreens) gets larger tap targets. */
@media (pointer: coarse) {
  .btn, .btn-icon, .nav-item, .tab, .menu-toggle {
    min-height: 44px;            /* WCAG 2.5.5 target size */
  }
  /* Disable hover-only flourishes that get stuck after a tap. */
  .card:hover, .stat-card:hover, .nav-item:hover { transform: none; }
}

/* -------- REDUCED MOTION -------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* slideUp keyframe for the mobile bottom-sheet modal. */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Utility */
.text-muted { color: var(--ink-muted); }
.text-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 2rem; }
.mb-md { margin-bottom: 1rem; }
.full-w { width: 100%; }
