:root {
    color-scheme: dark;
    --bg: #0d1016;
    --panel: #151a23;
    --panel-2: #1b2230;
    --text: #edf1f7;
    --muted: #a8b1c1;
    --border: #2d3748;
    --accent: #8cb4ff;
    --accent-strong: #b5ceff;
    --good: #72d5a5;
    --warn: #f1c86b;
    --bad: #ff8d96;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: radial-gradient(circle at top, #172033 0, var(--bg) 32rem);
    color: var(--text);
}

button, select { font: inherit; }

.shell {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: max(22px, env(safe-area-inset-top)) 16px max(36px, env(safe-area-inset-bottom));
}

header { padding: 10px 4px 18px; }
h1 { margin: 4px 0 10px; font-size: clamp(1.8rem, 8vw, 2.6rem); line-height: 1.08; }
h2 { margin: 0 0 14px; font-size: 1.05rem; }
p { line-height: 1.55; }
.eyebrow { margin: 0; color: var(--accent); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.lead { margin: 0; color: var(--muted); }

.panel {
    margin: 12px 0;
    padding: 17px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: 0; }
.badge { padding: 4px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: .78rem; white-space: nowrap; }
.badge.running { color: var(--accent-strong); }
.badge.good { color: var(--good); }
.badge.bad { color: var(--bad); }

.metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 0;
}
.metrics.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics div { min-width: 0; padding: 12px; background: var(--panel-2); border-radius: 12px; }
dt { color: var(--muted); font-size: .78rem; }
dd { margin: 5px 0 0; font-weight: 600; overflow-wrap: anywhere; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .82rem; }
select {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
button {
    min-height: 44px;
    padding: 10px 14px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
button.primary { color: #08101e; background: var(--accent); border-color: var(--accent); font-weight: 650; }
button:disabled { opacity: .45; }
button:not(:disabled):active { transform: translateY(1px); }

.note { margin: 11px 0 0; color: var(--muted); font-size: .82rem; }
.progress-track { height: 7px; margin: 18px 0 10px; overflow: hidden; background: var(--panel-2); border-radius: 99px; }
#progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .2s ease; }
#status-text { min-height: 1.5em; margin: 0; }
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.stages li { padding: 8px; color: var(--muted); text-align: center; background: var(--panel-2); border-radius: 9px; font-size: .76rem; }
.stages li.active { color: var(--accent-strong); }
.stages li.done { color: var(--good); }
.stages li.failed { color: var(--bad); }

.verdict { margin-top: 14px; padding: 13px; border-left: 3px solid var(--border); background: var(--panel-2); border-radius: 8px; line-height: 1.5; }
.verdict.good { border-left-color: var(--good); }
.verdict.warn { border-left-color: var(--warn); }
.verdict.bad { border-left-color: var(--bad); }

details summary { cursor: pointer; color: var(--muted); }
pre { max-height: 300px; overflow: auto; margin: 14px 0 0; padding: 12px; background: #090c11; border-radius: 10px; color: #cbd5e1; font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
footer { padding: 10px 5px; color: var(--muted); font-size: .78rem; }

@media (max-width: 620px) {
    .metrics.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .controls { grid-template-columns: 1fr; }
    .stages { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 390px) {
    .metrics { grid-template-columns: 1fr; }
    .actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    #progress-bar { transition: none; }
}
