/* Application shell for the customer dashboard and the admin console. Uses the tokens
   defined in tsx.css; adds only layout and app-specific pieces. */

.app { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .app { grid-template-columns: 252px minmax(0, 1fr); }
  /* The side panel is fixed (out of flow), so the content column is placed explicitly: without
     this the grid would auto-place the page into the panel's own track. */
  .app > :not(.side) { grid-column: 2; } }

/* The side panel is the brand's night ground in both themes. It is exactly one screen tall and
   never scrolls with the page: the brand and the footer stay put, and only the menu between them
   scrolls on a very short screen, so nothing is ever cut off. It is FIXED, not sticky: a sticky
   panel is confined to the grid's height, and anything that makes the document taller than the
   grid (an absolutely positioned element, a late-rendered table) pushed it up and left a blank
   strip under it at the end of a long scroll. The grid still reserves its column. */
.side { display: none; position: fixed; top: 0; left: 0; width: 252px; height: 100vh; height: 100dvh; overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--night); color: var(--night-muted); border-right: 1px solid var(--night-rule); padding: 16px 12px 14px;
  --rule: var(--night-rule); --sheet: var(--night-2); --sheet-2: #1a2238; --ink: var(--night-ink); --ink-2: #c3c8d8; --muted: var(--night-muted); }
@media (min-width: 1000px) { .side { display: grid; } }
.side .brand { padding: 4px 12px 14px; color: #fff; }
.side #sideNav { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.side-group { font-size: var(--t-xs); color: #98a0b6; padding: 12px 14px 4px; }  /* 5.9:1 on the night panel */
.side-group:first-child { padding-top: 4px; }
.side a.item { position: relative; display: flex; align-items: center; gap: 11px; padding: 7px 14px; border-radius: var(--r-s); color: #c3c8d8; text-decoration: none; font-size: var(--t-sm); font-weight: 500; }
.side a.item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side a.item[aria-current="page"] { background: rgba(124, 120, 245, .16); color: #fff; }
.side a.item[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--track-b); border-radius: 2px; }
.side a.item svg { width: 17px; height: 17px; flex: none; }
.side-foot { padding: 12px 10px 0; border-top: 1px solid var(--night-rule); font-size: var(--t-xs); color: var(--night-muted); display: grid; gap: 8px; }
.side-foot a { color: #c3c8d8; }
.side-foot a:hover { color: #fff; }
.side .theme-switch { border-color: var(--night-rule); justify-self: start; }
.side .theme-switch button { color: var(--night-muted); }
.side .theme-switch button[aria-pressed="true"] { background: #fff; color: var(--night); }
.side-toggle { display: flex; align-items: center; gap: 11px; width: 100%; padding: 7px 4px; background: none; border: 0; border-radius: var(--r-s); color: var(--night-muted); font: 500 var(--t-xs) var(--f-text); cursor: pointer; }
.side-toggle:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.side-toggle svg { width: 17px; height: 17px; flex: none; transition: transform .2s; }

/* Narrow: the panel keeps only its icons, which name themselves on hover. The menu stays where it
   was, so the icons sit exactly under the place each label used to start. */
@media (min-width: 1000px) {
  .side-narrow .app { grid-template-columns: 72px minmax(0, 1fr); }
  .side-narrow .side { width: 72px; padding-inline: 10px; }
  .side-narrow .side .brand { padding: 4px 0 14px; justify-content: center; }
  .side-narrow .side .wordmark, .side-narrow .side-group, .side-narrow .side-foot > :not(.side-toggle) { display: none; }
  .side-narrow .side #sideNav { gap: 4px; padding-top: 8px; }
  .side-narrow .side a.item { justify-content: center; padding: 10px 0; font-size: 0; gap: 0; }
  .side-narrow .side-foot { padding-inline: 0; }
  .side-narrow .side-toggle { justify-content: center; padding: 9px 0; }
  .side-narrow .side-toggle span { display: none; }
  .side-narrow .side-toggle svg { transform: scaleX(-1); }
}
@media (prefers-reduced-motion: reduce) { .side-toggle svg { transition: none; } }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 clamp(16px, 3vw, 48px); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.topbar .brand { display: inline-flex; }
@media (min-width: 1000px) { .topbar .brand { display: none; } }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: var(--t-sm); min-width: 0; }
.topbar .who .email { color: var(--muted); max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }
@media (min-width: 640px) { .topbar .who .email { display: inline; } }
.credit-pill { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--sheet); font-size: var(--t-xs); white-space: nowrap; }
.credit-pill b { font: 600 var(--t-sm) var(--f-mono); font-variant-numeric: tabular-nums; }

.mobile-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 var(--gutter); border-bottom: 1px solid var(--rule); background: var(--sheet); }
@media (min-width: 1000px) { .mobile-tabs { display: none; } }
.mobile-tabs a { padding: 11px 10px; font-size: var(--t-sm); color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.mobile-tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

.view { padding: clamp(20px, 3vw, 40px) clamp(16px, 3vw, 48px) 72px; max-width: 1680px; }
.view-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.view-head h1 { font-size: clamp(1.6rem, 3vw, var(--t-3xl)); margin: 0; }
.view-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.grid-2 { display: grid; gap: 20px; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .grid-2.wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.stack-lg > * + * { margin-top: 20px; }

/* Key figures across the top of a view: a ruled strip, not cards. */
/* The dividers are the 1px gaps over the rule colour, so they sit between cells however the row
   wraps, and a part-filled last row is closed with the sheet colour rather than left grey. */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r-m); overflow: hidden; }
.strip > div { padding: 16px 18px; background: var(--sheet); }
.strip > :last-child { grid-column: auto / -1; }
.strip .k { font-size: var(--t-xs); color: var(--muted); }
.strip .v { display: block; margin-top: 4px; font: 700 var(--t-2xl)/1.1 var(--f-display); font-stretch: 108%; font-variant-numeric: tabular-nums; }
.strip .s { display: block; margin-top: 2px; font-size: var(--t-xs); color: var(--muted); }

/* Charts */
.chart { width: 100%; height: 220px; }
.chart .bar-pass { fill: var(--pass); }
.chart .bar-review { fill: var(--review); }
.chart .bar-flag { fill: var(--flag); }
.chart .axis { stroke: var(--rule); }
.chart text { fill: var(--muted); font: 11px var(--f-text); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--t-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; display: inline-block; }
.legend .pass i { background: var(--pass); border-radius: 50%; }
.legend .review i { background: var(--review); transform: rotate(45deg) scale(.85); }
.legend .flag i { background: var(--flag); }

/* Image check */
.drop { display: grid; place-items: center; gap: 8px; min-height: 220px; padding: 24px; border: 1.5px dashed var(--rule); border-radius: var(--r-m); background: var(--sheet); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--stamp); background: var(--stamp-wash); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { font-size: var(--t-md); }
.examined { position: relative; border: 1px solid var(--rule-strong); border-radius: var(--r-m); overflow: hidden; background: var(--sheet-2); }
.examined img { width: 100%; height: auto; }
.examined .box { position: absolute; border: 2px solid var(--flag); box-shadow: 0 0 0 1px #fff9; }
.examined .box.faint { border-style: dashed; border-width: 1.5px; }
.examined .box span { position: absolute; left: -2px; bottom: calc(100% + 2px); background: var(--flag); color: #fff; font: 600 10px/1 var(--f-mono); padding: 3px 5px; white-space: nowrap; }
.outline-only { aspect-ratio: var(--ar, 4 / 3); background: repeating-linear-gradient(45deg, var(--sheet-2) 0 10px, var(--sheet) 10px 20px); }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.result-head .answer { font: 700 var(--t-xl)/1.1 var(--f-display); font-stretch: 110%; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: var(--t-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd.mono, .kv dd code { font-family: var(--f-mono); font-size: .85rem; }
.indicator { padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: var(--t-sm); }
.indicator:last-child { border-bottom: 0; }
.indicator .meta { display: block; margin-top: 3px; font: 400 var(--t-xs) var(--f-mono); color: var(--muted); }

/* Filters bar */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.filters .field > label { font-size: var(--t-xs); font-weight: 500; color: var(--muted); }
.filters :is(input, select) { width: 100%; min-width: 0; height: 40px; }
/* Pager under every long list: summary, rows per page, Previous, page numbers, Next. Numbers are
   real buttons (keyboard and screen readers get them); the current page is marked, not just
   coloured. On a phone the numbers give way to "Page 3 of 50". */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 16px; border-top: 1px solid var(--rule); font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.pager[hidden] { display: none; }
.pager-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.pager-size { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; font-size: var(--t-xs); }
.pager-size select { height: 32px; padding: 0 8px; font-size: var(--t-xs); }
.pager-pages { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.pager-pages .gap { padding: 0 4px; color: var(--muted); }
.pager .page { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--r-s); background: none; color: var(--ink); font: inherit; font-size: var(--t-xs); cursor: pointer; }
.pager .page:hover { border-color: var(--rule); background: var(--sheet-2); }
.pager .page[aria-current="page"] { background: var(--stamp); border-color: var(--stamp); color: var(--stamp-ink); cursor: default; font-weight: 600; }
.pager .page:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pager-compact { display: none; padding: 0 4px; color: var(--ink); }
@media (max-width: 720px) {
  .pager-pages { display: none; }
  .pager-compact { display: inline; }
  .pager-ctl { width: 100%; justify-content: space-between; margin-left: 0; }
  .pager-size { margin-right: auto; }
}

/* Secrets shown once */
.secret { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--r-m); background: var(--code-bg); color: var(--code-ink); font: 500 .9rem var(--f-mono); word-break: break-all; }
.secret code { flex: 1 1 260px; background: none; padding: 0; color: inherit; }
.backup-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; font: 500 var(--t-md) var(--f-mono); padding: 14px 16px; background: var(--sheet-2); border-radius: var(--r-m); }
.qr { width: 200px; max-width: 100%; padding: 8px; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-m); }
.qr svg { width: 100%; height: auto; }

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--rule); margin: 0; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { flex: none; width: 20px; height: 20px; margin-top: 2px; border: 1.5px solid var(--rule); border-radius: 50%; display: grid; place-items: center; }
.checklist li.done .mark { background: var(--pass); border-color: var(--pass); }
.checklist li.done .mark::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.checklist li.done .what { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--rule); }

/* Auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .auth { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.auth-side { display: none; position: relative; overflow: hidden; isolation: isolate; background: var(--night) radial-gradient(ellipse at 80% 110%, rgba(79, 70, 229, .35), transparent 60%); color: var(--night-ink); padding: 48px; flex-direction: column; justify-content: space-between; }
@media (min-width: 960px) { .auth-side { display: flex; } }
.auth-side .brand { color: #fff; }
.auth-side blockquote { margin: 0; font: 600 var(--t-xl)/1.35 var(--f-display); font-stretch: 105%; max-width: 30ch; }
.auth-side .facts { display: grid; gap: 10px; font-size: var(--t-sm); color: color-mix(in srgb, var(--paper) 72%, transparent); }
.auth-main { display: grid; place-items: center; padding: 32px var(--gutter); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h1 { font-size: var(--t-3xl); }
.steps-note { display: flex; gap: 8px; font-size: var(--t-xs); color: var(--muted); margin-bottom: 18px; }
.steps-note b { color: var(--ink); }

.role-note { font-size: var(--t-xs); color: var(--muted); }
[hidden] { display: none !important; }
.view:focus { outline: none; }
.grid-2 > *, .demo-grid > *, .app > *, .strip > *, .filters > * { min-width: 0; }
/* Short laptop screens: the footer keeps only the theme choice, so the whole menu stays in view. */
@media (min-width: 1000px) and (max-height: 720px) {
  .side-foot > :not(.theme-switch):not(.side-toggle) { display: none; }
  .side .brand { padding-bottom: 8px; }
}
@media (max-width: 420px) { .topbar .brand .wordmark { display: none; } .topbar { gap: 8px; } }
