/* BackupProof dashboard. Calm, ink-blue ops tool: cool neutral surfaces, one
   accent, status colours reserved for status. System fonts only (CSP). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e4e8ee;
  --border: #d8dde5;
  --border-strong: #c3cad5;
  --text: #16202c;
  --muted: #536072;
  --accent: #1f55b5;
  --accent-hover: #17469a;
  --accent-soft: #e7eefb;
  --accent-text: #ffffff;
  --ok: #17703f;
  --ok-bg: #e2f3e9;
  --warn: #8a5300;
  --warn-bg: #fcf0d6;
  --bad: #b3261e;
  --bad-hover: #96201a;
  --bad-bg: #fbe6e4;
  --info: #3f4b62;
  --info-bg: #e8ecf2;
  --code-bg: #f0f2f6;
  --focus: #1f55b5;
  --scrim: rgba(17, 25, 38, .42);
  --shadow: 0 1px 2px rgba(22, 32, 44, .05), 0 1px 3px rgba(22, 32, 44, .06);
  --shadow-lg: 0 12px 32px rgba(22, 32, 44, .16), 0 2px 6px rgba(22, 32, 44, .08);
  --radius: 10px;
  --radius-sm: 6px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 19px;
  --fs-xl: 24px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --mono: ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --z-sticky: 10; --z-scrim: 20; --z-drawer: 30; --z-modal: 50; --z-toast: 100;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #161b22;
    --surface-2: #1d232c;
    --surface-3: #262e39;
    --border: #2a323d;
    --border-strong: #3a4452;
    --text: #e4e8ee;
    --muted: #9aa5b3;
    --accent: #7fa7f5;
    --accent-hover: #9cbbf8;
    --accent-soft: #1c2a44;
    --accent-text: #0b1220;
    --ok: #5cc98a;
    --ok-bg: #14301f;
    --warn: #e2b350;
    --warn-bg: #33290f;
    --bad: #f0807a;
    --bad-hover: #f59d98;
    --bad-bg: #3a1a19;
    --info: #b4bdcb;
    --info-bg: #252c36;
    --code-bg: #0c0f13;
    --focus: #8fb3f8;
    --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(31, 85, 181, .15);
  overflow-wrap: break-word;
}
body.modal-open { overflow: hidden; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { text-wrap: balance; overflow-wrap: anywhere; }
h1 { font-size: var(--fs-xl); line-height: 1.2; margin: 0 0 4px; font-weight: 650; letter-spacing: -.015em; }
h2 { font-size: var(--fs-md); line-height: 1.3; margin: 0 0 12px; font-weight: 620; letter-spacing: -.005em; }
h3 { font-size: var(--fs-base); margin: 20px 0 8px; font-weight: 620; }
h1:focus, h2:focus { outline: none; }
p { margin: 0 0 10px; text-wrap: pretty; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0;
}
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
/* .break: prose that may contain long words; code.break: hashes, paths, IDs */
.break { overflow-wrap: anywhere; }
code.break, .break code, pre.break { word-break: break-all; }
.tnum, td, th, .tile .num, .count, .pager, dl.kv dd, time { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: var(--z-toast); padding: 10px 14px;
  background: var(--accent); color: var(--accent-text); border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: calc(12px + env(safe-area-inset-top)); text-decoration: none; }

/* focus: one visible ring everywhere */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible,
.choice:focus-visible, .tab:focus-visible, .picker-item:focus-visible, .pill-btn:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.check-card:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.check-card:has(input:focus:not(:focus-visible)) { outline: none; }
#main:focus, main:focus, [tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus);
}
button, a, summary, label, select, input[type=checkbox], .choice, .tab, .picker-item { touch-action: manipulation; }

/* layout */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 228px; flex: 0 0 228px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16.5px; padding: 18px 20px 16px; letter-spacing: -.01em; }
.brand-mark { display: inline-flex; color: var(--accent); }
.brand-mark .ico-svg { width: 22px; height: 22px; stroke-width: 2; }
.brand-accent { color: var(--accent); }
.nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 2px; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.nav a {
  color: var(--text); padding: 8px 10px; border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center;
  position: relative; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .count { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; line-height: 18px; }
.userbox { border-top: 1px solid var(--border); padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); font-size: var(--fs-sm); }
.userbox .who { font-weight: 600; overflow-wrap: anywhere; }
.userbox .role { color: var(--muted); font-size: var(--fs-xs); }
.userbox .btns { margin: 8px 0 6px; }
.topbar { display: none; }
.main { flex: 1; min-width: 0; padding: 28px 36px 56px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { min-width: 0; flex: 1 1 320px; }
.page-head .lede, .page-title .lede { margin: 2px 0 0; max-width: 68ch; }
.back { margin-bottom: 6px; }
.back a { color: var(--muted); }
.back a:hover { color: var(--accent); }

@media (max-width: 800px) {
  html { scroll-padding-top: calc(64px + env(safe-area-inset-top)); }
  .layout { display: block; }
  .sidebar {
    position: fixed; z-index: var(--z-drawer); left: 0; top: 0; bottom: 0; height: 100%;
    width: min(280px, 86vw); padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left);
    transform: translateX(-100%); visibility: hidden; box-shadow: var(--shadow-lg);
    transition: transform .2s var(--ease), visibility 0s linear .2s; overscroll-behavior: contain;
  }
  .layout.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s var(--ease), visibility 0s; }
  .scrim { position: fixed; inset: 0; background: var(--scrim); z-index: var(--z-scrim); display: none; }
  .layout.nav-open .scrim { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: var(--z-sticky);
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
  }
  .topbar .brand { padding: 0; }
  .main { padding: 18px calc(16px + env(safe-area-inset-right)) 44px calc(16px + env(safe-area-inset-left)); }
  h1 { font-size: 21px; }
}
@media (min-width: 801px) { .scrim { display: none; } }

/* components */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .card { padding: 14px 14px; } }

/* stat tiles: the first ("restore tested") leads */
.tiles { display: grid; grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .num { font-size: 28px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; }
.tile .num .of { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.tile .lbl { color: var(--muted); font-size: var(--fs-sm); }
.tile.ok .num { color: var(--ok); }
.tile.warn .num { color: var(--warn); }
.tile.bad .num { color: var(--bad); }
.tile.lead { box-shadow: inset 4px 0 0 var(--ok), var(--shadow); }
.tile.lead:not(.all) { box-shadow: inset 4px 0 0 var(--border-strong), var(--shadow); }
.tile.lead:not(.all) .num { color: var(--text); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: var(--fs-sm); font-weight: 550; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
  white-space: nowrap; text-decoration: none; line-height: 1.35;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .08s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn[aria-busy="true"] { opacity: .85; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.solid:hover { background: var(--bad-hover); border-color: var(--bad-hover); }
@media (prefers-color-scheme: dark) { .btn.danger.solid, .nav .count { color: #1a0b0a; } }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.icon { padding: 7px 9px; }
.btn.icon .ico-svg { width: 20px; height: 20px; }
.btn.wrap { white-space: normal; overflow-wrap: anywhere; text-align: left; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
@media (pointer: coarse) { .btn.sm { min-height: 40px; padding: 6px 12px; } .btn { min-height: 40px; } }

/* status pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; padding: 1px 9px; border-radius: 999px;
  background: var(--info-bg); color: var(--info); white-space: nowrap; line-height: 1.6; border: 1px solid transparent;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill-btn { font-family: inherit; cursor: pointer; transition: border-color .15s var(--ease), filter .15s var(--ease); }
.pill-btn:hover { border-color: currentColor; }
.pill-btn[aria-expanded="true"] { border-color: currentColor; }
.pill-i { width: 13px; height: 13px; opacity: .75; stroke-width: 2.2; }
.pill-note {
  flex: 1 0 100%; font-size: var(--fs-sm); font-weight: 400; color: var(--text); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 6px 10px; margin-top: 2px;
}
.badge {
  display: inline-block; font-size: 11.5px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border);
  color: var(--muted); font-family: var(--mono); white-space: nowrap;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.off { background: var(--bad); }

.banner { border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 16px; border: 1px solid transparent; border-left-width: 4px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); border-left-color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); border-left-color: var(--warn); }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); border-left-color: var(--ok); }
.banner.info { background: var(--info-bg); color: var(--info); border-left-color: var(--border-strong); }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner a { color: inherit; text-decoration: underline; }
.banner .btns { margin-top: 8px; }
.banner .btn { text-decoration: none; }
.banner .field-label, .banner .field .hint { color: inherit; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); white-space: nowrap; border-bottom-color: var(--border-strong); }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: var(--fs-xs); }
tr.clickable { cursor: pointer; }
tbody tr { content-visibility: auto; contain-intrinsic-size: auto 44px; }

/* responsive table → cards */
@media (max-width: 800px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; display: flex; gap: 10px; min-width: 0; }
  table.stack td > * { min-width: 0; }
  table.stack td::before {
    content: attr(data-label); flex: 0 0 104px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600;
  }
  table.stack td[data-label=""]::before { display: none; }
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  tbody tr:hover td { background: none; }
}

/* forms */
form .row, .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > .field-label, .field > span:first-child { font-size: var(--fs-sm); font-weight: 600; }
.field .hint, .hint { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; line-height: 1.45; }
.field-error { color: var(--bad); font-size: var(--fs-sm); font-weight: 550; }
.field-error::before { content: "✗ "; }
[aria-invalid="true"] { border-color: var(--bad) !important; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], input[type=email], select, textarea {
  font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); width: 100%; min-width: 0; min-height: 36px;
  transition: border-color .15s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:disabled { background: var(--surface-2); color: var(--muted); }
::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 64px; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 12px; font-size: 14px; cursor: pointer; flex-wrap: wrap; }
.check input { margin-top: 3px; }
.check > span { flex: 1; min-width: 0; }
.check .field-error { flex-basis: 100%; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 6px; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 650; padding: 0 6px; font-size: var(--fs-sm); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.assert-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; margin-bottom: 8px; }
@media (max-width: 600px) { .assert-row { grid-template-columns: 1fr; } }
.form-error { color: var(--bad); font-size: var(--fs-sm); font-weight: 550; margin-bottom: 8px; }
.form-error:empty { display: none; }
.form-error:focus { outline: none; }

/* auth */
.auth { max-width: 400px; margin: 0 auto; padding: max(8vh, 24px) 16px 32px; }
.auth .card { padding: 26px 26px 22px; box-shadow: var(--shadow-lg); }
.auth .brand { padding: 0 0 16px; font-size: 18px; }
.auth-title { font-size: 21px; margin-bottom: 4px; }
.auth-foot { text-align: center; margin-top: 14px; }

/* checks */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: 0; }
.checks .ico { font-weight: 700; text-align: center; }
.checks .ico.ok { color: var(--ok); }
.checks .ico.bad { color: var(--bad); }
.checks .detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.roots { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 4px 10px; font-size: var(--fs-sm); align-items: baseline; }
.roots code { word-break: break-all; }

dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 500px) { dl.kv { grid-template-columns: 1fr; gap: 0; } dl.kv dt { font-size: var(--fs-xs); margin-top: 6px; } dl.kv dd { margin-bottom: 2px; } }

.log { max-height: 420px; min-height: 80px; font-size: 12px; line-height: 1.5; white-space: pre-wrap; overscroll-behavior: contain; }
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox pre { flex: 1; min-width: 0; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty p { max-width: 52ch; margin: 0 auto 12px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 12px auto 0; max-width: 520px; text-align: left; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; color: var(--text); }
.steps li::before { content: counter(step); flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--surface-2); text-align: center; font-weight: 600; line-height: 24px; }
.steps li.done { color: var(--muted); }
.steps li.done::before { content: "✓"; color: var(--ok); }
.steps li > :first-child { flex: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; color: var(--muted); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }

/* toasts & modal */
.toast-stack {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); pointer-events: none;
}
.toasts { display: flex; flex-direction: column; gap: 8px; }
.toast {
  pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); padding: 10px 14px; max-width: 420px; overflow-wrap: anywhere;
  animation: toast-in .2s var(--ease);
}
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.modal-bg {
  position: fixed; inset: 0; background: var(--scrim); z-index: var(--z-modal); display: flex; align-items: flex-start; justify-content: center;
  padding: max(8vh, calc(16px + env(safe-area-inset-top))) 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
  animation: fade-in .15s var(--ease);
}
.modal {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); width: 100%; max-width: 640px;
  padding: 22px 22px 18px; box-shadow: var(--shadow-lg); overscroll-behavior: contain; min-width: 0;
  animation: modal-in .18s var(--ease);
}
.modal > h2 { font-size: var(--fs-lg); }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }

/* ---------------------------------------------------------------- plain-language UI */
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }
.block { display: block; }
.mt { margin-top: 26px; }
.label { font-weight: 600; font-size: var(--fs-sm); margin: 14px 0 6px; }
.btn.lg { padding: 10px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.link { border-color: transparent; background: none; color: var(--accent); padding-left: 0; }
.btn.link:hover { text-decoration: underline; background: none; }
.btns.center { justify-content: center; margin-top: 18px; }
.form-actions.start { justify-content: flex-start; }
.ico-svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.nav-l { display: inline-flex; align-items: center; gap: 10px; }
.nav-l .ico-svg { width: 18px; height: 18px; opacity: .8; }
.nav a.active .ico-svg { opacity: 1; }
h1.with-ico { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1.with-ico .ico-svg { width: 26px; height: 26px; color: var(--accent); }
h1.with-ico span { overflow-wrap: anywhere; min-width: 0; }
.check .hint.block { margin-top: 2px; }
.glyph { font-weight: 700; }

/* collapsible details */
details.more { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 8px; }
details.more > summary {
  cursor: pointer; color: var(--accent); font-size: var(--fs-sm); font-weight: 550; list-style: none; padding: 4px 6px; margin-left: -6px;
  border-radius: var(--radius-sm); display: inline-block; transition: background-color .15s var(--ease);
}
details.more > summary:hover { background: var(--accent-soft); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "\25B8"; display: inline-block; width: 1em; transition: transform .15s var(--ease); }
details.more[open] > summary::before { transform: rotate(90deg); }
.more-body { padding-top: 8px; min-width: 0; }

/* wizard step bar */
.wsteps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.wsteps li { display: flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--muted); padding: 4px 12px 4px 5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.wsteps .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.wsteps li.cur { color: var(--text); border-color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--accent) inset; }
.wsteps li.cur .n { background: var(--accent); color: var(--accent-text); }
.wsteps li.done { color: var(--text); }
.wsteps li.done .n { background: var(--ok-bg); color: var(--ok); }
@media (max-width: 520px) { .wsteps li:not(.cur) .l { display: none; } .wsteps li:not(.cur) { padding-right: 5px; } }

/* welcome (empty Home) */
.welcome { text-align: center; padding: 40px 24px 36px; }
.welcome .muted { max-width: 56ch; margin: 0 auto 6px; }
.welcome-ico { color: var(--accent); display: inline-flex; padding: 14px; border-radius: 18px; background: var(--accent-soft); margin-bottom: 6px; }
.welcome-ico .ico-svg { width: 40px; height: 40px; stroke-width: 1.5; }
.welcome-steps { list-style: none; counter-reset: ws; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 22px; padding: 0; margin: 20px 0 6px; color: var(--muted); font-size: var(--fs-sm); }
.welcome-steps li { counter-increment: ws; display: flex; align-items: center; gap: 7px; }
.welcome-steps li::before { content: counter(ws); width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 650; color: var(--text); }
h2.big { font-size: 23px; margin: 8px 0; letter-spacing: -.015em; }
.btn-sub { display: block; font-size: 11.5px; font-weight: 400; opacity: .8; }
.btn.stack { flex-direction: column; gap: 0; white-space: normal; }

/* choice cards */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.choices.small { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
@media (max-width: 420px) { .choices, .choices.small { grid-template-columns: minmax(0, 1fr); } }
.choice {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; min-width: 0;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.choices.small .choice { padding: 10px 12px; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.choice:active:not(:disabled) { transform: translateY(1px); }
.choice:disabled { opacity: .5; cursor: not-allowed; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice-ico { color: var(--accent); padding-top: 1px; }
.choice-ico .ico-svg { width: 24px; height: 24px; }
.choice-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.choice-title { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.choice-desc { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.subform { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.wizard { padding: 22px 24px; }
.wizard h2 { font-size: var(--fs-lg); margin-bottom: 14px; }
.wizard > .form-actions { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px; }
@media (max-width: 520px) { .wizard { padding: 16px 14px; } }
.card.inset { box-shadow: none; background: var(--bg); margin-top: 12px; }

/* free-space bar */
.bar-wrap { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }

/* checkbox cards & lists */
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-bottom: 12px; }
@media (max-width: 420px) { .check-list { grid-template-columns: minmax(0, 1fr); } }
.check-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; min-width: 0;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.check-card:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.check-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check-card input { margin-top: 3px; }
.check-card > span { min-width: 0; }
.path-list { list-style: none; padding: 0; margin: 0 0 12px; }
.path-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.path-list li > code, .path-list li > span { flex: 1; min-width: 0; }
.plain-list { margin: 0; padding-left: 18px; font-size: var(--fs-sm); }
.inline-field { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.inline-field > .field { flex: 1 1 240px; }
.inline-field > .btn { margin-top: 25px; }
.summary { font-size: 16px; line-height: 1.6; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; overflow-wrap: anywhere; max-width: 72ch; border-left: 4px solid var(--accent); }

/* items list */
.items { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border); align-items: start; }
.item:first-child { padding-top: 4px; }
.item:last-child { border-bottom: 0; padding-bottom: 4px; }
.item-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; position: relative; }
.item.is-ok .item-ico { background: var(--ok-bg); color: var(--ok); }
.item.is-warn .item-ico { background: var(--warn-bg); color: var(--warn); }
.item.is-bad .item-ico { background: var(--bad-bg); color: var(--bad); }
.item-title { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-weight: 600; font-size: 15.5px; }
.item-title a { color: var(--text); overflow-wrap: anywhere; }
.item-title a:hover { color: var(--accent); }
.item-sub { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.item-reason { margin: 6px 0 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.item-facts { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: var(--fs-sm); color: var(--text); margin-top: 6px; }
.fact-l { color: var(--muted); }
.fact-ok { color: var(--ok); font-weight: 600; }
.fact-bad { color: var(--bad); font-weight: 600; }
.item-actions { align-self: center; }
@media (max-width: 640px) {
  .item { grid-template-columns: 40px minmax(0, 1fr); }
  .item-actions { grid-column: 1 / -1; }
}
.running { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--warn); margin-top: 8px; }

/* spinner & progress */
.spinner { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; flex: 0 0 auto; }
.spinner.sm { width: 12px; height: 12px; }
.btn.primary .spinner { border-color: color-mix(in srgb, var(--accent-text) 35%, transparent); border-top-color: var(--accent-text); }
@keyframes spin { to { transform: rotate(360deg); } }
.prog { padding: 12px 0; border-bottom: 1px solid var(--border); }
.prog-name { font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.progress { display: flex; align-items: center; gap: 10px; font-size: 15px; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--surface-2); flex-wrap: wrap; }
.progress.ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.progress.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; border: 1px solid var(--bad); }
.progress > span { overflow-wrap: anywhere; min-width: 0; }
.progress a { color: inherit; text-decoration: underline; }
.prog-ico { font-weight: 700; }

/* item detail hero: the status is the headline */
.hero { border-left: 5px solid var(--border-strong); padding: 20px 22px; }
.hero.ok { border-left-color: var(--ok); }
.hero.warn { border-left-color: var(--warn); }
.hero.bad { border-left-color: var(--bad); }
.hero-status { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.hero-label { font-size: 23px; font-weight: 700; margin: 0; letter-spacing: -.015em; }
.hero.ok .hero-label { color: var(--ok); }
.hero.warn .hero-label { color: var(--warn); }
.hero.bad .hero-label { color: var(--bad); }
.hero-reason { color: var(--muted); margin: 0; max-width: 70ch; }
.hero dl.kv { margin-top: 6px; }
.hero .form-actions { margin-top: 16px; }

/* cards grid (storage, computers) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .cards { grid-template-columns: minmax(0, 1fr); } }
.card.mini { margin-bottom: 0; display: flex; flex-direction: column; }
.card.mini > .form-actions { margin-top: auto; padding-top: 10px; }
.card.mini.dim { opacity: .6; }
.mini-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.mini-head h2 { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.mini-head > div { min-width: 0; }

/* storage chooser */
.storage-chooser h3:first-child { margin-top: 0; font-size: var(--fs-md); }
.pwbox { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px; }
code.pw { font-size: 16px; letter-spacing: .5px; word-break: break-all; flex: 1 1 220px; }
.callout { border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px; background: var(--accent-soft); }
.banner p:last-child { margin-bottom: 0; }

/* folder picker */
.picker-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.picker-head code { flex: 1; min-width: 0; }
.picker-list { max-height: 50vh; max-height: 50dvh; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.picker-list ul { list-style: none; margin: 0; padding: 0; }
.picker-item { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 0; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.picker-item:hover { background: var(--surface-2); }
.picker-item .ico-svg { color: var(--accent); }
.picker-item span { overflow-wrap: anywhere; min-width: 0; }
.picker-list > p { padding: 8px; margin: 0; }

/* connect modal */
.modal.wide { max-width: 760px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 6px 0 14px; overflow-x: auto; }
.tab {
  font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; color: var(--muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: color .15s var(--ease), background-color .15s var(--ease);
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.plain-steps { padding-left: 20px; margin: 0 0 12px; }
.plain-steps li { margin-bottom: 10px; }
.plain-steps .copybox { margin-top: 6px; }
@media (max-width: 520px) { .copybox { flex-direction: column; } .modal-bg { padding: calc(12px + env(safe-area-inset-top)) 8px calc(12px + env(safe-area-inset-bottom)); } .modal { padding: 16px 14px 14px; } }

/* motion: respect people who asked for less */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .spinner { animation-duration: 2.4s !important; animation-iteration-count: infinite !important; }
}
