:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2129; --muted: #677083; --line: #dde1e7; --accent: #2457d6; --accent-text: #fff;
  --good: #1e7c45; --good-bg: #e6f4ec; --bad: #b42318; --bad-bg: #fdecea; --warn: #9a6200; --warn-bg: #fff4dc; --code: #f1f3f6; --chip: #eef2fb;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --panel: #1c1f25; --text: #e6e8ec; --muted: #9aa3b2; --line: #2e333c; --accent: #6b93ff; --accent-text: #0b0e14;
    --good: #5cc98b; --good-bg: #16301f; --bad: #ff8a80; --bad-bg: #3a1a18; --warn: #f0b84d; --warn-bg: #36290f; --code: #15181d; --chip: #23293a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body.prod .top { box-shadow: inset 0 -3px 0 var(--bad); }
button, select, input, textarea { font: inherit; color: inherit; }
button, .button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost, .ghost.button { background: transparent; }
button.small { padding: 2px 8px; font-size: 12px; }
select, input, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; font-family: var(--mono); font-size: 13px; resize: vertical; tab-size: 2; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
h3 { margin: 16px 0 8px; font-size: 14px; }
code { font-family: var(--mono); }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 16px; }
.env { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.spacer { flex: 1; }
.recipes { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--code); color: var(--muted); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.protected::before { content: "PROTECTED · "; font-weight: 700; color: var(--bad); }

.tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
main { padding: 16px; max-width: 1600px; margin: 0 auto; }
.tab { display: none; }
.tab.on { display: block; }

.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; background: var(--panel); }
.drop.over { border-color: var(--accent); background: var(--chip); }
.drop p { margin: 4px 0; }
.drop details { text-align: left; margin-top: 8px; }
.drop textarea { margin: 8px 0; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 12px 0; }
.opts label { display: flex; align-items: center; gap: 6px; }
.opts.stack, .stack { flex-direction: column; align-items: stretch; }
.opts.stack label { flex-direction: column; align-items: stretch; gap: 3px; }
.opts.stack label.check, label.check { flex-direction: row; align-items: center; }
.opts label.wide select { min-width: 280px; max-width: 100%; }
.file-name { font-weight: 600; }
.row-opts { display: flex; gap: 12px; flex-wrap: wrap; }
.row-opts label { flex: 1; min-width: 160px; }
.mode { display: flex; gap: 16px; flex-wrap: wrap; }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 6px; margin: 12px 0; }
.disabled { opacity: .5; pointer-events: none; }

.table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
thead th { position: sticky; top: 0; background: var(--code); z-index: 1; cursor: pointer; }
#table thead th:hover { color: var(--accent); }
td.num, th.num { text-align: right; color: var(--muted); }
#results tbody tr { cursor: pointer; }
#results tbody tr:hover { background: var(--chip); }
tr.st-ok td:nth-child(4) { color: var(--good); font-weight: 600; }
tr.st-failed td:nth-child(4), tr.st-failed td:last-child { color: var(--bad); }
tr.st-sending td:nth-child(4) { color: var(--accent); }
tr.st-stopped td:nth-child(4) { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.col { min-width: 0; }
.editor { margin: 12px 0; }
.editor-head, .preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.preview-head input[type=number] { width: 80px; }
.preview-head #c-find { margin-left: auto; min-width: 200px; }
.fields-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--chip); border: 1px solid transparent; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-family: var(--mono); }
.chip.extra { opacity: .75; }
.help td { white-space: normal; max-width: none; vertical-align: top; }
pre.code { background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 70vh; font: 12.5px/1.5 var(--mono); margin: 0; white-space: pre; }
.summary { margin: 0 0 8px; }
.summary div { margin: 2px 0; }
.error-list { color: var(--bad); font-size: 13px; margin-top: 8px; }
.progress { position: relative; height: 22px; background: var(--code); border-radius: 6px; overflow: hidden; margin: 12px 0; border: 1px solid var(--line); }
#bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#progress-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
#result-detail { margin-top: 12px; }
.history { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; font-size: 13px; }
.history li { padding: 4px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-family: var(--mono); }
.history li:hover { background: var(--chip); }
.history li.bad::before { content: "✕ "; }
.history li.good::before { content: "✓ "; }
select.list { min-width: 220px; }
.toast { position: fixed; right: 16px; bottom: 16px; padding: 10px 14px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); max-width: 420px; z-index: 10; white-space: pre-line; }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
@media (max-width: 600px) { main { padding: 12px; } .top { padding: 8px 12px; } }

/* setup */
h2 { font-size: 16px; margin: 4px 0 8px; }
.sim-tag { background: #7a3fd1; color: #fff; border-radius: 99px; padding: 1px 10px; font-size: 11px; font-weight: 700; vertical-align: middle; }
.steps { padding-left: 22px; margin: 0; }
.steps li { margin: 0 0 12px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.steps li.done { opacity: .7; }
.steps li.done strong { text-decoration: line-through; }
.steps li .small { margin: 4px 0; }
.checks { list-style: none; padding: 0; margin: 10px 0 0; }
.checks li { padding: 6px 8px 6px 28px; border-bottom: 1px solid var(--line); position: relative; font-size: 13px; }
.checks li::before { position: absolute; left: 8px; top: 6px; font-weight: 700; }
.checks li.good::before { content: "✓"; color: var(--good); }
.checks li.bad::before { content: "✕"; color: var(--bad); }
.checks li.skip::before { content: "–"; color: var(--warn); }
.checks li.plain { padding-left: 8px; }
.checks li.good, .checks li.bad { color: var(--text); }
.hint { color: var(--warn); margin-top: 2px; }
.scenario { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #7a3fd1; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.sc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.scenario ul { margin: 6px 0 0; padding-left: 18px; }
#env-status table td { max-width: 260px; }
a.button { text-decoration: none; color: inherit; }

/* hosted: who is signed in, and the sign-in page */
.who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
