:root {
    --bg: #12151a;
    --panel: #1a1e25;
    --panel-2: #20252e;
    --line: #2c323d;
    --text: #e3e7ee;
    --muted: #8b94a3;
    --accent: #4aa3ff;
    --accent-ink: #06121f;
    --good: #3ecf8e;
    --warn: #f0b429;
    --bad: #ff5d5d;
    --idle: #5c6573;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    --sans: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }

a { color: var(--accent); }

button, input, select, textarea { font: inherit; color: inherit; }

input, select, textarea {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 7px 9px;
    min-width: 0;
}

textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 13px; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 7px 12px;
    cursor: pointer;
}

button:hover { border-color: #3d4554; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 3px 8px; font-size: 12px; }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; color: var(--muted); padding: 0 0 0 12px; }
button.link:hover { color: var(--text); }

.bar {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 16px;
    height: 52px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }

.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 15px 10px 13px; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.who { color: var(--muted); white-space: nowrap; }

main { padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 1500px; margin: 0 auto; }

.tab { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
main > *, .tab > * { min-width: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; min-width: 0; }
.card.narrow { max-width: 380px; width: 100%; margin: 60px auto; }
.card form, form.card { display: grid; gap: 12px; align-content: start; }

h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
label input { color: var(--text); font-size: 14px; }
label.inline { display: flex; align-items: center; gap: 8px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: 12px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; }

.muted { color: var(--muted); }
.err { color: var(--bad); margin: 0; min-height: 1em; }
.ok { color: var(--good); margin: 0; }
.hint { color: var(--muted); font-size: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile.hl .v { color: var(--accent); }

.scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions button { margin-left: 4px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.pill.good::before { background: var(--good); }
.pill.warn::before { background: var(--warn); }
.pill.bad::before { background: var(--bad); }
.pill.info::before { background: var(--accent); }

.meter { width: 120px; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.full i { background: var(--warn); }

.chips { display: flex; gap: 3px; flex-wrap: wrap; }
.chip { min-width: 26px; padding: 1px 4px; border-radius: 3px; font-size: 11px; text-align: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-family: var(--mono); }
.chip.accepted { background: rgba(62, 207, 142, .16); border-color: rgba(62, 207, 142, .5); color: var(--good); }
.chip.pending { background: rgba(74, 163, 255, .14); border-color: rgba(74, 163, 255, .45); color: var(--accent); }
.chip.queued { color: var(--muted); }
.chip.failed { background: rgba(255, 93, 93, .14); border-color: rgba(255, 93, 93, .45); color: var(--bad); }

.events { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 520px; overflow: auto; }
.events li { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events li span { overflow-wrap: anywhere; }
.events time { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.events li.warn span { color: var(--warn); }

.usage { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; margin: 8px 0 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; overflow-x: auto; }
.newkey { background: var(--bg); border: 1px dashed var(--accent); border-radius: 4px; padding: 10px 12px; margin: 12px 0; font-family: var(--mono); word-break: break-all; }

.seat { font-family: var(--mono); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlgHead { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.dlgBody { padding: 14px; display: grid; gap: 12px; overflow-wrap: anywhere; }
.dlgBody p { margin: 0; }
.dlgForm { display: grid; gap: 12px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li::marker { color: var(--muted); }
.who-line { font-family: var(--mono); font-size: 13px; }

@media (max-width: 700px) {
    .bar { flex-wrap: wrap; height: auto; padding: 8px 16px 0; gap: 8px; }
    .tabs { order: 3; flex-basis: 100%; }
    .events li { grid-template-columns: 1fr; gap: 0; }
    .card.narrow { margin: 24px auto; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
