:root {
    --red: #E30613;
    --red-dark: #AA0310;
    --green: #00e86a;
    --amber: #f5b301;
    --radius: 18px;
    --radius-lg: 26px;

    --bg: #050505;
    --bg-1: #0a0a0c;
    --bg-2: #111114;
    --card: rgba(255,255,255,0.02);
    --card-border: rgba(255,255,255,0.08);
    --line: rgba(255,255,255,0.08);
    --line-strong: rgba(255,255,255,0.16);
    --text: #ffffff;
    --text-muted: rgba(255,255,255,0.68);
    --text-dim: rgba(255,255,255,0.55);
    --glass: rgba(10,10,12,0.85);
    --input-bg: #111114;
    --surface-1: rgba(255,255,255,0.03);
    --surface-2: rgba(255,255,255,0.06);
    --good: #3ee08a;
    --bad: #ff5c66;
    --warn: #f5c04a;
    --shadow-card: 0 30px 80px -20px rgba(0,0,0,0.8);
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --bg-1: #f7f7f9;
    --bg-2: #f1f1f4;
    --card: rgba(0,0,0,0.015);
    --card-border: rgba(0,0,0,0.08);
    --line: rgba(0,0,0,0.07);
    --line-strong: rgba(0,0,0,0.15);
    --text: #0a0a0a;
    --text-muted: rgba(10,10,10,0.66);
    --text-dim: rgba(10,10,10,0.55);
    --glass: rgba(255,255,255,0.85);
    --input-bg: #ffffff;
    --surface-1: rgba(0,0,0,0.02);
    --surface-2: rgba(0,0,0,0.04);
    --good: #0a7d3e;
    --bad: #c4000c;
    --warn: #8a5a00;
    --shadow-card: 0 20px 60px -16px rgba(10,10,10,0.18);
    color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; margin: 0; letter-spacing: -.3px; }
h1 { font-size: clamp(30px, 4.6vw, 44px); line-height: 1.04; letter-spacing: -1.2px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }
.accent { color: var(--red); }
.muted { color: var(--text-muted); margin: 0; }
.small { font-size: 13px; }
.hint { color: var(--text-dim); font-size: 12.5px; margin: 0; }
.label {
    margin: 0 0 6px;
    font: 500 11px 'JetBrains Mono', monospace;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--red);
}
.error { color: var(--bad); margin: 0; font-size: 14px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* Header */
.topbar {
    position: sticky; top: 0; z-index: 10;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 72px; }
.alpha-logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.alpha-logo-symbol { width: 36px; height: 36px; object-fit: contain; }
.alpha-logo-wordmark { width: 150px; height: 20px; object-fit: contain; }
.app-name {
    padding-left: 16px; border-left: 1px solid var(--line-strong);
    font: 600 15px 'Space Grotesk', sans-serif; white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.who { color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tag {
    font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 1.5px; text-transform: uppercase;
    padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-muted);
}
.tag.prod { border-color: var(--red); color: var(--text); }

/* Controls */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 9px 18px;
    border: 1px solid var(--line-strong); border-radius: 999px;
    font: 600 14px 'Inter', sans-serif; color: var(--text); background: transparent;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { background: var(--surface-2); }
.button.primary { background: var(--red); border-color: var(--red); color: #fff; }
.button.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.button.danger { border-color: var(--bad); color: var(--bad); }
.button:disabled, .button[aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.icon-button {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border: 1px solid var(--line-strong); border-radius: 12px; background: transparent; color: var(--text); cursor: pointer;
}
.link-button { background: none; border: 0; color: var(--text-muted); font: 500 13px 'Inter', sans-serif; cursor: pointer; padding: 4px; }
.link-button:hover { color: var(--text); }

label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
input {
    width: 100%; min-height: 44px; padding: 10px 14px;
    border: 1px solid var(--line-strong); border-radius: 12px;
    background: var(--input-bg); color: var(--text); font: 500 15px 'Inter', sans-serif;
}
input:focus { outline: none; border-color: var(--text-muted); }

.card {
    border: 1px solid var(--card-border); border-radius: var(--radius);
    background: var(--card); padding: 24px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Login */
.login { display: grid; place-items: center; min-height: calc(100vh - 73px); padding: 40px 0; }
.login-card { width: min(440px, 100%); display: grid; gap: 18px; padding: 32px; background: var(--bg-1); box-shadow: var(--shadow-card); border-radius: var(--radius-lg); }

/* App layout */
.layout { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; padding: 32px 0 64px; align-items: start; }
.side { display: grid; gap: 24px; }
#start-form { display: grid; gap: 14px; }

.runs { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.runs button {
    width: 100%; text-align: left; display: grid; gap: 2px;
    padding: 10px 12px; border-radius: 12px; border: 1px solid transparent;
    background: transparent; color: var(--text); cursor: pointer; font: inherit;
}
.runs button:hover { background: var(--surface-1); border-color: var(--line); }
.runs button[aria-current="true"] { background: var(--surface-2); border-color: var(--line-strong); }
.runs .status { justify-self: start; margin-bottom: 4px; }
.runs .run-dealer { font-weight: 600; overflow-wrap: anywhere; }
.runs .run-when { color: var(--text-dim); font-size: 12px; }

/* Run */
.run { padding: 28px; }
.empty { padding: 48px 0; text-align: center; display: grid; gap: 8px; }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
#run-title { font-size: 28px; letter-spacing: -.6px; overflow-wrap: anywhere; }

.run-head-side { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.button.small { min-height: 34px; padding: 6px 14px; font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.status {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong);
    font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 1.5px; text-transform: uppercase;
}
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.status.running::before, .status.queued::before, .status.resuming::before { background: var(--green); }
.status.paused::before, .status.pausing::before { background: var(--amber); }
.status.stopped::before, .status.stopping::before, .status.failed::before { background: var(--red); }
.status.finished::before { background: var(--text); }

.progress { margin-top: 24px; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
#progress-bar { display: block; height: 100%; width: 0; background: var(--red); transition: width .4s ease; }
.progress-line { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 20px 0 8px; }
.stat { border: 1px solid var(--card-border); border-radius: 14px; padding: 12px 14px; display: grid; gap: 2px; background: var(--surface-1); }
.stat-label { font: 500 10.5px 'JetBrains Mono', monospace; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); }
.stat-value { font: 600 24px 'Space Grotesk', sans-serif; }
.stat-value.good { color: var(--good); }
.stat-note { font-size: 11.5px; color: var(--text-dim); }
.stat-note:empty { display: none; }
.stat-value.bad { color: var(--bad); }
.stat-value.warn { color: var(--warn); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; align-items: center; }
.actions .spacer { flex: 1; }

.notice {
    border: 1px solid var(--warn); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
    background: var(--surface-1); font-size: 14px;
}
.notice ul { margin: 6px 0 0; padding-left: 18px; }

.block { margin-top: 28px; }
.findings-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }
.check input { width: 16px; height: 16px; min-height: 0; accent-color: var(--red); }
.start-option { align-items: flex-start; color: var(--text); font-size: 13.5px; font-weight: 500; }
.start-option input { margin-top: 2px; flex-shrink: 0; }
.start-option .hint { display: block; margin-top: 2px; font-weight: 400; }

/* Problems to fix */
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.todo-item {
    border: 1px solid var(--card-border); border-left: 3px solid var(--bad); border-radius: 14px;
    padding: 14px 16px; background: var(--surface-1); display: grid; gap: 6px; font-size: 14px;
}
.todo-item.t-EXCLUDED_BUT_SERVED { border-left-color: var(--warn); }
.todo-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.todo-top .muted { font-size: 13px; }
.todo-item .link-button { justify-self: start; padding-left: 0; }
.why { margin: 0; }
.said { margin: 0; color: var(--text-muted); font-size: 13.5px; overflow-wrap: anywhere; }
.said q { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.split { margin: 0; color: var(--text-muted); font-size: 13.5px; }
.fix { margin: 0; }
.fix strong { color: var(--text); }

/* Grid */
.key { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-muted); }
.key li { display: inline-flex; align-items: center; gap: 6px; }
.mark {
    display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
    font: 700 12px 'Inter', sans-serif; border: 1px solid var(--line-strong); color: var(--text-dim);
}
.m-OFFERED_NOT_SERVED { background: var(--bad); border-color: var(--bad); color: #fff; }
.m-EXCLUDED_BUT_SERVED { background: var(--warn); border-color: var(--warn); color: #111; }
.m-OK { color: var(--good); border-color: var(--good); }
.m-INCONCLUSIVE { border-style: dashed; }
.grid { min-width: 0; }
.grid th:first-child, .grid .grid-service { position: sticky; left: 0; z-index: 1; background: var(--bg-1); }
.grid .grid-service {
    text-align: left; font: 500 13.5px 'Inter', sans-serif; letter-spacing: 0; text-transform: none; color: var(--text);
    padding: 10px; border-top: 1px solid var(--line); vertical-align: middle; white-space: normal; min-width: 170px;
}
.grid td { padding: 6px; vertical-align: middle; }
.cell {
    width: 100%; min-width: 128px; min-height: 36px; display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent;
    color: var(--text-muted); font: 500 12.5px 'Inter', sans-serif; text-align: left; cursor: pointer;
}
.cell:hover { background: var(--surface-2); }
.cell[aria-pressed="true"] { border-color: var(--text-muted); background: var(--surface-2); color: var(--text); }
.c-OFFERED_NOT_SERVED { color: var(--bad); font-weight: 600; }
.c-EXCLUDED_BUT_SERVED { color: var(--warn); font-weight: 600; }
.c-PENDING, .c-SKIPPED { color: var(--text-dim); }
.m-SKIPPED { border-style: dashed; }
.cell-none { color: var(--text-dim); }

.cell-detail {
    margin-top: 12px; border: 1px solid var(--line-strong); border-radius: 14px; padding: 16px 18px;
    background: var(--surface-1); display: grid; gap: 8px; font-size: 14px;
}
.cell-detail:focus { outline: none; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; }
.detail-head > div { flex: 1; min-width: 0; }
.detail-head h4 { margin: 0; font: 600 17px 'Space Grotesk', sans-serif; overflow-wrap: anywhere; }
.facts { margin: 6px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.facts dt { color: var(--text-dim); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.legend { margin: 12px 0; font-size: 13.5px; color: var(--text-muted); }
.legend summary { cursor: pointer; color: var(--text-muted); font-weight: 500; }
.legend dl { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; }
.legend dd { margin: 0; }
.legend ul { margin: 8px 0 0; padding-left: 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--card-border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left; padding: 10px; white-space: nowrap; background: var(--surface-1);
    font: 500 10.5px 'JetBrains Mono', monospace; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim);
}
td { padding: 10px; border-top: 1px solid var(--line); vertical-align: top; }
td.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.variant { display: block; color: var(--text-dim); font-size: 12.5px; }

.verdict {
    display: inline-block; white-space: nowrap; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; border: 1px solid var(--line-strong);
}
.v-OFFERED_NOT_SERVED { color: var(--bad); border-color: var(--bad); }
.v-EXCLUDED_BUT_SERVED { color: var(--warn); border-color: var(--warn); }
.v-OK { color: var(--good); border-color: var(--good); }
.v-EXCLUDED { color: var(--text-muted); }
.v-INCONCLUSIVE { color: var(--text-dim); border-style: dashed; }

@media (max-width: 960px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    table:not(.grid) { min-width: 820px; }
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .alpha-logo-wordmark, .who { display: none; }
    .topbar-inner { gap: 10px; }
    .topbar-right { gap: 8px; }
    .app-name { padding-left: 10px; font-size: 14px; }
    .topbar .button { padding: 8px 14px; }
    .run { padding: 20px; }
    .run-head { flex-direction: column; }
    .run-head-side { flex-direction: row; align-items: center; flex-wrap: wrap; }
    .actions .spacer { display: none; }
    .legend dl { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .facts { grid-template-columns: 1fr; }
    .facts dd { margin-bottom: 6px; }
    .cell { min-width: 112px; }
}
@media (max-width: 420px) {
    .topbar .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
