:root {
    --bg: #f6f6f4;
    --fg: #1d1d1b;
    --muted: #6b6b66;
    --line: #dddcd6;
    --panel: #ffffff;
    --accent: #2357c6;
    --accent-fg: #ffffff;
    --error: #b42318;
    --ok-bg: #e5f4ea; --ok-fg: #17663a;
    --warn-bg: #fdf1dc; --warn-fg: #8a5300;
    --bad-bg: #fde8e6; --bad-fg: #a3271a;
    --neutral-bg: #ececea; --neutral-fg: #45453f;
    --attention-bg: #fff7e8; --attention-line: #f0c983;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161615;
        --fg: #ecebe6;
        --muted: #a09f99;
        --line: #33322f;
        --panel: #1f1f1d;
        --accent: #7aa2f7;
        --accent-fg: #10131a;
        --error: #f97066;
        --ok-bg: #173323; --ok-fg: #7fd6a0;
        --warn-bg: #3a2b10; --warn-fg: #f3c278;
        --bad-bg: #3d1a17; --bad-fg: #f7a39a;
        --neutral-bg: #2b2b28; --neutral-fg: #cfcec8;
        --attention-bg: #2c2414; --attention-line: #6b5524;
    }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.5; font-size: 15px; }
a { color: var(--accent); }
main { max-width: 76rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
h4 { font-size: .9rem; margin: 1rem 0 .4rem; }
.lead { color: var(--muted); max-width: 48rem; margin-top: -.5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; overflow-wrap: anywhere; }
.error { color: var(--error); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; color: var(--fg); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: .35rem .6rem; border-radius: 6px; }
.nav a:hover { color: var(--fg); background: var(--bg); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--bg); font-weight: 600; }
.account { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.logout { display: flex; align-items: center; gap: .6rem; color: var(--muted); }
.env { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 999px; }
.env-test { background: var(--warn-bg); color: var(--warn-fg); }
.env-live { background: var(--ok-bg); color: var(--ok-fg); }

/* Controls */
button { font: inherit; padding: .45rem .95rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: var(--accent-fg); cursor: pointer; }
button.secondary { background: var(--panel); border-color: var(--line); color: var(--fg); }
button.secondary:hover { border-color: var(--muted); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
button.danger { color: var(--error); }
input, select { font: inherit; width: 100%; min-height: 2.4rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
input[type="radio"], input[type="checkbox"] { width: auto; }
input[type="file"] { padding: .3rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
label.radio { display: flex; align-items: center; gap: .5rem; color: var(--fg); }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; margin: 0; }
legend { font-size: .9rem; color: var(--muted); padding: 0 .25rem; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }

/* A setting per row: name and explanation left, the field with its unit right. */
.setting-rows { display: grid; margin-bottom: 1rem; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem); gap: .5rem 2rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.setting-row:first-child { border-top: 0; }
.setting-row .hint { margin-top: .2rem; }
.setting-title { display: block; color: var(--fg); font-weight: 600; font-size: inherit; }
.with-unit { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.with-unit input { width: 6.5rem; flex: none; }
.setting-row select + .with-unit { margin-top: .5rem; }
[data-shown-for][hidden] { display: none; }
@media (max-width: 640px) { .setting-row { grid-template-columns: 1fr; } }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0 1rem; align-items: start; margin-bottom: 1rem; }
.grid-form > .hint, .grid-form > p { grid-column: 1 / -1; margin-bottom: .75rem; }
/* Label text, field and hint each share a row with their neighbours, so fields line up
   even when a label wraps to two lines. */
.grid-form > label, .grid-form > div { grid-row: span 3; display: grid; grid-template-rows: subgrid; row-gap: .3rem; align-items: end; margin-bottom: .75rem; }
.grid-form > label > .hint { align-self: start; }
.grid-form > div > :first-child { grid-row: 2; }
.inline-form { display: inline-flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input { width: auto; min-width: 14rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 1rem 0; }
.actions.sticky { position: sticky; bottom: 0; padding: .75rem 0; background: var(--bg); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: center; margin: 1rem 0; }
/* A table cell: flex here would break the table's borders on empty cells. */
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { display: inline-block; vertical-align: middle; }
.row-actions > * + * { margin-left: 1rem; }

.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .35rem .75rem; border-radius: 6px; text-decoration: none; color: var(--muted); border: 1px solid transparent; }
.tabs a[aria-current="page"] { border-color: var(--line); background: var(--panel); color: var(--fg); font-weight: 600; }

/* Messages */
.flash { padding: .7rem 1rem; border-radius: 6px; background: var(--ok-bg); color: var(--ok-fg); border: 1px solid color-mix(in srgb, var(--ok-fg) 30%, transparent); margin: 0 0 1rem; }
.flash-error { background: var(--bad-bg); color: var(--bad-fg); border-color: color-mix(in srgb, var(--bad-fg) 30%, transparent); }
.notice { padding: .7rem 1rem; border-radius: 6px; background: var(--warn-bg); color: var(--warn-fg); border: 1px solid color-mix(in srgb, var(--warn-fg) 30%, transparent); }
.notice-error { background: var(--bad-bg); color: var(--bad-fg); border-color: color-mix(in srgb, var(--bad-fg) 30%, transparent); }
.attention { background: var(--attention-bg); border: 1px solid var(--attention-line); border-radius: 8px; padding: .25rem 1.25rem .75rem; margin: 1rem 0; }
.attention h2 { margin-top: .75rem; }
.attention ul { margin: 0; padding: 0; list-style: none; }
.attention li { margin: .3rem 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--attention-line); }
.empty { color: var(--muted); padding: 1rem 0; }

/* Tables and cards */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }
tr.gone td { opacity: .6; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.costs { max-width: 36rem; margin-bottom: .5rem; }
table.costs tfoot th { color: var(--fg); font-weight: 600; font-size: inherit; border-top: 1px solid var(--line); border-bottom: 0; }
tr.has-followup td { border-bottom: 0; }
tr.followup td { padding-top: 0; }
.component-list li { white-space: nowrap; }
/* Actions on a status update: one explanation, then the possible outcomes. */
.update-actions, .update-actions form { display: grid; gap: .6rem; }
.update-actions { padding: .75rem 1rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.update-actions label { max-width: 32rem; }
.update-actions .buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0; }
.card table { border: 0; }
.card h2 { margin-top: 0; }

.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.tag { display: inline-block; font-size: .8rem; padding: .05rem .45rem; border-radius: 4px; background: var(--neutral-bg); color: var(--neutral-fg); margin: .1rem 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .75rem 1.5rem; margin: 0 0 1rem; }
.facts.compact { gap: .5rem 1.25rem; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: .1rem 0 0; overflow-wrap: anywhere; }

.crumbs { margin: 0 0 .25rem; font-size: .9rem; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0 2rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .5rem; }
.pager { display: flex; gap: 1.5rem; }
.prose { max-width: 48rem; }

/* Login */
.login { max-width: 22rem; margin: 4rem auto; padding: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 1rem; }

.attention, .notice, .flash, .timeline, .error { overflow-wrap: anywhere; }

@media (max-width: 640px) {
    main { padding: 1rem 1rem 3rem; }
    .top { flex-direction: column; align-items: stretch; gap: .5rem; }
    .nav { order: 3; gap: 0; margin: 0 -.6rem; }
    .brand { order: 1; }
    .facts { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
    .account { order: 2; margin-left: 0; justify-content: space-between; }
    .inline-form input { min-width: 0; width: 100%; }
    th, td { padding: .45rem .5rem; }
}

form + .facts, form + .empty { margin-top: 1rem; }
.stack-form { display: grid; gap: 1.1rem; max-width: 36rem; }
.stack-form > label { color: var(--fg); font-weight: 500; }
.stack-form .hint { font-weight: 400; }
details summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
details[open] summary { margin-bottom: .5rem; }
.size-info p { margin: .25rem 0; }
.size-info .notice { margin-top: .5rem; }
.inline-notice { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; }
.options-box { display: grid; gap: .9rem; padding: .75rem 1rem 1rem; }
.options-box > div { display: grid; gap: .9rem; }
.options-box label { color: var(--fg); }

/* Log */
.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: end; margin: 1rem 0; }
.filters label { min-width: 12rem; flex: 1 1 12rem; }
.filter-buttons { display: flex; gap: 1rem; align-items: center; }
.log { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.log li { display: grid; grid-template-columns: 15rem 1fr; gap: .2rem 1rem; padding: .45rem .9rem; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
@media (max-width: 640px) { .log li { grid-template-columns: 1fr; } }
.log li:last-child { border-bottom: 0; }
.log-head { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: baseline; font-size: .82rem; color: var(--muted); }
.log-head .log-level { min-width: 3.6rem; }
.log-head time { font-variant-numeric: tabular-nums; }
.log-level { font-weight: 700; text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; }
.log-source { color: var(--muted); }
.log-message { overflow-wrap: anywhere; }
.log-message .tag { margin-left: .3rem; text-decoration: none; }
.log-debug .log-message { color: var(--muted); font-size: .9rem; }
.log-warning { border-left-color: var(--warn-fg) !important; }
.log-warning .log-level { color: var(--warn-fg); }
.log-error { border-left-color: var(--error) !important; background: color-mix(in srgb, var(--bad-bg) 45%, transparent); }
.log-error .log-level { color: var(--error); }
.log pre { margin: .4rem 0 0; padding: .6rem; background: var(--bg); border-radius: 6px; font-size: .8rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.heading-link { font-weight: 400; margin-left: .5rem; }
.log-context { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .15rem; font-size: .78rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Help */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem; margin: 1.5rem 0; }
.flow-step { flex: 1 1 8rem; display: grid; gap: .2rem; align-content: center; padding: .8rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.flow-main { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.flow-label { font-weight: 650; }
.flow-note { font-size: .8rem; color: var(--muted); }
.flow-arrow { align-self: center; color: var(--muted); font-size: 1.3rem; }
@media (max-width: 760px) { .flow { flex-direction: column; } .flow-arrow { transform: rotate(90deg); align-self: center; } }
.steps { list-style: none; counter-reset: step; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1rem; }
.steps li { counter-increment: step; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1rem .9rem 3.2rem; }
.steps li::before { content: counter(step); position: absolute; left: 1rem; top: 1rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.steps h3 { margin: 0 0 .3rem; }
.steps p { margin: 0 0 .4rem; font-size: .92rem; }
.steps a { font-size: .88rem; }
.check { padding-left: 1.1rem; }
.check li { margin: .5rem 0; }
table.compact td { padding: .35rem .75rem; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.legend section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; }
.legend dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1rem; margin: 0; align-items: baseline; }
.legend dd { margin: 0; font-size: .92rem; }

/* Help: new product guide */
.guide { list-style: none; counter-reset: guide; padding: 0; max-width: 52rem; }
.guide > li { counter-increment: guide; position: relative; padding: 0 0 1.5rem 3rem; }
.guide > li + li { border-top: 1px solid var(--line); padding-top: 1.25rem; }
.guide > li::before { content: counter(guide); position: absolute; left: 0; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 700; }
.guide > li + li::before { top: 1.25rem; }
.guide h2 { margin: .2rem 0 .6rem; }
.guide p, .guide li li { margin: 0 0 .5rem; }
.guide img { display: block; width: 100%; height: auto; margin: .75rem 0 1rem; border: 1px solid var(--line); border-radius: 8px; }
.guide ol.circled li::marker { color: #e11d48; font-weight: 700; }
.guide .notice p:last-of-type, .guide .notice ul { margin-bottom: 0; }
@media (max-width: 760px) { .guide > li { padding-left: 0; } .guide > li::before { position: static; margin-bottom: .5rem; } }

/* Order status and progress */
.order-status { display: grid; gap: 1rem; }
.order-status-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.order-status-head p { margin: 0; flex: 1 1 20rem; }
.pill-large { font-size: .95rem; padding: .25rem .8rem; }
.progress { list-style: none; display: grid; grid-template-columns: repeat(6, 1fr); gap: .3rem; padding: 0; margin: 0; }
.progress li { position: relative; padding-top: .9rem; font-size: .78rem; color: var(--muted); text-align: center; }
.progress li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: .4rem; border-radius: 999px; background: var(--line); }
.progress li.done::before { background: var(--ok-fg); opacity: .55; }
.progress li.current::before { background: var(--accent); }
.progress-warn li.current::before { background: var(--warn-fg); }
.progress-bad li.current::before { background: var(--error); }
.progress-ok li.current::before { background: var(--ok-fg); }
.progress li.current { color: var(--fg); font-weight: 600; }
.progress-compact { width: 10.5rem; gap: .15rem; }
.progress-compact li { padding-top: 0; height: .35rem; }
.progress-compact li span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.status-cell { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; }
.nowrap { white-space: nowrap; }
.button-link { display: inline-block; padding: .35rem .8rem; border-radius: 6px; background: var(--accent); color: var(--accent-fg); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.button-link:hover { filter: brightness(1.08); }
.attention li:last-child { border-bottom: 0; }
.issue-text { flex: 1 1 30rem; }
.issue-text > span { display: block; font-size: .92rem; color: var(--muted); }
.issue-text strong .mono { font-size: .9em; }
.close-order { flex: 1 1 100%; }
.close-order[open] { padding: .75rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.close-order .hint { margin: .5rem 0; }
.combobox { position: relative; }
.combobox-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + .25rem); max-height: 18rem; overflow-y: auto; margin: 0; padding: .25rem; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.combobox-list li { padding: .45rem .6rem; border-radius: 6px; cursor: pointer; color: var(--fg); font-weight: 400; }
.combobox-list li[aria-selected="true"] { background: var(--accent); color: var(--accent-fg); }
.combobox-list .combobox-empty { color: var(--muted); cursor: default; }

/* Users */
.order-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1rem; align-items: stretch; }
.order-cards .facts { grid-template-columns: 1fr; margin: 0; }
.order-cards address { font-style: normal; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 1rem; align-items: start; }
.grid-2 form.card label { display: block; margin-bottom: .75rem; }
.reveal { border-color: var(--ok-fg); }
.reveal .password { font-size: 1.25rem; letter-spacing: .05em; user-select: all; margin: .25rem 0 .5rem; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li + li { margin-top: .25rem; }
