/* ============================================================================
   School Focus — Admin dashboard styles
   Reuses the landing-page design system (blue/purple brand, dark/light mode).
   ========================================================================== */

:root {
  color-scheme: dark;  /* render native controls (select popup, scrollbars, date pickers) dark */
  --blue:        #3A66D6;
  --purple:      #7B53D6;
  --indigo:      #1C21B4;
  --danger:      #E5484D;
  --success:     #30A46C;
  --warning:     #F5A623;
  --warning-bg:  rgba(245,166,35,0.15);

  /* dark mode defaults */
  --bg:          #161A33;
  --bg-2:        #1a1f3c;
  --surface:     rgba(255,255,255,0.05);
  --surface-2:   rgba(255,255,255,0.08);
  --border:      rgba(255,255,255,0.1);
  --border-2:    rgba(255,255,255,0.18);
  --fg:          #F0F2FF;
  --fg-muted:    rgba(240,242,255,0.6);
  --fg-subtle:   rgba(240,242,255,0.35);
  --nav-bg:      rgba(22,26,51,0.82);
  --card-bg:     rgba(255,255,255,0.05);
  --shadow:      0 10px 30px rgba(0,0,0,0.35);

  --radius:      16px;
  --radius-sm:   10px;
  --radius-lg:   24px;
  --ease:        cubic-bezier(0.16,1,0.3,1);
  --font:        'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg:          #F0F4FF;
  --bg-2:        #E6ECFF;
  --surface:     rgba(58,102,214,0.06);
  --surface-2:   rgba(58,102,214,0.1);
  --border:      rgba(58,102,214,0.13);
  --border-2:    rgba(58,102,214,0.22);
  --fg:          #1A1F3C;
  --fg-muted:    rgba(26,31,60,0.62);
  --fg-subtle:   rgba(26,31,60,0.38);
  --nav-bg:      rgba(240,244,255,0.9);
  --card-bg:     rgba(255,255,255,0.75);
  --shadow:      0 10px 30px rgba(58,102,214,0.12);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
[x-cloak] { display: none !important; }

/* Focus visibility — never remove (a11y) */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font-family: var(--font); font-size: 0.95rem; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: transform .15s var(--ease), background .2s, opacity .2s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2f57c0; }
.btn-ghost { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.85rem; }
.btn-icon { padding: 0; width: 44px; }
.btn-icon.btn-sm { width: 36px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(12px);
}
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.card-sub { color: var(--fg-muted); font-size: 0.9rem; margin-bottom: 18px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--fg-muted); }
.field .req { color: var(--danger); }
.input, .select {
  width: 100%; min-height: 44px; padding: 0 14px;
  font-family: var(--font); font-size: 0.95rem;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  transition: border-color .2s, background .2s;
}
.input:focus, .select:focus { border-color: var(--blue); outline: none; background: var(--surface-2); }
.select option { background: var(--bg-2); color: var(--fg); }
.input::placeholder { color: var(--fg-subtle); }
.field-error { color: var(--danger); font-size: 0.8rem; margin-top: 6px; }
.field-help { color: var(--fg-subtle); font-size: 0.8rem; margin-top: 6px; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; line-height: 1.4;
  border: 1px solid var(--border);
}
.badge-success { background: rgba(48,164,108,0.15); color: var(--success); border-color: rgba(48,164,108,0.3); }
.badge-failed  { background: rgba(229,72,77,0.15); color: var(--danger); border-color: rgba(229,72,77,0.3); }
.badge-partial { background: rgba(245,166,35,0.15); color: var(--warning); border-color: rgba(245,166,35,0.3); }
.badge-muted   { background: var(--surface); color: var(--fg-muted); }
.badge-role    { background: rgba(123,83,214,0.15); color: var(--purple); border-color: rgba(123,83,214,0.3); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th, table.data td { text-align: left; padding: 14px 18px; white-space: nowrap; }
table.data thead th {
  background: var(--surface); color: var(--fg-muted);
  font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface); }
.num { font-variant-numeric: tabular-nums; }

/* ── Layout: sidebar + main ───────────────────────────────────────────────── */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--nav-bg); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  backdrop-filter: blur(16px);
  position: sticky; top: 0; height: 100dvh;
  overflow-y: auto;               /* scroll the menu when it's taller than the screen */
  scrollbar-width: thin;          /* Firefox: slim scrollbar */
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
/* Keep the nav-spacer from forcing the list taller than the viewport (which would hide the
   overflow); it only pushes Sign out down when there's spare room. */
.sidebar .nav-spacer { flex: 1 1 0; min-height: 8px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; font-weight: 800; font-size: 1.15rem; }
.brand-logo { height: 28px; width: auto; flex-shrink: 0; display: block; }
.login-brand .brand-logo { height: 34px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--fg-muted); font-weight: 600; font-size: 0.92rem;
  cursor: pointer; transition: background .18s, color .18s;
}
.nav-item:hover { background: var(--surface); color: var(--fg); }
.nav-item.active { background: var(--surface-2); color: var(--fg); }
.nav-item.active svg { color: var(--blue); }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.nav-spacer { flex: 1; }
/* Sidebar group heading — a labelled rule separating the admin tools from the teaching nav.
   flex-shrink:0 so it can't be squashed when the menu overflows and scrolls. */
.nav-section {
  flex-shrink: 0;
  margin: 14px 0 4px; padding: 12px 12px 0;
  border-top: 1px solid var(--border);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-muted);
}

/* Admin permissions: per-staff toggles */
.perm-check { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; }
.perm-check:disabled { cursor: not-allowed; opacity: 0.55; }

/* Safeguarding: highlight unactioned SOS rows */
.sg-row-sos td { background: rgba(229,72,77,0.08); }
.sg-row-sos td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--nav-bg); backdrop-filter: blur(16px); z-index: 10;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; }
.topbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--fg-muted); font-size: 0.88rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--purple)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; }
.avatar-img { object-fit: cover; background: none; border: 1px solid var(--border); }

/* Persona (portal) switcher in the topbar */
.persona-switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.persona-btn { border: none; background: transparent; color: var(--fg-muted); font-size: 0.82rem; font-weight: 600; padding: 5px 12px; border-radius: calc(var(--radius-sm) - 3px); cursor: pointer; }
.persona-btn.active { background: var(--blue); color: #fff; }

/* Slide-in drawer (Pupil 360) */
.drawer { width: 100%; max-width: 860px; max-height: 90vh; display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: 1.2rem; font-weight: 700; }
.drawer-body { padding: 20px 24px; overflow-y: auto; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--bg-2); }

/* Register: day-of-classes strip (lessons laid out across the screen) */
.reg-dayhead { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.reg-daytitle { font-size: 1.05rem; font-weight: 700; }
.reg-strip { display: flex; flex-wrap: wrap; gap: 12px; }
.reg-card {
  flex: 1 1 168px; min-width: 150px; max-width: 240px;
  display: flex; flex-direction: column; gap: 8px;
  text-align: left; color: inherit; font: inherit; cursor: pointer;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  transition: border-color .15s, background .15s, transform .05s;
}
.reg-card:hover { border-color: var(--border-2); background: var(--surface); }
.reg-card:active { transform: translateY(1px); }
.reg-card-taken { border-left: 3px solid var(--success); }
.reg-card-disabled { opacity: 0.55; cursor: default; }
.reg-card-disabled:hover { border-color: var(--border); background: var(--card-bg); }
.reg-card-disabled:active { transform: none; }
.reg-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reg-period { display: inline-flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; color: var(--fg); }
.reg-class { font-size: 1.05rem; font-weight: 700; }
.reg-meta { display: flex; flex-wrap: wrap; gap: 5px; font-size: 0.8rem; color: var(--fg-subtle); }

/* Register: mark-entry drawer */
.register-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.mark-input { width: 64px; min-height: 40px; padding: 0 8px; text-align: center; text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em; }
kbd { font-family: var(--font); font-size: 0.78rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-warn { background: var(--warning-bg); color: var(--warning); }

/* Parent: My Children */
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; max-width: 1000px; }
.child-card { text-align: left; color: inherit; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 16px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  transition: border-color .15s, background .15s; }
.child-card:hover { border-color: var(--border-2); background: var(--surface); }
.child-head { display: flex; align-items: center; gap: 12px; }
.child-name { font-size: 1.05rem; font-weight: 700; }
.child-stats { display: flex; gap: 10px; }
.child-stat { flex: 1; text-align: center; background: var(--surface); border-radius: var(--radius-sm); padding: 10px 6px; }
.child-stat-num { display: block; font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.child-stat-label { font-size: 0.68rem; color: var(--fg-subtle); text-transform: uppercase; letter-spacing: 0.03em; }

/* Parent: message threads */
.msg-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.msg { max-width: 78%; width: fit-content; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 0.9rem; line-height: 1.45; }
.msg-time { font-size: 0.7rem; margin-top: 4px; color: var(--fg-subtle); }
.msg-mine { margin-left: auto; background: var(--blue); color: #fff; }
.msg-mine .msg-time { color: rgba(255,255,255,0.75); }
.msg-theirs { background: var(--surface-2); }
/* Subtle "linked to <pupil>" note at the foot of a message */
.msg-linked { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--fg-subtle); }
/* Unread inbox rows */
.msg-unread td { background: rgba(58,102,214,0.10); }
.msg-unread td:first-child { box-shadow: inset 3px 0 0 var(--blue); font-weight: 700; }

/* Timetable grid */
.tt-wrap { max-width: 1120px; }
.tt-table { table-layout: fixed; min-width: 720px; }
.tt-table th, .tt-table td { text-align: left; vertical-align: top; padding: 8px 10px; border: 1px solid var(--border); }
.tt-table thead th { background: var(--surface); font-size: 0.8rem; }
.tt-rowhead { background: var(--surface); font-weight: 600; }
.tt-rowhead span { display: block; }
.tt-time { font-weight: 400; font-size: 0.72rem; color: var(--fg-subtle); margin-top: 2px; }
.tt-class { font-weight: 600; font-size: 0.9rem; }
.tt-cell-sub { font-size: 0.72rem; color: var(--fg-subtle); margin-top: 2px; }
/* Live "now" highlight: today's column tinted, the current lesson cell outlined */
.tt-th-today { color: var(--fg); background: rgba(123,83,214,0.10); }
.tt-td-today { background: rgba(123,83,214,0.06); }
.tt-td-now { background: rgba(58,102,214,0.20); box-shadow: inset 0 0 0 2px var(--blue); }
.tt-cell { display: block; width: 100%; text-align: left; background: none; border: none; padding: 0; margin: 0; color: inherit; font: inherit; }
.tt-cell-btn { cursor: pointer; border-radius: 6px; padding: 4px 6px; margin: -4px -6px; transition: background 0.12s; }
.tt-cell-btn:hover { background: var(--surface-2); }
.tt-cell-btn .tt-class { color: var(--blue); }
/* Calendar month grid — reuses tt-table borders; equal-width day cells with a fixed height. */
.cal-table thead th { text-align: center; }
.cal-cell { height: 92px; width: 14.28%; vertical-align: top; }
.roster-row { cursor: pointer; }
.roster-row:hover { background: var(--surface-2); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--fg); }
.input-sm { padding: 5px 9px; font-size: 0.82rem; width: 100%; min-height: 34px; }
select.input-sm { min-width: 88px; padding-right: 24px; }
.filter-row th { padding-top: 0; padding-bottom: 10px; font-weight: 400; }

.content { padding: 28px; max-width: 1680px; width: 100%; }
.page-head { margin-bottom: 24px; }
.page-head h2 { font-size: 1.5rem; font-weight: 800; }
.page-head p { color: var(--fg-muted); margin-top: 4px; }

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.sync-group-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-subtle); margin: 0 0 12px; }

.stat .stat-val { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .stat-label { color: var(--fg-muted); font-size: 0.88rem; margin-top: 2px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* ── Search field ─────────────────────────────────────────────────────────── */
.search-field { position: relative; width: 280px; max-width: 100%; }
.search-field .input { padding-left: 40px; padding-right: 38px; }
.search-field .search-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--fg-subtle); pointer-events: none; width: 17px; height: 17px; }
/* Centre via top offset (spinner is 18px); the spin animation owns `transform`, so a
   translateY here would be overridden and the spinner would drop out of centre. */
.search-field .search-spin { position: absolute; right: 13px; top: calc(50% - 9px); border-color: var(--border-2); border-top-color: var(--blue); }
.search-field .search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 24px; height: 24px; border: none; background: transparent; color: var(--fg-subtle); cursor: pointer; border-radius: 6px; }
.search-field .search-clear:hover { background: var(--surface-2); color: var(--fg); }
.search-field .search-clear svg { width: 15px; height: 15px; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, rgba(123,83,214,0.18), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 24px; font-weight: 800; font-size: 1.4rem; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: grid; place-items: center; padding: 20px; z-index: 100; backdrop-filter: blur(4px); }
.modal { width: 100%; max-width: 440px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.modal-sub { color: var(--fg-muted); font-size: 0.9rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-2);
  box-shadow: var(--shadow); font-size: 0.9rem; font-weight: 500; max-width: 360px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--blue); }

/* ── Skeleton / loading ───────────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-dark { border-color: var(--border-2); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Build version stamp — fixed bottom-right, unobtrusive. */
.app-version { position: fixed; bottom: 8px; right: 12px; font-size: 0.7rem; font-variant-numeric: tabular-nums; color: var(--fg-subtle); z-index: 150; pointer-events: none; user-select: none; letter-spacing: 0.02em; }

.empty { text-align: center; padding: 48px 20px; color: var(--fg-muted); }
.empty svg { color: var(--fg-subtle); margin-bottom: 12px; }

/* ── Icons sizing ─────────────────────────────────────────────────────────── */
svg[data-lucide] { width: 18px; height: 18px; stroke-width: 2; }
.nav-item svg[data-lucide] { width: 19px; height: 19px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s var(--ease); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; }
  .menu-btn { display: inline-flex !important; }
  .content { padding: 20px 16px; }
}
.menu-btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Seating plan designer ──────────────────────────────────────────────────
   The plan reads like paper: a deliberately light canvas in both themes, so a
   printed or projected layout looks the same as on screen. Coordinates are in a
   fixed logical space (default 1000x700) and rendered 1:1, so the wrap scrolls
   on small screens rather than rescaling the maths. */
.seat-canvas-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f1f5f9;
  max-height: 70vh;
}
.seat-canvas {
  position: relative;
  background-color: #ffffff;
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
  touch-action: none; /* let us handle pointer drags ourselves */
}
.seat-item {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  user-select: none;
  cursor: grab;
  overflow: hidden;   /* clip the edge-to-edge photo to the desk's rounded corners */
}
.seat-item:active { cursor: grabbing; }
.seat-item-desk         { background: #ffffff; border: 2px solid #94a3b8; color: #334155; }
.seat-item-teacher_desk { background: #e0e7ff; border: 2px solid #6366f1; color: #3730a3; }
.seat-item-board        { background: #0f3d5c; border: 2px solid #0f3d5c; color: #ffffff; }
.seat-item-door         { background: #f59e0b; border: 2px solid #d97706; color: #ffffff; }
.seat-item.is-selected  { outline: 3px solid #2563eb; outline-offset: 2px; z-index: 5; }
.seat-item.is-readonly  { cursor: default; }
.seat-marquee {
  position: absolute;
  border: 1px dashed #2563eb;
  background: rgba(37, 99, 235, 0.08);
  pointer-events: none;
  z-index: 10;
}

/* Seat slots inside a desk. The desk is rotated, so its slots rotate with it (pupils really do sit
   around a turned table) — but the NAME is counter-rotated so it stays readable at any angle. */
.seat-slots {
  position: absolute;
  inset: 0;                 /* fill the desk edge-to-edge */
  display: grid;
  gap: 1px;
}
.seat-slot {
  display: flex; align-items: center; justify-content: center;
  border-radius: 0;
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
  font-size: 10px; line-height: 1.1; text-align: center;
  overflow: hidden; padding: 0;
  cursor: pointer;
  transition: outline-color .15s;
}
.seat-slot:hover { outline: 2px solid #2563eb; outline-offset: -2px; }
.seat-slot.is-taken { background: #dbeafe; color: #1e3a8a; font-weight: 700; }

/* "My seat" card header — a full-width toggle that reads as a heading row. The room is collapsed
   by default and revealed on click. */
.seat-view-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  width: 100%; padding: 0; border: 0; background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.seat-view-head:hover .seat-view-class { text-decoration: underline; }
.seat-view-caret { color: var(--fg-muted); font-size: 0.8rem; width: 10px; flex-shrink: 0; }
/* NOT .card-sub — that carries margin-bottom:18px for block use, which knocks an inline name
   out of alignment inside this flex row. */
.seat-view-teacher { color: var(--fg-muted); font-size: 0.9rem; margin: 0; }

/* Pupil/parent "My seat" — read-only. A classmate's seat is shown as an anonymous filled slot (the
   API never sends who sits there), while the pupil's own seat is called out. */
.seat-view .seat-slot { cursor: default; }
.seat-view .seat-slot:hover { outline: none; }
.seat-view .seat-slot.is-occupied { background: rgba(148, 163, 184, 0.45); }
.seat-view .seat-slot.is-mine {
  background: #16a34a; color: #ffffff; font-weight: 700;
  outline: 2px solid #15803d; outline-offset: -2px;
}

/* Fullscreen presenter (for the projector). Fixed overlay so it works even without the native
   Fullscreen API; the Fullscreen button escalates to true fullscreen when available. */
.seat-presenter {
  position: fixed; inset: 0; z-index: 200;
  background: #0f172a;
  display: flex; flex-direction: column;
}
.seat-presenter-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  background: #1e293b; color: #f1f5f9;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.seat-presenter-bar .card-sub { color: rgba(241,245,249,0.65); }
.seat-presenter-stage {
  flex: 1; overflow: auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px;
}
.seat-pop {
  position: fixed; z-index: 210;
  width: 230px;
  background: var(--card-bg); color: var(--fg);
  border: 1px solid var(--border-2); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  padding: 12px;
  backdrop-filter: blur(12px);
}
/* Pupil card on a seat (ClassCharts-style): photo left, first name + surname right, points badge
   top-right. Fills the seat; only rendered when the seat is occupied (empty seats stay grey). */
.seat-card {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; gap: 7px;
  padding: 6px; background: #ffffff; overflow: hidden;
  text-align: left;
  font-family: var(--font);   /* same face as the rest of the app */
}
.seat-card-photo {
  height: 100%; width: auto; aspect-ratio: 3 / 4;
  object-fit: cover; border-radius: 4px; flex-shrink: 0;
}
.seat-card-info { flex: 1; min-width: 0; line-height: 1.2; }
/* Names: slightly smaller, both the same slate colour (not black + grey). First name keeps a little
   right padding so it truncates before the points badge instead of running under it. */
.seat-card-first { font-weight: 500; font-size: 12px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 20px; }
.seat-card-last  { font-weight: 500; font-size: 11px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-card-points {
  position: absolute; top: 3px; right: 3px;
  min-width: 17px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #16a34a; color: #fff;
  font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.seat-card-points.is-neg { background: #dc2626; }
