/* Neutral dark theme (default). Greys only; colour is reserved for ok / warn / bad status. */
:root {
  --bg: #0e0f11; --panel: #16171a; --ink: #e6e7ea; --muted: #9a9ea6; --line: #2a2c31; --soft: #1d1f23; --soft2: #26282e;
  --accent: #d9dbe0; --accent-soft: #2b2d33; --accent-ink: #0e0f11; --warn: #e0b35a; --warn-soft: #332a17; --bad: #ec8a80; --bad-soft: #3a1f1c;
  --ok: #8fcf9f; --ok-soft: #1d2f22;
  --blue: #a9b8d0; --blue-soft: #232a36;
  --s1: #44474e; --s2: #5a5e67; --s3: #747983; --s4: #9a9fa9; --s5: #c9cdd5;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif; --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f4f5; --panel: #ffffff; --ink: #1b1c1f; --muted: #5f6269; --line: #dfe0e4; --soft: #eeeff1; --soft2: #e3e4e8;
  --accent: #1b1c1f; --accent-soft: #e7e8ec; --accent-ink: #ffffff; --warn: #8a5a00; --warn-soft: #fbf0d9; --bad: #a3271d; --bad-soft: #f8e3e0;
  --ok: #1f7a3d; --ok-soft: #e1f2e6; --blue: #2b4f8a; --blue-soft: #e3e9f5;
  --s1: #a0a3aa; --s2: #85888f; --s3: #6a6d75; --s4: #4b4e55; --s5: #1b1c1f; color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a, .link { color: var(--accent); }
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 6px 12px; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.sm { padding: 2px 8px; font-size: 12px; }
button.sm.arm { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
button.danger { color: var(--bad); border-color: var(--bad); }
input[type="search"], input[type="text"], input[type="number"], input[type="email"], input[type="password"], select {
  font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); min-width: 0; }
input[type="search"] { width: 260px; max-width: 100%; }
label.tog { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.loginbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(420px, 100%); display: grid; gap: 12px; }
.loginbox label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.loginbox input { width: 100%; }
.err { color: var(--bad); font-size: 13px; min-height: 1.2em; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand .mark::after { border-color: var(--accent-ink) !important; }
.brand .mark::after { content: ""; position: absolute; left: 4px; right: 4px; top: 7px; height: 8px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: skewX(-20deg) rotate(-20deg); opacity: .9; }

/* header */
.top { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.lanes { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.lanes button { border: 0; border-radius: 0; padding: 7px 14px; color: var(--muted); display: grid; gap: 1px; text-align: left; }
.lanes button b { font-weight: 600; color: inherit; }
.lanes button small { font-size: 11px; opacity: .85; }
.lanes button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.fresh { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.me { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }

/* layout */
.wrap { padding: 18px max(16px, env(safe-area-inset-left)) 140px; max-width: 1560px; margin: 0 auto; display: grid; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.sec-h { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 11px; color: var(--muted); font-size: 13px; }
.seg button[aria-selected="true"] { background: var(--soft2); color: var(--ink); }

/* flow ribbon */
.flow { display: grid; gap: 10px; }
.ribbon { display: flex; gap: 0; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.stage { flex: 1 0 150px; min-width: 150px; background: var(--panel); border: 1px solid var(--line); border-left-width: 0; padding: 10px 12px 10px; display: grid; gap: 3px; cursor: pointer; position: relative; text-align: left; border-radius: 0; }
.stage:first-child { border-left-width: 1px; border-radius: 10px 0 0 10px; }
.stage:last-child { border-radius: 0 10px 10px 0; }
.stage:hover { background: var(--soft); }
.stage[aria-selected="true"] { background: var(--accent-soft); border-color: var(--s4); box-shadow: inset 0 -3px 0 var(--accent); z-index: 1; }
.stage .lab { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage .val { font-family: var(--mono); font-size: 20px; font-weight: 500; line-height: 1.15; }
.stage .val small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.stage .sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage .conv { position: absolute; top: 6px; right: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--soft); border-radius: 4px; padding: 0 5px; }
.stage.off { opacity: .6; }
.stage .bar { height: 3px; border-radius: 2px; background: var(--soft2); overflow: hidden; margin-top: 4px; }
.stage .bar i { display: block; height: 100%; background: var(--s4); }

/* bars (breakdown) */
.bars { display: grid; gap: 4px; }
.brow { display: grid; grid-template-columns: minmax(0, 1fr) 110px 66px 48px 64px; gap: 10px; align-items: center; font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--soft); }
.brow .nm { display: flex; gap: 6px; align-items: center; min-width: 0; }
.brow .nm span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .trk { height: 7px; background: var(--soft2); border-radius: 3px; overflow: hidden; }
.brow .trk i { display: block; height: 100%; background: var(--s4); }
.brow .n { font-family: var(--mono); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.brow .d { font-family: var(--mono); font-size: 11.5px; text-align: right; color: var(--muted); }
.brow .d.up { color: var(--ok); } .brow .d.dn { color: var(--bad); }
.bhead { display: grid; grid-template-columns: minmax(0, 1fr) 110px 66px 48px 64px; gap: 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bhead span:not(:first-child) { text-align: right; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 3px; min-width: 0; }
.card .lab { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card .val { font-family: var(--mono); font-size: 19px; font-weight: 500; line-height: 1.15; }
.card .val small { font-size: 12px; color: var(--muted); font-weight: 400; }
.card .lines { font-size: 12px; color: var(--muted); display: grid; gap: 1px; }
.card .lines b { color: var(--ink); font-weight: 500; font-family: var(--mono); }
.card svg { width: 100%; height: 28px; display: block; margin-top: 4px; }
.card.off { opacity: .65; }
.card.warn { border-color: var(--warn); }

/* table */
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
/* on wide screens the table fits, so the box stops being a scroll container and the header can stick under the page header */
@media (min-width: 1240px) { .tablebox { overflow: visible; } }
table { border-collapse: collapse; width: 100%; min-width: 1100px; }
thead th { position: sticky; top: var(--top-h, 0px); background: var(--panel); z-index: 2; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th:first-child { text-align: left; }
thead th button { border: 0; background: none; padding: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; }
thead th[aria-sort] button::after { content: " ↓"; } thead th[aria-sort="ascending"] button::after { content: " ↑"; }
thead th.grp { color: var(--accent); }
tbody td { padding: 4px 10px; border-bottom: 1px solid var(--soft); text-align: right; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody td.name { text-align: left; font-family: var(--sans); font-size: 13.5px; white-space: normal; min-width: 260px; max-width: 460px; }
tbody tr:hover td { background: var(--soft); }
tbody td.z { color: var(--line); }
tbody td.acts { text-align: left; font-family: var(--sans); white-space: nowrap; }
tbody td.acts .row { display: flex; gap: 5px; flex-wrap: nowrap; align-items: center; }
tr.l1 td { font-weight: 600; } tr.l1 td.name { font-size: 14px; }
tr.l2 td.name { padding-left: 28px; } tr.l3 td.name { padding-left: 46px; } tr.l4 td.name { padding-left: 64px; color: var(--muted); }
tr.l4 td.name .nm { color: var(--ink); }
.caret { display: inline-block; width: 16px; color: var(--muted); border: 0; background: none; padding: 0; text-align: left; }
.lvl { font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }
.pill { font-size: 12px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.no { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.mid { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.pill.pend { border-style: dashed; }
input.h { width: 68px; font-family: var(--mono); font-size: 12.5px; text-align: right; padding: 3px 6px; }
input.h.set { border-color: var(--accent); background: var(--accent-soft); }
.hint { display: block; font-size: 11px; color: var(--muted); font-family: var(--sans); }
.more { padding: 10px; text-align: center; }
td.add { background: color-mix(in srgb, var(--soft2) 60%, transparent); }

/* queue control */
.reqs { display: grid; gap: 6px; }
.req { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 4px; background: var(--soft); }
.req .hd { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; }
.req .hd .ctl { margin-left: auto; display: flex; gap: 5px; }
.req .what { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.req.done { opacity: .75; }
.prio { font-family: var(--mono); font-size: 11.5px; background: var(--ink); color: var(--bg); border-radius: 4px; padding: 0 6px; }
.prog { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: var(--soft2); }
.prog i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 11.5px; color: var(--muted); }
.legend b { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.form { display: grid; gap: 8px; border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
.form .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form input[type="number"] { width: 80px; }
.order { display: grid; gap: 3px; }
.orow { display: grid; grid-template-columns: 34px minmax(0, 1fr) 120px 96px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--soft); }
.orow .h small { display: block; color: var(--muted); font-size: 11px; }
.orow.dirty { border-color: var(--warn); }
.orow .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.orow .nm { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orow .h { font-family: var(--mono); font-size: 12px; text-align: right; }
.orow .ctl { display: flex; gap: 3px; justify-content: flex-end; }
.msg { padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.bad { background: var(--bad-soft); color: var(--bad); }

/* activity */
.act { display: grid; font-size: 13px; max-height: 520px; overflow: auto; }
.act .e { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) 9em; gap: 2px 10px; padding: 5px 0; border-top: 1px solid var(--soft); align-items: baseline; }
.act .t { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.act .w { font-weight: 500; }
.act .what { overflow-wrap: anywhere; color: var(--muted); }
.act .r { font-size: 12px; color: var(--ok); text-align: right; }
.act .r.bad { color: var(--bad); } .act .r.warn { color: var(--warn); }

/* defs */
details.defs summary { cursor: pointer; font-weight: 600; }
details.defs dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 8px 0 0; }
details.defs dt { font-weight: 600; } details.defs dd { margin: 0; color: var(--muted); max-width: 95ch; }
@media (max-width: 600px) { details.defs dl { grid-template-columns: minmax(0, 1fr); } }

/* selection bar, modal, toast */
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0,0,0,.08); }
.selbar .in { padding: 10px max(16px, env(safe-area-inset-left)); max-width: 1560px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.selbar .big { font-family: var(--mono); font-size: 18px; font-weight: 500; }
.selbar .acts { margin-left: auto; display: flex; gap: 8px; }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; }
.modalbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(680px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 12px; }
.modalbox ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; max-height: 300px; overflow: auto; }
.modalbox .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; max-width: min(640px, 92vw); opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok-soft); color: var(--ok); }
.spark { stroke: var(--s5); fill: none; stroke-width: 1.5; }
.sparkfill { fill: var(--accent); opacity: .12; }
@media (prefers-reduced-motion: no-preference) { .stage .bar i, .brow .trk i, .prog i { transition: width .35s ease; } }

/* processing control */
.ctlgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.ctlcard { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; background: var(--soft); min-width: 0; }
.ctlcard h3 { font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ctlcard .kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 10px; font-size: 12.5px; color: var(--muted); }
.ctlcard .kv b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.ctlcard .plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.ctlcard .plan label { display: grid; gap: 2px; font-size: 11.5px; color: var(--muted); }
.ctlcard .plan input, .ctlcard .plan select { width: 100%; font-family: var(--mono); font-size: 12.5px; padding: 3px 6px; }
.ctlcard .plan .wide { grid-column: 1 / -1; }
.ctlcard .foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ctlcard.off { opacity: .7; }
.chip.live { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.dry { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
details.ctlacts summary { cursor: pointer; font-size: 13px; color: var(--muted); }
