:root {
	--bg: #f5f6f8;
	--surface: #ffffff;
	--ink: #17202b;
	--muted: #5b6676;
	--line: #dde2e8;
	--accent: #1f5fd1;
	--accent-ink: #ffffff;
	--good: #1d7a46;
	--warn: #9a5b00;
	--bad: #b42318;
	--synthetic: #6a3fb5;
	--radius: 10px;
	--shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
	color-scheme: light dark;
	font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f141a;
		--surface: #171e26;
		--ink: #e6ebf1;
		--muted: #9aa6b5;
		--line: #2a3440;
		--accent: #6d9eff;
		--accent-ink: #0b1220;
		--good: #5cc98b;
		--warn: #f0b54f;
		--bad: #ff7b72;
		--synthetic: #b796ff;
	}
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.05rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-bottom: 0.6rem; }
h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 1.25rem 0 0.5rem; }
p { margin: 0.25rem 0; }
code { font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brandmark { display: flex; align-items: center; gap: 0.6rem; margin-right: auto; }
.logo { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.subtitle { color: var(--muted); font-size: 0.8rem; }
.topbar-status { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

.banner { padding: 0.6rem 1.25rem; background: color-mix(in srgb, var(--synthetic) 14%, var(--surface)); color: var(--ink); border-bottom: 1px solid color-mix(in srgb, var(--synthetic) 40%, var(--line)); font-weight: 600; }
.banner.live { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

.sign-in { display: grid; place-items: center; padding: 4rem 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.card + .card { margin-top: 1rem; }
.narrow { width: min(28rem, 100%); }

.workbench { display: grid; grid-template-columns: 17rem minmax(0, 1fr); min-height: calc(100vh - 3.6rem); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.main { padding: 1.25rem; min-width: 0; }

.brand-list, .run-list, .schedule-list, .evidence, .events { list-style: none; margin: 0; padding: 0; }
.brand-list button { width: 100%; text-align: left; display: block; padding: 0.55rem 0.65rem; border-radius: 8px; border: 1px solid transparent; background: none; color: inherit; font: inherit; cursor: pointer; }
.brand-list button:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.brand-list button[aria-current="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.brand-list .name { display: block; font-weight: 600; }
.brand-list .meta { font-size: 0.8rem; }

.brand-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.columns { display: grid; grid-template-columns: minmax(18rem, 25rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.column { min-width: 0; }
.column.wide { min-width: 0; }

.meta, .hint { color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); font-size: 0.9rem; padding: 0.5rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state.small { padding: 2rem 1rem; }
.error { color: var(--bad); font-size: 0.9rem; }

.stack { display: flex; flex-direction: column; gap: 0.35rem; }
.row { display: flex; align-items: center; gap: 0.6rem; justify-content: space-between; }
.row.end { justify-content: flex-end; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; gap: 0.6rem; }
.limits { display: grid; grid-template-columns: 1fr 5rem; gap: 0.35rem 0.6rem; align-items: center; margin-top: 0.5rem; }

label { font-size: 0.85rem; font-weight: 600; }
input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.6rem; width: 100%; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; font-weight: 600; border-radius: 8px; padding: 0.45rem 0.9rem; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
button:disabled { opacity: 0.55; cursor: progress; }
button.ghost { background: transparent; color: var(--accent); }
button.danger { border-color: var(--bad); background: var(--bad); color: #fff; }
button.danger.ghost { background: transparent; color: var(--bad); }
button.small { padding: 0.2rem 0.6rem; font-size: 0.85rem; }
details summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }

.badge, .state { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.synthetic { color: var(--synthetic); border-color: color-mix(in srgb, var(--synthetic) 50%, var(--line)); }
.badge.live { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.badge.ok, .state.completed, .state.verified { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.badge.bad, .state.failed, .state.interrupted, .state.uncertain, .state.rejected, .state.partial { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
.state.running, .state.queued { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.state.awaiting_approval, .state.applied_unverified { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }

.run-list li + li, .schedule-list li + li { border-top: 1px solid var(--line); }
.run-list button { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.5rem; width: 100%; padding: 0.55rem 0.25rem; cursor: pointer; }
.run-list button:focus-visible { outline: 2px solid var(--accent); }
.run-list button[aria-current="true"] .objective-line { color: var(--accent); }
.run-list .objective-line { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-list .meta { grid-column: 1 / -1; font-size: 0.8rem; }
.schedule-list li { padding: 0.6rem 0; display: grid; gap: 0.2rem; }

.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.run-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.run-actions button { white-space: nowrap; }
.objective-text { margin: 0.6rem 0; padding: 0.6rem 0.75rem; background: var(--bg); border-radius: 8px; white-space: pre-wrap; }

.approval { margin: 1rem 0; padding: 1rem; border: 2px solid var(--warn); border-radius: var(--radius); background: color-mix(in srgb, var(--warn) 6%, var(--surface)); }
.approval.closed { border-color: var(--line); background: var(--surface); }
.approval dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.25rem 1rem; margin: 0.75rem 0; }
.approval dt { color: var(--muted); font-size: 0.85rem; }
.approval dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.change { font-size: 1.3rem; font-weight: 700; margin: 0.25rem 0; }
.approval dd.state { white-space: normal; border-radius: 8px; justify-self: start; }

.report .summary { font-size: 1.02rem; }
.report ul { padding-left: 1.2rem; margin: 0.3rem 0; }
.report li { margin: 0.35rem 0; }
.cite { display: inline-block; margin-left: 0.3rem; font: 0.75rem ui-monospace, Menlo, monospace; color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 0.3rem; }
.suggestion { display: flex; gap: 0.5rem; align-items: flex-start; justify-content: space-between; }

.evidence li { border: 1px solid var(--line); border-radius: 8px; margin: 0.4rem 0; }
.evidence li:target { border-color: var(--accent); }
.evidence summary { padding: 0.45rem 0.6rem; color: var(--ink); }
.evidence pre { margin: 0; padding: 0.6rem; max-height: 18rem; overflow: auto; font-size: 0.78rem; background: var(--bg); border-top: 1px solid var(--line); }

.events li { display: grid; grid-template-columns: 5.2rem 1fr; gap: 0.6rem; padding: 0.3rem 0; font-size: 0.88rem; border-bottom: 1px dashed var(--line); }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .detail { color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); width: min(30rem, calc(100% - 2rem)); }
dialog::backdrop { background: rgb(0 0 0 / 35%); }

@media (max-width: 1100px) {
	.columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
	.workbench { grid-template-columns: minmax(0, 1fr); }
	.sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
	.topbar { flex-wrap: wrap; }
	.main { padding: 0.75rem; }
}
