/* Components.  Every colour, font, size, radius and spacing value is a token
   from tokens.css (generated from brand/brand.json).  tests/test_ui.py fails
   on any colour or length literal in this file, so a rebrand is one edit. */

*, *::before, *::after { box-sizing: border-box; }

/* A layout class setting display would otherwise override the hidden
   attribute and show steps a screen meant to hide (it did: the sign-in form
   stayed visible under the two-factor step). */
[hidden] { display: none !important; }

html {
  color-scheme: light dark;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  -webkit-font-smoothing: antialiased;
}

body { margin: 0; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand-link); }
img { max-width: 100%; }

:focus-visible {
  outline: calc(var(--border-width) * 2) solid var(--brand-primary);
  outline-offset: var(--space-1);
}

/* Numbers are the product.  Monospaced, tabular, right-aligned, so a
   variance column can be read down without the digits wandering. */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-sm); }

/* --- Icons: inline SVG drawn in currentColor --------------------------------- */
.icon { width: var(--space-5); height: var(--space-5); flex: none;
        fill: none; stroke: currentColor; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; }
.icon--lg { width: var(--space-7); height: var(--space-7); }

/* --- Button ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--color-surface-alt); }
.btn--primary { background: var(--brand-primary); border-color: var(--brand-primary);
                color: var(--brand-on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--brand-primary-hover);
                      border-color: var(--brand-primary-hover); }
.btn--accent { background: var(--brand-accent); border-color: var(--brand-accent);
               color: var(--brand-on-accent); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--color-surface-alt); }
.btn--danger { background: var(--status-mismatch); border-color: var(--status-mismatch);
               color: var(--status-on-status); }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-4) var(--space-6); font-size: var(--text-base); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* --- Input ----------------------------------------------------------------- */
.field { display: grid; gap: var(--space-2); }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-bold); }
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.field__error { font-size: var(--text-sm); color: var(--status-mismatch); }
.field__error:empty { display: none; }
.input {
  min-height: calc(var(--space-7) + var(--space-3));
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit; font-size: var(--text-sm);
}
.input:hover { border-color: var(--color-text-muted); }
.input:focus { outline: none; border-color: var(--brand-primary);
               box-shadow: 0 0 0 calc(var(--border-width) * 3) var(--color-surface-alt); }
.input[aria-invalid="true"] { border-color: var(--status-mismatch); }
.input--search { min-width: calc(var(--space-8) * 5); padding-left: var(--space-7); }
.search { position: relative; display: inline-flex; align-items: center; }
.search .icon { position: absolute; left: var(--space-4); color: var(--color-text-muted);
                width: var(--space-5); height: var(--space-5); pointer-events: none; }

/* A toggle switch: a checkbox styled as a switch, label beside it. */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer;
          font-size: var(--text-sm); user-select: none; }
.switch input { appearance: none; margin: 0; flex: none; cursor: pointer;
                width: calc(var(--space-7) + var(--space-2)); height: var(--space-6);
                border-radius: var(--radius-pill); background: var(--color-border);
                position: relative; transition: background 120ms ease; }
.switch input::after { content: ""; position: absolute; top: var(--space-2); left: var(--space-2);
                       width: var(--space-5); height: var(--space-5);
                       border-radius: var(--radius-pill); background: var(--color-surface);
                       box-shadow: var(--shadow-sm); transition: transform 120ms ease; }
.switch input:checked { background: var(--brand-primary); }
.switch input:checked::after { transform: translateX(calc(var(--space-5) - var(--space-1))); }
.switch input:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Table ----------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm);
         line-height: var(--leading-tight); }
.table th, .table td { padding: var(--space-4) var(--space-5);
                       border-bottom: var(--border-width) solid var(--color-border);
                       text-align: left; vertical-align: middle; }
.table th { color: var(--color-text-muted); font-size: var(--text-xs);
            font-weight: var(--weight-bold); text-transform: uppercase;
            background: var(--color-surface-alt); position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-alt); }
.table a { color: var(--brand-primary); font-weight: var(--weight-bold); text-decoration: none; }
.table a:hover { text-decoration: underline; }
/* .table's own cell rule would otherwise win and left-align the numbers. */
.table .num { text-align: right; }
.table th.num { font-family: var(--font-sans); }
/* A table inside a card runs edge to edge. */
.card > .table, .card > .table-scroll { margin: 0 calc(var(--space-6) * -1);
                                        width: calc(100% + var(--space-6) * 2); }
.card > .table:last-child, .card > .table-scroll:last-child
  { margin-bottom: calc(var(--space-6) * -1); }
.card > .table th:first-child, .card > .table td:first-child { padding-left: var(--space-6); }
.card > .table th:last-child, .card > .table td:last-child { padding-right: var(--space-6); }

/* --- Badge ----------------------------------------------------------------- */
/* Status is never colour alone: a badge always carries its word, and the
   markup gives it role="status" text a screen reader announces. */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  line-height: var(--leading-base);
  color: var(--status-on-status);
  background: var(--status-unchecked);
  white-space: nowrap;
}
.badge--match { background: var(--status-match); }
.badge--mismatch { background: var(--status-mismatch); }
.badge--unchecked { background: var(--status-unchecked); }
.badge--review { background: var(--status-review); }
/* A neutral tag (file kinds, floors): no status meaning, so no status colour. */
.tag { display: inline-flex; align-items: center; padding: var(--space-1) var(--space-3);
       border-radius: var(--radius-sm); background: var(--color-surface-alt);
       color: var(--color-text); font-size: var(--text-xs); font-weight: var(--weight-bold);
       text-transform: uppercase; }
.tag--accent { background: var(--brand-accent); color: var(--brand-on-accent); }

/* --- Card ------------------------------------------------------------------ */
.card {
  display: grid; gap: var(--space-5); align-content: start;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  min-width: 0;
}
.card__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4);
              justify-content: space-between; }
.card__title { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold);
               line-height: var(--leading-tight); }
.card__sub { color: var(--color-text-muted); font-size: var(--text-sm); }

/* --- Dialog (native <dialog>: focus trapping and Escape come for free) ------ */
.dialog {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  padding: var(--space-7);
  width: min(100%, calc(var(--space-8) * 10));
}
.dialog::backdrop { background: var(--brand-primary); opacity: 0.4; }
.dialog__title { font-size: var(--text-xl); font-weight: var(--weight-bold); margin-bottom: var(--space-5); }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--space-3);
                   margin-top: var(--space-6); }

/* --- Toast ----------------------------------------------------------------- */
.toast-region { position: fixed; right: var(--space-6); bottom: var(--space-6);
                display: grid; gap: var(--space-3); z-index: 10; }
.toast {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  border-left-width: calc(var(--border-width) * 4);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
}
.toast--error { border-left-color: var(--status-mismatch); }
.toast--success { border-left-color: var(--status-match); }

/* --- Empty state ----------------------------------------------------------- */
.empty { display: grid; justify-items: center; gap: var(--space-4);
         padding: var(--space-8) var(--space-5); text-align: center;
         color: var(--color-text-muted); }
.empty__icon { display: grid; place-items: center; width: var(--space-8); height: var(--space-8);
               border-radius: var(--radius-pill); background: var(--color-surface-alt);
               color: var(--brand-primary); }
.empty__title { margin: 0; color: var(--color-text); font-size: var(--text-lg);
                font-weight: var(--weight-bold); }

@media (prefers-reduced-motion: no-preference) {
  .btn, .input, .table tbody tr, .nav__item, .project-card, .step
    { transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease; }
}

/* --- App frame: sidebar + main column ----------------------------------------- */
/* The window is the frame: the sidebar stays put and only the main column scrolls. */
html:has(body.app), body.app { height: 100%; }
.app { display: grid; grid-template-columns: calc(var(--space-8) * 5) minmax(0, 1fr);
       height: 100%; }
.sidebar { display: flex; flex-direction: column; overflow-y: auto;
           gap: var(--space-6); padding: var(--space-6) var(--space-5);
           background: var(--brand-primary); color: var(--brand-on-primary); }
.sidebar__brand { display: block; padding: 0 var(--space-3); }
.sidebar__brand img { display: block; width: calc(var(--space-8) * 3); height: auto; }
.sidebar__product { font-size: var(--text-xs); font-weight: var(--weight-bold);
                    text-transform: uppercase; opacity: 0.75;
                    padding: 0 var(--space-3); }
.nav { display: grid; gap: var(--space-2); }
.nav__label { padding: var(--space-4) var(--space-3) var(--space-2); font-size: var(--text-xs);
              font-weight: var(--weight-bold); text-transform: uppercase; opacity: 0.6; }
.nav__item { display: flex; align-items: center; gap: var(--space-4);
             padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
             color: inherit; text-decoration: none; font-size: var(--text-sm);
             font-weight: var(--weight-bold); opacity: 0.85; }
.nav__item:hover { background: var(--brand-primary-hover); opacity: 1; }
.nav__item[aria-current="page"] { background: var(--brand-accent); color: var(--brand-on-accent);
                                  opacity: 1; }
.sidebar__user { margin-top: auto; display: grid; gap: var(--space-3);
                 padding: var(--space-4); border-radius: var(--radius-md);
                 background: var(--brand-primary-hover); font-size: var(--text-sm); }
.sidebar__who { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.sidebar__who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; flex: none; width: var(--space-7);
          height: var(--space-7); border-radius: var(--radius-pill);
          background: var(--brand-accent); color: var(--brand-on-accent);
          font-weight: var(--weight-bold); text-transform: uppercase; }
.sidebar .btn { color: var(--brand-on-primary); border-color: currentColor; background: transparent; }
.sidebar .btn:hover { background: var(--brand-primary); }

.main { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.page { width: 100%; max-width: calc(var(--space-8) * 26); margin: 0 auto;
        padding: var(--space-7); display: grid; gap: var(--space-6); align-content: start; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-5);
               justify-content: space-between; }
.page-header__text { display: grid; gap: var(--space-2); min-width: 0; }
.page-title { font-size: var(--text-2xl); font-weight: var(--weight-bold);
              line-height: var(--leading-tight); }
.page-sub { color: var(--color-text-muted); font-size: var(--text-sm); }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--text-sm);
          color: var(--color-text-muted); }
.crumbs a { color: var(--color-text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand-primary); text-decoration: underline; }
.crumbs span[aria-hidden] { opacity: 0.6; }
.page-note { margin-top: auto; padding: var(--space-5) var(--space-7); color: var(--color-text-muted);
             font-size: var(--text-xs); display: flex; align-items: center; gap: var(--space-3);
             border-top: var(--border-width) solid var(--color-border); }


/* --- Layout helpers ------------------------------------------------------------ */
.stack { display: grid; gap: var(--space-5); align-content: start; }
.stack--tight { gap: var(--space-3); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.toolbar .card__title { margin: 0; margin-right: auto; }
.toolbar__gap { flex: 1; }
.grid-2 { display: grid; gap: var(--space-6);
          grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-8) * 9), 1fr)); }
/* Main column and side column; wraps to one column when there is no room. */
.split { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.split > :first-child { flex: 2 1 calc(var(--space-8) * 12); min-width: 0; }
.split > :last-child { flex: 1 1 calc(var(--space-8) * 7); min-width: 0; }

/* --- Headline figures --------------------------------------------------------- */
.kpis { display: grid; gap: var(--space-5);
        grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-8) * 4), 1fr)); }
.kpi { display: grid; gap: var(--space-2); padding: var(--space-5) var(--space-6);
       background: var(--color-surface); border: var(--border-width) solid var(--color-border);
       border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.kpi__label { font-size: var(--text-xs); font-weight: var(--weight-bold);
              text-transform: uppercase; color: var(--color-text-muted); }
.kpi__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
              font-size: var(--text-2xl); font-weight: var(--weight-bold);
              line-height: var(--leading-tight); }
.kpi__note { font-size: var(--text-xs); color: var(--color-text-muted); }

/* --- Workflow steps (project page) --------------------------------------------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.step { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
        gap: var(--space-5); padding: var(--space-4) var(--space-5);
        border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md);
        background: var(--color-surface); }
.step__dot { display: grid; place-items: center; width: var(--space-7); height: var(--space-7);
             border-radius: var(--radius-pill); border: calc(var(--border-width) * 2) solid var(--color-border);
             font-family: var(--font-mono); font-weight: var(--weight-bold); font-size: var(--text-sm);
             color: var(--color-text-muted); }
.step__title { font-weight: var(--weight-bold); }
.step__note { font-size: var(--text-sm); color: var(--color-text-muted); }
.step[data-state="done"] .step__dot { background: var(--status-match); border-color: var(--status-match);
                                      color: var(--status-on-status); }
.step[data-state="current"] { border-color: var(--brand-primary);
                              box-shadow: inset calc(var(--border-width) * 4) 0 0 var(--brand-primary); }
.step[data-state="current"] .step__dot { border-color: var(--brand-primary); color: var(--brand-primary); }
.step[data-state="blocked"] { opacity: 0.6; }

/* Tabs between the legend's two steps. */
.tabs { display: flex; gap: var(--space-2); border-bottom: var(--border-width) solid var(--color-border); }
.tab { display: inline-flex; align-items: center; gap: var(--space-3);
       padding: var(--space-4) var(--space-5); margin-bottom: calc(var(--border-width) * -1);
       border: 0; border-bottom: calc(var(--border-width) * 3) solid transparent;
       background: none; color: var(--color-text-muted); font: inherit; font-weight: var(--weight-bold);
       cursor: pointer; text-decoration: none; }
.tab[aria-selected="true"] { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
.tab__num { display: grid; place-items: center; width: var(--space-6); height: var(--space-6);
            border-radius: var(--radius-pill); background: var(--color-surface-alt);
            font-size: var(--text-xs); }
.tab[aria-selected="true"] .tab__num { background: var(--brand-primary); color: var(--brand-on-primary); }

/* --- Project cards (home) ----------------------------------------------------- */
.projects { display: grid; gap: var(--space-5);
            grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-8) * 6), 1fr)); }
.project-card { display: grid; gap: var(--space-5); padding: var(--space-6);
                background: var(--color-surface); border: var(--border-width) solid var(--color-border);
                border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
                color: inherit; text-decoration: none; }
.project-card:hover { border-color: var(--brand-primary); box-shadow: var(--shadow-md); }
.project-card__top { display: flex; align-items: flex-start; justify-content: space-between;
                     gap: var(--space-4); }
.project-card__name { font-size: var(--text-lg); font-weight: var(--weight-bold);
                      line-height: var(--leading-tight); }
.project-card__figures { display: flex; gap: var(--space-6); }
.figure { display: grid; gap: var(--space-1); }
.figure__value { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: var(--weight-bold); }
.figure__label { font-size: var(--text-xs); color: var(--color-text-muted); }
.project-card__foot { display: flex; justify-content: space-between; font-size: var(--text-xs);
                      color: var(--color-text-muted); padding-top: var(--space-4);
                      border-top: var(--border-width) solid var(--color-border); }
.meter { height: var(--space-3); border-radius: var(--radius-pill); background: var(--color-surface-alt);
         overflow: hidden; }
.meter__bar { height: 100%; background: var(--brand-accent); border-radius: var(--radius-pill); }

/* --- Sign-in screens ----------------------------------------------------------- */
html:has(body.auth), body.auth { height: 100%; }
.auth { display: flex; flex-wrap: wrap; min-height: 100%; }
.auth > * { flex: 1 1 calc(var(--space-8) * 9); }
.auth__brand { display: flex; flex-direction: column; justify-content: space-between;
               gap: var(--space-7); padding: var(--space-8);
               background: var(--brand-primary); color: var(--brand-on-primary); }
.auth__brand img { width: calc(var(--space-8) * 4); height: auto; }
.auth__pitch { display: grid; gap: var(--space-5); max-width: calc(var(--space-8) * 9); }
.auth__pitch h2 { font-size: var(--text-2xl); line-height: var(--leading-tight); }
.auth__points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4);
                font-size: var(--text-sm); }
.auth__points li { display: flex; gap: var(--space-3); align-items: flex-start; }
.auth__points .icon { color: var(--brand-accent); }
.auth__panel { display: grid; place-items: center; padding: var(--space-7); }
.auth__card { width: min(100%, calc(var(--space-8) * 8)); }
.auth__card .btn--primary { width: 100%; }
.qr { justify-self: center; border-radius: var(--radius-md); }
.codes { display: grid; grid-template-columns: repeat(2, auto); gap: var(--space-2) var(--space-6);
         margin: 0; padding-left: var(--space-6); font-family: var(--font-mono); }

/* --- Old frame, kept for any page not yet moved to the sidebar ------------------ */
.topbar { display: flex; justify-content: space-between; align-items: center;
          padding: var(--space-3) var(--space-5);
          border-bottom: var(--border-width) solid var(--color-border);
          background: var(--color-surface); }
.topbar__user { display: flex; align-items: center; gap: var(--space-4);
                color: var(--color-text-muted); font-size: var(--text-sm); }
.topbar a { color: inherit; text-decoration: none; }

/* A warning the reader must see before trusting the numbers beside it. */
.notice { margin: 0; padding: var(--space-4) var(--space-5);
          border: var(--border-width) solid var(--color-border);
          border-left: calc(var(--border-width) * 4) solid var(--status-review);
          border-radius: var(--radius-md); background: var(--color-surface-alt);
          font-size: var(--text-sm); }
.notice--info { border-left-color: var(--brand-primary); }
.notice--done { border-left-color: var(--status-match); }
.dropzone { display: grid; gap: var(--space-3); justify-items: center;
            padding: var(--space-7); text-align: center; cursor: pointer;
            border: calc(var(--border-width) * 2) dashed var(--color-border);
            border-radius: var(--radius-lg); color: var(--color-text-muted);
            background: var(--color-surface-alt); }
.dropzone:hover, .dropzone[data-over] { border-color: var(--brand-primary); }
.dropzone strong { color: var(--color-text); }
.dropzone input { position: absolute; opacity: 0; width: var(--border-width); height: var(--border-width); }
.dropzone .icon { color: var(--brand-primary); }
progress { width: 100%; height: var(--space-3); accent-color: var(--brand-accent); }
fieldset.field { border: 0; margin: 0; padding: 0; }

/* Plan picker: each plan a checkable chip. */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.chip { display: inline-flex; align-items: center; gap: var(--space-3);
        padding: var(--space-3) var(--space-4); border: var(--border-width) solid var(--color-border);
        border-radius: var(--radius-pill); font-size: var(--text-sm); cursor: pointer;
        background: var(--color-surface); }
.chip:has(input:checked) { border-color: var(--brand-primary); background: var(--color-surface-alt); }

/* --- Legend onboarding ---------------------------------------------------------- */
.legend-img { display: block; max-height: calc(var(--space-8) * 1); background: var(--color-surface);
              border-radius: var(--radius-sm); }
.table-picks { display: grid; gap: var(--space-4);
               grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-8) * 5), 1fr)); }
.table-pick { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5);
              border: var(--border-width) solid var(--color-border);
              border-radius: var(--radius-md); background: var(--color-surface); cursor: pointer; }
.table-pick:has(input:checked) { border-color: var(--brand-primary);
  box-shadow: inset 0 0 0 var(--border-width) var(--brand-primary); }
.table-pick__head { display: flex; align-items: center; gap: var(--space-3);
                    font-weight: var(--weight-bold); font-size: var(--text-sm); }
.table-pick__preview { display: flex; gap: var(--space-3); align-items: center; min-height: var(--space-7); }
.table-pick .legend-img { max-height: var(--space-7); max-width: calc(var(--space-8) * 1.5); }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.row { display: grid; align-items: center; gap: var(--space-5);
       grid-template-columns: var(--space-6) calc(var(--space-8) * 2) minmax(0, 1fr) auto;
       padding: var(--space-4) var(--space-5); border-radius: var(--radius-md);
       border: var(--border-width) solid var(--color-border); background: var(--color-surface); }
.row[data-device="false"] { background: var(--color-surface-alt); }
.row[data-device="false"] .row__meaning { opacity: 0.5; }
.row__n { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); }
.row__symbol { display: flex; align-items: center; justify-content: center; overflow: hidden;
               height: calc(var(--space-8) * 1.25); padding: var(--space-2);
               border-radius: var(--radius-md); background: var(--color-surface);
               border: var(--border-width) solid var(--color-border); }
.row__symbol img { height: 100%; width: 100%; object-fit: contain; }
.row__meaning { display: grid; gap: var(--space-2); min-width: 0; }
.row__printed { max-height: var(--space-7); max-width: 100%; object-fit: contain;
                object-position: left; opacity: 0.8; }
.row__source { display: inline-flex; align-items: center; gap: var(--space-2);
               font-size: var(--text-xs); color: var(--color-text-muted); }
.row__source[data-source="none"] { color: var(--status-review); font-weight: var(--weight-bold); }
.meaning { display: grid; gap: var(--space-1); }
.meaning .input { width: 100%; }

/* Sticky action bar at the foot of a long form. */
.actionbar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap;
             align-items: center; gap: var(--space-5); justify-content: space-between;
             padding: var(--space-4) var(--space-6); border-radius: var(--radius-lg);
             background: var(--color-surface); border: var(--border-width) solid var(--color-border);
             box-shadow: var(--shadow-md); }
.actionbar__progress { display: grid; gap: var(--space-2); min-width: calc(var(--space-8) * 5); }
.actionbar__text { font-size: var(--text-sm); }

/* --- Symbol confirmation ------------------------------------------------------ */
kbd { font-family: var(--font-mono); font-size: var(--text-xs);
      padding: 0 var(--space-2); border: var(--border-width) solid var(--color-border);
      border-radius: var(--radius-sm); background: var(--color-surface-alt); }
.btn kbd { color: inherit; background: transparent; border-color: currentColor; }
/* List beside the focused group on a wide screen, above it on a narrow one:
   flex-wrap does this with token sizes, where a media query could not. */
.review { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.review__list { flex: 1 1 calc(var(--space-8) * 7); }
.review__focus { flex: 2 1 calc(var(--space-8) * 10); position: sticky; top: var(--space-5); }
.review__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2);
                max-height: calc(var(--space-8) * 14); overflow-y: auto; }
.review__item { display: flex; align-items: center; gap: var(--space-4); width: 100%;
                padding: var(--space-3) var(--space-4); text-align: left;
                border: var(--border-width) solid var(--color-border);
                border-radius: var(--radius-md); background: var(--color-surface);
                color: var(--color-text); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.review__item:hover { background: var(--color-surface-alt); }
.review__item[aria-current="true"] { border-color: var(--brand-primary);
  box-shadow: inset calc(var(--border-width) * 4) 0 0 var(--brand-primary); }
.review__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
                white-space: nowrap; }
.review__thumb { height: var(--space-7); width: var(--space-7); object-fit: contain;
                 background: var(--color-surface); }
/* Found and legend glyphs side by side at one size: the comparison is the job. */
.review__compare { display: flex; flex-wrap: wrap; gap: var(--space-6); }
.review__figure { margin: 0; display: grid; gap: var(--space-2); justify-items: center;
                  color: var(--color-text-muted); font-size: var(--text-sm); }
.review__glyph, .review__none { height: calc(var(--space-8) * 3); width: calc(var(--space-8) * 3);
                object-fit: contain; image-rendering: pixelated;
                border: var(--border-width) solid var(--color-border);
                border-radius: var(--radius-md); background: var(--color-surface); }
.review__none { display: grid; place-items: center; text-align: center; padding: var(--space-3); }
.review__rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1);
                max-height: calc(var(--space-8) * 10); overflow-y: auto; }
.review__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center;
               gap: var(--space-3); padding: var(--space-3) var(--space-4); cursor: pointer;
               border-radius: var(--radius-sm); }
.review__row:hover, .review__row[aria-selected="true"] { background: var(--color-surface-alt); }
.review__row .legend-img { max-height: var(--space-7); }

/* --- Drawing viewer ------------------------------------------------------------ */
.viewer { position: relative; overflow: auto; height: calc(var(--space-8) * 14);
          border: var(--border-width) solid var(--color-border);
          border-radius: var(--radius-lg); background: var(--color-surface-alt); }
.viewer__canvas { position: relative; }
.viewer__img, .viewer__overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
/* The page image is opaque black on white in either theme: it is the
   document as issued, and inverting it would misrepresent its line weights. */
.viewer__img { background: var(--color-surface); user-select: none; }
.viewer__box { fill: none; stroke: var(--status-review); vector-effect: non-scaling-stroke;
               stroke-width: calc(var(--border-width) * 2); }
.viewer__box--current { stroke: var(--brand-accent); stroke-width: calc(var(--border-width) * 4); }

/* --- Report -------------------------------------------------------------------- */
.table .table__group td { border-top: calc(var(--border-width) * 2) solid var(--color-border);
                          font-weight: var(--weight-bold); background: var(--color-surface-alt); }
.table .btn { padding: var(--space-2) var(--space-4); }
.visually-hidden { position: absolute; width: var(--border-width); height: var(--border-width);
                   overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.table .table__flag td { font-size: var(--text-xs); color: var(--color-text-muted);
                         border-bottom-style: dashed; }
/* Wide tables (a column per revision) scroll inside their card, not the page. */
.table-scroll { overflow-x: auto; }
