/* NEURON ACADEMY OMR System — navy, white, subtle teal */
:root {
  --navy: #1e3a8a; --navy-700: #1b3277; --navy-900: #13245a; --navy-50: #eef2fa; --navy-100: #dbe3f4;
  --teal: #0e9c99; --teal-700: #0b7d7a; --teal-50: #e6f6f5;
  --bg: #f4f6fb; --surface: #ffffff; --text: #1c2434; --muted: #5f6b7d; --faint: #8a94a6;
  --border: #dde3ee; --border-strong: #c5cee0;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #a15c07; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --info: #1d4ed8; --info-bg: #dbeafe; --neutral-bg: #eef1f6;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(19, 36, 90, .06), 0 2px 8px rgba(19, 36, 90, .06);
  --shadow-lg: 0 12px 40px rgba(19, 36, 90, .22);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sidebar: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); }
a { color: var(--navy); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--navy-900); }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
svg.ico { width: 1.1em; height: 1.1em; vertical-align: -0.2em; flex: none; }
.empty .ill svg.ico { width: 28px; height: 28px; }
.drop svg.ico { width: 30px; height: 30px; }

.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); text-align: center; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--navy-900), var(--navy) 70%); color: #fff; display: flex;
  flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand img { width: 44px; height: 44px; border-radius: 50%; background: #fff; padding: 2px; }
.brand .name { font-weight: 750; letter-spacing: .4px; font-size: 15px; line-height: 1.15; }
.brand .prog { font-size: 10.5px; color: #9fe3df; letter-spacing: .6px; font-weight: 600; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #dbe4ff;
  text-decoration: none; font-weight: 550; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 #3fd1cc; }
.nav .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 8px 6px; }
.sidebar .foot { padding: 12px 16px; font-size: 11.5px; color: #b8c6f0; border-top: 1px solid rgba(255,255,255,.12); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 26px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .crumbs { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumbs a { text-decoration: none; }
.menu-btn { display: none; }
.userchip { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); cursor: pointer; }
.userchip .av { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: grid;
  place-items: center; font-size: 12px; font-weight: 700; }
.queue-pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--info-bg); color: var(--info); font-weight: 600; }
.content { padding: 22px 26px 40px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card > .hd h2, .card > .hd h3 { flex: 1; }
.card > .bd { padding: 16px 18px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--navy); }
.tile.teal::after { background: var(--teal); } .tile.warn::after { background: #e4a11b; }
.tile.ok::after { background: var(--ok); } .tile.bad::after { background: var(--bad); }
.tile .lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.tile .val { font-size: 27px; font-weight: 750; color: var(--navy-900); margin-top: 2px; }
.tile .hint { font-size: 12px; color: var(--faint); }
a.tile { text-decoration: none; color: inherit; }
a.tile:hover { border-color: var(--border-strong); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--navy-900); font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--navy-50); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-700); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.teal:hover { background: var(--teal-700); }
.btn.danger { color: var(--bad); border-color: #f0b4b4; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--navy-50); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 11px 18px; font-size: 15px; }
.btn .ico { width: 16px; height: 16px; }
.linkbtn { background: none; border: 0; color: var(--navy); cursor: pointer; padding: 0; font-weight: 600; text-decoration: underline; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: attr(data-icon); font-size: 10.5px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.teal { background: var(--teal-50); color: var(--teal-700); }
.badge.neutral { background: var(--neutral-bg); color: var(--muted); }
.badge.muted { background: #f1f2f4; color: var(--faint); }
.badge.outline { background: transparent; border-color: var(--border-strong); color: var(--muted); }

/* ---------- forms ---------- */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
label.f .req { color: var(--bad); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text);
  font-size: 14px; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,156,153,.15); }
textarea { min-height: 80px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--navy); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.help { font-size: 12px; color: var(--faint); font-weight: 400; }
.search { position: relative; min-width: 220px; }
.search input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .45px; color: var(--muted);
  font-weight: 700; padding: 10px 12px; background: #f8fafd; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid #edf0f6; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafbfe; }
table.t tr.click { cursor: pointer; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.t.compact td, table.t.compact th { padding: 6px 9px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

/* ---------- empty / alerts ---------- */
.empty { text-align: center; padding: 38px 18px; color: var(--muted); }
.empty .ill { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; background: var(--navy-50); display: grid; place-items: center; color: var(--navy); }
.empty h3 { margin-bottom: 4px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; border: 1px solid; font-size: 13.5px; }
.alert .ico { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.alert.warn { background: #fffaeb; border-color: #f6d58a; color: #6e4204; }
.alert.bad { background: #fff5f5; border-color: #f2b8b8; color: #7f1414; }
.alert.info { background: #f2f7ff; border-color: #bcd3fb; color: #173f8f; }
.alert.ok { background: #f2fbf5; border-color: #a7e3bd; color: #135c2f; }
.alert .grow { flex: 1; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--navy); }
.tabs a.active { color: var(--navy); border-bottom-color: var(--teal); }
.tabs a .count { font-size: 11px; background: var(--navy-50); color: var(--navy); border-radius: 999px; padding: 1px 7px; margin-left: 5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: #fff; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- progress ---------- */
.bar { height: 8px; background: var(--navy-50); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--navy)); border-radius: 999px; }
.bar.ok > span { background: var(--ok); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 26, 60, .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .12s ease; }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(900px, 100%); }
.modal.xwide { width: min(1200px, 100%); }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal .mh h2 { flex: 1; }
.modal .mb { padding: 18px 20px; overflow-y: auto; }
.modal .mf { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--navy-900); color: #fff; padding: 11px 15px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: fade .15s ease; }
.toast.ok { background: #14532d; } .toast.bad { background: #7f1d1d; } .toast.warn { background: #713f12; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .hero { background: radial-gradient(circle at 20% 15%, #2a4db3 0, var(--navy) 40%, var(--navy-900) 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login .hero img { width: 120px; height: 120px; border-radius: 50%; background: #fff; padding: 4px; }
.login .hero h1 { color: #fff; font-size: 32px; letter-spacing: .5px; }
.login .hero .prog { color: #8ee6e1; font-weight: 700; letter-spacing: 1.2px; }
.login .hero ul { margin: 6px 0 0; padding-left: 18px; color: #d7e0ff; line-height: 1.8; }
.login .panel { display: grid; place-items: center; padding: 32px; }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }

/* ---------- answer key editor ---------- */
.key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.key-col { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.key-col .kh { background: var(--navy); color: #fff; padding: 8px 12px; font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; }
.key-row { display: grid; grid-template-columns: 38px repeat(4, 1fr) 30px; align-items: center; gap: 4px; padding: 3px 8px; border-bottom: 1px solid #f0f2f7; }
.key-row:nth-child(odd) { background: #fafbfe; }
.key-row.focus { background: var(--teal-50) !important; box-shadow: inset 3px 0 0 var(--teal); }
.key-row.missing .qn { color: var(--bad); }
.key-row .qn { font-weight: 700; font-size: 13px; text-align: right; padding-right: 4px; color: var(--navy-900); }
.opt { height: 26px; border-radius: 50%; border: 1.6px solid var(--navy); background: #fff; color: var(--navy); font-size: 12px; font-weight: 700; cursor: pointer; width: 26px; justify-self: center; padding: 0; }
.opt.on { background: var(--navy); color: #fff; }
.opt:hover { box-shadow: 0 0 0 3px rgba(30,58,138,.15); }
.key-extra { font-size: 11px; font-weight: 700; color: var(--teal-700); text-align: center; }
.key-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
kbd { font-family: var(--mono); font-size: 11.5px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: #fff; }

/* ---------- upload ---------- */
.drop { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 34px 18px; text-align: center; background: #fbfcfe; cursor: pointer; transition: all .15s; }
.drop:hover, .drop.over { border-color: var(--teal); background: var(--teal-50); }
.drop .big { font-size: 16px; font-weight: 700; color: var(--navy-900); }
.filelist { display: flex; flex-direction: column; gap: 6px; }
.fileitem { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.fileitem .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* ---------- review centre ---------- */
.review { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, 1fr); gap: 16px; align-items: start; }
.viewer { position: sticky; top: 70px; }
.viewer .vbar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.viewport { height: calc(100vh - 175px); min-height: 420px; overflow: auto; background: #5c6475; position: relative; border-radius: 0 0 var(--radius) var(--radius); }
.stage { position: relative; margin: 0 auto; transform-origin: 0 0; }
.stage img { display: block; width: 100%; height: auto; user-select: none; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ov-b { fill: none; stroke-width: 3.5; }
.ov-b.det { stroke: #2563eb; }
.ov-b.final { stroke: #16a34a; stroke-width: 5; }
.ov-b.pend { stroke: #f59e0b; stroke-width: 5; stroke-dasharray: 8 5; }
.ov-row { fill: rgba(14,156,153,.12); stroke: var(--teal); stroke-width: 3; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.qcol h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 0 0 4px; }
.qcells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.qcell { border: 1px solid var(--border); border-radius: 6px; padding: 3px 0 2px; text-align: center; cursor: pointer; background: #fff; line-height: 1.1; position: relative; }
.qcell .n { font-size: 10px; color: var(--faint); display: block; }
.qcell .a { font-size: 13.5px; font-weight: 750; color: var(--navy-900); }
.qcell.pend { background: var(--warn-bg); border-color: #f2c766; }
.qcell.pend .a { color: var(--warn); }
.qcell.inv .a { color: var(--bad); font-size: 11px; }
.qcell.blank .a { color: var(--faint); }
.qcell.manual::after { content: "✎"; position: absolute; top: 0; right: 2px; font-size: 9px; color: var(--teal-700); }
.qcell.flag { box-shadow: inset 0 -2px 0 #f59e0b; }
.qcell.correct { border-color: #9bd8b1; } .qcell.incorrect { border-color: #f0a9a9; }
.qcell.sel { outline: 2.5px solid var(--teal); outline-offset: 1px; }
.qcell.out { opacity: .4; }
.flagged { display: flex; flex-direction: column; gap: 10px; }
.fq { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff; }
.fq.sel { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,156,153,.15); }
.fq .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.fq .qno { font-weight: 800; color: var(--navy-900); font-size: 15px; }
.fq img.crop { display: block; max-width: 100%; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.fq .opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fq .opts .btn { min-width: 40px; }
.cov { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.field-row:last-child { border-bottom: 0; }
.field-row img { width: 100%; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.ocr { font-size: 11.5px; color: var(--muted); }
.stu-card { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid #a7e3bd; background: #f2fbf5; border-radius: 9px; }
.stu-card .av { width: 38px; height: 38px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 800; }
.score-big { font-size: 30px; font-weight: 800; color: var(--navy-900); }

/* ---------- misc ---------- */
.hbar { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; margin: 6px 0; }
.hbar .bar { height: 10px; }
pre.json { background: #f7f8fb; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.overlay-img { border: 1px solid var(--border); border-radius: 8px; max-height: 70vh; overflow: auto; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .review { grid-template-columns: 1fr; }
  .viewer { position: static; }
  .viewport { height: 62vh; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 32px; }
  .topbar { padding: 10px 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login .hero { padding: 32px 22px; }
  .kv { grid-template-columns: 120px 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .actions, .tabs { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}
.split-side { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.split-side.wide { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1180px) { .split-side, .split-side.wide { grid-template-columns: 1fr; } }
/* grid children may shrink below their content (the scan viewer sizes itself to its column) */
.grid > *, .review > *, .stack > * { min-width: 0; }
@media (max-width: 1180px) { .review { grid-template-columns: minmax(0, 1fr); } }
