/* RecruitScout console — "dispatch ledger"
   Warm paper and ink, one signal colour, hairline rules instead of boxes,
   monospaced labels and tabular figures. Dark mode is the same ledger at night. */

@font-face {
  font-family: "Bricolage";
  src: url("/static/app/fonts/bricolage.woff2?v=1") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #f3f0e8;
  --surface: #f9f7f2;
  --sunk: #ebe7dc;
  --ink: #161513;
  --ink-2: #57534b;
  --ink-3: #8c867a;
  --rule: #d6d0c3;
  --rule-2: #e4dfd4;
  --rule-strong: #161513;
  --accent: #509b8f;          /* logo teal: running, ready, primary action (dark labels on it for contrast) */
  --accent-ink: #0e1d1a;
  --accent-text: #2b6b60;     /* deeper logo teal for text and focus rings on paper (5.5:1) */
  --accent-wash: #dcebe8;
  --green: #1d6b45;
  --amber: #9a6200;
  --amber-wash: #f6ead0;
  --red: #b42318;
  --red-wash: #f8e1dd;
  --shadow: 0 1px 0 rgba(22, 21, 19, .04), 0 12px 32px rgba(22, 21, 19, .10);
  --display: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 4px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121110; --surface: #191816; --sunk: #201e1b; --ink: #ede9e0; --ink-2: #aaa499; --ink-3: #736e65;
    --rule: #302d28; --rule-2: #25231f; --rule-strong: #ede9e0;
    --accent: #5fb0a3; --accent-ink: #0b1a17; --accent-text: #73c6b8; --accent-wash: #15302b;
    --green: #5cc48d; --amber: #e3a948; --amber-wash: #33270f; --red: #ff7a68; --red-wash: #3a1814;
    --shadow: 0 12px 40px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121110; --surface: #191816; --sunk: #201e1b; --ink: #ede9e0; --ink-2: #aaa499; --ink-3: #736e65;
  --rule: #302d28; --rule-2: #25231f; --rule-strong: #ede9e0;
  --accent: #5fb0a3; --accent-ink: #0b1a17; --accent-text: #73c6b8; --accent-wash: #15302b;
  --green: #5cc48d; --amber: #e3a948; --amber-wash: #33270f; --red: #ff7a68; --red-wash: #3a1814;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: square; stroke-linejoin: miter; flex: none; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
[hidden] { display: none !important; }
.num, .tbl td.r { font-variant-numeric: tabular-nums; }

/* ---------- shell: a ruled left rail on paper ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 24px 0 18px;
  border-right: 1px solid var(--rule); background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 22px 28px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; display: block; color: var(--accent); }
.brand-mark svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.7; stroke-linecap: butt; }
.brand-mark circle { fill: currentColor; stroke: none; }
.brand-name { font: 750 18px/1 var(--display); letter-spacing: -.03em; }
.nav { display: grid; gap: 0; border-top: 1px solid var(--rule); counter-reset: nav; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 13px 22px;
  color: var(--ink-2); text-decoration: none; font: 600 15px/1.2 var(--display); letter-spacing: -.01em;
  border-bottom: 1px solid var(--rule); counter-increment: nav;
}
.nav a::before { content: counter(nav, decimal-leading-zero); font: 500 11px/1 var(--mono); color: var(--ink-3); letter-spacing: .02em; }
.nav a svg { display: none; }
.nav a:hover { color: var(--ink); background: var(--sunk); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.nav-dot { margin-left: auto; width: 7px; height: 7px; background: transparent; }
.nav-dot.on { background: var(--accent); animation: blink 1.2s steps(2, start) infinite; }
.nav-dot.paused { background: var(--amber); }
@keyframes blink { to { visibility: hidden; } }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 14px 22px 0; border-top: 1px solid var(--rule); }
.conn { display: flex; align-items: center; gap: 8px; font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.conn-dot { width: 7px; height: 7px; background: var(--amber); }
.conn.live .conn-dot { background: var(--green); }
.conn.down .conn-dot { background: var(--red); }
.side-actions { display: flex; align-items: center; gap: 2px; }
.install-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; margin-right: 4px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius);
  font: 600 12px/1 var(--body); white-space: nowrap;
}
.install-btn svg { width: 14px; height: 14px; }
.install-btn:hover { background: var(--ink); color: var(--paper); }
.side:has(.install-btn:not([hidden])) .conn span:last-child { display: none; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; min-height: 24px; line-height: 1.55; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 24px; height: 24px; background: var(--ink); color: var(--paper); font: 600 12px/1 var(--mono); }
.steps svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--accent-text); }
.steps-note { line-height: 1.6; color: var(--ink-2); }
.steps-note strong:first-child { display: block; color: var(--ink); font: 700 16px/1.3 var(--display); margin-bottom: 6px; }
.steps-note code { font: 12.5px var(--mono); background: var(--sunk); padding: 1px 5px; color: var(--ink); }
.theme-btn { background: none; border: 0; color: var(--ink-3); padding: 7px; cursor: pointer; display: grid; }
.theme-btn:hover { color: var(--ink); background: var(--sunk); }

.main { padding: 36px 44px 64px; min-width: 0; max-width: 1400px; width: 100%; }

/* ---------- page head ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
h1 { font: 780 52px/.95 var(--display); letter-spacing: -.045em; margin: 0 0 12px; }
h2 { font: 700 18px/1.25 var(--display); margin: 0; letter-spacing: -.02em; }
.sub { margin: 0; color: var(--ink-2); max-width: 62ch; font-size: 14.5px; }
.hint { color: var(--ink-3); font-size: 12.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sep { width: 1px; height: 24px; background: var(--rule); margin: 0 6px; }

/* ---------- buttons: square, inked ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--rule-strong); background: transparent; color: var(--ink);
  font: 600 13.5px/1 var(--body); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .12s, color .12s, box-shadow .12s, transform .06s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-go:hover { background: var(--accent); color: var(--accent-ink); box-shadow: 1px 1px 0 var(--ink); transform: translate(2px, 2px); }
.btn-on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-text); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-ghost { border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunk); color: var(--ink); }
.btn.busy { pointer-events: none; }
.btn.busy::before { content: ""; width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
.btn.busy svg { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { background: none; border: 0; padding: 7px; color: var(--ink-2); cursor: pointer; display: grid; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 210px;
  background: var(--surface); border: 1px solid var(--rule-strong); box-shadow: 4px 4px 0 var(--ink); padding: 4px;
}
.menu-list a { display: block; padding: 9px 10px; color: var(--ink); text-decoration: none; font-weight: 500; }
.menu-list a:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- figures strip: a ruled ledger row ---------- */
.strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  border-top: 2px solid var(--rule-strong); border-bottom: 1px solid var(--rule);
  margin-bottom: 36px;
}
.stage { position: relative; padding: 16px 20px 18px; min-width: 0; }
.stage + .stage { border-left: 1px solid var(--rule); }
.stage-label { font: 500 10.5px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.stage-value { font: 700 40px/1 var(--display); letter-spacing: -.04em; margin-top: 14px; font-variant-numeric: tabular-nums; }
.stage-value small { font: 500 12px var(--mono); color: var(--ink-3); margin-left: 6px; letter-spacing: 0; text-transform: uppercase; }
.stage-note { color: var(--ink-2); font-size: 12.5px; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage.status { background: var(--ink); color: var(--paper); }
.stage.status .stage-label { color: color-mix(in srgb, var(--paper) 55%, transparent); }
.stage.status .stage-note { color: color-mix(in srgb, var(--paper) 72%, transparent); }
.status-word { display: flex; align-items: center; gap: 10px; font: 750 30px/1 var(--display); letter-spacing: -.035em; margin-top: 14px; }
.pulse { width: 11px; height: 11px; background: color-mix(in srgb, var(--paper) 40%, transparent); flex: none; }
.pulse.on { background: var(--accent); animation: blink 1s steps(2, start) infinite; }
.pulse.paused { background: var(--amber); }

/* ---------- notice ---------- */
.notice {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; margin: -12px 0 24px;
  background: var(--amber-wash); color: var(--ink); border-left: 3px solid var(--amber);
}
.notice svg { color: var(--amber); }
.notice button { margin-left: auto; }

/* ---------- tabs & panels ---------- */
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--rule-strong); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; padding: 10px 0 12px; color: var(--ink-3); cursor: pointer; white-space: nowrap;
  font: 650 16px/1 var(--display); letter-spacing: -.02em; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.count { font: 500 11px/1 var(--mono); color: var(--ink-3); margin-left: 6px; font-variant-numeric: tabular-nums; vertical-align: 2px; }
.panel { min-height: 220px; }
.panel-tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.search {
  height: 36px; border: 0; border-bottom: 1px solid var(--rule-strong); border-radius: 0; padding: 0 2px; background: transparent; min-width: 260px;
}
.search::placeholder { color: var(--ink-3); }
.search:focus { outline: none; border-bottom-color: var(--accent); box-shadow: 0 1px 0 var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); }
.seg button { border: 0; background: none; padding: 7px 13px; color: var(--ink-2); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button span { font: 500 11px var(--mono); color: var(--ink-3); margin-left: 4px; font-variant-numeric: tabular-nums; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.seg button[aria-checked="true"] span { color: color-mix(in srgb, var(--paper) 65%, transparent); }

/* ---------- tables: ledger rows, no boxes ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font: 500 10.5px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3);
  padding: 12px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
.tbl th { padding-left: 12px; padding-right: 12px; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl tbody tr:hover td { background: var(--surface); }
.tbl .r { text-align: right; }
.tbl td.r { font-family: var(--mono); font-size: 13px; }
.t-main { font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { color: var(--ink-3); font-size: 12.5px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-dim { color: var(--ink-2); white-space: nowrap; }
.t-time { color: var(--ink-3); white-space: nowrap; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.t-mono { font: 12px var(--mono); color: var(--ink-3); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.tag::before { content: ""; width: 6px; height: 6px; background: var(--ink-3); flex: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.fresh td { animation: fresh 1.8s ease-out; }
@keyframes fresh { from { background: var(--accent-wash); } to { background: transparent; } }

.fit { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.fit-bar { width: 60px; height: 8px; background: repeating-linear-gradient(90deg, var(--rule) 0 5px, transparent 5px 6px); overflow: hidden; }
.fit-bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 6px); }
.fit-bar.mid i { background: repeating-linear-gradient(90deg, var(--amber) 0 5px, transparent 5px 6px); }
.fit-bar.low i { background: repeating-linear-gradient(90deg, var(--red) 0 5px, transparent 5px 6px); }
.fit b { font: 600 13px var(--mono); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }

.state { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; background: currentColor; }
.state.ok { color: var(--accent-text); }
.state.wait { color: var(--amber); }
.state.bad { color: var(--red); }
.state.none { color: var(--ink-3); }
.state.none::before { background: none; border: 1px solid currentColor; }
.state small { font: 500 11px var(--mono); color: var(--ink-3); margin-left: 2px; }
.warn-text { color: var(--amber); font-size: 12.5px; }
.pref-updated { color: var(--accent); }

/* ---------- groups ---------- */
.groups { display: grid; }
.grp { border-bottom: 1px solid var(--rule); }
.grp-head {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto 20px; gap: 22px; align-items: center;
  padding: 16px 0; background: none; border: 0; text-align: left; cursor: pointer;
}
.grp-head:hover .grp-name { color: var(--accent-text); }
.grp-name { font: 680 17px/1.25 var(--display); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp-meta { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp-count { font: 700 26px/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; text-align: right; }
.grp-count small { font: 500 10.5px var(--mono); color: var(--ink-3); margin-left: 5px; text-transform: uppercase; letter-spacing: .06em; }
.grp-head .chev { transition: transform .15s; color: var(--ink-3); }
.grp.open .chev { transform: rotate(90deg); color: var(--accent-text); }
.grp-jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 28px; padding: 0 0 18px; }
.job { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule-2); min-width: 0; }
.job > div { min-width: 0; }

/* ---------- logs: a terminal transcript ---------- */
.log { list-style: none; margin: 0; padding: 10px 0; max-height: 600px; overflow-y: auto; font: 12.5px/1.55 var(--mono); }
.log li { display: grid; grid-template-columns: 70px 72px minmax(0, 1fr); gap: 12px; padding: 5px 0; align-items: baseline; border-bottom: 1px dashed var(--rule-2); }
.log time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.log .lvl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.lvl-SUCCESS { color: var(--green); }
.lvl-WARNING { color: var(--amber); }
.lvl-ERROR { color: var(--red); }
.lvl-INFO { color: var(--ink-3); }
.log .msg { color: var(--ink); word-break: break-word; font-family: var(--body); font-size: 13px; }

/* ---------- empty & skeleton ---------- */
.empty { padding: 56px 20px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font: 700 20px/1.2 var(--display); letter-spacing: -.02em; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }
.sk { display: block; height: 11px; background: linear-gradient(90deg, var(--rule-2), var(--sunk), var(--rule-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- dialogs ---------- */
.dlg {
  border: 1px solid var(--rule-strong); border-top: 4px solid var(--accent); border-radius: 0; padding: 0;
  width: min(540px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 8px 8px 0 var(--ink);
}
.dlg-wide { width: min(840px, calc(100vw - 32px)); }
.dlg::backdrop { background: color-mix(in srgb, var(--paper) 55%, rgba(0, 0, 0, .55)); backdrop-filter: blur(2px); }
.dlg[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px 16px; border-bottom: 1px solid var(--rule); }
.dlg-head h2 { font-size: 22px; letter-spacing: -.03em; }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--rule); background: var(--paper); }
.row { display: flex; gap: 8px; }
.preview-frame { position: relative; background: #ffffff; height: min(62vh, 640px); }
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.preview-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #6b665c; background: #ffffff; font: 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.form { padding: 20px 22px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field > span { font: 500 10.5px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.field input, .field select { height: 40px; border: 1px solid var(--rule-strong); border-radius: 0; padding: 0 12px; background: var(--paper); width: 100%; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 3px 3px 0 var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toggle { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--rule-strong); cursor: pointer; background: var(--paper); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { width: 38px; height: 20px; border: 1px solid var(--rule-strong); background: var(--surface); position: relative; flex: none; margin-top: 1px; transition: background .15s; }
.toggle-ui::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; background: var(--ink); transition: transform .15s; }
.toggle input:checked + .toggle-ui { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(18px); background: var(--accent-ink); }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 24px; bottom: 24px; display: grid; gap: 8px; z-index: 100; max-width: min(400px, calc(100vw - 32px)); }
.toast {
  background: var(--ink); color: var(--paper); padding: 12px 16px; border-left: 4px solid var(--accent);
  font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: pop .16s ease-out; box-shadow: var(--shadow);
}
.toast.err { border-left-color: var(--red); }
.toast.out { opacity: 0; transition: opacity .2s; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .strip { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stage.status { grid-column: 1 / -1; }
  .stage + .stage { border-left: 0; }
  .stage:not(.status) + .stage:not(.status) { border-left: 1px solid var(--rule); }
  .stage:not(.status) { border-top: 1px solid var(--rule); }
}
@media (max-width: 760px) {
  /* top bar with the brand, a bottom tab bar like a native app; safe areas for notches and the home bar */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 12px; z-index: 30;
    border-right: 0; border-bottom: 1px solid var(--rule);
    padding: calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 12px calc(16px + env(safe-area-inset-left));
    /* solid on purpose: a backdrop-filter here would trap the fixed bottom nav inside this bar */
    background: var(--paper);
  }
  .brand { padding: 0; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule-strong);
    background: var(--paper);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .nav a { flex-direction: column; justify-content: center; gap: 4px; min-height: 58px; padding: 8px 6px; font-size: 13px; border-bottom: 0; }
  .nav a + a { border-left: 1px solid var(--rule); }
  .nav a::before { font-size: 10px; }
  .nav a[aria-current="page"]::after { left: 0; right: 0; top: -1px; bottom: auto; width: auto; height: 3px; }
  .nav-dot { position: absolute; top: 12px; right: calc(50% - 30px); margin: 0; }
  .side-foot { margin: 0 0 0 auto; gap: 10px; padding: 0; border-top: 0; }
  .conn span:last-child { display: none; }
  .theme-btn { padding: 9px; }
  .install-btn { height: 34px; padding: 0 12px; font-size: 13px; }
  .side:has(.install-btn:not([hidden])) .brand-name { display: none; }
  .main { padding: 26px calc(16px + env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .toasts { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }

  h1 { font-size: 40px; }
  .head { margin-bottom: 22px; gap: 18px; }
  .actions { width: 100%; }
  .actions > .btn:not(.btn-ghost) { flex: 1 1 auto; justify-content: center; }
  .actions > .btn-go { flex-basis: 100%; }
  .actions > .btn-ghost, .actions .menu .btn-ghost { padding: 0 10px; }

  /* touch-sized controls; 16px inputs stop iOS zooming in on focus */
  .btn { height: 42px; padding: 0 15px; }
  .btn-sm { height: 36px; padding: 0 12px; }
  .icon-btn { padding: 10px; }
  .search, .field input, .field select { font-size: 16px; height: 44px; }
  .seg button { padding: 10px 11px; }
  .tabs { gap: 22px; }
  .tabs button { padding: 12px 0 13px; }

  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 28px; }
  .stage { padding: 14px 14px 16px; }
  /* status spans the row, then two figures per row with one divider between them */
  .strip .stage:not(.status):nth-child(even) { border-left: 0; }
  .strip .stage:not(.status):nth-child(odd) { border-left: 1px solid var(--rule); }
  .stage-value { font-size: 32px; margin-top: 10px; }
  .status-word { font-size: 26px; }
  .search { min-width: 0; flex: 1; }
  .sep { display: none; }
  .panel-tools .search { flex-basis: 100%; }
  .panel-tools .seg { width: 100%; }
  .panel-tools .seg button { flex: 1; }

  /* tables become ledger cards: first cell is the title, the rest a 2-column grid labelled by column name */
  .tbl-wrap { overflow-x: visible; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
  .tbl td, .tbl td:first-child, .tbl td:last-child { padding: 0; border: 0; min-width: 0; }
  .tbl tbody tr:hover td { background: none; }
  .tbl td.r { text-align: left; }
  .tbl td:first-child, .tbl td:not([data-label]) { grid-column: 1 / -1; }
  .tbl td:first-child .t-main { font: 680 16px/1.3 var(--display); letter-spacing: -.015em; }
  .tbl td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font: 500 10px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 4px; }
  .tbl .fit { justify-content: flex-start; gap: 8px; }
  .tbl .fit-bar { width: 36px; }
  .tbl .state small { display: block; margin: 2px 0 0; }
  .t-main, .t-sub { max-width: none; white-space: normal; }
  .tbl td:not(:first-child) .t-main, .tbl td:not(:first-child) .t-sub { overflow-wrap: anywhere; }
  .t-mono { max-width: none; }
  .tag { max-width: 100%; white-space: normal; align-items: baseline; }
  .tag::before { transform: translateY(-1px); }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .row-actions .btn { flex: 1; justify-content: center; }

  .grp-head { grid-template-columns: minmax(0, 1fr) auto 20px; gap: 14px; }
  .grp-head .grp-fit { display: none; }
  .grp-jobs { grid-template-columns: minmax(0, 1fr); }
  .log { max-height: none; }
  .log li { grid-template-columns: 62px minmax(0, 1fr); }
  .log .lvl { display: none; }

  /* dialogs slide up as bottom sheets */
  .dlg, .dlg-wide { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh; box-shadow: none; border-left: 0; border-right: 0; border-bottom: 0; }
  .dlg[open] { display: flex; flex-direction: column; }
  .dlg > form { display: flex; flex-direction: column; min-height: 0; }
  .form { overflow-y: auto; }
  .preview-frame { height: 58dvh; }
  .dlg-foot { flex-wrap: wrap; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-foot .row { width: 100%; }
  .dlg-foot .row .btn { flex: 1; justify-content: center; }
  .field-row { grid-template-columns: 1fr; }
}
/* no sticky hover highlight on touch screens */
@media (hover: none) {
  .tbl tbody tr:hover td, .nav a:hover { background: none; }
  .btn:hover { background: transparent; color: var(--ink); }
  .btn-primary:hover { background: var(--ink); color: var(--paper); border-color: var(--rule-strong); }
  .btn-go:hover { background: var(--accent); color: var(--accent-ink); box-shadow: 3px 3px 0 var(--ink); transform: none; }
  .btn-ghost:hover { background: transparent; color: var(--ink-2); }
}
/* installed app (PWA): no text-selection callouts on controls, no rubber-band bounce */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
  .btn, .nav a, .tabs button, .seg button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
