/* ==========================================================================
   Student Guide — design system
   Wayfinding-led: deep teal for place and direction, amber for attention.
   Written with logical properties throughout so the Arabic RTL layout is a
   true mirror rather than a set of overrides.
   ========================================================================== */

/* ----------------------------------------------------------------- tokens */
:root {
  /* Brand */
  --sg-teal-50:  #eef7f7;
  --sg-teal-100: #d3ecec;
  --sg-teal-200: #a7d8d9;
  --sg-teal-400: #3f9ba3;
  --sg-teal-600: #10656d;
  --sg-teal-700: #0c4f56;
  --sg-teal-900: #06333a;

  --sg-amber-100: #fdf0d9;
  --sg-amber-500: #b96c0b;
  --sg-amber-600: #9a5709;

  /* Neutrals — very slightly warm, so long reading feels less clinical */
  --sg-n-0:   #ffffff;
  --sg-n-25:  #fbfaf8;
  --sg-n-50:  #f5f4f1;
  --sg-n-100: #ebe9e4;
  --sg-n-200: #dcd9d2;
  --sg-n-300: #bdb9b0;
  --sg-n-500: #77736b;
  --sg-n-700: #423f3a;
  --sg-n-900: #1c1a17;

  /* Status */
  --sg-green-50:  #e9f6ed;  --sg-green-600: #1a7f3c;
  --sg-red-50:    #fdecec;  --sg-red-600:   #b3261e;
  --sg-blue-50:   #eaf1fb;  --sg-blue-600:  #1a5fb4;

  /* Semantic — light theme */
  --bg:          var(--sg-n-25);
  --bg-raised:   var(--sg-n-0);
  --bg-sunken:   var(--sg-n-50);
  --bg-hover:    var(--sg-n-50);
  --border:      var(--sg-n-200);
  --border-soft: var(--sg-n-100);
  --text:        var(--sg-n-900);
  --text-muted:  var(--sg-n-500);
  --text-invert: var(--sg-n-0);

  --primary:        var(--sg-teal-600);
  --primary-hover:  var(--sg-teal-700);
  --primary-soft:   var(--sg-teal-50);
  --primary-border: var(--sg-teal-200);
  --on-primary:     #ffffff;

  --accent:      var(--sg-amber-600);
  --accent-soft: var(--sg-amber-100);

  --ok:     var(--sg-green-600); --ok-soft:   var(--sg-green-50);
  --danger: var(--sg-red-600);   --danger-soft: var(--sg-red-50);
  --info:   var(--sg-blue-600);  --info-soft:  var(--sg-blue-50);

  --focus: #0b6fd0;

  /* Scale */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --sp-1: 4px; --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --shadow-sm: 0 1px 2px rgba(28,26,23,.06), 0 1px 3px rgba(28,26,23,.04);
  --shadow-md: 0 2px 4px rgba(28,26,23,.05), 0 6px 16px rgba(28,26,23,.07);
  --shadow-lg: 0 8px 32px rgba(28,26,23,.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --nav-h: 60px;
  --bottom-h: 62px;
  --content-max: 1180px;
}

/* Dark theme — explicit choice wins, system preference is the fallback. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #14161a;
    --bg-raised:   #1b1e24;
    --bg-sunken:   #101216;
    --bg-hover:    #232730;
    --border:      #333944;
    --border-soft: #262b33;
    --text:        #e9ecf1;
    --text-muted:  #a2aab8;

    --primary:        #4bb3ba;
    --primary-hover:  #6bc7cd;
    --primary-soft:   #10333a;
    --primary-border: #1d5960;
    --on-primary:     #06232a;

    --accent:      #e2a33f;
    --accent-soft: #3a2c12;

    --ok:     #56c880; --ok-soft:     #14301f;
    --danger: #f28b82; --danger-soft: #34191a;
    --info:   #7fb2f0; --info-soft:   #172436;

    --focus: #7fb2f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 2px 4px rgba(0,0,0,.35), 0 6px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg:          #14161a;
  --bg-raised:   #1b1e24;
  --bg-sunken:   #101216;
  --bg-hover:    #232730;
  --border:      #333944;
  --border-soft: #262b33;
  --text:        #e9ecf1;
  --text-muted:  #a2aab8;

  --primary:        #4bb3ba;
  --primary-hover:  #6bc7cd;
  --primary-soft:   #10333a;
  --primary-border: #1d5960;
  --on-primary:     #06232a;

  --accent:      #e2a33f;
  --accent-soft: #3a2c12;

  --ok:     #56c880; --ok-soft:     #14301f;
  --danger: #f28b82; --danger-soft: #34191a;
  --info:   #7fb2f0; --info-soft:   #172436;

  --focus: #7fb2f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 4px rgba(0,0,0,.35), 0 6px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html[dir="rtl"] body { font-family: var(--font-ar); line-height: 1.7; }

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.25; font-weight: 650; letter-spacing: -0.011em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }
@media (min-width: 768px) { h1 { font-size: 2rem; } h2 { font-size: 1.4rem; } }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 { letter-spacing: 0; }

p { margin: 0 0 var(--sp-3); }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: var(--sp-5) 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: var(--sp-3); inset-block-start: -60px;
  z-index: 200; background: var(--primary); color: var(--on-primary);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md);
  transition: inset-block-start .15s;
}
.skip-link:focus { inset-block-start: var(--sp-3); }

/* --------------------------------------------------------------- layout */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.container {
  width: 100%; max-width: var(--content-max);
  margin-inline: auto; padding-inline: var(--sp-4);
}
@media (min-width: 768px) { .container { padding-inline: var(--sp-5); } }

main { flex: 1; padding-block: var(--sp-4) calc(var(--bottom-h) + var(--sp-6)); }
@media (min-width: 900px) { main { padding-block: var(--sp-5) var(--sp-7); } }

.stack   { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm{ display: flex; flex-direction: column; gap: var(--sp-2); }
.row     { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
/* Mobile-first and in ascending order: a later rule at equal specificity wins,
   so the widest breakpoint must come last. */
@media (min-width: 700px)  { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 700px)  { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 700px)  { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px)  { .grid-main { grid-template-columns: minmax(0,2fr) minmax(0,1fr); align-items: start; } }

.mt-0 { margin-block-start: 0; }
.mb-0 { margin-block-end: 0; }
.mt-4 { margin-block-start: var(--sp-4); }
.mt-5 { margin-block-start: var(--sp-5); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .8rem; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.full { width: 100%; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 50;
  background: var(--bg-raised);
  border-block-end: 1px solid var(--border-soft);
  min-height: var(--nav-h);
  display: flex; align-items: center;
}
.topbar__inner { display: flex; align-items: center; gap: var(--sp-3); width: 100%; }

.brand { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 700; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand__mark { flex: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-size: 1rem; letter-spacing: -.01em; }
.brand__sub { font-size: .7rem; color: var(--text-muted); font-weight: 500; }

.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: var(--sp-1); }

/* Desktop navigation lives in the header; mobile uses the bottom bar. */
.nav-desktop { display: none; }
@media (min-width: 900px) {
  .nav-desktop { display: flex; align-items: center; gap: var(--sp-1); margin-inline-start: var(--sp-4); }
  .nav-desktop a {
    padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
    color: var(--text-muted); text-decoration: none; font-size: .9rem; font-weight: 550;
  }
  .nav-desktop a:hover { background: var(--bg-hover); color: var(--text); }
  .nav-desktop a.is-active { background: var(--primary-soft); color: var(--primary); }
}

/* Bottom navigation — always reachable on a phone. */
.nav-bottom {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 60;
  background: var(--bg-raised);
  border-block-start: 1px solid var(--border);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-block-end: env(safe-area-inset-bottom);
}
.nav-bottom a {
  min-height: var(--bottom-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--text-muted);
  font-size: .68rem; font-weight: 550; padding: var(--sp-1);
}
.nav-bottom a.is-active { color: var(--primary); }
.nav-bottom a .icon { width: 22px; height: 22px; }
@media (min-width: 900px) { .nav-bottom { display: none; } }

/* Overflow menu for the routes that do not fit the bottom bar. */
.menu-panel {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20,22,26,.45);
  display: flex; align-items: flex-end;
}
.menu-panel[hidden] { display: none; }
.menu-panel__sheet {
  background: var(--bg-raised); width: 100%;
  border-start-start-radius: var(--r-xl); border-start-end-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); max-height: 85vh; overflow-y: auto;
}
.menu-panel__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
.menu-panel__grid a {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 48px; padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  text-decoration: none; color: var(--text); font-size: .9rem; font-weight: 550;
}
.menu-panel__grid a:hover { background: var(--bg-hover); }
@media (min-width: 900px) { .menu-panel { display: none !important; } }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; overflow: hidden; }
.card--accent { border-color: var(--primary-border); background: var(--primary-soft); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-block-end: var(--sp-3); }
.card__head h2, .card__head h3 { margin: 0; }
.card__title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 650; margin-block-end: var(--sp-2); }
html[dir="rtl"] .card__title { letter-spacing: 0; }

/* The dashboard's headline card — the "what now, where" answer. */
.now-card {
  background: linear-gradient(135deg, var(--sg-teal-700), var(--sg-teal-900));
  color: #fff; border: 0; border-radius: var(--r-lg);
  padding: var(--sp-5); box-shadow: var(--shadow-md);
}
:root[data-theme="dark"] .now-card { background: linear-gradient(135deg, #0d4a52, #06272d); }
.now-card__label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; font-weight: 650; }
html[dir="rtl"] .now-card__label { letter-spacing: 0; }
.now-card__course { font-size: 1.45rem; font-weight: 700; margin-block: var(--sp-2) var(--sp-1); line-height: 1.2; }
.now-card__meta { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: .95rem; opacity: .95; }
.now-card__meta > span { display: inline-flex; align-items: center; gap: 6px; }
.now-card__countdown { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.now-card .btn--ghost-invert {
  background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3);
}
.now-card .btn--ghost-invert:hover { background: rgba(255,255,255,.24); color: #fff; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-size: .925rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn--secondary { background: var(--bg-raised); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--bg-hover); color: var(--text); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.92); color: #fff; }
.btn--sm { min-height: 36px; padding: 6px var(--sp-3); font-size: .85rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }

/* Icon-only controls still meet the 44px touch target. */
.icon-btn {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md); border: 1px solid transparent;
  background: transparent; color: var(--text-muted); cursor: pointer;
  font: inherit; text-decoration: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ------------------------------------------------------------------ form */
.field { display: flex; flex-direction: column; gap: 6px; margin-block-end: var(--sp-4); }
.field > label, .label { font-size: .875rem; font-weight: 600; color: var(--text); }
.field__hint { font-size: .8rem; color: var(--text-muted); }
.field__error { font-size: .82rem; color: var(--danger); font-weight: 550; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font: inherit; font-size: .95rem;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
/* A single chevron drawn as an SVG data URI. The previous two-gradient
   triangle mirrored incorrectly under RTL and rendered as a broken mark; a
   chevron is horizontally symmetric, so only its position needs flipping. */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2712%27%20height%3D%278%27%20viewBox%3D%270%200%2012%208%27%3E%3Cpath%20d%3D%27M1%201.5%206%206.5%2011%201.5%27%20fill%3D%27none%27%20stroke%3D%27%2377736b%27%20stroke-width%3D%271.8%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E");
  background-position: right 14px center;
  background-size: 12px 8px;
  background-repeat: no-repeat;
  padding-inline-end: var(--sp-6);
}
html[dir="rtl"] select {
  background-position: left 14px center;
  padding-inline-end: var(--sp-3);
  padding-inline-start: var(--sp-6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) select { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2712%27%20height%3D%278%27%20viewBox%3D%270%200%2012%208%27%3E%3Cpath%20d%3D%27M1%201.5%206%206.5%2011%201.5%27%20fill%3D%27none%27%20stroke%3D%27%23a2aab8%27%20stroke-width%3D%271.8%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E"); }
}
:root[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2712%27%20height%3D%278%27%20viewBox%3D%270%200%2012%208%27%3E%3Cpath%20d%3D%27M1%201.5%206%206.5%2011%201.5%27%20fill%3D%27none%27%20stroke%3D%27%23a2aab8%27%20stroke-width%3D%271.8%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%2F%3E%3C%2Fsvg%3E"); }

.check { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; cursor: pointer; font-size: .9rem; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; margin: 0; }

/* Chip-style multi-select for equipment filters. */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 6px var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-full);
  background: var(--bg-raised); font-size: .85rem; font-weight: 550; cursor: pointer;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip:has(input:checked) { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.filters { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@media (min-width: 620px) { .filters { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .filters { grid-template-columns: repeat(4, 1fr); } }
.filters .field { margin-block-end: 0; }
.filters__actions { display: flex; gap: var(--sp-2); align-items: end; }

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: .76rem; font-weight: 650; line-height: 1.5;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1px solid var(--border-soft); white-space: nowrap;
}
.badge--ok      { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge--info    { background: var(--info-soft);   color: var(--info);   border-color: transparent; }
.badge--accent  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge--primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-block-start: 1px solid var(--border-soft); }

.item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); min-height: 56px;
  text-decoration: none; color: inherit;
}
a.item:hover { background: var(--bg-hover); }
.item__time {
  flex: none; width: 62px; font-variant-numeric: tabular-nums;
  font-size: .82rem; font-weight: 650; color: var(--text-muted); line-height: 1.3;
}
.item__body { flex: 1; min-width: 0; }
.item__title { display: block; font-weight: 600; font-size: .95rem; }
.item__sub { display: block; font-size: .82rem; color: var(--text-muted); }
.item__end { flex: none; display: flex; align-items: center; gap: var(--sp-2); }
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Left rule that marks a schedule item's state. */
.item--rule { border-inline-start: 3px solid var(--border); }
.item--now      { border-inline-start-color: var(--primary); background: var(--primary-soft); }
.item--conflict { border-inline-start-color: var(--danger); }
.item--cancelled .item__title { text-decoration: line-through; opacity: .65; }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: var(--sp-3); text-align: start; border-block-end: 1px solid var(--border-soft); vertical-align: middle; }
th { font-weight: 650; font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
html[dir="rtl"] th { letter-spacing: 0; }
tbody tr:hover { background: var(--bg-hover); }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- week grid */
.week { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@media (min-width: 1000px) { .week { grid-template-columns: repeat(5, 1fr); gap: var(--sp-2); } }
.week__day { background: var(--bg-raised); border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: var(--sp-3); }
.week__day--today { border-color: var(--primary-border); background: var(--primary-soft); }
.week__name { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-block-end: var(--sp-2); }
html[dir="rtl"] .week__name { letter-spacing: 0; }
.week__slot {
  background: var(--bg); border: 1px solid var(--border-soft);
  border-inline-start: 3px solid var(--primary);
  border-radius: var(--r-sm); padding: var(--sp-2); margin-block-end: var(--sp-2); font-size: .82rem;
}
.week__slot--conflict { border-inline-start-color: var(--danger); }
.week__slot strong { display: block; font-size: .85rem; }
.week__slot span { color: var(--text-muted); font-size: .78rem; }

/* ------------------------------------------------------------- timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; inset-block: 8px 8px;
  inset-inline-start: 7px; width: 2px; background: var(--border);
}
.timeline > li { position: relative; padding-inline-start: var(--sp-6); padding-block: var(--sp-2); }
html[dir="rtl"] .timeline > li { padding-inline-start: var(--sp-6); }
.timeline > li::before {
  content: ""; position: absolute; inset-inline-start: 2px; inset-block-start: 18px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-raised); border: 2px solid var(--primary);
}
.timeline > li.is-internal::before { border-color: var(--accent); }
.timeline__meta { font-size: .78rem; color: var(--text-muted); }

/* Room day timeline: a simple proportional bar, readable at 360px. */
.day-track { display: flex; flex-direction: column; gap: var(--sp-2); }
.day-block {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm); border: 1px solid var(--border-soft);
  border-inline-start: 3px solid var(--accent); background: var(--bg-sunken);
}
.day-block--class { border-inline-start-color: var(--primary); }
.day-block__time { font-variant-numeric: tabular-nums; font-size: .82rem; font-weight: 650; white-space: nowrap; }

/* ------------------------------------------------------------ campus map */
.map {
  position: relative; width: 100%; aspect-ratio: 3 / 2;
  /* Capped: the labels are SVG text and scale with the box, so an uncapped
     map renders absurdly large type on a wide screen. */
  max-width: 560px; margin-inline: auto; display: block;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.map__pin {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-raised); color: var(--primary);
  border: 2px solid var(--primary); border-radius: var(--r-full);
  font-size: .78rem; font-weight: 700; text-decoration: none;
  box-shadow: var(--shadow-sm); padding: 4px 8px;
}
.map__pin:hover { background: var(--primary); color: var(--on-primary); }
.map__pin--from { border-color: var(--ok); color: var(--ok); }
.map__pin--to   { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- alerts */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); border: 1px solid transparent;
  font-size: .9rem; margin-block-end: var(--sp-4);
}
.alert--success { background: var(--ok-soft);     color: var(--ok);     border-color: currentColor; }
.alert--error   { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.alert--warning { background: var(--accent-soft); color: var(--accent); border-color: currentColor; }
.alert--info    { background: var(--info-soft);   color: var(--info);   border-color: currentColor; }
.alert .icon { flex: none; margin-block-start: 2px; }
.alert p:last-child { margin-block-end: 0; }

.demo-banner {
  background: var(--accent-soft); color: var(--accent);
  border-block-end: 1px solid var(--border-soft);
  font-size: .82rem; font-weight: 550;
}
.demo-banner .container { display: flex; align-items: center; gap: var(--sp-2); padding-block: var(--sp-2); flex-wrap: wrap; }

/* ---------------------------------------------------------- empty states */
.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--text-muted); }
.empty .icon { width: 40px; height: 40px; opacity: .5; margin-block-end: var(--sp-3); }
.empty h3 { color: var(--text); margin-block-end: var(--sp-1); }
.empty p { margin: 0 auto; max-width: 42ch; font-size: .9rem; }

/* --------------------------------------------------------------- stats */
.stat { background: var(--bg-raised); border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: var(--sp-4); }
.stat__value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { font-size: .82rem; color: var(--text-muted); font-weight: 550; }

/* Horizontal bars for analytics — accessible without colour alone. */
.bar { display: grid; grid-template-columns: minmax(90px, 1.4fr) minmax(0, 3fr) auto; gap: var(--sp-3); align-items: center; padding-block: 6px; font-size: .85rem; }
.bar__track { background: var(--bg-sunken); border-radius: var(--r-full); height: 10px; overflow: hidden; }
.bar__fill { background: var(--primary); height: 100%; border-radius: var(--r-full); }
.bar__value { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 48px; text-align: end; }

/* ------------------------------------------------------------- segmented */
.segmented { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: 3px; gap: 3px; }
.segmented a {
  min-height: 38px; display: inline-flex; align-items: center; padding: 0 var(--sp-3);
  border-radius: var(--r-sm); text-decoration: none; color: var(--text-muted);
  font-size: .875rem; font-weight: 600;
}
.segmented a.is-active { background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------ ballot */
.ballot { display: flex; flex-direction: column; gap: var(--sp-3); }
.ballot__option {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); border: 2px solid var(--border);
  border-radius: var(--r-md); cursor: pointer; background: var(--bg-raised);
}
.ballot__option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.ballot__option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.ballot__option input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; margin-block-start: 2px; }
.ballot__name { font-weight: 650; }

/* --------------------------------------------------------------- public */
.hero { padding-block: var(--sp-6) var(--sp-5); }
@media (min-width: 900px) { .hero { padding-block: var(--sp-8) var(--sp-7); } }
.hero h1 { font-size: 1.9rem; max-width: 18ch; }
@media (min-width: 900px) { .hero h1 { font-size: 3rem; } }
.hero__lead { font-size: 1.05rem; color: var(--text-muted); max-width: 62ch; }
@media (min-width: 900px) { .hero__lead { font-size: 1.15rem; } }
.hero__cta { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-block-start: var(--sp-5); }

.feature { padding: var(--sp-4); }
.feature__icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; margin-block-end: var(--sp-3);
}
.feature__icon .icon { width: 24px; height: 24px; }
.feature h3 { font-size: 1.02rem; }
.feature p { color: var(--text-muted); font-size: .92rem; margin: 0; }

.site-footer {
  border-block-start: 1px solid var(--border-soft);
  padding-block: var(--sp-5);
  margin-block-start: var(--sp-6);
  color: var(--text-muted); font-size: .85rem;
}
.site-footer a { color: var(--text-muted); }

/* Auth screen */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.auth-card { width: 100%; max-width: 430px; }
.demo-accounts { display: flex; flex-direction: column; gap: var(--sp-2); }
.demo-account {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--bg-sunken);
}
.demo-account__role { font-weight: 650; font-size: .875rem; }
.demo-account__email { font-size: .78rem; color: var(--text-muted); font-family: var(--font-mono); }

/* ------------------------------------------------------------ utilities */
.divider { height: 1px; background: var(--border-soft); margin-block: var(--sp-4); }
.pill-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.qr-token { font-family: var(--font-mono); font-size: .85rem; letter-spacing: .08em; }
.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* Anything the user did not ask to move, does not move. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .topbar, .nav-bottom, .demo-banner, .site-footer, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Width steps for analytics bars — keeps inline styles out of the markup
   so the Content-Security-Policy can stay at style-src 'self'. */
.w-0 { width: 0%; }
.w-2 { width: 2%; }
.w-4 { width: 4%; }
.w-6 { width: 6%; }
.w-8 { width: 8%; }
.w-10 { width: 10%; }
.w-12 { width: 12%; }
.w-14 { width: 14%; }
.w-16 { width: 16%; }
.w-18 { width: 18%; }
.w-20 { width: 20%; }
.w-22 { width: 22%; }
.w-24 { width: 24%; }
.w-26 { width: 26%; }
.w-28 { width: 28%; }
.w-30 { width: 30%; }
.w-32 { width: 32%; }
.w-34 { width: 34%; }
.w-36 { width: 36%; }
.w-38 { width: 38%; }
.w-40 { width: 40%; }
.w-42 { width: 42%; }
.w-44 { width: 44%; }
.w-46 { width: 46%; }
.w-48 { width: 48%; }
.w-50 { width: 50%; }
.w-52 { width: 52%; }
.w-54 { width: 54%; }
.w-56 { width: 56%; }
.w-58 { width: 58%; }
.w-60 { width: 60%; }
.w-62 { width: 62%; }
.w-64 { width: 64%; }
.w-66 { width: 66%; }
.w-68 { width: 68%; }
.w-70 { width: 70%; }
.w-72 { width: 72%; }
.w-74 { width: 74%; }
.w-76 { width: 76%; }
.w-78 { width: 78%; }
.w-80 { width: 80%; }
.w-82 { width: 82%; }
.w-84 { width: 84%; }
.w-86 { width: 86%; }
.w-88 { width: 88%; }
.w-90 { width: 90%; }
.w-92 { width: 92%; }
.w-94 { width: 94%; }
.w-96 { width: 96%; }
.w-98 { width: 98%; }
.w-100 { width: 100%; }

/* Overflow trigger in the bottom bar is a button, styled to match its links. */
.nav-more {
  min-height: var(--bottom-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: 0; background: transparent; color: var(--text-muted);
  font: inherit; font-size: .68rem; font-weight: 550; cursor: pointer; padding: var(--sp-1);
}
.nav-more[aria-expanded="true"] { color: var(--primary); }
.nav-more .icon { width: 22px; height: 22px; }

.card--flush > .card__head { padding: var(--sp-4) var(--sp-4) 0; margin-block-end: var(--sp-3); }
.card--flush > p { padding-inline: var(--sp-4); padding-block-end: var(--sp-4); }

/* A card that is itself a link should read as a card, not as body-text link. */
a.card { text-decoration: none; color: inherit; display: block; transition: border-color .15s, box-shadow .15s; }
a.card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-md); color: inherit; }
a.card:hover h2, a.card:hover h3, a.card:hover strong { color: var(--primary); }

/* Filter groups use the card surface rather than the browser's default frame. */
fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
fieldset > legend { padding: 0; font-size: .875rem; font-weight: 600; }

/* Details/summary disclosure used by the admin composer. */
details > summary {
  cursor: pointer; min-height: 44px; display: flex; align-items: center;
  list-style: none; font-size: 1rem;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; margin-inline-start: auto; font-size: 1.3rem; color: var(--text-muted); }
details[open] > summary::after { content: "−"; }

/* Tab labels must never wrap onto a second line at 360px. */
.nav-bottom a span, .nav-more span {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; line-height: 1.2;
}

/* ------------------------------------------- responsive + touch corrections */

/* Grid and flex children default to min-width:auto, so a long unbreakable
   string pushes the whole column past the viewport. This is the fix for the
   sideways scroll the 360px audit found on the dashboard. */
.grid > *, .stack > *, .row > *, .row-between > * { min-width: 0; }
.card, .stat, .item, .week__day, .week__slot { min-width: 0; }

/* Every interactive control meets the 44px touch target at any width. */
.brand { min-height: 44px; }
.brand__name { white-space: nowrap; }
.card__head a,
.card--flush > p > a {
  min-height: 44px; display: inline-flex; align-items: center;
  padding-inline: var(--sp-1);
}
.segmented a { min-height: 44px; }
.btn--sm { min-height: 44px; }
.timeline a, .item a { min-height: 44px; display: inline-flex; align-items: center; }

/* Long words (references, emails, codes) wrap instead of forcing overflow. */
.item__title, .item__sub, .stat__label, .badge, td, th { overflow-wrap: anywhere; }
.qr-token { overflow-wrap: anywhere; }

/* A long filter row (Arabic status labels, for instance) must scroll inside
   itself rather than widening the page. */
.segmented {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.segmented a { white-space: nowrap; flex: none; }

/* The skip link is off-screen until focused; keep it from defining page width. */
.skip-link { max-width: calc(100% - var(--sp-5)); white-space: nowrap; }

/* The administrator has eight desktop nav items; without this they wrap onto a
   second line. Labels stay on one line and the row scrolls if it ever needs to. */
@media (min-width: 900px) {
  .nav-desktop {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
  }
  .nav-desktop::-webkit-scrollbar { display: none; }
  .nav-desktop a { white-space: nowrap; flex: none; }
}
