/* Exam Seating Plan Finder
   Wayfinding-signage look: deep navy, route blue, signal yellow on cool grey.
   Mobile-first; admin console shares the same tokens. */

:root {
  --ink: #0f2138;
  --ink-2: #3f5169;
  --ink-3: #6b7b90;
  --paper: #eef2f6;
  --card: #ffffff;
  --line: #d5dde6;
  --line-2: #e5ebf1;
  --route: #1f4fd6;
  --route-dark: #163ba3;
  --route-tint: #e6edff;
  --signal: #ffc72c;
  --signal-ink: #1c1500;
  --ok: #16794c;
  --ok-tint: #dff4e8;
  --warn: #8a5300;
  --warn-tint: #fff1cf;
  --err: #b42318;
  --err-tint: #fde7e4;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 33, 56, 0.08), 0 6px 18px rgba(15, 33, 56, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: 0.005em; }
p { margin: 0 0 0.75rem; }
a { color: var(--route); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1rem; }
.muted { color: var(--ink-3); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: 700 1rem/1 var(--font-body);
  padding: 0.8rem 1.1rem; min-height: 44px;
  border-radius: 8px; border: 2px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--route); border-color: var(--route); color: #fff; }
.btn.primary:hover { background: var(--route-dark); border-color: var(--route-dark); }
.btn.danger { color: var(--err); border-color: #f0b8b2; }
.btn.danger:hover { background: var(--err-tint); border-color: var(--err); }
.btn.small { min-height: 34px; padding: 0.4rem 0.7rem; font-size: 0.875rem; }
.btn.big { min-height: 56px; font-size: 1.15rem; width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

label, .label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
label .opt { font-weight: 400; color: var(--ink-3); }
input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], select, textarea, input[type="file"] {
  width: 100%; font: inherit; color: var(--ink);
  padding: 0.7rem 0.8rem; min-height: 46px;
  background: #fff; border: 2px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { border-color: var(--route); outline: none; box-shadow: 0 0 0 3px var(--route-tint); }
input[type="file"] { padding: 0.55rem; background: var(--paper); }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--route); margin-right: 0.5rem; vertical-align: -0.15rem; }
.check { display: flex; align-items: flex-start; font-weight: 400; margin: 0; }
.field { margin-bottom: 1rem; }
.hint { font-size: 0.875rem; color: var(--ink-3); margin: 0.3rem 0 0; }

.notice { padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid; margin-bottom: 1rem; font-size: 0.975rem; }
.notice.error { background: var(--err-tint); border-color: #f0b8b2; color: #7a1a12; }
.notice.warning { background: var(--warn-tint); border-color: #f0d28a; color: #5f3a00; }
.notice.success { background: var(--ok-tint); border-color: #a9dcc0; color: #0d4d30; }
.notice.info { background: var(--route-tint); border-color: #b9c9f5; color: #0f2d80; }

/* ---------------------------------------------------------------- student page */
.topbar { background: var(--ink); color: #fff; }
.topbar .wrap { display: flex; align-items: center; gap: 0.7rem; min-height: 52px; }
.topbar svg { width: 26px; height: 26px; color: var(--signal); flex: none; }
.topbar .uni { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; letter-spacing: 0.02em; }

.finder { flex: 1; padding-top: 1.5rem; padding-bottom: 2rem; }
.intro { margin-bottom: 1.25rem; }
.intro h1 { font-size: clamp(2.6rem, 9vw, 4.4rem); font-weight: 700; color: var(--ink); }
.lede { color: var(--ink-2); font-size: 1.1rem; margin-top: 0.6rem; max-width: 34rem; }

.finder-grid { display: grid; gap: 1.25rem; }
.form.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; border: 1px solid var(--line-2); }
.roll-input { font-family: var(--font-display); font-weight: 600; font-size: 1.9rem; letter-spacing: 0.06em; text-transform: uppercase; min-height: 60px; }
.roll-input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 500; color: #9aa8b8; }
details.extra { margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
details.extra summary { cursor: pointer; padding: 0.75rem 0.9rem; font-weight: 700; min-height: 44px; }
details.extra .extra-body { padding: 0 0.9rem 0.4rem; display: grid; gap: 0.2rem; }
.form-message { min-height: 0; margin-bottom: 0.9rem; }
.form-message:empty { display: none; }

/* the route panel */
.route { background: var(--ink); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.1rem 1.4rem; }
.route:focus { outline: none; }
.route-head { margin-bottom: 1.1rem; }
.route-title { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; margin: 0; line-height: 1.15; }
.route-sub { color: #b6c3d4; margin: 0.25rem 0 0; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { position: relative; display: flex; gap: 0.9rem; align-items: center; padding: 0.55rem 0 1.1rem; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 21px; top: 3.1rem; bottom: -0.25rem; width: 2px;
  background: repeating-linear-gradient(to bottom, #4a6a94 0 6px, transparent 6px 11px);
}
.node { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid #4a6a94; display: grid; place-items: center; color: #b6c3d4; background: var(--ink); z-index: 1; }
.node svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.step .label { font-size: 0.95rem; color: #b6c3d4; font-weight: 400; margin: 0; }
.step .value { display: block; font-family: var(--font-display); font-weight: 600; font-size: 2.1rem; line-height: 1.05; overflow-wrap: anywhere; }
.route[data-state="empty"] .step .value, .route[data-state="message"] .step .value { color: rgba(255, 255, 255, 0.28); }
.route[data-state="message"] .steps { opacity: 0.45; }
.step.seat { margin-top: 0.15rem; padding: 0.9rem 1rem; border-radius: 10px; background: #1a3352; }
.step.seat .node { border-color: var(--signal); color: var(--signal-ink); background: var(--signal); }
.step.seat .value { font-size: 3.6rem; color: var(--signal); }
.route[data-state="empty"] .step.seat .value, .route[data-state="message"] .step.seat .value { color: rgba(255, 199, 44, 0.3); }
.route[data-state="found"] .step.seat { background: var(--signal); }
.route[data-state="found"] .step.seat .label { color: #5a4600; }
.route[data-state="found"] .step.seat .value { color: var(--signal-ink); }
.route[data-state="found"] .step.seat .node { background: var(--signal-ink); color: var(--signal); border-color: var(--signal-ink); }
.route[data-state="found"] .step.seat.unassigned .value { font-size: 1.5rem; }
.route[aria-busy="true"] .steps { opacity: 0.5; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; margin: 1.4rem 0 0; padding-top: 1.1rem; border-top: 1px solid #2c4666; }
.facts div { min-width: 0; }
.facts dt { font-size: 0.85rem; color: #b6c3d4; }
.facts dd { margin: 0.1rem 0 0; font-weight: 700; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.route-actions { margin-top: 1.25rem; }
.route-actions .btn { background: transparent; color: #fff; border-color: #4a6a94; width: 100%; }
.route-actions .btn:hover { border-color: #fff; }

@keyframes light-up { from { opacity: 0.15; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .route.reveal .step { animation: light-up 0.4s ease-out both; }
  .route.reveal .step:nth-child(2) { animation-delay: 0.12s; }
  .route.reveal .step:nth-child(3) { animation-delay: 0.24s; }
  .route.reveal .step:nth-child(4) { animation-delay: 0.36s; }
}

.foot { padding-top: 1.2rem; padding-bottom: 1.6rem; color: var(--ink-3); font-size: 0.9rem; }
.foot p { max-width: 40rem; margin: 0; }

@media (min-width: 900px) {
  .finder { padding-top: 2.75rem; }
  .finder-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; gap: 2rem; }
  .form.card { padding: 1.5rem; }
  .route { position: sticky; top: 1rem; padding: 1.75rem 1.75rem 1.9rem; }
  .step .value { font-size: 2.4rem; }
  .step.seat .value { font-size: 4.4rem; }
  .facts { grid-template-columns: repeat(3, 1fr); }
  .route-actions .btn { width: auto; }
}

/* ---------------------------------------------------------------- generic pages (login, errors) */
.center-page { flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }
.center-card { width: 100%; max-width: 420px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.6rem; border: 1px solid var(--line-2); }
.center-card h1 { font-size: 2.2rem; margin-bottom: 0.4rem; }

/* ---------------------------------------------------------------- admin console */
.shell { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 0.6rem 0.8rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; }
.side .brand { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; margin-right: auto; }
.side .brand svg { width: 24px; height: 24px; color: var(--signal); }
.side nav { display: flex; gap: 0.25rem; overflow-x: auto; width: 100%; order: 3; padding-bottom: 0.2rem; }
.side nav a { color: #d5e0ee; text-decoration: none; padding: 0.55rem 0.8rem; border-radius: 8px; white-space: nowrap; font-weight: 700; min-height: 40px; display: inline-flex; align-items: center; }
.side nav a:hover { background: #1a3352; }
.side nav a[aria-current="page"] { background: var(--signal); color: var(--signal-ink); }
.side .who { font-size: 0.875rem; color: #b6c3d4; display: flex; align-items: center; gap: 0.6rem; }
.side .who .btn { background: transparent; color: #fff; border-color: #4a6a94; min-height: 34px; padding: 0.35rem 0.7rem; font-size: 0.875rem; }
.admin-main { padding: 1.1rem 1rem 3rem; min-width: 0; }
.admin-main h1 { font-size: 2.2rem; margin-bottom: 1rem; }
.admin-main h2 { font-size: 1.45rem; margin: 1.6rem 0 0.7rem; }
.page-head { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.back { display: inline-block; margin-bottom: 0.4rem; font-size: 0.925rem; }

.panel { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1.25rem; }
.panel > h2:first-child { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.4rem; }
.stat { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); }
.stat .n { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.stat .t { color: var(--ink-2); margin-top: 0.3rem; font-size: 0.925rem; }
.stat.attention { border-left: 5px solid var(--signal); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--card); }
.panel .table-wrap { border: 0; border-radius: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
table.data th, table.data td { padding: 0.65rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data th { background: #f6f8fb; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { display: flex; flex-wrap: wrap; gap: 0.35rem; min-width: 11rem; }
table.data td .btn-row { gap: 0.35rem; }
table.data .actions form { margin: 0; }
.empty-state { padding: 2rem 1rem; text-align: center; color: var(--ink-2); }

.pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.825rem; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.active, .pill.completed { background: var(--ok-tint); color: var(--ok); }
.pill.inactive, .pill.queued { background: #e8edf2; color: var(--ink-2); }
.pill.processing { background: var(--route-tint); color: var(--route-dark); }
.pill.warnings { background: var(--warn-tint); color: var(--warn); }
.pill.failed, .pill.error { background: var(--err-tint); color: var(--err); }
.pill.warning { background: var(--warn-tint); color: var(--warn); }
.pill.info { background: var(--route-tint); color: var(--route-dark); }

.grid-form { display: grid; gap: 0.9rem; grid-template-columns: 1fr; }
.upload-rows { display: grid; gap: 0.75rem; margin: 0.8rem 0; }
.upload-row { border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem; background: #f8fafc; display: grid; gap: 0.6rem; }
.upload-row .fname { font-weight: 700; overflow-wrap: anywhere; }
.upload-row .cols { display: grid; gap: 0.6rem; grid-template-columns: 1fr; }
details.adv { border: 1px solid var(--line); border-radius: 8px; padding: 0 0.9rem; margin: 0.9rem 0; }
details.adv summary { cursor: pointer; padding: 0.7rem 0; font-weight: 700; }
details.adv .grid-form { padding-bottom: 0.9rem; }

.filters { display: grid; gap: 0.6rem; grid-template-columns: 1fr 1fr; align-items: end; }
.filters .full { grid-column: 1 / -1; }
.filters label { font-size: 0.85rem; margin-bottom: 0.15rem; }
.filters input, .filters select { min-height: 40px; padding: 0.45rem 0.6rem; }
.pager { display: flex; gap: 0.5rem; align-items: center; justify-content: space-between; margin-top: 0.9rem; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 0; }
.kv dt { font-size: 0.85rem; color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.issue-msg { min-width: 14rem; }
.issue-ctx { display: block; margin-top: 0.2rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--ink-3); overflow-wrap: anywhere; }
.inline-form { display: inline; }
.progress-note { display: flex; gap: 0.6rem; align-items: center; }
.spinner { width: 16px; height: 16px; border: 3px solid #b9c9f5; border-top-color: var(--route); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .grid-form.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid-form.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .upload-row .cols { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .kv { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 980px) {
  .shell { grid-template-columns: 236px minmax(0, 1fr); }
  .side { flex-direction: column; align-items: stretch; flex-wrap: nowrap; padding: 1.1rem 0.9rem; position: sticky; top: 0; height: 100vh; }
  .side .brand { margin: 0 0 1rem; font-size: 1.4rem; }
  .side nav { flex-direction: column; order: 0; overflow: visible; width: auto; }
  .side .who { order: 5; margin-top: auto; flex-direction: column; align-items: flex-start; }
  .admin-main { padding: 1.75rem 2rem 3rem; }
}

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.btn-row.mt { margin-top: 1rem; }
.btn-row form { margin: 0; }
