:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #677085;
    --border: #dfe2e8;
    --primary: #1f6feb;
    --primary-text: #ffffff;
    --danger: #c62828;
    --success: #2e7d32;
    --warning: #a15c00;
    --radius: 8px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
a { color: var(--primary); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar a { text-decoration: none; color: var(--muted); }
.topbar a.active, .topbar a:hover { color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.brand { font-weight: 700; color: var(--text) !important; }
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }

body.auth { display: grid; place-items: center; min-height: 100vh; }
.auth-card { width: min(400px, calc(100vw - 2rem)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.auth-card .brand { text-align: center; font-size: 1.35rem; }

.stack { display: flex; flex-direction: column; gap: .85rem; }
.narrow { max-width: 380px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=search] {
    font: inherit; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; min-width: 0;
}
input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.code-input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }

.btn {
    font: inherit; display: inline-block; padding: .5rem 1rem; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }

.alert { padding: .65rem .9rem; border-radius: 6px; margin: 0 0 1rem; border: 1px solid; }
.alert-error, .alert-danger { color: var(--danger); background: #fdecec; border-color: #f5c2c2; }
.alert-success { color: var(--success); background: #eaf6eb; border-color: #bfe2c1; }
.alert-warning { color: var(--warning); background: #fff5e5; border-color: #f3d39b; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-success { background: #eaf6eb; color: var(--success); }
.badge-danger { background: #fdecec; color: var(--danger); }

.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); margin: .75rem 0; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.row-warn td { background: #fff8ec; }

.backup-codes { columns: 2; list-style: none; padding: 0; font-size: 1.1rem; }
.backup-codes li { padding: .25rem 0; }
.totp-setup { margin: 1rem 0; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* --- Phase 2: projects ------------------------------------------------- */
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 800px) { .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; } }
form > div, .card form div:has(> label) { margin-bottom: .75rem; }
input[type=number], input[type=url], select, textarea {
    font: inherit; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; width: 100%;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.card input[type=text], .card input[type=email], .card input[type=password] { width: 100%; }
.inline input[type=text], .inline input[type=search] { width: auto; }
label:has(input[type=checkbox]), label:has(input[type=radio]) { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0; }
legend, .card label.required:not(:has(input)) { font-weight: 500; }
.help, .help-text, [id$=_help] { color: var(--muted); font-size: .85rem; margin: .2rem 0 0; }
.backup-codes li, .card ol li, .card ul.plain li { color: inherit; }
.db-row { border: 1px dashed var(--border); border-radius: 6px; padding: .75rem; margin-bottom: .75rem; }
.mt { margin-top: 1rem; }
.key { background: #f0f2f5; padding: .75rem; border-radius: 6px; white-space: pre-wrap; word-break: break-all; font-size: .85rem; }
.copy-key { position: relative; }
.copy-key .key { padding-right: 2.75rem; }
.copy-btn { position: absolute; top: .4rem; right: .4rem; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; }
.copy-btn:hover { color: var(--text); border-color: var(--muted); }
.copy-btn .icon-check, .copy-btn.copied .icon-copy { display: none; }
.copy-btn.copied .icon-check { display: block; }
.copy-btn.copied { color: var(--success); border-color: var(--success); }
.help-box summary { cursor: pointer; color: var(--primary); margin: .25rem 0 .5rem; }
.danger-zone { border-color: #f5c2c2; margin-top: 2rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.status { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.status-ok { background: #eaf6eb; color: var(--success); }
.status-warning { background: #fff5e5; color: var(--warning); }
.status-failed { background: #fdecec; color: var(--danger); }
.status-skipped { background: #eef0f3; color: var(--muted); }
pre.detail { margin: .35rem 0 0; font-size: .8rem; white-space: pre-wrap; color: var(--muted); }
.row-muted td { color: var(--muted); }
.badge { background: #eef0f3; color: var(--muted); }
.narrow-card { max-width: 460px; }
.code.secret, code.secret { font-size: 1rem; background: #fff5e5; padding: .15rem .4rem; border-radius: 4px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile { display: flex; flex-direction: column; gap: .25rem; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); position: relative; padding-left: 2.25rem; }
.tile:hover { border-color: var(--muted); }
.tile-light { position: absolute; left: 1rem; top: 1.25rem; width: .7rem; height: .7rem; border-radius: 50%; }
.light-green { background: var(--success); }
.light-red { background: var(--danger); }
.light-grey { background: #b5bac4; }
.light-off { background: transparent; border: 2px solid #b5bac4; }

@media print {
    .topbar, .inline, .alert-success { display: none !important; }
    body { background: #fff; }
    .card { border: 0; }
}

/* --- Phase 3: runs ----------------------------------------------------- */
.light-yellow { background: #e0a100; }
.step-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.step p { margin: .5rem 0 0; }
.step details { margin-top: .5rem; }
pre.plain { margin: 0; white-space: pre-wrap; font-family: inherit; }
.danger-text { color: var(--danger); }
.status-running { background: #e8f0fe; color: var(--primary); }
a.status { text-decoration: none; }
.page-head h2 { margin: 0; }

/* --- Phase 6: snapshots & restore --------------------------------------- */
.breadcrumbs { margin: 0 0 .75rem; color: var(--muted); }
.inline-form { display: inline; }
.restore-summary { background: #fff5e5; border: 1px solid #f3d39b; border-radius: 6px; padding: .75rem 1rem; }
.restore-summary dl { margin: 0; }

/* --- Forms & wizard (UX overhaul) --------------------------------------- */
.field { margin-bottom: 1rem; }
.field > label, .field > legend { display: block; font-weight: 600; margin-bottom: .3rem; }
.field-check { margin-bottom: .75rem; }
label.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; flex-direction: row; }
label.check input { width: 1.05rem; height: 1.05rem; }
.form-errors { list-style: none; padding: 0; margin: .3rem 0 0; color: var(--danger); font-size: .9rem; }
.form-errors li { color: var(--danger) !important; }
input:invalid:focus, .field:has(.form-errors) input, .field:has(.form-errors) select, .field:has(.form-errors) textarea { border-color: var(--danger); }

label.option { display: flex; align-items: flex-start; gap: .55rem; padding: .35rem 0; cursor: pointer; font-weight: 400; flex-direction: row; }
label.option input { margin-top: .25rem; }
.option-text { display: flex; flex-direction: column; }
.option-text strong { font-weight: 500; }
.option-text small { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.cards label.option { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
.cards label.option:has(input:checked) { border-color: var(--primary); background: #f2f7ff; box-shadow: 0 0 0 1px var(--primary); }

.wizard-nav { display: flex; gap: .25rem; list-style: none; padding: 0; margin: 0 0 1.25rem; counter-reset: step; flex-wrap: wrap; }
.wizard-nav li { flex: 1; min-width: 120px; }
.wizard-nav button { width: 100%; display: flex; align-items: center; gap: .5rem; background: none; border: 0; border-bottom: 3px solid var(--border); padding: .5rem .25rem; font: inherit; color: var(--muted); cursor: pointer; text-align: left; }
.wizard-nav .num { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--border); color: var(--text); font-size: .85rem; font-weight: 600; flex: none; }
.wizard-nav li.done button { border-color: #9ec1f7; color: var(--text); }
.wizard-nav li.done .num { background: #9ec1f7; }
.wizard-nav li.active button { border-color: var(--primary); color: var(--text); font-weight: 600; }
.wizard-nav li.active .num { background: var(--primary); color: #fff; }
.wizard-nav li.error .num { background: var(--danger); color: #fff; }
.wizard-step h2 { font-size: 1.25rem; }
.wizard-actions { display: flex; justify-content: flex-end; gap: .5rem; margin: 1rem 0 2rem; }
.wizard-actions [hidden] { display: none; }

.grid-host { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 3fr); }
@media (max-width: 800px) { .grid-host { grid-template-columns: 1fr; } }
details.advanced { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .75rem; }
details.advanced > summary { cursor: pointer; color: var(--primary); font-weight: 500; margin-bottom: .75rem; }
.help-box { background: #f6f8fb; border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; margin-bottom: 1rem; }
.help-box p { margin: 0 0 .5rem; }

.schedule { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem .25rem; }
.schedule-fields { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; }
.schedule-fields .field { min-width: 150px; }
.schedule-fields input[type=time] { font: inherit; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; }
.schedule-description { color: var(--success); font-weight: 500; margin: 0 0 .5rem; }
.field > .schedule + .help { margin-top: .4rem; }

.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.preset { text-align: left; font: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; cursor: pointer; display: flex; flex-direction: column; gap: .2rem; }
.preset small { color: var(--muted); }
.preset.active { border-color: var(--primary); background: #f2f7ff; box-shadow: 0 0 0 1px var(--primary); }
.retention-fields { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.retention-fields input { width: 5rem; }

/* --- Project page ------------------------------------------------------- */
h1.with-light { display: flex; align-items: center; gap: .6rem; }
h1.with-light .tile-light { position: static; width: .85rem; height: .85rem; }
.subline { margin: .25rem 0 0; }
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 10; min-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .35rem 0; }
.menu-items a, .menu-items button { display: block; width: 100%; text-align: left; padding: .5rem 1rem; background: none; border: 0; font: inherit; color: var(--text); text-decoration: none; cursor: pointer; }
.menu-items a:hover, .menu-items button:hover { background: #f2f4f7; }
.menu-items form { margin: 0; }
.checklist { margin: 0; padding-left: 1.4rem; }
.checklist li { margin-bottom: 1rem; padding-left: .25rem; }
.checklist li p { margin: .2rem 0 .4rem; }
.checklist li.done strong { text-decoration: line-through; color: var(--muted); }
.checklist li.done::marker { content: '✔ '; color: var(--success); }
.checklist details { margin-top: .4rem; }
.checklist details > summary { cursor: pointer; }
.setup { border-color: #9ec1f7; }

/* --- Folder picker ------------------------------------------------------ */
.picker { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; background: #fbfcfd; }
.picker-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.picker-status { margin: 0; }
.picker-ok { color: var(--success); }
.picker-error { color: var(--danger); font-weight: 500; }
.picker-busy { color: var(--muted); }
.picker-browser { border: 1px solid var(--border); border-radius: 6px; background: #fff; margin-bottom: 1rem; }
.picker-crumbs { padding: .5rem .75rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.picker-crumbs button, button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; }
.picker-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .35rem .75rem; border-bottom: 1px solid #f0f2f5; }
.picker-list li:last-child { border-bottom: 0; }
.picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-actions { display: inline-flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.picker-suggest { font-size: .8rem; color: #8a5a00; background: #fff5e5; border: 1px solid #f3d39b; border-radius: 999px; padding: .05rem .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .15rem .35rem .15rem .65rem; font-size: .9rem; border: 1px solid var(--border); }
.chip button { background: none; border: 0; cursor: pointer; font-size: 1rem; line-height: 1; color: inherit; }
.chip-on, .btn.chip-on { background: #eaf6eb; border-color: #bfe2c1; color: var(--success); }
.chip-off, .btn.chip-off { background: #fdecec; border-color: #f5c2c2; color: var(--danger); }
.key-install-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .25rem; }
.key-install-form input[type=password] { flex: 1 1 14rem; max-width: 22rem; }
.key-revoke { flex-basis: 100%; margin: .5rem 0; }
.key-revoke ul { margin: .25rem 0 0; padding-left: 1.25rem; font-size: .9rem; }

/* Live view */
.live-card:has(> [data-live-project]:empty) { display: none; }
.live-slot { display: block; margin-top: .35rem; font-size: .85rem; }
.live-slot:empty { display: none; }
.live-head { display: flex; align-items: center; gap: .4rem; font-weight: 600; }
.live-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--primary); animation: live-pulse 1.4s ease-in-out infinite; }
.live-step { margin: .2rem 0 .35rem; }
.live-bar { height: .45rem; background: #e8ebf0; border-radius: 999px; overflow: hidden; }
.live-bar span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .6s ease; }
.live-bar.indeterminate span { width: 35% !important; animation: live-slide 1.6s ease-in-out infinite; }
.live-facts { color: var(--muted); margin-top: .3rem; font-variant-numeric: tabular-nums; }
.live-file { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .25rem; }
.live-steps { margin: .5rem 0; padding-left: 1.1rem; font-size: .85rem; }
.live-steps .status-failed { color: var(--danger); }
.live-steps .status-warning { color: var(--warning); }
.live-next { color: var(--muted); font-variant-numeric: tabular-nums; }
.live-next strong { color: var(--text); }
@keyframes live-pulse { 50% { opacity: .3; } }
@keyframes live-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .live-dot, .live-bar.indeterminate span { animation: none; } }

/* Statistics */
.charts { gap: 0 1.25rem; }
.chart { width: 100%; height: 260px; }
.chart-calendar { height: 190px; }

/* --- Dashboard (full width) --------------------------------------------- */
.container.wide { max-width: 1680px; }
.overall { margin: .2rem 0 0; font-weight: 600; }
.overall-green { color: var(--success); }
.overall-yellow { color: var(--warning); }
.overall-red { color: var(--danger); }
.section-title { font-size: 1.05rem; margin: 1.5rem 0 .75rem; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; border-top: 3px solid var(--border); }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-green { border-top-color: var(--success); }
.kpi-red { border-top-color: var(--danger); }
.kpi-red .kpi-value { color: var(--danger); }
.kpi-blue { border-top-color: var(--primary); }

.attention { border-left: 4px solid var(--danger); }
.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.attention-list li:last-child { border-bottom: 0; }
.attention-list .tile-light { position: static; flex: none; }
.attention-text { flex: 1; display: flex; flex-direction: column; }
.attention-actions { display: flex; gap: .5rem; flex: none; }
@media (max-width: 700px) { .attention-list li { flex-wrap: wrap; } }

.tiles { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tile { padding: 1rem 1.1rem; border-left: 4px solid var(--border); gap: .6rem; }
.tile-green { border-left-color: var(--success); }
.tile-yellow { border-left-color: #e0a100; }
.tile-red { border-left-color: var(--danger); }
.tile-off { opacity: .7; }
.tile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.tile-name { font-size: 1.05rem; overflow-wrap: anywhere; }
.pill { font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; background: #eef0f3; color: var(--muted); }
.pill-green { background: #eaf6eb; color: var(--success); }
.pill-yellow { background: #fff5e5; color: var(--warning); }
.pill-red { background: #fdecec; color: var(--danger); }
.tile-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.tile-facts dt { color: var(--muted); font-size: .75rem; }
.tile-facts dd { margin: 0; font-size: .9rem; font-weight: 500; }

.dashboard-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.2fr); gap: 1rem; margin-top: 1.5rem; }
@media (max-width: 1200px) { .dashboard-bottom { grid-template-columns: 1fr 1fr; } .dashboard-bottom > :first-child { grid-column: 1 / -1; } }
@media (max-width: 800px) { .dashboard-bottom { grid-template-columns: 1fr; } }
.recent-runs { list-style: none; margin: 0; padding: 0; }
.recent-runs li { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid #f0f2f5; }
.recent-runs li:last-child { border-bottom: 0; }
.recent-runs li .muted { grid-column: 2; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.status-success { background: #eaf6eb; color: var(--success); }

/* --- Small screens ------------------------------------------------------ */
@media (max-width: 800px) {
    .topbar { flex-wrap: wrap; gap: .5rem; padding: .6rem 1rem; }
    .user-menu-name { display: none; }
    .container { padding: 1rem; }
    .page-head { flex-wrap: wrap; }
}
.alert-info { color: #1d4f91; background: #eaf2ff; border-color: #b9d3f7; }
.done-note { color: var(--success); margin: .2rem 0 .4rem; font-size: .9rem; }
.setup-history summary { cursor: pointer; color: var(--success); }
.setup-history ul { margin: .4rem 0 0; padding-left: 1rem; }

/* --- Live progress (stages + bar) --------------------------------------- */
.live-head .muted { font-weight: 400; }
.live-stages { display: flex; list-style: none; margin: .75rem 0 .6rem; padding: 0; gap: 0; counter-reset: stage; }
.live-stages li { flex: 1; position: relative; padding-top: 1.6rem; text-align: center; font-size: .85rem; color: var(--muted); counter-increment: stage; }
.live-stages li::before { content: counter(stage); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 1.3rem; height: 1.3rem; border-radius: 50%; background: #e8ebf0; color: var(--muted); font-size: .75rem; font-weight: 600; display: grid; place-items: center; z-index: 1; }
.live-stages li::after { content: ''; position: absolute; top: .62rem; left: -50%; width: 100%; height: 2px; background: #e8ebf0; }
.live-stages li:first-child::after { display: none; }
.live-stages li.stage-done { color: var(--text); }
.live-stages li.stage-done::before { content: '✓'; background: var(--success); color: #fff; }
.live-stages li.stage-done::after, .live-stages li.stage-current::after { background: var(--success); }
.live-stages li.stage-current { color: var(--primary); font-weight: 600; }
.live-stages li.stage-current::before { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px #dbe8fd; }
.live-stages li.stage-failed { color: var(--danger); }
.live-stages li.stage-failed::before { content: '!'; background: var(--danger); color: #fff; }
.live-stages li.stage-skipped::before { content: '–'; }
.live-progress { display: flex; align-items: center; gap: .75rem; }
.live-progress .live-bar { flex: 1; height: .7rem; }
.live-percent { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3rem; text-align: right; }
.live-step { font-weight: 500; overflow-wrap: anywhere; }
.alert-down { color: var(--danger); background: #fdecec; border-color: #f5c2c2; }

/* --- Live progress in dashboard tiles ----------------------------------- */
.tile-running { border-left-color: var(--primary) !important; }
.live-slot:not(:empty) { border-top: 1px solid var(--border); padding-top: .6rem; margin-top: .1rem; }
.live-compact { display: flex; flex-direction: column; gap: .35rem; }
.live-compact-head { display: flex; align-items: center; gap: .45rem; }
.live-compact-head strong { color: var(--primary); }
.live-compact-value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.live-bar.thin { height: .35rem; }
/* Unknown progress: calm moving stripes instead of a jumping block */
.live-bar.indeterminate span { width: 100% !important; animation: live-stripes 1.2s linear infinite; background: repeating-linear-gradient(-45deg, var(--primary) 0 8px, #6ea3f5 8px 16px); background-size: 22.6px 22.6px; opacity: .55; }
@keyframes live-stripes { to { background-position: 22.6px 0; } }
@media (prefers-reduced-motion: reduce) { .live-bar.indeterminate span { animation: none; } }
.live-stalled { color: var(--warning); background: #fff5e5; border-radius: 6px; padding: .3rem .55rem; font-size: .85rem; margin-top: .2rem; }

/* --- Login & second factor ---------------------------------------------- */
body.auth { display: block; min-height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, #e3edfd 0%, var(--bg) 60%); }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; gap: 1rem; }
.auth-card { width: min(420px, 100%); padding: 2rem 2rem 1.75rem; box-shadow: 0 10px 30px rgba(20, 40, 80, .08); }
.auth-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.5rem; }
.auth-logo { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 10px; background: var(--primary); color: #fff; flex: none; }
.auth-product { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.auth-company { color: var(--muted); font-size: .8rem; letter-spacing: .06em; }
.auth-title { font-size: 1.45rem; margin: 0 0 .25rem; }
.auth-lead { color: var(--muted); margin: 0 0 1.25rem; }
.auth-hint { color: var(--muted); font-size: .85rem; margin: .45rem 0 0; text-align: center; }
.auth-section .alert { margin-top: .75rem; }
.btn-large { padding: .7rem 1rem; font-size: 1rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-dark { background: #1d2330; border-color: #1d2330; color: #fff; }
.btn-dark:hover { background: #2c3446; }
.btn:focus-visible, .password-toggle:focus-visible { outline: 3px solid #9ec1f7; outline-offset: 2px; }
.auth-card label { font-weight: 600; }
.auth-card input[type=email], .auth-card input[type=password], .auth-card input[type=text] { width: 100%; padding: .65rem .75rem; font-size: 1rem; }
.field-password { display: flex; flex-direction: column; gap: .25rem; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 5.5rem !important; }
.password-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--primary); font: inherit; font-size: .85rem; cursor: pointer; padding: .3rem .5rem; border-radius: 4px; }
.caps-hint { color: var(--warning); font-size: .85rem; margin: 0; }
.auth-card .code-input { font-size: 1.8rem; letter-spacing: .45em; text-align: center; padding: .6rem; font-variant-numeric: tabular-nums; }
.auth-help { margin-top: 1.25rem; font-size: .9rem; }
.auth-help summary { cursor: pointer; color: var(--primary); }
.auth-help p { color: var(--muted); margin: .5rem 0 0; }
.auth-footer { display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--muted); font-size: .82rem; text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 480px) { .auth-card { padding: 1.5rem 1.25rem; } }

/* --- Cancel / queue actions --------------------------------------------- */
.live-actions { display: flex; justify-content: flex-end; margin-top: .6rem; }
.live-card:has(> [data-live-project]:empty) .live-actions { display: none; }
.alert-action { display: inline-block; margin-left: .75rem; }
.status-cancelled { background: #eef0f3; color: var(--muted); }
.stage-cancelled { color: var(--muted); }

/* --- Account & users ---------------------------------------------------- */
.badge-success { background: #eaf6eb; color: var(--success); }
.badge-danger { background: #fdecec; color: var(--danger); }
.avatar { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: #dbe8fd; color: #1d4f91; font-weight: 700; font-size: .85rem; flex: none; }
.avatar-large { width: 4.5rem; height: 4.5rem; font-size: 1.4rem; }
.avatar-small { width: 1.6rem; height: 1.6rem; font-size: .65rem; }
img.avatar { object-fit: cover; background: #e5e7eb; }
.user-menu { margin-left: auto; }
.user-menu-button { display: inline-flex; align-items: center; gap: .45rem; padding: .2rem .5rem .2rem .25rem; border-radius: 999px; color: var(--muted); cursor: pointer; }
.user-menu-button:hover, .user-menu[open] > .user-menu-button, .user-menu-button.active { color: var(--text); background: #f2f4f7; }
.user-menu-caret { flex: none; transition: transform .15s; }
.user-menu[open] .user-menu-caret { transform: rotate(180deg); }
.user-menu-items { min-width: 240px; }
.user-menu-head { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; line-height: 1.3; }
.user-menu-items a.user-menu-logout { border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .6rem; }
.live-hint { display: flex; align-items: center; gap: .4rem; }
.avatar-drop { flex: none; display: grid; justify-items: center; gap: .25rem; }
.avatar-drop form { margin: 0; }
.avatar-zone { position: relative; display: block; border-radius: 50%; cursor: pointer; outline: 2px dashed transparent; outline-offset: 4px; transition: outline-color .15s, transform .15s; }
.avatar-zone:hover, .avatar-zone:focus-within { outline-color: #9db8e6; }
.avatar-zone.is-dragover { outline-color: #2563eb; transform: scale(1.06); }
.avatar-zone.is-busy { opacity: .55; pointer-events: none; }
.avatar-zone-hint { position: absolute; inset: auto 0 0 0; height: 40%; display: grid; place-items: center; border-radius: 0 0 999px 999px; background: rgba(17, 24, 39, .55); color: #fff; font-size: .7rem; font-weight: 600; opacity: 0; transition: opacity .15s; }
.avatar-zone:hover .avatar-zone-hint, .avatar-zone:focus-within .avatar-zone-hint, .avatar-zone.is-dragover .avatar-zone-hint { opacity: 1; }
.avatar-status { margin: 0; max-width: 9rem; text-align: center; min-height: 1em; }
.avatar-status.is-error { color: #b42318; }
.profile-avatar-remove { margin: 0; }
.profile-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.profile-main { flex: 1; min-width: 220px; }
.profile-main h1 { margin: 0; }
.profile-main p { margin: .2rem 0 0; }
.profile-edit summary { list-style: none; }
.profile-edit[open] summary { display: none; }
.security-item { padding: 1.1rem 1.25rem; }
.security-head { display: flex; align-items: flex-start; gap: .9rem; }
.security-text { flex: 1; }
.security-text h3 { margin: 0 0 .15rem; font-size: 1.05rem; }
.security-text p { margin: 0; }
.security-icon { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; font-weight: 700; flex: none; }
.security-icon.is-ok { background: #eaf6eb; color: var(--success); }
.security-icon.is-open { background: #fff5e5; color: var(--warning); }
.security-icon.is-bad { background: #fdecec; color: var(--danger); }
.security-actions { margin: .9rem 0 0 2.7rem; }
details.security-actions > summary { list-style: none; display: inline-block; }
details.security-actions[open] > summary { margin-bottom: .75rem; }
.passkey-list { list-style: none; margin: .9rem 0 0 2.7rem; padding: 0; }
.passkey-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.passkey-list li > div { display: flex; flex-direction: column; }
.passkey-add { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0 0 2.7rem; }
.passkey-add input { flex: 1 1 14rem; max-width: 22rem; }
.passkey-add .alert { flex-basis: 100%; }
.menu-form { padding: .75rem 1rem; }
.menu-form form + form { margin-top: .5rem; border-top: 1px solid var(--border); padding-top: .5rem; }
.users-layout { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .users-layout { grid-template-columns: 1fr; } }
.user-cell { display: flex; align-items: center; gap: .6rem; }
.users-table td { vertical-align: middle; }
.menu-danger { padding: .5rem 1rem; border-top: 1px solid var(--border); }
.menu-danger summary { cursor: pointer; color: var(--danger); }
.menu-danger form { margin-top: .5rem; }
.setup-step { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.setup-step h2 { font-size: 1.05rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.step-num { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--primary); color: #fff; font-size: .8rem; }
.setup-qr { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.setup-qr img { border: 1px solid var(--border); border-radius: 8px; padding: .4rem; background: #fff; }
.setup-link-card { border-left: 4px solid var(--primary); }
@media (max-width: 600px) { .security-actions, .passkey-list, .passkey-add { margin-left: 0; } }
.btn-link { background: none; border-color: transparent; color: #b42318; }

/* Dialogs (modal and confirmation) */
.dialog { border: 0; padding: 0; border-radius: 14px; width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(16, 24, 40, .28), 0 2px 6px rgba(16, 24, 40, .08); overflow: visible; }
.dialog > form { display: flex; flex-direction: column; max-height: calc(100vh - 3rem); margin: 0; }
.dialog::backdrop { background: rgba(16, 24, 40, .45); backdrop-filter: blur(3px); }
.dialog[open] { animation: dialog-in .18s ease-out; }
.dialog[open]::backdrop { animation: backdrop-in .18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes backdrop-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dialog[open], .dialog[open]::backdrop { animation: none; } }
.dialog-header { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem .9rem; border-bottom: 1px solid var(--border); }
.dialog-header p { margin: 0; }
.dialog-title { margin: 0; font-size: 1.08rem; line-height: 1.3; }
.dialog-close { margin-left: auto; align-self: flex-start; width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.dialog-close:hover { background: #f2f4f7; color: var(--text); }
.dialog-content { padding: 1rem 1.25rem; overflow-y: auto; }
.dialog-content > p:first-child { margin-top: 0; }
.dialog-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 14px 14px; }
.dialog-confirm { width: min(27rem, calc(100vw - 2rem)); }
.dialog-confirm .dialog-body { display: flex; gap: .9rem; padding: 1.35rem 1.35rem 1.1rem; }
.dialog-confirm .dialog-message { margin: .35rem 0 0; color: var(--muted); }
.dialog-confirm .dialog-message:empty { display: none; }
.dialog-icon { flex: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: #e8f0fe; color: var(--primary); font-weight: 800; font-size: 1.1rem; }
.dialog-confirm.is-danger .dialog-icon { background: #fdecec; color: var(--danger); }
.dialog-confirm .btn-danger { background: var(--danger); color: #fff; }
.dialog-confirm .dialog-footer { border-top: 0; }

/* Visible projects of a viewer: switch, chips and search */
form:has(input[name="admin"][value="1"]:checked) .viewer-only { display: none; }
.viewer-only { border: 0; padding: 0; margin: 0; }
.viewer-only > legend { font-weight: 600; margin-bottom: .35rem; padding: 0; }
.switch { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: normal; }
.switch input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { flex: none; position: relative; width: 2.3rem; height: 1.3rem; border-radius: 999px; background: #cfd5df; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(1rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.picker { margin-top: .8rem; }
.picker[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: .2rem; padding: .2rem .25rem .2rem .65rem; border-radius: 999px; background: #e8f0fe; color: #1d4f91; font-size: .88rem; font-weight: 500; }
.chip-remove { border: 0; background: none; color: inherit; width: 1.3rem; height: 1.3rem; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; opacity: .7; }
.chip-remove:hover, .chip-remove:focus-visible { opacity: 1; background: rgba(29, 79, 145, .12); }
.picker-empty { margin: 0; }
.picker-empty[hidden] { display: none; }
.combobox { margin-top: .6rem; }
.combobox input { width: 100%; }
.combobox-results { list-style: none; margin: .3rem 0 0; padding: .25rem 0; border: 1px solid var(--border); border-radius: var(--radius); max-height: 13.5rem; overflow-y: auto; background: var(--surface); }
.combobox-results [role="option"] { padding: .4rem .75rem; cursor: pointer; }
.combobox-results [role="option"]:hover, .combobox-results [role="option"].is-active { background: #eef3fd; }
.picker-more { padding: .4rem .75rem; }
.picker-summary { margin: .6rem 0 0; color: var(--muted); }
.picker-summary.is-error { color: var(--danger); font-weight: 600; }

.dialog-danger .dialog-icon { background: #fdecec; color: var(--danger); }
.dialog-facts { margin: 0 0 1rem; padding-left: 1.1rem; display: grid; gap: .35rem; }
.dialog-content label input { display: block; width: 100%; margin-top: .3rem; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:disabled { opacity: .45; cursor: not-allowed; }
.menu-items .menu-item-danger { color: var(--danger); border-top: 1px solid var(--border); }

/* List tables (projects, runs): flush card, the whole row opens the detail page (lib/row_links.js) */
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table { margin: 0; }
.list-table th { padding: .7rem 1rem; background: #fafbfc; white-space: nowrap; }
.list-table td { padding: .85rem 1rem; }
.list-table tbody tr:last-child td { border-bottom: 0; }
.list-table td .small { display: block; margin-top: .1rem; }
.list-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-target { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.row-link { cursor: pointer; transition: background .1s; }
.row-link:hover td { background: #f7f9fc; }
.row-link:hover .row-target { color: var(--primary); }
.row-link .row-target:focus-visible { outline: none; }
.row-link:has(.row-target:focus-visible) td { background: #eef3fd; }
.row-off td { color: var(--muted); }
@media (max-width: 640px) {
    .list-table thead { display: none; }
    .list-table, .list-table tbody, .list-table tr, .list-table td { display: block; }
    .list-table tr { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
    .list-table td { border: 0; padding: .15rem 0; }
    .list-table td.hide-mobile { display: none; }
    .list-table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .75rem; margin-top: .35rem; }
    .list-table td[data-label] .small { display: inline; margin-left: .3rem; }
    .list-table .num { text-align: left; }
}

/* Project list */
.project-table .col-project { width: 34%; }
.project-cell { display: flex; align-items: flex-start; gap: .75rem; }
.project-cell .tile-light { position: static; flex: none; margin-top: .4rem; }
.project-cell .live-slot:not(:empty) { display: block; border-top: 0; padding-top: 0; margin-top: .5rem; max-width: 22rem; }
.col-schedule { line-height: 1.45; }
@media (max-width: 900px) { .col-schedule { display: none; } }
@media (max-width: 640px) { .project-table td:not(:first-child) { padding-left: 1.45rem; } }

/* Main navigation on small screens: menu button with a dropdown list */
.nav-toggle { display: none; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; }
.nav-toggle:hover { background: #f2f4f7; }
.nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: inline; }
@media (max-width: 800px) {
    .nav-toggle { display: inline-grid; }
    .topbar .main-nav { display: none; order: 3; flex: 0 0 calc(100% + 2rem); flex-direction: column; gap: 0; margin: .35rem -1rem -.6rem; padding: .35rem 0; border-top: 1px solid var(--border); }
    .topbar .main-nav.is-open { display: flex; }
    .main-nav a { padding: .7rem 1rem; font-size: 1rem; border-left: 3px solid transparent; }
    .main-nav a:hover { background: #f7f9fc; }
    .main-nav a.active { color: var(--primary); font-weight: 600; background: #eef3fd; border-left-color: var(--primary); }
}

/* Run list */
.list-table .day-row th { padding: .55rem 1rem; background: #f3f5f8; color: var(--text); font-size: .85rem; font-weight: 600; border-bottom: 1px solid var(--border); }
.list-table .day-row th span { color: var(--muted); font-weight: 400; margin-left: .35rem; }
.run-table .row-target { font-weight: 500; }
.run-table td { padding-top: .6rem; padding-bottom: .6rem; }
.run-type { font-size: .9rem; margin-left: .15rem; }
.run-what { max-width: 26rem; }
.run-error { display: block; color: var(--danger); margin-top: .2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-row { text-align: center; padding: 2rem 1rem !important; }
@media (max-width: 640px) {
    .list-table .day-row { padding: 0; border-bottom: 0; }
    .list-table .day-row th { display: block; }
    .run-table tr.row-link { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
    .run-table tr.row-link > td:not([data-label]) { grid-column: 1 / -1; }
    .run-table tr.row-link > td:first-child:has(+ .run-project) { grid-column: 1; }
    .run-table .run-project { grid-column: 2 / -1 !important; text-align: right; color: var(--muted); }
    .run-table td.hide-mobile { display: none; }
    .run-table tr.row-link > td { padding: .1rem 0; }
    .run-what { max-width: none; }
    .run-error { white-space: normal; }
}

/* Run filters: status chips, project list with search, active filters */
.run-filters { margin-bottom: 1rem; }
.run-filters-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.status-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.toggle-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .4rem .3rem .75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: .88rem; font-weight: 500; cursor: pointer; user-select: none; transition: background .1s, border-color .1s; }
.toggle-chip:hover { border-color: #b5bac4; }
.toggle-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-chip:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle-count { min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: #eef0f3; color: var(--muted); font-size: .78rem; text-align: center; font-variant-numeric: tabular-nums; }
.toggle-chip:has(input:checked) { border-color: var(--primary); background: #eef3fd; color: #1d4f91; box-shadow: 0 0 0 1px var(--primary); }
.toggle-chip:has(input:checked) .toggle-count { background: var(--primary); color: #fff; }
.toggle-failed:has(input:checked) { border-color: var(--danger); background: #fdecec; color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.toggle-failed:has(input:checked) .toggle-count { background: var(--danger); }
.toggle-warning:has(input:checked) { border-color: #e0a100; background: #fff5e5; color: var(--warning); box-shadow: 0 0 0 1px #e0a100; }
.toggle-warning:has(input:checked) .toggle-count { background: #e0a100; }
.toggle-success:has(input:checked) { border-color: var(--success); background: #eaf6eb; color: var(--success); box-shadow: 0 0 0 1px var(--success); }
.toggle-success:has(input:checked) .toggle-count { background: var(--success); }

.filter-pop { position: relative; }
.filter-pop > summary { list-style: none; }
.filter-pop > summary::-webkit-details-marker { display: none; }
.filter-pop-button { display: inline-flex; align-items: center; gap: .5rem; max-width: 18rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-pop-button.is-active { border-color: var(--primary); color: #1d4f91; background: #eef3fd; }
.filter-pop[open] .filter-pop-button svg { transform: rotate(180deg); }
.filter-pop-panel { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20; width: min(20rem, calc(100vw - 2rem)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.filter-pop-panel input[type="search"] { width: calc(100% - 1.2rem); margin: .6rem; }
.filter-options { list-style: none; margin: 0; padding: 0 0 .3rem; max-height: 16rem; overflow-y: auto; border-top: 1px solid var(--border); }
.filter-options label { display: flex; align-items: center; gap: .55rem; padding: .45rem .8rem; cursor: pointer; font-weight: normal; margin: 0; }
.filter-options label:hover { background: #f2f4f7; }
.filter-options input { flex: none; margin: 0; }
.filter-options li[hidden] { display: none; }
.filter-none { padding: .5rem .8rem; margin: 0; }
.filter-pop-footer { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem .6rem; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin-top: .75rem; }
.chip-link { text-decoration: none; padding: .2rem .65rem; gap: .35rem; }
.chip-link span { opacity: .7; font-size: 1rem; line-height: 1; }
.chip-link:hover { background: #dbe7fd; }
.chip-link:hover span { opacity: 1; }
.filter-reset { font-size: .88rem; margin-left: .25rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1rem 0; }
@media (max-width: 640px) {
    .filter-pop { width: 100%; }
    .filter-pop-button { width: 100%; max-width: none; justify-content: space-between; }
    .filter-pop-panel { left: 0; right: auto; width: 100%; }
}
.run-results { transition: opacity .15s; }
.run-results[aria-busy="true"] { opacity: .55; }
.filter-pop-footer { align-items: center; }

/* Run detail: breadcrumb, key figures, steps as a timeline */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; font-size: .88rem; margin-bottom: .6rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.run-head { align-items: flex-start; }
.run-title { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.run-title .status { font-size: .85rem; padding: .2rem .65rem; }
.run-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.run-actions .inline-form { margin: 0; }
.run-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; padding: 0; }
.run-stat { display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.25rem; border-right: 1px solid var(--border); }
.run-stat:nth-child(4) { border-right: 0; }
.run-stat-label { color: var(--muted); font-size: .8rem; }
.run-stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.run-stat-hint { color: var(--muted); font-size: .8rem; }
.run-snapshots { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding: .7rem 1.25rem; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }
.snapshot-link { text-decoration: none; font-size: .9rem; }
.snapshot-link:hover { text-decoration: underline; }
.timeline { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.timeline .step { position: relative; display: flex; gap: 1rem; padding-bottom: 1rem; }
.timeline .step::before { content: ""; position: absolute; left: .55rem; top: 1.5rem; bottom: 0; width: 2px; background: var(--border); }
.timeline .step:last-child::before { display: none; }
.timeline-dot { flex: none; position: relative; z-index: 1; width: 1.2rem; height: 1.2rem; margin-top: .9rem; border-radius: 50%; background: var(--surface); border: 2px solid #b5bac4; }
.step-success .timeline-dot { border-color: var(--success); background: var(--success); box-shadow: inset 0 0 0 3px var(--surface); }
.step-warning .timeline-dot { border-color: #e0a100; background: #e0a100; box-shadow: inset 0 0 0 3px var(--surface); }
.step-failed .timeline-dot { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 3px var(--surface); }
.step-running .timeline-dot { border-color: var(--primary); animation: step-pulse 1.4s ease-in-out infinite; }
@keyframes step-pulse { 50% { box-shadow: 0 0 0 5px rgba(31, 111, 235, .18); } }
@media (prefers-reduced-motion: reduce) { .step-running .timeline-dot { animation: none; } }
.step-body { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.step-failed .step-body { border-color: #f5c2c2; }
.step-body .step-head code { font-size: .8rem; color: var(--muted); }
.step-duration { margin-left: auto; font-variant-numeric: tabular-nums; }
.step-message { margin: .35rem 0 0; }
.step-body details { margin-top: .5rem; }
.step-body summary { cursor: pointer; color: var(--primary); font-size: .88rem; }
.step-body pre { max-height: 22rem; overflow: auto; }
@media (max-width: 800px) {
    .run-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .run-stat:nth-child(2n) { border-right: 0; }
    .run-stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

/* Full log of a run in a large modal */
.dialog-log { width: min(96rem, calc(100vw - 3rem)); height: calc(100vh - 3rem); }
.dialog-log-inner { display: flex; flex-direction: column; height: 100%; }
.dialog-log .dialog-header p { margin: .15rem 0 0; }
.log-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 1.25rem; border-bottom: 1px solid var(--border); background: #fafbfc; }
.log-toolbar-spacer { flex: 1; }
.log-wrap { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; font-weight: normal; margin: 0; color: var(--muted); cursor: pointer; }
.log-view { flex: 1; min-height: 0; margin: 0; padding: .75rem 0; overflow: auto; background: #0f1623; color: #d6dbe4; font: .82rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 0 0 14px 14px; counter-reset: line; }
.log-view:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.log-line { display: block; padding: 0 1.25rem 0 4.2rem; position: relative; white-space: pre; min-height: 1.55em; }
.log-view.is-wrapped .log-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-line::before { counter-increment: line; content: counter(line); position: absolute; left: 0; width: 3.2rem; text-align: right; color: #4b5567; user-select: none; }
.log-time { color: #7d889c; }
.log-section { color: #fff; font-weight: 700; margin-top: .6rem; background: rgba(255, 255, 255, .05); }
.log-result-ok { color: #7ee2a0; }
.log-result-warning, .log-warning { color: #f5c46b; }
.log-error { color: #ff9b9b; background: rgba(229, 72, 77, .14); }
.log-result-failed { font-weight: 700; }
.log-line.is-flash { background: rgba(229, 72, 77, .4); transition: background .3s; }
@media (max-width: 640px) {
    .dialog-log { width: 100vw; height: 100vh; max-height: 100vh; max-width: 100vw; border-radius: 0; }
    .log-view { border-radius: 0; }
    .log-line { padding-left: 2.9rem; }
    .log-line::before { width: 2.2rem; }
}

/* Snapshots: kind filter, file browser */
.segmented { display: inline-flex; gap: .25rem; padding: .25rem; margin-bottom: 1rem; background: #eceff3; border-radius: 10px; }
.segmented a { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .8rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.segmented a:hover { color: var(--text); }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.name-cell { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.file-icon { flex: none; color: #8a93a5; }
.file-icon-folder { color: #e0a100; }
.file-icon-db { color: #6b5bd2; }
.file-icon-files { color: var(--primary); }
.up-icon { width: 18px; text-align: center; font-size: 1.05rem; line-height: 1; }
.file-name { overflow-wrap: anywhere; }
.list-table td.row-actions { position: relative; z-index: 1; text-align: right; white-space: nowrap; width: 1%; }
.row-actions .inline-form { display: inline; margin: 0; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: #eef3fd; border-color: transparent; }
.file-table tr .btn-ghost { opacity: 0; transition: opacity .1s; }
.file-table tr:hover .btn-ghost, .file-table tr:focus-within .btn-ghost { opacity: 1; }
@media (hover: none) { .file-table tr .btn-ghost { opacity: 1; } }
.file-table .row-target { font-weight: 500; }
.row-up td { padding-top: .5rem; padding-bottom: .5rem; }
.row-up .row-target { font-weight: 400; color: var(--muted); }
.path-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .95rem; }
.path-bar a { text-decoration: none; }
.path-bar a:hover { text-decoration: underline; }
.path-sep { color: #b5bac4; }
.path-count { margin-left: auto; }
.file-table td, .snapshot-table td { padding-top: .6rem; padding-bottom: .6rem; }
@media (max-width: 640px) {
    .list-table td.row-actions { width: auto; text-align: left; padding-top: .4rem; }
    .file-table tr.row-up { padding: .5rem 1rem; }
    .file-table tbody tr:not(.row-up), .snapshot-table tbody tr:not(.day-row) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
    .file-table tbody tr > td, .snapshot-table tbody tr > td { padding: .1rem 0; }
    .file-table tbody tr > td:not([data-label]), .snapshot-table tbody tr > td:not([data-label]) { grid-column: 1 / -1; }
    .snapshot-table td.hide-mobile { display: none; }
    .file-table tr .btn-ghost { opacity: 1; padding-left: 0; }
    .segmented { display: flex; }
    .segmented a { flex: 1; justify-content: center; }
}

/* Friendly notices and error pages */
.notice-card { display: flex; gap: 1.1rem; align-items: flex-start; max-width: 46rem; padding: 1.75rem; }
.notice-icon { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: #e8f0fe; color: var(--primary); }
.notice-icon.is-warning { background: #fff5e5; color: var(--warning); }
.notice-icon.is-danger { background: #fdecec; color: var(--danger); }
.notice-body h1 { font-size: 1.35rem; margin: .35rem 0 .6rem; }
.notice-body p { margin: 0 0 .75rem; line-height: 1.55; }
.notice-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.muted-on-primary { opacity: .8; font-weight: 400; }
.error-code { color: var(--muted); font-size: .85rem; margin-top: 1rem; }
@media (max-width: 640px) { .notice-card { flex-direction: column; padding: 1.25rem; } }

/* Audit log */
.audit-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.audit-filters .segmented { margin-bottom: 0; }
.audit-search { display: flex; align-items: center; gap: .5rem; flex: 0 1 28rem; }
.audit-search input { flex: 1; min-width: 0; }
.audit-table td { padding-top: .6rem; padding-bottom: .6rem; }
.audit-table .user-cell .small { display: block; }
.audit-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; }
.audit-event { display: flex; gap: .6rem; align-items: flex-start; }
.audit-event .small { display: block; margin-top: .1rem; }
.audit-dot { flex: none; width: .55rem; height: .55rem; margin-top: .45rem; border-radius: 50%; background: #b5bac4; }
.audit-good .audit-dot { background: var(--success); }
.audit-warn .audit-dot { background: #e0a100; }
.audit-bad .audit-dot { background: var(--danger); }
.audit-bad td { background: #fffafa; }
.audit-bad strong { color: var(--danger); }
.audit-target { margin-left: .3rem; color: var(--text); }
.audit-ip { font-size: .82rem; }
.segmented-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented-scroll a { white-space: nowrap; }
@media (max-width: 640px) {
    .audit-search { flex-basis: 100%; }
    .audit-table tbody tr:not(.day-row) { display: grid; grid-template-columns: auto 1fr; gap: 0 .75rem; }
    .audit-table tbody tr > td { padding: .1rem 0; }
    .audit-table td[data-label] { grid-column: 2; }
    .audit-table td[data-label]::before { display: none; }
    .audit-table td.audit-time { width: auto; padding-top: .15rem; }
    .segmented-scroll { display: flex; }
    .segmented-scroll a { flex: none; }
}

/* Restores */
.restore-what code { font-size: .88rem; }
.restore-what .row-target { font-weight: 500; }
.restore-table td { padding-top: .6rem; padding-bottom: .6rem; }
.restore-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem 1.5rem; align-items: center; }
.restore-end { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.restore-end strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.restore-end strong a { color: inherit; text-decoration: none; }
.restore-end strong a:hover { color: var(--primary); }
.restore-arrow { font-size: 1.6rem; color: #b5bac4; }
.restore-facts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: .75rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.restore-facts dt { color: var(--muted); font-size: .8rem; }
.restore-facts dd { margin: .15rem 0 0; overflow-wrap: anywhere; }
.safety-card { border-left: 4px solid var(--success); }
.safety-card h2 { font-size: 1.05rem; margin: 0 0 .4rem; }
.safety-card p { margin: 0; line-height: 1.55; }
.restore-log { padding: 0; }
.restore-log summary { padding: .9rem 1.25rem; cursor: pointer; font-weight: 600; }
.restore-log .log-view { border-radius: 0 0 var(--radius) var(--radius); padding: .75rem 1.25rem; white-space: pre-wrap; max-height: 28rem; }
.restore-steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 .75rem; counter-reset: step; }
.restore-steps li { flex: 1; padding: .55rem .75rem; border-radius: var(--radius); background: #eef0f3; color: var(--muted); font-size: .9rem; counter-increment: step; }
.restore-steps li::before { content: counter(step) ". "; font-weight: 600; }
.restore-steps li.is-done { background: #eaf6eb; color: var(--success); }
.restore-steps li.is-done::before { content: "✓ "; }
.restore-steps li.is-current { background: #e8f0fe; color: var(--primary); font-weight: 600; }
@media (max-width: 800px) {
    .restore-flow { grid-template-columns: 1fr; }
    .restore-arrow { transform: rotate(90deg); justify-self: start; }
    .restore-facts { grid-template-columns: 1fr 1fr; }
    .restore-steps { flex-direction: column; }
}
@media (max-width: 640px) {
    .restore-table tbody tr:not(.day-row) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
    .restore-table tbody tr > td { padding: .1rem 0; }
    .restore-table tbody tr > td:not([data-label]) { grid-column: 1 / -1; }
}

/* Retention on the project page */
.retention-lead { margin: 0 0 .5rem; }
.retention-bar { display: flex; list-style: none; margin: 0; padding: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.retention-bar li { flex: 1; display: flex; flex-direction: column; gap: .1rem; padding: .45rem .65rem; font-size: .85rem; min-width: 0; }
.retention-bar li + li { border-left: 1px solid var(--border); }
.retention-bar li:nth-child(1) { background: #e8f0fe; }
.retention-bar li:nth-child(2) { background: #f1f5fd; }
.retention-bar li:nth-child(3) { background: #f8fafe; }
.retention-bar span { color: var(--muted); font-size: .8rem; }
.retention-help { margin-top: .5rem; font-size: .88rem; }
.retention-help summary { cursor: pointer; color: var(--primary); }
.retention-help ul { margin: .5rem 0 0; padding-left: 1.1rem; display: grid; gap: .35rem; color: var(--muted); line-height: 1.5; }
.retention-help strong { color: var(--text); }
@media (max-width: 640px) { .retention-bar { flex-direction: column; } .retention-bar li + li { border-left: 0; border-top: 1px solid var(--border); } }

/* Settings */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-head h2 { margin: 0; }
.card-head + p { margin-top: .5rem; }
.card-flush-head { padding: 1.25rem 1.25rem .75rem; }
.card-flush-head h2 { margin: 0 0 .35rem; }
.card-flush-head p { margin: 0; max-width: 60rem; line-height: 1.5; }
.system-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; }
.system-item { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); }
.system-item .tile-light { position: static; flex: none; margin-top: .35rem; }
.system-item .small { display: block; }
.system-hint { margin: .75rem 0 0; }
.key-fingerprint { margin: .5rem 0 0; }
.small-heading { font-size: .95rem; margin: 1.25rem 0 .4rem; }
.key-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; line-height: 1.5; }
.host-table td .small { display: block; }
.host-table td .host-role { display: inline; }
.host-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.fingerprint { color: var(--muted); word-break: break-all; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { background: #fdecec; }
.host-table a { text-decoration: none; font-weight: 500; }
.host-table a:hover { text-decoration: underline; }
