/* Restorly panel components beyond the design pack's components.css.
 * Built from tokens only (DESIGN.md §3, §7): no raw colours here.
 * tokens.css and components.css are copied unchanged from docs/design/.
 */

/* The hidden attribute wins over component display rules (.stack, .row):
 * conditional fields (data-when) and closed panels stay hidden. */
[hidden] { display: none !important; }

/* ---------- Skip link ---------- */
.skip-link { position: absolute; left: var(--space-4); top: -100px; z-index: 100; padding: var(--space-2) var(--space-4); background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); }
.skip-link:focus { top: var(--space-3); }

/* ---------- Icons ---------- */
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn .icon { width: 16px; height: 16px; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-6); flex-wrap: wrap; }
.page-head__lead { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: 16px; }
.hero-status__lead { margin: 0; color: var(--text-muted); font-size: 16px; }

/* ---------- Top bar extras ---------- */
.topbar form { margin: 0; }
.menu-btn { display: none; }
@media (max-width: 700px) {
  .menu-btn { display: inline-flex; }
  .topbar__right > form > .theme-switch, .topbar__right > .density-form { display: none; }
}
.user-menu { position: relative; }
.user-menu__panel { position: absolute; right: 0; top: calc(100% + var(--space-2)); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); padding: var(--space-2); display: flex; flex-direction: column; z-index: 20; }
/* The menu button sits at the left of the top bar, so its panel opens to the
 * right; anchored right: 0 (the avatar menu's default) it would open off the
 * left edge of a phone and only a sliver would show. Capped to the viewport. */
.menu-btn .user-menu__panel { right: auto; left: 0; max-width: calc(100vw - 2 * var(--space-4)); }
.user-menu__panel a, .user-menu__panel button { text-align: left; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); min-height: var(--touch-target); display: flex; align-items: center; gap: var(--space-2); font: inherit; font-weight: var(--weight-semibold); color: var(--text); background: transparent; border: 0; cursor: pointer; }
.user-menu__panel a:hover, .user-menu__panel button:hover { background: var(--surface-2); text-decoration: none; }
.user-menu__who { padding: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--text-muted); border-bottom: 1px solid var(--surface-2); margin-bottom: var(--space-1); }
.avatar-btn { border: 0; padding: 0; cursor: pointer; font: inherit; }
/* Theme and density in the user menu only where the top bar hides them. */
.user-menu__appearance { display: none; }
.user-menu__label { display: block; padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--text-sm); color: var(--text-muted); }
.user-menu__panel .user-menu__appearance .segmented button { min-height: var(--touch-target); padding-inline: var(--space-3); font-weight: var(--weight-semibold); }
@media (max-width: 700px) {
  .user-menu__appearance { display: block; padding: 0 var(--space-2) var(--space-2); border-top: 1px solid var(--surface-2); margin-top: var(--space-1); }
}
/* Settings → General: cards side by side on wide screens. */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: var(--gap-grid); align-items: start; }

/* ---------- Tabs (pill style, like nav__item) ---------- */
.tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: var(--space-2); }
.tabs__item { padding: 8px 12px; border-radius: var(--radius-pill); color: var(--text-muted); font-weight: var(--weight-semibold); }
.tabs__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tabs__item[aria-current="page"], .tabs__item[aria-selected="true"] { background: var(--surface-2); color: var(--link); }

/* ---------- Dialog ---------- */
.dialog { border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); max-width: min(560px, calc(100vw - 32px)); width: 100%; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog__body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--space-3); }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: var(--space-6); bottom: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); z-index: 50; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: var(--weight-semibold); display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Tooltip ---------- */
.tooltip { position: relative; display: inline-flex; }
.tooltip__text { position: absolute; bottom: calc(100% + 6px); right: 0; width: max-content; max-width: min(320px, calc(100vw - 32px)); background: var(--text); color: var(--surface); font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 6px 10px; border-radius: var(--radius-sm); white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--dur-fast) var(--ease); z-index: 30; }
.tooltip:hover .tooltip__text, .tooltip:focus-within .tooltip__text { opacity: 1; visibility: visible; }
/* Banners and their actions wrap on narrow screens. */
.banner { flex-wrap: wrap; }
.banner > * { min-width: 0; overflow-wrap: anywhere; }
/* Grid and flex children may shrink below their content, so a wide table
   scrolls inside its .table-wrap instead of widening the page. */
.page, .split > *, .stack > *, .wizard > * { min-width: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Sparkline ---------- */
.sparkline { width: 120px; height: 28px; color: var(--link); overflow: visible; }
.sparkline polyline { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.sparkline circle { fill: currentColor; }

/* ---------- Copy-to-clipboard field ---------- */
.copy-field { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius-md); overflow: hidden; }
.copy-field__value { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: var(--text-sm); padding: var(--space-3); overflow-x: auto; white-space: pre; background: var(--surface-2); }
.copy-field .btn { border-radius: 0; }

/* ---------- Empty, loading and error states ---------- */
.empty { text-align: center; padding: var(--space-12) var(--space-6); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.empty__text { color: var(--text-muted); margin: 0; max-width: 520px; }
.skeleton { background: var(--surface-2); border-radius: var(--radius-sm); min-height: 14px; }
.skeleton--row { height: 44px; margin-bottom: var(--space-2); }

/* ---------- Definition lists (details, settings) ---------- */
/* The label column is as wide as its longest label, but at most 45%: on a
   phone a long label wraps instead of squeezing the values (IDs, hashes). */
.facts { display: grid; grid-template-columns: fit-content(45%) minmax(0, 1fr); gap: var(--space-2) var(--space-6); margin: 0; font-size: var(--text-sm); }
.facts dt { color: var(--text-subtle); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Logs and code ---------- */
.log { font-family: var(--font-mono); font-size: var(--text-xs); background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-3); overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 480px; }
/* A custom check's SQL, shown under its result: what was tested, as it ran. */
.check-sql { margin-top: var(--space-2); padding: var(--space-2) var(--space-3); }
details > summary { cursor: pointer; font-weight: var(--weight-semibold); min-height: var(--touch-target); display: flex; align-items: center; }

/* ---------- Timeline (run stages) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline__item { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: var(--space-3); padding: var(--space-2) 0; align-items: center; border-bottom: 1px solid var(--surface-2); }
.timeline__item:last-child { border-bottom: 0; }
/* A status shown by its icon alone (run stages): a centred round badge. */
.chip--icon { width: 24px; height: 24px; padding: 0; gap: 0; justify-content: center; line-height: 0; }
.chip--icon svg { display: block; }

/* ---------- Sign-in and setup (centered card) ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); }
.auth__card { width: 100%; max-width: 440px; }
.auth__brand { display: flex; justify-content: center; margin-bottom: var(--space-4); }
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form .btn { align-self: flex-start; }

/* ---------- Wizard progress rail ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.steps__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); color: var(--text-muted); font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.steps__num { width: 26px; height: 26px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; font-size: var(--text-xs); flex-shrink: 0; }
.steps__item[aria-current="step"] { background: var(--surface-2); color: var(--link); }
.steps__item[aria-current="step"] .steps__num { background: var(--primary); color: var(--on-primary); }
.steps__item--done .steps__num { background: var(--success-bg); color: var(--success-fg); }

/* ---------- Progress widths (CSP forbids inline style attributes) ---------- */
.pct-0 { width: 0; } .pct-5 { width: 5%; } .pct-10 { width: 10%; } .pct-15 { width: 15%; } .pct-20 { width: 20%; }
.pct-25 { width: 25%; } .pct-30 { width: 30%; } .pct-35 { width: 35%; } .pct-40 { width: 40%; } .pct-45 { width: 45%; }
.pct-50 { width: 50%; } .pct-55 { width: 55%; } .pct-60 { width: 60%; } .pct-65 { width: 65%; } .pct-70 { width: 70%; }
.pct-75 { width: 75%; } .pct-80 { width: 80%; } .pct-85 { width: 85%; } .pct-90 { width: 90%; } .pct-95 { width: 95%; }
.pct-100 { width: 100%; }

/* ---------- Cards that link to a detail page ---------- */
.card__title a { color: var(--text); }
.card__title a:hover { color: var(--link); }

/* ---------- Small helpers ---------- */
.text-sm { font-size: var(--text-sm); }
.wrap { flex-wrap: wrap; }
.right { text-align: right; }
.list__item--row { flex-direction: row; justify-content: space-between; align-items: center; }
.list__item--row > span:first-child { color: var(--text); }
.table-wrap { overflow-x: auto; position: relative; }

/* ---------- Configuration (diff, issue lists, confirm checkbox) ---------- */
.diff__add { display: block; background: var(--success-bg); color: var(--success-fg); }
.diff__del { display: block; background: var(--danger-bg); color: var(--danger-fg); }
.diff__gap { display: block; color: var(--text-subtle); }
.issues { margin: 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); overflow-wrap: anywhere; }
.issues--error { color: var(--danger-fg); }
.issues--warning { color: var(--warning-fg); }
.check { display: flex; align-items: flex-start; gap: var(--space-3); }
.check input { margin-top: 3px; accent-color: var(--danger-fg); }
details.card > summary { cursor: pointer; }

/* ---------- Personality layer (ADR 0028) ----------
   Faint line art about what Restorly does: backup → restore → proof.
   Decorative only: CSS masks coloured with --link, so it follows the theme,
   never carries meaning, is invisible to screen readers and loads nothing
   from outside. Opacity is the only knob. */
:root { --deco: var(--link); --deco-opacity: 0.07; --deco-grid-opacity: 0.55; }
:root[data-theme="dark"] { --deco-opacity: 0.10; --deco-grid-opacity: 0.45; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { --deco-opacity: 0.10; --deco-grid-opacity: 0.45; } }

/* A dot grid behind the top of every page, fading out (a blueprint, not a pattern). */
body { position: relative; isolation: isolate; }
body::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 560px; z-index: -1; pointer-events: none;
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1.4px);
  background-size: 22px 22px; opacity: var(--deco-grid-opacity);
  -webkit-mask-image: linear-gradient(to bottom, black, transparent);
  mask-image: linear-gradient(to bottom, black, transparent);
}

/* Hero: a database stack, the restore arrow, the proof (shield and check) and the hash chain. */
.hero-status { position: relative; overflow: hidden; isolation: isolate; }
.hero-status::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: var(--space-3); bottom: var(--space-3); right: 240px; aspect-ratio: 480 / 220;
  background: var(--deco); opacity: calc(var(--deco-opacity) * 2);
  -webkit-mask: url(../deco/hero.svg) no-repeat center / contain, linear-gradient(to right, transparent, black 35%);
  -webkit-mask-composite: source-in;
  mask: url(../deco/hero.svg) no-repeat center / contain, linear-gradient(to right, transparent, black 35%);
  mask-composite: intersect;
}

/* Database cards: a cropped database watermark in the corner. */
.card--db { position: relative; overflow: hidden; isolation: isolate; }
.card--db::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  right: -50px; bottom: -64px; width: 116px; height: 136px; transform: rotate(-8deg);
  background: var(--deco); opacity: var(--deco-opacity);
  -webkit-mask: url(../deco/cylinder.svg) no-repeat center / contain;
  mask: url(../deco/cylinder.svg) no-repeat center / contain;
}

/* The evidence PDF's From, To and Download do not fit one line on a phone:
 * the two months stack, lined up, with the button under them. */
@media (max-width: 700px) {
  .evidence-form { display: grid; grid-template-columns: max-content minmax(0, 1fr); }
  .evidence-form > label { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; }
  .evidence-form .select { width: 100%; min-width: 0; }
  .evidence-form > .btn { grid-column: 1 / -1; justify-self: start; }
}

/* Report history: the hash chain as a rail of links through the chain column. */
.table td.chain { position: relative; padding-left: calc(var(--row-pad-x) + 22px); }
.table td.chain::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--row-pad-x) + 5px);
  border-left: 2px dotted var(--border-strong);
}
.table td.chain::after {
  content: ""; position: absolute; top: 50%; left: var(--row-pad-x); width: 12px; height: 20px; transform: translateY(-50%);
  background: var(--link); opacity: 0.55;
  -webkit-mask: url(../deco/link.svg) no-repeat center / contain;
  mask: url(../deco/link.svg) no-repeat center / contain;
}
.table tr:first-child td.chain::before { top: 50%; }
.table tr:last-child td.chain::before { bottom: 50%; }

/* Empty states: a database that is not there yet. */
.empty::before {
  content: ""; width: 120px; height: 90px; pointer-events: none;
  background: var(--deco); opacity: 0.35;
  -webkit-mask: url(../deco/empty.svg) no-repeat center / contain;
  mask: url(../deco/empty.svg) no-repeat center / contain;
}

/* Sign-in: the story, large and faint, behind the card. */
.auth { position: relative; overflow: hidden; isolation: isolate; }
.auth::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: 50%; top: 50%; width: min(1180px, 150vw); aspect-ratio: 480 / 220; transform: translate(-50%, -54%);
  background: var(--deco); opacity: var(--deco-opacity);
  -webkit-mask: url(../deco/hero.svg) no-repeat center / contain;
  mask: url(../deco/hero.svg) no-repeat center / contain;
}

/* Under 1100 px the headline needs the room: the art steps back behind it. */
@media (max-width: 1100px) {
  .hero-status::before { right: -40px; opacity: var(--deco-opacity); }
}
@media print {
  body::before, .hero-status::before, .card--db::after, .auth::before, .empty::before { display: none; }
}

/* ---------- Settings ---------- */
.choice-list { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
/* Without a border the legend is a label like the others, flush left. */
.choice-list > legend { padding: 0; }
.choice-list .check input { accent-color: var(--primary); }
.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag-list li { background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-1) var(--space-3); }
.user-actions > summary { list-style: none; cursor: pointer; }
.user-actions > summary::-webkit-details-marker { display: none; }
.user-actions__panel { margin-top: var(--space-3); min-width: 240px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); align-items: end; }
.filter-grid__actions { padding-bottom: 2px; }
.nowrap { white-space: nowrap; }
.wrap-anywhere { overflow-wrap: anywhere; }
.table--modules { table-layout: fixed; min-width: 760px; }
.table--modules .col-module { width: 42%; }
.table--modules .col-state { width: 17%; }
.table--modules .col-details { width: 27%; }
.table--modules .col-switch { width: 14%; }
.table--modules td { overflow-wrap: anywhere; }
.table--modules .btn { white-space: nowrap; }

/* ---------- Wizard (ADR 0029) ---------- */
.wizard { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.wizard__rail { position: sticky; top: calc(var(--topbar-height) + var(--space-4)); display: flex; flex-direction: column; gap: var(--space-4); }
.wizard__rail a.steps__item { text-decoration: none; }
.wizard__rail a.steps__item:hover { background: var(--surface-2); text-decoration: none; }
.wizard__body { gap: var(--space-5); }
.wizard__actions { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--space-4); margin-top: var(--space-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.match-list__head { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--text-subtle); font-weight: var(--weight-semibold); }
.match-list__row:last-child { border-bottom: 0; }
.match-list--files .match-list__row { grid-template-columns: minmax(0, 1fr) 90px; }
html.js .js-hide { display: none; }
@media (max-width: 1100px) {
  .wizard { grid-template-columns: 1fr; }
  .wizard__rail { position: static; }
  .wizard__rail .steps { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .match-list__row { grid-template-columns: minmax(0, 1fr) 90px; }
  .match-list__row > :nth-child(2), .match-list__row > :nth-child(3) { display: none; }
  .match-list--files .match-list__row > :nth-child(2) { display: block; }
}

/* ---------- Custom checks editor (ADR 0030) ---------- */
.template-box { border: 1px dashed var(--border-strong); border-radius: var(--radius-md); padding: var(--space-4); margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.check-test { border-top: 1px solid var(--border); padding-top: var(--space-3); }
.check-result + .check-result { border-top: 1px solid var(--surface-2); padding-top: var(--space-3); }
.danger-zone > summary { cursor: pointer; color: var(--danger-fg); }
.danger-zone[open] { display: flex; flex-direction: column; gap: var(--space-3); }

/* ---------- Client switcher (module multisite) ---------- */
.client-switch { display: flex; align-items: center; gap: var(--space-2); }
.client-switch .select { min-width: 180px; }
@media (max-width: 700px) { .client-switch .select { min-width: 0; max-width: 140px; } }
.signin-or { text-align: center; margin: 0; }

/* ---------- Loading (DESIGN.md §5: skeletons, never a page spinner) ---------- */
/* htmx marks the element while its request runs (the live pattern preview). */
#pattern-preview.htmx-request > * { opacity: 0.45; transition: opacity var(--duration-fast, 120ms); }
#pattern-preview.htmx-request::before { content: ""; display: block; height: 4px; border-radius: var(--radius-pill); margin-bottom: var(--space-2);
  background: linear-gradient(90deg, var(--surface-2), var(--border-strong), var(--surface-2)); background-size: 200% 100%; animation: restorly-shimmer 1.2s linear infinite; }
@keyframes restorly-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #pattern-preview.htmx-request::before { animation: none; } }
@media (max-width: 700px) {
  .hero-status { flex-direction: column; align-items: flex-start; gap: var(--space-4); padding: var(--space-5); }
}
.table td > strong.mono, .table th[scope="row"].mono { white-space: nowrap; }
.run-log { overflow-y: auto; }
/* Authenticator setup QR code (ADR 0043): dark on light in both themes. */
.totp-enrol { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); align-items: start; }
@media (max-width: 560px) { .totp-enrol { grid-template-columns: 1fr; justify-items: center; } .totp-enrol > .stack { width: 100%; } }
.steps-list { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); }
.qr-box { display: inline-block; padding: var(--space-2); border-radius: var(--radius-md); border: 1px solid var(--border); margin-block: var(--space-2); }
.qr-code { display: block; width: 200px; height: 200px; }
details > summary { cursor: pointer; color: var(--link); font-size: var(--text-sm); }

/* ---------- Grouped fields ---------- */
fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); margin: 0; min-width: 0; }
fieldset > legend { padding: 0 var(--space-2); font-weight: var(--weight-semibold); }

/* ---------- Your account ---------- */
.account-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-grid); align-items: start; }
.account-layout .span-2 { grid-column: 1 / -1; }
@media (max-width: 900px) { .account-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Access forms (ADR 0063) ---------- */
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2) var(--space-4); max-height: 260px; overflow: auto; padding: var(--space-2); border: 1px solid var(--surface-2); border-radius: var(--radius-md); }
.align-start { align-items: start; }
/* Choices (not confirmations) use the primary colour. */
fieldset .check input { accent-color: var(--primary); }

/* ---------- Theme switch: System, Light, Dark as three icons ---------- */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: transparent; }
.theme-switch__btn, .theme-switch button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text-subtle); cursor: pointer; }
.theme-switch__btn svg, .theme-switch button svg { width: 16px; height: 16px; }
.theme-switch__btn:hover, .theme-switch button:hover { color: var(--text); }
.theme-switch [aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.theme-switch form { margin: 0; display: contents; }

/* What each role can do (Settings → Users, Teams). */
.roles-help h3 { margin: 0 0 var(--space-1); font-size: var(--text-md, 15px); font-weight: var(--weight-semibold); }
.roles-help p { margin: 0; color: var(--text-muted); font-size: var(--text-sm); line-height: 1.5; }
.roles-help__roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.roles-help__more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--surface-2); }
@media (max-width: 900px) { .roles-help__roles, .roles-help__more { grid-template-columns: minmax(0, 1fr); } }


/* A licence upload waiting for confirmation (Settings → Licence). */
.review-confirm { border-color: var(--warning-fg); margin-bottom: var(--space-5); }
.review-confirm__warnings { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-1); color: var(--warning-fg); font-weight: var(--weight-semibold); }

/* ---------- A save confirmed in the form (Teams, a user's access) ---------- */
.banner--success { background: var(--success-bg); color: var(--success-fg); }
.saved-note { align-items: flex-start; scroll-margin-top: calc(var(--topbar-height) + var(--space-6)); }
.saved-note__title { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-md); }
.saved-note__title svg { width: 18px; height: 18px; }
.saved-note__facts { margin: 0; font-weight: var(--weight-regular); color: var(--text); }
.saved-note__facts dt { color: var(--success-fg); font-weight: var(--weight-semibold); }

/* The report branding logo in use (Settings → General). */
.branding-logo {
  display: block;
  width: auto;
  max-width: 160px;
  height: 40px;
  object-fit: contain;
  margin-block: var(--space-2);
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* On a phone a run's checks read as a list: each check a block with its
   name, status, result, level and time, no sideways scrolling (second
   walkthrough). The header stays for screen readers. */
@media (max-width: 700px) {
  .table--stack { min-width: 0; }
  .table--stack thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .table--stack, .table--stack tbody { display: block; width: 100%; }
  /* Check, then status, level and time on one line, then the result. */
  .table--stack tr {
    display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-4);
    padding: var(--space-3) var(--row-pad-x); border-bottom: 1px solid var(--border);
  }
  .table--stack td { flex: 0 0 auto; border: 0; padding: var(--space-1) 0; text-align: start; }
  .table--stack td:nth-child(1) { order: 1; flex-basis: 100%; }
  .table--stack td:nth-child(3) { order: 2; }
  .table--stack td:nth-child(2) { order: 3; }
  .table--stack td:nth-child(5) { order: 4; }
  .table--stack td:nth-child(4) { order: 5; flex-basis: 100%; }
  .table--stack td[data-label]::before { content: attr(data-label) " "; color: var(--text-muted); font-size: var(--text-sm); }
  .table--stack .table--stack__title { font-weight: 600; overflow-wrap: anywhere; }
}
