:root {
    color-scheme: light;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-soft: #f8f9fc;
    --border: #e4e8f0;
    --text: #172033;
    --muted: #5b6578;
    --accent: #3157d5;
    --accent-hover: #2547ba;
    --accent-text: #ffffff;
    --danger: #b42318;
    --danger-text: #ffffff; /* text on a filled danger button or count */
    --border-control: #7d8696; /* form controls only (3:1); cards keep the hairline --border */
    --ok-text: #146c3d;
    --warn-text: #8a4b00;
    --error-text: #b42318;
    --info-text: #1d4aab;
    --dot-up: #1f9d55;
    --dot-down: #d92d20;
    --dot-off: #7d8696;
    --dot-warn: #b26b00;
    /* Status dots carry a shape (check, cross, bang, ring) so online/offline is never colour only. */
    --dot-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 12.5 3.8 3.8 7.2-7.6'/%3E%3C/svg%3E");
    --dot-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='m8 8 8 8M16 8l-8 8'/%3E%3C/svg%3E");
    --dot-bang: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M12 6.5v7M12 17.5v.1'/%3E%3C/svg%3E");
    --dot-ring: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8696' stroke-width='3'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E");
    --info-bg: #eef3ff;
    --info-border: #b9c8f5;
    --warn-bg: #fff8e8;
    --warn-border: #f0d18a;
    --error-bg: #fff0ee;
    --error-border: #f0b4ad;
    --ok-bg: #eaf7ef;
    --ok-border: #a8d9b8;
    --sidebar: #17243a;
    --sidebar-text: #d8e0ef;
    --sidebar-muted: #9aa8bf;
    --radius: 12px;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, SFMono-Regular, Menlo, monospace;
    font-family: system-ui, "Segoe UI Variable Text", "Segoe UI", -apple-system, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #111722;
        --surface: #192230;
        --surface-soft: #202b3b;
        --border: #303c4f;
        --text: #e8edf5;
        --muted: #a3afc2;
        --accent: #88a4ff;
        --accent-hover: #a6b9ff;
        --accent-text: #10182a;
        --danger: #ff8b81;
        --danger-text: #10182a;
        --border-control: #66748b;
        --ok-text: #7ae0a8;
        --warn-text: #f3c56f;
        --error-text: #ffa39b;
        --info-text: #a7bfff;
        --dot-warn: #d98a00;
        --dot-ring: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b95aa' stroke-width='3'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3C/svg%3E");
        --info-bg: #1b2744;
        --info-border: #3d5290;
        --warn-bg: #302916;
        --warn-border: #77612e;
        --error-bg: #351d20;
        --error-border: #784047;
        --ok-bg: #193126;
        --ok-border: #376b50;
        --sidebar: #101722;
        --sidebar-text: #d8e0ef;
        --sidebar-muted: #9aa8bf;
    }
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
code, .mono { font-family: var(--font-mono); }
code { font-size: .9em; }
.mono { font-size: .93em; }
code.wrap { word-break: break-all; white-space: pre-wrap; }
code.small { font-size: .8em; }
code.secret { font-size: 1.1em; letter-spacing: .05em; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-nav); display: flex; width: 244px; flex-direction: column; padding: 24px 14px 16px; background: var(--sidebar); color: var(--sidebar-text); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 8px 34px; color: #fff; font-size: 14px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 10px; background: rgba(255,255,255,.1); color: #fff; font-size: 17px; }
.nav-label { margin: 0 10px 8px; color: var(--sidebar-muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.admin-label { margin-top: 28px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; min-height: 40px; padding: 9px 11px; border: 1px solid transparent; border-radius: 8px; color: var(--sidebar-text); font-size: 13px; font-weight: 550; text-decoration: none; transition: background .15s ease, border-color .15s ease; }
.sidebar nav a:hover, .sidebar nav a:focus-visible { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.09); color: #fff; }
.sidebar nav a[aria-current="page"] { border-color: rgba(157,180,255,.18); background: rgba(94,126,226,.24); color: #fff; }
.sidebar-bottom { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: var(--sidebar-muted); font-size: 11px; }
.sidebar-bottom strong { display: block; margin-bottom: 3px; color: var(--sidebar-text); font-size: 12px; font-weight: 600; }
.workspace { min-height: 100vh; margin-left: 244px; }
.topbar { display: flex; min-height: 64px; align-items: center; justify-content: flex-end; gap: 16px; padding: 10px clamp(18px, 4vw, 48px); border-bottom: 1px solid var(--border); background: var(--surface); }
.logout { display: flex; align-items: center; gap: 16px; margin: 0; }
.who { color: var(--muted); font-size: 12px; text-decoration: none; }
.topbar .link { color: var(--muted); font-size: 12px; }
main { width: min(100%, 1440px); margin: 0 auto; padding: 34px clamp(18px, 4vw, 48px) 56px; }
h1 { margin: 0 0 7px; font-size: clamp(23px, 2.2vw, 29px); font-weight: 700; letter-spacing: -.04em; line-height: 1.2; }
h2 { margin: 0 0 14px; font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1, .page-head h2 { margin: 0; }

.card { margin-bottom: 18px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 5px rgba(27,39,66,.025); }
.card.narrow { max-width: 440px; margin: 48px auto; }
.card > :last-child { margin-bottom: 0; }
form label { display: block; margin-bottom: 15px; font-weight: 600; }
form label small { display: block; color: var(--muted); font-weight: 400; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--border-control); border-radius: 8px; outline: none; background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
textarea { resize: vertical; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 16px; }
.filters label { margin: 0; }
.filters a { padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; }
.filters a.active { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
button, .button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; transition: background .15s ease, border-color .15s ease; }
button:hover, .button:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--accent-text); }
button.secondary, .button.secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
button.secondary:hover, .button.secondary:hover { border-color: var(--accent); color: var(--accent); }
button.danger, .button.danger { border-color: var(--danger); background: var(--danger); color: var(--danger-text); }
button.danger:hover, .button.danger:hover { color: var(--danger-text); }
.btn-sm { min-height: 30px; padding: 4px 12px; font-size: 13px; }
.row-actions { white-space: nowrap; text-align: right; }
/* Customer page: nothing scrolls; the cards sit side by side and long lists are paged. */
.cust-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.cust-cards .card { margin: 0; padding: 14px 16px; }
.cust-cards h2 { margin: 0 0 6px; font-size: 16px; }
.cust-cards form > label { margin-bottom: 8px; }
.cust-cards .grid2 { grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: end; }
.cust-cards p { margin: 0 0 8px; }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 500; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .actions { gap: 6px 8px; }
/* One compact toolbar row on desktop; phones keep the 44 px touch targets. */
@media (min-width: 681px) { .workspace .page-head :is(button, .button, details.menu > summary) { min-height: 30px; padding: 4px 12px; font-size: 13px; } }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-soft) 72%, transparent); }
tbody tr:has(input[type="checkbox"]:checked) { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pre { white-space: pre-wrap; }
.muted { color: var(--muted); }

.notice { margin-bottom: 14px; padding: 11px 14px; border: 1px solid; border-radius: 9px; }
.notice-error { border-color: var(--error-border); background: var(--error-bg); color: var(--error-text); }
.notice-warning { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-text); }
.notice-success { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-text); }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-soft); font-size: 11px; font-weight: 650; vertical-align: middle; white-space: nowrap; }
.badge-active, .badge-success, .badge-succeeded, .badge-ok, .badge-pull, .badge-committed { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-text); }
.badge-suspended, .badge-denied, .badge-completed_with_warnings, .badge-queued, .badge-pending, .badge-pull_pending, .badge-unknown, .badge-warning { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-text); }
.badge-disabled, .badge-decommissioned, .badge-failure, .badge-partial, .badge-failed, .badge-cancelled, .badge-interrupted, .badge-expired, .badge-revoked, .badge-critical, .badge-error { border-color: var(--error-border); background: var(--error-bg); color: var(--error-text); }
.badge-running { border-color: var(--ok-border); background: var(--surface); color: var(--ok-text); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 13px; margin: 22px 0; }
.stat { position: relative; display: block; min-height: 105px; padding: 17px 18px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: 0 8px 20px rgba(27,39,66,.07); color: var(--text); }
.stat-value { display: block; font-size: 29px; font-weight: 700; letter-spacing: -.04em; line-height: 1.2; }
.stat-label { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 550; }
.dashboard-intro { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .14em; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 3px; }
.section-heading p { margin: 0; font-size: 12px; }
.section-heading .badge { margin-top: 2px; }
.text-link { font-size: 12px; font-weight: 650; text-decoration: none; }
.schedule-note { margin: 12px 0 0; }
.badge-scheduled { border-color: var(--border); background: var(--surface-soft); }
.pager { display: flex; justify-content: center; gap: 16px; margin-top: 16px; }
.log-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 10px; margin: 0 0 6px; }
.log-filters label { flex: 1 1 130px; margin: 0; font-size: 12px; font-weight: 600; }
.log-filters input, .log-filters select { margin-top: 2px; padding: 5px 8px; font-size: 13px; }
.log-filters button { flex: 0 0 auto; width: auto; padding: 6px 14px; }
.log-context { margin: 10px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.log-message { min-width: 16em; overflow-wrap: anywhere; }
.log-message details { margin-top: 4px; color: var(--muted); }
.empty-state { text-align: center; }
form.inline { display: inline; margin-left: 8px; }
.actions form { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 20px; }
.methods li { margin: 2px 0; }
.small { font-size: .85em; }
form.row { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
form.row label { margin: 0; }

@media (max-width: 900px) {
    .sidebar { width: 210px; }
    .workspace { margin-left: 210px; }
}
@media (max-width: 680px) {
    .sidebar { position: static; width: auto; padding: 12px 14px 10px; }
    .brand { margin: 0 4px 11px; }
    .nav-label, .sidebar-bottom { display: none; }
    .sidebar nav { display: flex; overflow-x: auto; gap: 5px; padding-bottom: 2px; }
    .sidebar nav a { min-height: 35px; flex: 0 0 auto; padding: 7px 10px; font-size: 12px; }
    .admin-label { margin-top: 16px; }
    .workspace { margin-left: 0; }
    .topbar { min-height: 52px; padding: 8px 16px; }
    main { padding: 24px 16px 40px; }
    .card { padding: 17px; }
    .logout { gap: 10px; }
    .who { max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .stat { min-height: 88px; padding: 13px; }
    .stat-value { font-size: 24px; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dd { margin-bottom: 8px; }
}
@media (max-width: 720px) {
    table { display: block; overflow-x: auto; }
    th, td { white-space: nowrap; }
}
/* ---- Menu: compact first (tiers below) so it rarely needs to scroll; when the window is too short it scrolls on its own (contained, never moves the page) with a thin indicator on hover and focus. It is the navigation, the one allowed secondary scroller (docs/ui-kit.md). ---- */
.sidebar-bottom { flex-shrink: 0; }
@media (min-width: 681px) {
    .sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: transparent transparent; }
    .sidebar:hover, .sidebar:focus-within { scrollbar-color: var(--sidebar-muted) transparent; }
    .sidebar::-webkit-scrollbar { width: 6px; }
    .sidebar::-webkit-scrollbar-thumb { border-radius: 3px; background: transparent; }
    .sidebar:hover::-webkit-scrollbar-thumb, .sidebar:focus-within::-webkit-scrollbar-thumb { background: var(--sidebar-muted); }
}
/* Menu button (top bar, left): hides and shows the sidebar; the state is the cookie vbm_nav, drawn by layout.php as .nav-collapsed on the first paint. No animation, so nothing to reduce. */
.topbar-lead { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.nav-collapse { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }
.nav-collapse:hover { border-color: var(--accent); color: var(--accent); }
.nav-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-shell.nav-collapsed .sidebar { display: none; }
.app-shell.nav-collapsed .workspace { margin-left: 0; }
@media (max-width: 680px) {
    .nav-collapse { display: none; }
    .topbar-lead { display: contents; }
    .app-shell.nav-collapsed .sidebar { display: flex; }
}
.banner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3, 12px); flex-wrap: wrap; }

/* ---- Design layer v2: tokens, accessibility, shared components (keep CSP-safe: no inline styles) ---- */
:root {
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
    --text-xs: 12px; --text-sm: 13px; --text-md: 14px; --text-lg: 16px;
    --radius-sm: 6px; --radius-pill: 999px;
    /* z-index scale (the only layers in use; never write a bare number): raised < sticky < overlay < nav < menu < nav-mobile < modal < skip */
    --z-raised: 1; --z-sticky: 2; --z-overlay: 4; --z-nav: 5; --z-menu: 10; --z-nav-mobile: 20; --z-modal: 30; --z-skip: 50;
}
.nav-label { font-size: 11px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.sidebar :focus-visible { outline-color: #fff; }
button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
@media (forced-colors: active) {
    :focus-visible { outline: 2px solid CanvasText; }
    .badge, .notice { border: 1px solid CanvasText; }
}
input[type="checkbox"], input[type="radio"] { display: inline-block; width: 18px; height: 18px; margin: 0 var(--space-2) 0 0; vertical-align: middle; accent-color: var(--accent); }
.input-xs { width: 6em; }
.input-sm { width: 12em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap th { position: sticky; top: 0; z-index: var(--z-raised); }
fieldset { margin: var(--space-4) 0 0; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
legend { padding: 0 var(--space-2); font-weight: 650; }
fieldset label { display: inline-block; margin: 0 var(--space-4) var(--space-3) 0; }
.bulk-bar { position: sticky; bottom: 0; z-index: var(--z-sticky); box-shadow: 0 -4px 12px rgba(27,39,66,.06); }
.bulk-bar.bulk-tall { position: static; margin-top: 16px; box-shadow: none; }
.guest-main { width: min(100%, 520px); margin: 0 auto; padding: var(--space-8) var(--space-4); }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.field-hint { display: block; color: var(--muted); font-size: var(--text-xs); }
.field-error { color: var(--danger); font-size: var(--text-xs); }
.notice-info { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }
.badge-info, .badge-migrating, .badge-drill { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }
.badge-neutral { border-color: var(--border); background: var(--surface-soft); color: var(--muted); }
.empty-state { padding: var(--space-8) var(--space-4); border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.empty-state h2 { margin-bottom: var(--space-2); }
.empty-state p { max-width: 46ch; margin: 0 auto var(--space-4); color: var(--muted); }
.danger-zone { border-color: var(--error-border); background: var(--error-bg); }
.danger-zone h2 { color: var(--danger); }
.steps { margin: var(--space-3) 0 0; padding-left: var(--space-5); }
.steps li { margin: var(--space-1) 0; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.test-log { margin: 0; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-soft); font: 12px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.calendar td { min-width: 112px; height: 92px; padding: var(--space-2); font-size: var(--text-xs); }
.calendar td.today { outline: 2px solid var(--accent); outline-offset: -2px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.calendar td strong { display: block; margin-bottom: var(--space-1); }
.calendar td > div { margin-top: var(--space-1); white-space: normal; }
@media (max-width: 680px) {
    .calendar, .calendar thead, .calendar tbody, .calendar tr, .calendar td { display: block; width: 100%; height: auto; }
    .calendar thead, .calendar td:empty { display: none; }
    .calendar td { white-space: normal; }
    .calendar td::before { content: attr(data-label); display: block; color: var(--muted); font-weight: 700; }
    .bulk-bar { position: static; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Weekly hour grid (hosting backup windows): day rows x 24 hour cells, no scripts needed */
.week-grid{border:1px solid var(--border,#d0d7de);border-radius:8px;padding:.75rem;overflow-x:auto}
.week-grid-head,.week-grid-row{display:grid;grid-template-columns:3rem repeat(24,minmax(1.4rem,1fr));gap:2px;align-items:center}
.week-grid-head span{font-size:.7rem;text-align:center;color:var(--muted,#667)}
.week-grid-day{font-weight:600;font-size:.85rem}
.week-cell{display:flex;justify-content:center;margin:0;padding:.15rem 0}
.week-cell input{margin:0;width:1.1rem;height:1.1rem}

/* ---- One-window desktop shell: the page never scrolls, only the content area (and wide tables) do ---- */
@media (min-width: 901px) {
    html, body { height: 100%; overflow: hidden; }
    .app-shell { height: 100vh; min-height: 0; }
    .workspace { display: flex; height: 100vh; min-height: 0; flex-direction: column; }
    .topbar { min-height: 48px; flex: 0 0 auto; padding: 6px 20px; }
    main { width: 100%; max-width: none; min-height: 0; flex: 1 1 auto; margin: 0; padding: 14px 20px 18px; overflow-y: auto; }
    .brand { margin-bottom: 18px; }
    .admin-label { margin-top: 14px; }
    .sidebar { padding: 16px 12px 12px; }
    .sidebar nav a { min-height: 34px; padding: 6px 10px; }
    h1 { font-size: 21px; margin-bottom: 4px; }
    h2 { margin-bottom: 8px; font-size: 15px; }
    .page-head { margin-bottom: 10px; }
    .card { margin-bottom: 12px; padding: 14px 16px; }
    th, td { padding: 7px 10px; line-height: 1.45; }
    .stats { margin: 12px 0; gap: 10px; }
    .stat { min-height: 78px; padding: 12px 14px; }
    .stat-value { font-size: 23px; }
    form label { margin-bottom: 10px; }
    input, select, textarea { padding: 7px 10px; }
}
.topbar-search { margin-right: auto; }
.topbar-search input { width: 260px; margin: 0; padding: 6px 10px; }
.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input { width: min(360px, 60vw); margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.settings-grid .card { margin: 0; }
.settings-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.settings-list li { display: grid; gap: 1px; }

/* ---- Quick-view popup (CSS only, works under the strict CSP): <a href="#id"> opens <div class="modal" id="id"> ---- */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: none; place-items: center; padding: 16px; }
.modal:target, .modal.is-open { display: grid; } /* is-open: a dialog the server renders open (a confirmation step), not one opened by a link */
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 28, .55); cursor: default; }
.modal-card { position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 18px 50px rgba(10, 16, 28, .35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.modal-close { padding: 2px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); text-decoration: none; }

/* ---- UI pass 2 (checked in a real browser): denser desktop shell, readable popup, phone menu ---- */
input.nav-toggle, .nav-burger { display: none; }
@media (min-width: 901px) {
    .brand { margin-bottom: 10px; }
    .nav-label { margin-bottom: 4px; }
    .admin-label { margin-top: 8px; }
    .sidebar nav { gap: 1px; }
    .sidebar nav a { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
    .notice { margin-bottom: 8px; padding: 6px 12px; font-size: 13px; }
    .bulk-bar { margin-top: 8px; padding: 6px 12px 8px; }
    .bulk-bar p { margin: 0; }
    .bulk-bar label { margin: 0 12px 0 0; font-size: 12px; }
    .bulk-bar select, .bulk-bar input { margin-top: 2px; padding: 4px 8px; }
    .settings-grid { display: block; columns: 3 300px; column-gap: 12px; }
    .settings-grid .card { break-inside: avoid; margin: 0 0 12px; }
}
/* Menu tiers: the admin menu (21 links) must fit without its own scrollbar at 1366 x 900 and 1366 x 768. */
@media (min-width: 901px) and (max-height: 900px) {
    .sidebar { padding-top: 10px; padding-bottom: 8px; }
    .sidebar-bottom { display: none; }
    .brand { margin-bottom: 6px; }
    .brand-mark { width: 28px; height: 28px; font-size: 14px; }
    .nav-label { margin-bottom: 2px; }
    .admin-label { margin-top: 4px; }
    .sidebar nav a { min-height: 27px; padding-block: 3px; }
}
@media (min-width: 901px) and (max-height: 820px) {
    .sidebar nav a { min-height: 25px; padding-block: 2px; }
}
.modal-card { width: min(940px, 100%); }
.modal-card .grid2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.modal-card textarea { min-height: 0; }
.top-cards { align-items: start; }
.top-cards > .card { margin: 0; }
@media (max-width: 680px) {
    .sidebar { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; overflow: visible; }
    .brand { margin: 0; }
    .nav-burger { display: inline-flex; min-height: 34px; align-items: center; padding: 4px 14px; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; color: #fff; font-weight: 650; cursor: pointer; }
    input.nav-toggle { position: absolute; display: block; width: 1px; height: 1px; opacity: 0; }
    .nav-toggle:focus-visible + .nav-burger { outline: 2px solid #fff; outline-offset: 2px; }
    .sidebar nav { display: none; }
    .nav-toggle:checked ~ nav { display: grid; flex: 1 0 100%; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 10px; overflow: visible; }
    .nav-toggle:checked ~ .nav-label { display: block; flex: 1 0 100%; margin-top: 10px; }
    .topbar-search { flex: 1 1 100%; margin: 0 0 6px; }
    .topbar-search input { width: 100%; }
    .topbar { flex-wrap: wrap; }
}
.brand:hover, .brand:focus-visible { color: #fff; }
@media (min-width: 901px) {
    .bulk-bar p { display: inline-flex; flex-wrap: wrap; align-items: end; gap: 6px 12px; margin: 0 12px 0 0; vertical-align: bottom; }
}

/* ---- Folds, fact strips, menus and panel grid: show the vital summary, reveal the rest on demand (CSS only) ---- */
details.fold { margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.fold > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 8px 14px; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
/* A long hint (a storage host name, a path) is cut with an ellipsis instead of wrapping to a second line. */
details.fold > summary .fold-hint { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.fold > summary::after { content: "▸"; margin-left: auto; color: var(--muted); }
details.fold[open] > summary::after { content: "▾"; }
details.fold > summary h2, details.fold > summary h3 { margin: 0; font-size: 14px; }
details.fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.fold-hint { color: var(--muted); font-size: 12px; }
.fold-body { padding: 2px 14px 12px; }
.fold-body > :last-child { margin-bottom: 0; }
.fold-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.fold-actions form { margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 18px; margin: 0 0 10px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
details.menu { position: relative; display: inline-block; }
details.menu > summary { display: inline-flex; min-height: 38px; align-items: center; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-weight: 650; cursor: pointer; list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: "▾"; margin-left: 8px; color: var(--muted); }
.menu-items { position: absolute; right: 0; z-index: var(--z-menu); display: grid; min-width: 210px; margin-top: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 28px rgba(10, 16, 28, .22); }
.menu-items a { padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.menu-items a:hover, .menu-items a:focus-visible { background: var(--surface-soft); }
.menu-items a.danger-link { color: var(--danger); }
details.bell > summary { min-height: 34px; padding: 6px 10px; gap: 6px; }
details.bell > summary::after { content: none; }
.bell-count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: var(--danger-text); font-size: 11px; line-height: 18px; text-align: center; }
.bell-items { width: min(380px, calc(100vw - 32px)); gap: 4px; padding: 6px; }
.bell-item { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--warn-border); border-radius: 8px; background: var(--warn-bg); font-size: 13px; }
.bell-item.bell-error { border-color: var(--error-border); background: var(--error-bg); }
.bell-item a { justify-self: start; padding: 2px 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 650; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.compact-table th, .compact-table td { padding: 5px 8px; }
.modal-card .grid2 { align-items: end; }
.modal-card form + form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
/* Tabs inside a form (CSS only): hidden radios, then the tab bar, then the form whose panes are shown by the checked radio. */
.tabs > input.tab-radio { display: none; }
.tab-bar { display: inline-flex; flex-wrap: wrap; max-width: 100%; gap: 2px; margin: 0 0 10px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.tab-bar label { display: inline-block; margin: 0; padding: 5px 14px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.tab-bar label:hover { color: var(--text); }
/* All panes share one grid cell, so the form is always as tall as its tallest tab and never changes size when switching. */
.tabs .panes { display: grid; }
.tabs .pane { grid-area: 1 / 1; visibility: hidden; }
/* The n-th radio shows the n-th tab label as active and the n-th pane (up to 4 tabs per form). */
.tabs > input.tab-radio:nth-of-type(1):checked ~ .tab-bar label:nth-child(1), .tabs > input.tab-radio:nth-of-type(2):checked ~ .tab-bar label:nth-child(2),
.tabs > input.tab-radio:nth-of-type(3):checked ~ .tab-bar label:nth-child(3), .tabs > input.tab-radio:nth-of-type(4):checked ~ .tab-bar label:nth-child(4),
.tabs > input.tab-radio:nth-of-type(5):checked ~ .tab-bar label:nth-child(5), .tabs > input.tab-radio:nth-of-type(6):checked ~ .tab-bar label:nth-child(6) { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(27, 39, 66, .14); }
.tabs > input.tab-radio:nth-of-type(1):checked ~ * .pane:nth-of-type(1), .tabs > input.tab-radio:nth-of-type(2):checked ~ * .pane:nth-of-type(2),
.tabs > input.tab-radio:nth-of-type(3):checked ~ * .pane:nth-of-type(3), .tabs > input.tab-radio:nth-of-type(4):checked ~ * .pane:nth-of-type(4),
.tabs > input.tab-radio:nth-of-type(5):checked ~ * .pane:nth-of-type(5), .tabs > input.tab-radio:nth-of-type(6):checked ~ * .pane:nth-of-type(6) { visibility: visible; }
/* A popup opened from a link in another tab (for example "Open next step") must show even though its tab is hidden. */
.tabs .pane .modal:target { visibility: visible; }
/* Inside a tab the former folds are plain sections: always open, nothing to click. */
.tabs .pane details.fold > summary { pointer-events: none; cursor: default; list-style: none; }
.tabs .pane details.fold > summary::-webkit-details-marker { display: none; }
.tabs .pane details.fold > summary::marker { content: ''; }
.tabs .pane details.fold > .fold-body { pointer-events: auto; }
/* A full-page tab area: only the shown pane takes space (display:none), so the page is as tall as its content and tables.js fits the lists to the window. */
.tabs.fill > .panes > .pane { display: none; }
.tabs.fill > input.tab-radio:nth-of-type(1):checked ~ .panes > .pane:nth-of-type(1),
.tabs.fill > input.tab-radio:nth-of-type(2):checked ~ .panes > .pane:nth-of-type(2),
.tabs.fill > input.tab-radio:nth-of-type(3):checked ~ .panes > .pane:nth-of-type(3),
.tabs.fill > input.tab-radio:nth-of-type(4):checked ~ .panes > .pane:nth-of-type(4),
.tabs.fill > input.tab-radio:nth-of-type(5):checked ~ .panes > .pane:nth-of-type(5),
.tabs.fill > input.tab-radio:nth-of-type(6):checked ~ .panes > .pane:nth-of-type(6),
.tabs.fill > .panes > .pane:has(.modal:target) { display: block; }
/* A tabbed form (backup settings, restore) keeps its size whichever tab is open: every pane stays in the one grid cell and only visibility changes. */
.tabs.compact > .panes > .pane { display: block; visibility: hidden !important; } /* !important: an outer page tab group must not reveal a pane of this inner one */
.tabs.compact > input.tab-radio:nth-of-type(1):checked ~ .panes > .pane:nth-of-type(1),
.tabs.compact > input.tab-radio:nth-of-type(2):checked ~ .panes > .pane:nth-of-type(2),
.tabs.compact > input.tab-radio:nth-of-type(3):checked ~ .panes > .pane:nth-of-type(3),
.tabs.compact > input.tab-radio:nth-of-type(4):checked ~ .panes > .pane:nth-of-type(4),
.tabs.compact > input.tab-radio:nth-of-type(5):checked ~ .panes > .pane:nth-of-type(5),
.tabs.compact > input.tab-radio:nth-of-type(6):checked ~ .panes > .pane:nth-of-type(6) { visibility: visible !important; }
.tabs.fill nav.filters { margin: 0 0 6px; }
.tabs.fill .pane .table-wrap { margin: 0; max-height: none; overflow-x: auto; } /* height is never limited, so only a wider-than-pane table scrolls, sideways */
.tabs.fill .pane .table-wrap th { top: 0; }
.tabs.fill .tab-bar { margin-bottom: 8px; }
.tab-count { margin-left: 6px; padding: 0 6px; border-radius: 9px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 650; }
.tab-bar label:hover .tab-count { color: var(--text); }

/* Website page: one header card. */
/* Website page: a status dot on a tab name (Wizard), the facts row with Edit and More at its end, the Wizard summary line. */
.tab-dot { display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; vertical-align: middle; }
.tab-dot-ok { background: var(--dot-up); }
.tab-dot-todo { box-sizing: border-box; border: 2px solid var(--dot-warn); background: transparent; }
.facts-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; }
.facts-row > .facts { flex: 1 1 24rem; margin: 0; }
.facts-row > .actions { flex: 0 0 auto; }
.wizard-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 var(--space-3); }


/* Overview: one status tile per setting. */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.status-item { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: inherit; text-decoration: none; min-width: 0; }
.status-item:hover { border-color: var(--accent); }
.status-item strong { font-size: 15px; overflow-wrap: anywhere; }
.status-label { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.status-label .dot { width: 14px; height: 14px; }
.status-item.state-ok .dot { background-color: var(--dot-up); background-image: var(--dot-check); }
.status-item.state-warn .dot { background-color: var(--dot-warn); background-image: var(--dot-bang); }
.status-item.state-bad .dot { background-color: var(--dot-down); background-image: var(--dot-x); }
.overview-actions { margin: 12px 0 0; display: flex; align-items: center; gap: 12px; }

/* Tab content in columns, so a tab fits the window without scrolling. */
.tabs.site-tabs .two-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.tabs.site-tabs .two-cards > details.fold { margin: 0; }
/* Denser cards inside the tabs so each tab fits a laptop window. */
.tabs.site-tabs > .panes > .pane details.fold > summary { padding-top: 7px; padding-bottom: 7px; }
.tabs.site-tabs > .panes > .pane details.fold > .fold-body { padding-top: 2px; padding-bottom: 8px; }
.tabs.site-tabs > .panes > .pane .fold-actions { margin: 0 0 6px; }
.tabs.site-tabs > .panes > .pane .compact-table td, .tabs.site-tabs > .panes > .pane .compact-table th { padding-top: 4px; padding-bottom: 4px; }
.tabs.site-tabs > .panes > .pane { min-width: 0; }
.tabs.site-tabs > .panes > .pane details.fold > summary::after { content: none; }
.tabs.site-tabs > .panes > .pane > .actions { margin: 0 0 6px; }
.tabs.site-tabs > .panes > .pane .fold-pair { gap: 8px; }
.tabs.site-tabs > .panes > .pane .fold-pair .fold-actions { display: inline-block; margin: 0 8px 4px 0; }
.tabs.site-tabs > .panes > .pane .fold-pair p { margin: 4px 0; }
.tabs.site-tabs .two-cards dl.kv { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 4px 14px; margin: 0; }
.tabs.site-tabs .two-cards dl.kv dt, .tabs.site-tabs .two-cards dl.kv dd { margin: 0; padding: 0; overflow-wrap: anywhere; }
.tabs.site-tabs dl.kv.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 18px; margin: 0; }
.tabs.site-tabs dl.kv.cols > div { min-width: 0; }
.tabs.site-tabs dl.kv.cols dt { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tabs.site-tabs dl.kv.cols dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 900px) { .tabs.site-tabs .two-cards { grid-template-columns: minmax(0, 1fr); } .tabs.site-tabs dl.kv.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .tabs.site-tabs .two-cards dl.kv { grid-template-columns: auto minmax(0, 1fr); } } /* four columns squeezed the host and host key into 3-character lines */
/* Online dot in the website list: green check = the agent answered its last check, red cross = it did not, grey ring = not checked yet. */
.dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: middle; background: var(--surface) var(--dot-ring) center / 100% no-repeat; }
.dot-up { background-color: var(--dot-up); background-image: var(--dot-check); }
.dot-down { background-color: var(--dot-down); background-image: var(--dot-x); }
.dot-cell { text-align: center; width: 1%; white-space: nowrap; }
.tabs.compact, form:has(> .tabs.compact) { font-size: 13px; }
.tabs.compact label { font-size: 12px; font-weight: 600; }
.tabs.compact input, .tabs.compact select, .tabs.compact textarea { margin-top: 3px; padding: 6px 9px; font-size: 13px; }
.tabs.compact input[type="checkbox"], .tabs.compact input[type="radio"] { margin-top: 0; padding: 0; }
.tabs.compact small, .tabs.compact .small { font-size: 11.5px; }
.tabs.compact p { margin: 6px 0; }
.tabs.compact textarea { field-sizing: content; max-height: 260px; }
.tabs.compact ul.methods { margin: 0 0 8px; padding-left: 18px; line-height: 1.5; }
.tabs.compact .grid2 { gap: 8px 14px; }
.modal-card form > .actions { position: sticky; bottom: -16px; z-index: var(--z-raised); margin-bottom: -16px; padding: 10px 0 16px; border-top: 1px solid var(--border); background: var(--surface); }
@media (max-width: 600px) { .modal-card form > .actions { position: static; margin-bottom: 0; padding-bottom: 0; } } /* narrow: the footer scrolls with the fields instead of covering them */

/* Hooks that only a theme shows: nav group headings (hidden here) and the skip link (visible on keyboard focus only). */
.nav-group { display: none; }
.skip-link { position: absolute; left: 12px; top: -100px; z-index: var(--z-skip); padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-text); }
.skip-link:focus { top: 8px; }

.job-limits .grid2 { align-items: end; }

/* Table tools (tables.js): search, layout switch, paging; and the card layout that turns every row into a card.
   The !important flags in the card layout beat the theme rules that make cells nowrap and the table scroll sideways. */
table [hidden], table[data-layout="cards"] tr[hidden] { display: none !important; } /* the card rules below set display:block on rows, which beat the first selector */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 8px; }
.table-search { flex: 1 1 220px; max-width: 360px; margin: 0; }
.table-search input { margin: 0; }
.table-layout { display: inline-flex; }
.table-layout button { border-radius: 0; }
.table-layout button:first-child { border-radius: 8px 0 0 8px; }
.table-layout button:last-child { margin-left: -1px; border-radius: 0 8px 8px 0; }
.table-count { margin-left: auto; color: var(--muted); font-size: 13px; }
.table-tools .table-pager { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 0; }
.table-pages { display: inline-flex; gap: 4px; }
.table-pager .ellipsis { color: var(--muted); }
.table-pager[hidden] { display: none; }
table[data-layout="cards"] { display: block !important; overflow: visible !important; border: 0 !important; background: none !important; box-shadow: none !important; }
table[data-layout="cards"] thead { display: none !important; }
table[data-layout="cards"] tbody { display: block !important; }
table[data-layout="cards"] tr { display: block !important; margin: 0 0 10px; padding: 4px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table[data-layout="cards"] td { display: grid !important; grid-template-columns: minmax(90px, 38%) 1fr; gap: 4px 12px; padding: 8px 0 !important; border-bottom: 1px solid var(--border); white-space: normal !important; overflow-wrap: anywhere; position: static !important; box-shadow: none !important; }
table[data-layout="cards"] td { width: auto !important; text-align: left !important; }
table[data-layout="cards"] td > :is(.badge, .dot, a.button, button, input[type="checkbox"]) { justify-self: start; }
table[data-layout="cards"] td:last-child { border-bottom: 0; }
table[data-layout="cards"] td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
table[data-layout="cards"] td[data-label=""] { display: block !important; }
table[data-layout="cards"] td[data-label=""]::before { content: none; }
table[data-layout="cards"] td.row-actions { text-align: left; }
@media (max-width: 480px) { table[data-layout="cards"] td { grid-template-columns: 1fr; } }

/* Choose-storage list (website Storage tab): grouped radio rows, searchable by tables.js. label.check is display:flex, so [hidden] needs its own rule. */
.choice-list { display: grid; gap: var(--space-3); margin: var(--space-3) 0; }
.choice-list fieldset { min-width: 0; margin: 0; padding: var(--space-3); } /* a fieldset is min-content wide by default: a long host stretched the phone popup */
.choice-list legend { max-width: 100%; overflow-wrap: anywhere; padding: 0 var(--space-2); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.choice { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.choice:hover { background: var(--surface-soft); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input { margin: 0; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-icon { flex: 0 0 auto; color: var(--muted); }
.choose-actions { position: sticky; bottom: 0; padding-top: var(--space-3); background: var(--surface); }
.choice[hidden], [data-filter-group][hidden], [data-filter][hidden], [data-filter-count][hidden] { display: none !important; }
@media (max-width: 680px) { .row-actions .btn-sm { min-height: 36px; } }
@media (forced-colors: active) {
    .choice:has(input:checked) { outline: 2px solid Highlight; }
}

/* Storage box form: show only the settings that fit the chosen provider (without :has support every group stays visible). */
.box-form:has(select[name=provider] option[value=sftp]:checked) .opt-tls,
.box-form:has(select[name=provider] option[value=sftp]:checked) .opt-ftp,
.box-form:has(select[name=provider] option[value=sftp]:checked) .opt-s3,
.box-form:has(select[name=provider] option[value=ftps]:checked) .opt-s3,
.box-form:has(select[name=provider] option[value=ftp]:checked) .opt-s3,
.box-form:has(select[name=provider] option[value=s3]:checked) .opt-ftp,
.box-form:has(select[name=provider] option[value=ftps]:checked) .opt-ftp,
.box-form:has(select[name=provider] option[value=ftp]:checked) .opt-tls,
.box-form:has(select[name=provider] option[value=ftp]:checked) .opt-rsync,
.box-form:has(select[name=provider] option[value=ftps]:checked) .opt-rsync,
.box-form:has(select[name=provider] option[value=s3]:checked) .opt-rsync { display: none; }
/* the provider names are long: give the select two columns so none is cut off (single column on phones) */
@media (min-width: 681px) { .box-form label:has(select[name=provider]) { grid-column: span 2; } }

/* an overlay scrollbar (phones) covered the last letters of long lines in popup panes */
.modal-card .tabs .pane { padding-right: 12px; }
/* upload connections only matter for stream/rawtar/rolling/auto: hidden for tar and zip (without :has support it stays visible) */
.pane:has(select[name=files_method] option[value=tar]:checked) .when-parallel,
.pane:has(select[name=files_method] option[value=zip]:checked) .when-parallel { display: none; }

/* Backup settings, Files tab: the window, pack mode and count fields follow the chosen files method (Automatic may pin either kind, so it shows both) */
.pane:not(:has(select[name=files_method] :is(option[value=auto], option[value=rolling], option[value=rolling_archive], option[value=rsync]):checked)) .when-rolling,
.pane:not(:has(select[name=files_method] :is(option[value=auto], option[value=rolling_archive], option[value=rsync]):checked)) .when-archive { display: none; }
.pane:has(select[name=files_method] :is(option[value=rolling], option[value=rolling_archive], option[value=rsync]):checked) .when-count { display: none; }
.bs-form:has(select[name=files_method] option[value=auto]:checked) .when-manual,
.bs-form:not(:has(select[name=files_method] option[value=auto]:checked)) .when-auto { display: none; }
.bs-form h3 { margin: 10px 0 4px; font-size: 14px; }

/* Backup settings, Priority tab: the Use / Skip lists (method-order.js moves the rows; hidden rows only keep an unsupported method's place) */
.order-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.order-cols h3 { margin-top: 0; }
.order-list { list-style: none; margin: 0; padding: 6px; display: grid; gap: 6px; align-content: start; min-height: 46px; border: 1px dashed var(--border-control); border-radius: 8px; background: var(--surface-soft); }
.order-list.drop-target { border-color: var(--accent); }
.order-list.is-empty::before { content: attr(data-empty); color: var(--muted); font-size: 13px; padding: 4px 6px; }
.order-list li { display: grid; gap: 2px; margin: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.order-list li[hidden] { display: none; }
.order-list li[draggable="true"] { cursor: grab; }
.order-list li.dragging { opacity: .5; }
.order-list li:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.order-name { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.order-tools, .order-fallback { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.order-fallback[hidden] { display: none; }
.order-list li { grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
.order-list li > .order-tools { grid-column: 2; grid-row: 1 / span 2; align-self: center; flex-wrap: nowrap; }
.order-list li > .order-fallback { grid-column: 1 / -1; }
.order-fallback input[type=number] { width: 64px; }
@media (max-width: 680px) { .order-cols { grid-template-columns: 1fr; } }

/* rolling merge status in the Backups panel */
.merge-status { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--info-border); background: var(--info-bg); border-radius: 8px; }
.merge-status h3 { margin: 0 0 4px; }
.merge-status p { margin: 4px 0; }
.merge-status .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
.merge-status .actions form { margin: 0; }

/* ---- UI kit (templates/ui/*; style guide at /settings/ui-kit): classes only the kit partials need ---- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.page-title { min-width: 0; }
.page-title p { margin: 2px 0 0; }
.back-link { display: inline-block; margin-bottom: 2px; font-size: 13px; text-decoration: none; }
.modal-card[data-size="480"] { width: min(480px, 100%); }
.modal-card[data-size="760"] { width: min(760px, 100%); }
.modal-card[data-size="940"] { width: min(940px, 100%); }
.modal-foot { position: sticky; bottom: -16px; margin: 12px -18px -16px; padding: 10px 18px; border-top: 1px solid var(--border); background: var(--surface); }
.modal-body > form > .actions { margin-top: 12px; }
.kit-sample { margin-bottom: 16px; }
.kit-sample > h2 { margin: 0 0 8px; font-size: 14px; }
.kit-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
/* A fold inside a tab can opt back in to being collapsible (website Backups tab: Methods and databases starts closed, its hint line keeps the vital facts visible). */
.tabs .pane details.fold.fold-collapsible > summary { pointer-events: auto; cursor: pointer; }
.tabs.site-tabs > .panes > .pane details.fold.fold-collapsible > summary::after { content: "▸"; }
.tabs.site-tabs > .panes > .pane details.fold.fold-collapsible[open] > summary::after { content: "▾"; }
/* Dense tables (ui/table dense): form controls inside a cell do not add their own height (permission matrix). */
.compact-table td select, .compact-table td input:not([type="checkbox"]):not([type="radio"]) { width: auto; min-width: 11em; margin: 0; padding: 2px 8px; }
.compact-table td input[type="checkbox"] { margin: 0; }
/* Website tabs: the lists sit in half-width cards, so their tools share ONE row (search, pager; the Table/Cards switch and the row count are left to phones and full-width lists). */
@media (min-width: 681px) {
.tabs.site-tabs .table-tools { flex-wrap: nowrap; gap: 6px; margin-bottom: 6px; }
.tabs.site-tabs .table-search { flex: 1 1 90px; min-width: 0; max-width: 200px; }
.tabs.site-tabs .table-layout, .tabs.site-tabs .table-count, .tabs.site-tabs .table-pager .muted { display: none; }
.tabs.site-tabs .table-tools .table-pager { margin-left: auto; flex-wrap: nowrap; }
}
/* A wide table in a tab pane scrolls inside its own wrapper instead of stretching the grid track (and the phone viewport) to its content width. */
.tabs > .panes { grid-template-columns: minmax(0, 1fr); }
.tabs > .panes > .pane { min-width: 0; }
/* Uniform detail layout (ui/detail): a summary beside (aside) or above (band) the one primary list. */
h3 { margin: 0 0 6px; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.detail-side, .detail-main { min-width: 0; }
.detail-side .facts { margin: 0 0 10px; }
.detail-side .notice { margin: 0 0 10px; white-space: pre-line; overflow-wrap: anywhere; }
.detail-side details.fold:last-child { margin-bottom: 0; }
.detail-side .fold-body ol { margin: 0; padding-left: 1.4em; }
.detail-side .fold-body > p { margin: 0 0 8px; }
.detail-side .fold-body form label { margin-bottom: 6px; }
.detail-main { margin: 0; }
.detail-main > h2 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.detail-main .table-search { max-width: 240px; }
.detail-main td.nowrap { width: 1%; white-space: nowrap; }
.detail--band .detail-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 12px; align-items: start; }
.detail--band .detail-side > .facts, .detail--band .detail-side > .notice { grid-column: 1 / -1; }
@media (min-width: 1000px) {
    .detail--aside { grid-template-columns: clamp(280px, 26vw, 380px) minmax(0, 1fr); }
    .detail--aside .facts { grid-template-columns: minmax(0, 1fr); gap: 5px; }
    .detail--aside .facts > div { display: grid; grid-template-columns: 98px minmax(0, 1fr); gap: 0 10px; }
}

/* Tooltip (View::tip): a <details> with a "?" summary, so a tap or click opens and closes it on a phone and on a desktop, the keyboard works, and inside a <label> the label stays with the field. No JavaScript. */
.tip { position: relative; display: inline-block; vertical-align: middle; margin-left: .35rem; font-weight: 400; }
.tip > .tip-t { display: inline-grid; place-items: center; box-sizing: border-box; width: 1.4rem; height: 1.4rem; margin: 0; padding: 0; border: 1px solid var(--border-control); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: .85rem; font-weight: 700; line-height: 1; cursor: pointer; list-style: none; user-select: none; }
.tip > .tip-t::-webkit-details-marker { display: none; }
.tip[open] > .tip-t { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tip > .tip-t:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tip > .tip-b { display: block; position: absolute; z-index: var(--z-menu); left: 0; top: calc(100% + .4rem); box-sizing: border-box; width: max-content; max-width: min(26rem, calc(100vw - 2rem)); padding: .6rem .8rem; border: 1px solid var(--border-control); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); font-size: 13px; line-height: 1.45; font-weight: 400; text-align: left; white-space: normal; }
/* A phone has no room for a floating box: the explanation opens in the text flow under the "?" and never leaves the screen. */
@media (max-width: 720px) { .tip { position: static; display: inline; } .tip > .tip-b { position: static; width: auto; max-width: none; margin: .4rem 0 0; box-shadow: none; background: var(--surface-soft); } }
