/* ============================================================
   Driving School — design system
   Vanilla CSS, no build step. Tokens → base → components.
   Class names are preserved from the original stylesheet so
   existing views inherit the new look without markup changes.
   ============================================================ */

/* ---- Inter (self-hosted, variable; latin + cyrillic) ---- */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---- Design tokens ---- */
:root {
  /* surfaces */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --surface-tint: #f5f8ff;

  /* ink */
  --text: #172033;
  --text-muted: #6b7280;
  --text-faint: #9aa3b2;

  /* lines */
  --border: #e6e8ee;
  --border-strong: #d7dbe3;

  /* brand */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8f0ff;

  /* semantic */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #15803d;
  --warning-bg: #fef3c7;
  --warning-text: #b45309;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #b42318;

  /* sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-elev: #131c30;
  --sidebar-text: #cbd5e1;
  --sidebar-faint: #7c889c;

  /* shape */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* depth */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(15, 23, 42, 0.05);
  --shadow-pop: 0 12px 30px rgba(15, 23, 42, 0.12);
  --ring: 0 0 0 3px var(--primary-soft);

  --font: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* ---- Reset / base ---- */
* { box-sizing: border-box; }

/* never scroll horizontally (mobile-first invariant); `clip` keeps position:sticky working, unlike `hidden` */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 1.25rem; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 0 0 1rem; }
h3 { font-size: 0.95rem; font-weight: 650; margin: 1.25rem 0 0.5rem; }

/* ============================================================
   App shell (back-office): sidebar + main
   ============================================================ */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.app-main { min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0.6rem 0.9rem; }
.sidebar-logo {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 1.05rem;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}
.sidebar-brand-text strong { display: block; font-size: 1rem; line-height: 1.2; color: #fff; }
.sidebar-brand-text span { font-size: 0.72rem; color: var(--sidebar-faint); }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-section {
  color: var(--sidebar-faint); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 0.85rem 0.7rem 0.3rem;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.7rem; border-radius: 11px;
  color: var(--sidebar-text); text-decoration: none; font-size: 0.9rem; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sidebar-ico { width: 18px; height: 18px; flex: none; opacity: 0.85; }

.sidebar-foot {
  margin-top: auto; padding-top: 0.85rem; border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; gap: 0.6rem;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, 0.12); display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.85rem;
}
.sidebar-user { min-width: 0; }
.sidebar-user .user-name { display: block; color: #fff; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .btn-ghost { color: var(--sidebar-faint); padding: 0; font-size: 0.78rem; font-weight: 600; }
.sidebar-user .btn-ghost:hover { color: #fff; background: transparent; }

/* slim top bar — only shown on mobile (drawer trigger) */
.app-topbar { display: none; }
.app-content { padding: 1.75rem 1.75rem 3rem; max-width: 1280px; width: 100%; }

.nav-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
  cursor: pointer; color: var(--text);
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after { position: absolute; top: 6px; }
.nav-backdrop { display: none; }

/* ============================================================
   Portal / auth top bar (used by _PortalLayout & login)
   ============================================================ */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--sidebar-bg); color: #fff; padding: 0 1.25rem; height: 58px;
}
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; min-width: 0; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 0.5rem; }
.nav a { color: var(--sidebar-text); text-decoration: none; padding: 0.35rem 0.6rem; border-radius: 10px; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.user { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: 0.75rem; }
.user-name { color: var(--sidebar-text); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.inline-form { display: inline; }

.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.25rem; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.55rem 1.05rem; border: 1px solid transparent; border-radius: 12px;
  font: inherit; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none;
  white-space: nowrap; transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.04s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-soft { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-soft:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--primary); border-color: transparent; padding-left: 0.6rem; padding-right: 0.6rem; }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-text); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; border-radius: 10px; }
.btn-ghost.btn-danger-text { color: var(--danger-text); }
.btn-ghost.btn-danger-text:hover { background: var(--danger-bg); color: var(--danger-text); }
.topbar .btn-ghost { color: var(--sidebar-text); }
.topbar .btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* ============================================================
   Cards & panels
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); max-width: 100%;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.form-card { max-width: 760px; }

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-header h2 { margin: 0; }

/* ============================================================
   Dashboard stats
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.1rem; }
.stat { display: flex; flex-direction: column; gap: 0.35rem; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.stat-hint { color: var(--text-muted); font-size: 0.78rem; }
a.stat-hint { color: var(--primary); font-weight: 600; }
a.stat-hint:hover { text-decoration: underline; }
.stat-wide { grid-column: 1 / -1; }
.status-breakdown { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.status-breakdown li { display: flex; align-items: center; gap: 0.4rem; }

/* ============================================================
   Forms
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.85rem 1.25rem; margin-bottom: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
.field label, .label { font-weight: 600; font-size: 0.85rem; color: var(--text); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="time"], input[type="date"], input[type="search"],
select, textarea {
  padding: 0.55rem 0.75rem; border: 1px solid var(--border-strong); border-radius: 11px;
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5 6 8l3-3.5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.7rem center; padding-right: 2rem; }
textarea { resize: vertical; min-height: 5rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.92rem; margin: 0.35rem 0; font-weight: 500; }
.check input { width: auto; }
.check-row { display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1.25rem; flex-wrap: wrap; }
.hint { color: var(--text-muted); font-size: 0.8rem; }

/* compact inline forms (student-360 add-charge / record-payment etc.) */
.mini-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px dashed var(--border); }
.mini-form .field { margin: 0; }
.mini-form input, .mini-form select { min-width: 7rem; }

/* ============================================================
   Auth (login)
   ============================================================ */
.auth-card {
  max-width: 400px; margin: 9vh auto 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.25rem; box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; font-size: 1.35rem; margin-bottom: 0.15rem; }
.auth-card h2 { text-align: center; color: var(--text-muted); font-weight: 400; font-size: 0.95rem; margin-bottom: 1.5rem; }

/* ============================================================
   Feedback
   ============================================================ */
.validation-summary { color: var(--danger-text); margin-bottom: 0.85rem; }
.validation-summary ul { margin: 0; padding-left: 1.1rem; }
.validation-summary:empty { display: none; }
.field-error { color: var(--danger-text); font-size: 0.8rem; }
.alert { padding: 0.8rem 1.05rem; border-radius: 12px; margin-bottom: 1.25rem; border: 1px solid transparent; font-weight: 500; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #b7e4c5; }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border-color: #f5c4c0; }
.empty-state { text-align: center; margin-top: 10vh; color: var(--text-muted); }

/* ============================================================
   List pages / grids
   ============================================================ */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.toolbar { display: flex; gap: 0.6rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type="text"], .toolbar input[type="search"] { min-width: 240px; width: auto; }
.toolbar select { width: auto; }
.toolbar label { display: inline-flex; gap: 0.35rem; align-items: center; color: var(--muted); font-size: 0.9rem; }
.toolbar-spacer { flex: 1 1 auto; }

/* Reports landing (Phase 6) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.report-card { display: flex; align-items: center; min-height: 84px; text-decoration: none; transition: box-shadow .15s ease, transform .15s ease; }
.report-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.report-card h2 { margin: 0; font-size: 1.05rem; }

/* Audit viewer (Phase 6) */
.audit-id { font-size: 0.8rem; color: var(--muted); }
.audit-changes summary { cursor: pointer; color: var(--accent); }
.audit-changes table { margin-top: 0.4rem; font-size: 0.85rem; }
.audit-changes th { text-align: left; padding-right: 0.6rem; font-weight: 600; white-space: nowrap; }
.audit-changes td { padding-right: 0.6rem; word-break: break-word; }

table.grid {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
}
table.grid th, table.grid td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); }
table.grid th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: var(--surface-tint); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions a { color: var(--primary); text-decoration: none; font-weight: 600; }
.row-actions a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }

/* cards holding a grid: let the table sit flush, and scroll (not bleed) when wider than the card */
.card table.grid { box-shadow: none; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card table.grid thead, .card table.grid tbody { width: 100%; }

.pager { display: flex; align-items: center; gap: 0.85rem; margin-top: 1.1rem; }
.pager-info { color: var(--text-muted); font-size: 0.85rem; }

/* ============================================================
   Badges / status pills
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; padding: 0.2rem 0.65rem; border-radius: var(--radius-pill);
  font-size: 0.76rem; font-weight: 700; background: #eef1f6; color: var(--text); line-height: 1.4; white-space: nowrap;
}
.badge-active, .badge-paid, .badge-passed, .badge-completed { background: var(--success-bg); color: var(--success-text); }
.badge-inactive, .badge-unpaid, .badge-pending, .badge-cancelled { background: #eef1f6; color: var(--text-muted); }
.badge-maintenance, .badge-partiallypaid { background: var(--warning-bg); color: var(--warning-text); }
.badge-overdue, .badge-failed, .badge-noshow { background: var(--danger-bg); color: var(--danger-text); }
.badge-scheduled { background: var(--primary-soft); color: var(--primary-dark); }

/* ============================================================
   Detail pages
   ============================================================ */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1.25rem; align-items: start; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.25rem; margin: 0; }
dl.kv dt { color: var(--text-muted); font-size: 0.85rem; }
dl.kv dd { margin: 0; font-weight: 500; }

.balance-summary { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 0.85rem; align-items: center; }
.balance-summary .amount { font-weight: 700; }
.balance-summary .due { color: var(--danger-text); }

/* invitation panel */
.link-row { display: flex; gap: 0.5rem; }
.link-row input { flex: 1; font-size: 0.85rem; }
.qr { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 0.85rem; background: #fff; padding: 6px; }

/* student-360 profile: compact aside (details/progress/invitation) + wide data column (finances/exams).
   Replaces auto-fit grid here so tall cards stack tightly instead of leaving large inter-row gaps. */
.profile-grid { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.profile-col { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
@media (max-width: 860px) { .profile-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Modal / confirm dialog
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 1.25rem;
  background: rgba(15, 23, 42, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow-pop); width: 100%; max-width: 26rem;
}
.modal-title { font-size: 1.15rem; margin: 0 0 0.5rem; }
.modal-message { margin: 0 0 1.25rem; color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
body.modal-open { overflow: hidden; }

/* ============================================================
   Calendar
   ============================================================ */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.cal-nav { display: flex; align-items: center; gap: 0.25rem; }
.cal-current { margin-left: 0.5rem; text-transform: capitalize; font-weight: 650; }
.cal-modes { display: flex; gap: 0.25rem; }
.cal-mode-active { background: var(--primary-soft); color: var(--primary-dark); border-color: transparent; }
.cal-filters { display: flex; gap: 0.5rem; margin-left: auto; }

.cal-day { display: flex; flex-direction: column; gap: 0.6rem; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.6rem; align-items: start; }
.cal-week-col { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.cal-week-head { display: block; text-align: center; font-weight: 650; font-size: 0.8rem; text-transform: capitalize; text-decoration: none; color: var(--text); padding: 0.45rem; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.cal-week-head:hover { background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; }
.cal-week-empty { text-align: center; color: var(--text-faint); margin: 0.25rem 0; font-size: 0.85rem; }

.cal-item { display: flex; gap: 0.65rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: 12px; padding: 0.6rem 0.75rem; box-shadow: var(--shadow-sm); }
.cal-practical { border-left-color: var(--primary); }
.cal-theory { border-left-color: #8a4fff; }
.cal-cancelled { opacity: 0.55; text-decoration: line-through; box-shadow: none; }
.cal-time { font-weight: 700; font-size: 0.85rem; white-space: nowrap; color: var(--primary-dark); }
.cal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.cal-title { font-weight: 600; }
.cal-meta { color: var(--text-muted); font-size: 0.82rem; }
.cal-actions a { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 0.82rem; }
.cal-week .cal-item { flex-direction: column; gap: 0.2rem; border-left-width: 3px; }

/* slot picker */
.slot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.6rem; margin: 0.85rem 0; }
.slot { display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--border-strong); border-radius: 12px; padding: 0.6rem 0.75rem; cursor: pointer; background: var(--surface); transition: border-color 0.12s, background 0.12s; }
.slot:hover { background: var(--surface-tint); border-color: var(--primary); }
.slot:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--ring); }
.slot-time { font-weight: 650; }
.slot-veh { color: var(--text-muted); font-size: 0.82rem; margin-left: auto; }
.override-card { margin-top: 1.25rem; }
.override-card summary { font-weight: 600; cursor: pointer; }

/* ============================================================
   Student portal (mobile-first)
   ============================================================ */
.portal-nav { display: flex; gap: 0.4rem; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.6rem 1rem; position: sticky; top: 0; z-index: 5; box-shadow: var(--shadow-sm); }
.portal-nav a { white-space: nowrap; text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: 0.9rem; padding: 0.45rem 0.85rem; border-radius: var(--radius-pill); }
.portal-nav a:hover { background: var(--surface-tint); color: var(--text); text-decoration: none; }
.portal-nav a.active { background: var(--primary); color: #fff; }
.badge-count { display: inline-block; min-width: 1.15rem; text-align: center; background: var(--danger); color: #fff; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 700; padding: 0 0.35rem; margin-left: 0.3rem; }
.portal-main { max-width: 760px; display: flex; flex-direction: column; gap: 1.1rem; }
/* flex items default to min-width:auto and refuse to shrink below content — let portal cards fit narrow phones */
.portal-main > * { min-width: 0; }
.portal-activate { max-width: 420px; margin: 7vh auto 0; text-align: center; }
.portal-activate h1 { font-size: 1.35rem; }
.portal-stack { display: flex; flex-direction: column; gap: 0.65rem; }
.portal-welcome { font-size: 1.2rem; font-weight: 650; margin: 0 0 0.85rem; }
.portal-lesson { display: flex; justify-content: space-between; align-items: center; gap: 0.85rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 14px; padding: 0.75rem 0.9rem; box-shadow: var(--shadow-sm); }
.portal-lesson-time { font-weight: 700; text-transform: capitalize; }
.portal-lesson-meta { color: var(--text-muted); font-size: 0.85rem; }

/* completion bar */
.progress-bar { height: 10px; background: #e9edf4; border-radius: var(--radius-pill); overflow: hidden; margin: 0.6rem 0 0.3rem; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #4f86ff); border-radius: inherit; }

/* notification feed */
.notif-item { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 14px; padding: 0.7rem 0.9rem; box-shadow: var(--shadow-sm); }
.notif-item.unread { background: var(--surface-tint); }
.notif-item.cancelled-kind { border-left-color: var(--danger); }
.notif-time { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.15rem; }

/* instructor PWA */
.portal-lesson { flex-wrap: wrap; }
.portal-lesson-main { min-width: 0; flex: 1 1 55%; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cred { margin-top: 0.35rem; font-size: 0.9rem; }
.cred code { background: var(--surface-2); padding: 0.1rem 0.45rem; border-radius: 6px; }
.app-banner { display: none; text-align: center; padding: 0.55rem 0.9rem; font-size: 0.9rem; font-weight: 600; }
.app-offline-banner { background: var(--danger-bg); color: var(--danger-text); }
.app-install-banner { background: var(--primary-soft); color: var(--primary-dark); }
body.app-offline .app-offline-banner { display: block; }
body.app-offline [data-online-only] { opacity: 0.5; pointer-events: none; }
body.app-offline [data-online-only] button { cursor: not-allowed; }

/* ============================================================
   Responsive — collapse sidebar into an off-canvas drawer
   ============================================================ */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; height: 100vh;
    transform: translateX(-100%); transition: transform 0.22s ease; z-index: 60; box-shadow: var(--shadow-pop);
  }
  .app-shell.nav-open .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity 0.22s; }
  .app-shell.nav-open .nav-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .app-topbar {
    display: flex; align-items: center; gap: 0.85rem; height: 58px; padding: 0 1rem;
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  }
  .app-topbar .topbar-brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
  .app-content { padding: 1.25rem 1.1rem 3rem; }
}

@media (max-width: 640px) {
  .app-content { padding: 1rem 0.9rem 3rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  h1 { font-size: 1.4rem; }
  .stat-value { font-size: 1.75rem; }
}
