/* Negahban panel — the approved 6-menu design (docs/04-panel-design.md, docs/design/artboards/).
   RTL, calm, one job per page. Dark by default; the choice lives in localStorage `ngb-theme` (static/theme.js).
   The CSP forbids inline styles, so every visual rule lives here. */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #0B0F14; --surface: #121820; --hover: #18202A; --line: #1F2833;
  --text: #E6EBF1; --muted: #9AA6B4; --faint: #7C8896;
  --accent: #5B9BFF; --on-accent: #06101E;
  --ok: #34C77B; --warn: #E9A93B; --bad: #F05A67;
  --add: rgba(52, 199, 123, .12); --del: rgba(240, 90, 103, .12);
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F5F6F8; --surface: #FFFFFF; --hover: #F0F2F5; --line: #E3E7EC;
  --text: #111827; --muted: #4B5563; --faint: #5F6B7A;
  --accent: #1F5FD1; --on-accent: #FFFFFF;
  --ok: #0E7A47; --warn: #8A5A00; --bad: #C0263A;
  --add: rgba(14, 122, 71, .10); --del: rgba(192, 38, 58, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Vazirmatn", system-ui, sans-serif;
  font-size: 14px; line-height: 1.6; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* text helpers */
.mono, code, kbd { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.code { font-family: var(--mono); font-size: .9em; padding: 1px 6px; margin: 0 2px; border-radius: 5px;
  background: var(--hover); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-bad { color: var(--bad); }
.c-faint { color: var(--faint); } .c-accent { color: var(--accent); }
.strong { font-weight: 700; }

/* status dots — always next to a text label */
.dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.lg { width: 9px; height: 9px; }
.dot.xl { width: 12px; height: 12px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.faint { background: var(--faint); } .dot.accent { background: var(--accent); }

/* ---- layout ---------------------------------------------------------------------------------------------------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 0 0 172px; width: 172px; height: 100vh; position: sticky; top: 0; padding: 20px 10px;
  border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; gap: 28px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); text-decoration: none; }
.side-brand span { font-size: 19px; font-weight: 800; }
.side-ver { align-self: center; margin-top: 3px; padding: 1px 6px; border-radius: 6px; background: var(--hover);
  color: var(--faint); font-family: var(--mono); font-size: 10.5px; font-weight: 500; line-height: 1.6; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px;
  text-decoration: none; font-size: 14px; color: var(--muted); }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); background: var(--hover); font-weight: 700; }
.nav a[aria-current="page"] svg { stroke: var(--accent); }
.nav svg { flex: none; }
.nav-badge { margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; }
.nav-badge.seen { background: var(--hover); color: var(--muted); }
.side-alert { margin: 0 4px; padding: 8px 10px; border-radius: 10px; background: var(--del); color: var(--bad);
  font-size: 12.5px; font-weight: 700; line-height: 1.6; text-decoration: none; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 0 8px; }
.side-user { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; color: var(--muted);
  overflow: hidden; }
.side-user small { font-size: 11.5px; color: var(--faint); }
.side-foot form { display: contents; }
.icon-btn { flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; padding: 0; }
.icon-btn:hover { color: var(--text); background: var(--hover); }
.theme-light-icon { display: none; }
:root[data-theme="light"] .theme-light-icon { display: inline; }
:root[data-theme="light"] .theme-dark-icon { display: none; }

.page { flex: 1 1 560px; min-width: 0; max-width: 1240px; padding: 40px 48px; display: flex; flex-direction: column;
  gap: 28px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; }
.head-text { display: flex; flex-direction: column; gap: 6px; }
.page-head h1 { font-size: 26px; font-weight: 800; line-height: 1.4; }
.page-sub { font-size: 13.5px; color: var(--faint); }
.head-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
/* "back to the list": a quiet pill, not a bare link (owner feedback 2026-10-12). The chevron icon points left;
   in this right-to-left page "back" points right, so it is mirrored. */
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
  padding: 0 10px 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none;
  transition: color .15s, border-color .15s, background-color .15s; }
.back svg { transform: scaleX(-1); color: var(--faint); transition: transform .15s, color .15s; }
.back:hover { color: var(--text); border-color: var(--faint); background: var(--hover); }
.back:hover svg { color: var(--accent); transform: scaleX(-1) translateX(-2px); }

.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split-main { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.split-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.split-half { flex: 1 1 380px; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.section-head a { font-size: 13px; text-decoration: none; }

/* ---- cards ------------------------------------------------------------------------------------------------------ */
.card { background: var(--surface); border-radius: 16px; padding: 24px; display: flex; flex-direction: column;
  gap: 16px; }
.card.tight { padding: 20px; gap: 12px; }
.card h2 { font-size: 16px; font-weight: 700; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card.attn { border-inline-start: 4px solid var(--warn); }
.card.attn-accent { border-inline-start: 4px solid var(--accent); }
.card.attn-bad { border-inline-start: 4px solid var(--bad); }
.attn-label { font-size: 13px; font-weight: 700; color: var(--warn); }
.card-rows { background: var(--surface); border-radius: 16px; padding: 8px 24px 24px; display: flex;
  flex-direction: column; gap: 4px; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; padding: 10px 0; }
.srow.col { flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; padding: 16px 0; }
.srow-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.srow-title { font-weight: 700; }
.srow-sub { font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.card-note { font-size: 13px; color: var(--faint); margin-bottom: 8px; line-height: 1.8; }
.lead { font-size: 14px; line-height: 2; color: var(--muted); }
.body-text { font-size: 14px; line-height: 1.8; }
.empty { color: var(--faint); font-size: 14px; line-height: 1.9; padding: 12px 0; }

/* ---- controls -------------------------------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font: inherit;
  font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn-primary { border-color: transparent; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { border-color: var(--bad); color: var(--bad); font-weight: 700; }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: 13.5px; }
.btn-xs { min-height: 36px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; min-height: 48px; font-size: 15px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.link-btn { border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer;
  padding: 0; min-height: 40px; }

.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.field .hint { color: var(--faint); }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.textarea { padding: 10px 12px; line-height: 1.8; resize: vertical; min-height: 96px; }
.input.ltr, .textarea.ltr { direction: ltr; text-align: left; font-family: var(--mono); font-size: 13.5px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.code-input { width: 140px; font-family: var(--mono); font-size: 16px; letter-spacing: 4px; text-align: center;
  direction: ltr; }
/* a row of fields: they share the row equally and their inputs sit on one line; the 2FA field is only as wide as its
   box, so the others take the rest (a grid column would leave a hole beside it) */
.form-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.form-grid > .field { flex: 1 1 220px; min-width: 0; }
.form-grid > .field-code { flex: 0 0 auto; }
.form-grid > .span-all { flex-basis: 100%; }
.span-all { grid-column: 1 / -1; }
.field-label { display: block; }
.input[type="file"] { padding: 7px 8px; line-height: 28px; direction: ltr; text-align: left; color: var(--muted);
  font-size: 13px; }
.input[type="file"]::file-selector-button { font: inherit; height: 28px; margin-inline-end: 10px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--hover); color: var(--text); cursor: pointer; }
.btn-row.pair > .btn { flex: 1 1 200px; max-width: 260px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.choice span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.choice input:checked + span { border-color: var(--text); background: var(--text); color: var(--bg); font-weight: 700; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 12px; background: var(--bg); }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check-text { display: flex; flex-direction: column; gap: 4px; }
.check-title { font-size: 14px; font-weight: 700; }
.check-sub { font-size: 12.5px; color: var(--muted); line-height: 1.8; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { min-height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  font-size: 13.5px; text-decoration: none; display: inline-flex; align-items: center; }
.pill:hover { color: var(--text); }
.pill[aria-current="page"] { border-color: var(--text); background: var(--text); color: var(--bg); font-weight: 700; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { min-height: 44px; padding: 0 16px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--faint);
  font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 700; }
.seg { display: flex; gap: 4px; }
.seg a { min-height: 36px; padding: 0 14px; border-radius: 8px; font-size: 13px; color: var(--faint);
  text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }
.seg a[aria-current="page"] { background: var(--hover); color: var(--text); font-weight: 700; }
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 10px;
  background: var(--surface); color: var(--faint); min-width: 240px; }
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px;
  width: 100%; min-height: 42px; }

details.disclosure > summary { list-style: none; display: inline-flex; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure[open] > summary { margin-bottom: 14px; }
.disclosure-body { display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 12px;
  background: var(--bg); }

.flash { border-radius: 12px; padding: 12px 16px; font-size: 14px; line-height: 1.8; }
.flash-ok { background: var(--add); color: var(--ok); }
.flash-err { background: var(--del); color: var(--bad); }

/* commands with a copy button */
.cmd { display: block; margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.8; padding: 14px;
  border-radius: 10px; background: var(--bg); overflow-wrap: anywhere; white-space: pre-wrap; direction: ltr;
  text-align: left; }
.cmd.dashed { background: transparent; border: 1px dashed var(--line); color: var(--faint); font-size: 12px;
  padding: 10px 14px; }
.cmd-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 10px;
  background: var(--bg); }
.cmd-row code { flex: 1; min-width: 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; text-align: left; }
.cmd-row .btn { background: var(--surface); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 16px; padding: 20px 10px 6px; }
.table { border-collapse: collapse; width: 100%; min-width: 820px; }
.table th { font-size: 12.5px; font-weight: 500; color: var(--faint); text-align: start; padding: 0 14px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { font-size: 14px; padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact { min-width: 640px; }
.table.compact td { padding: 10px 14px; font-size: 13px; }
.servers-table { min-width: 1000px; }
.move-col { width: 1%; padding-inline: 4px 0 !important; }
.grip { display: flex; align-items: center; justify-content: center; width: 28px; height: 40px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: grab; touch-action: none; }
.grip:hover, .grip:focus-visible { background: var(--hover); color: var(--text); }
tr.dragging td { background: var(--hover); }
tr.dragging .grip { cursor: grabbing; color: var(--accent); }
body.is-dragging { cursor: grabbing; user-select: none; }
.reach { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; line-height: 1.6; cursor: default; white-space: nowrap; }
.reach.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.reach.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.reach.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.reach.faint { background: var(--hover); color: var(--muted); }
.srow-title .reach { margin-inline-start: 10px; font-size: 12px; vertical-align: middle; }
.name-sub.wrap { white-space: normal; max-width: 340px; }
.reach-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.name-cell { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.name-cell:hover .name-main { color: var(--accent); }
.name-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name-main { font-weight: 700; }
.name-sub { font-size: 12.5px; color: var(--faint); line-height: 1.7; }
.badge-probe { font-size: 11.5px; font-weight: 500; color: var(--accent); margin-inline-start: 8px; }

/* ---- dashboard ------------------------------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.stat { text-decoration: none; color: var(--text); background: var(--surface); border-radius: 16px; padding: 24px;
  display: flex; flex-direction: column; gap: 12px; }
.stat:hover { background: var(--hover); }
.stat-label { font-size: 14px; color: var(--muted); }
.stat-num { font-size: 40px; font-weight: 800; line-height: 1; }
.stat-of { font-size: 18px; font-weight: 500; color: var(--faint); }
.stat-line { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.feed-row { display: flex; align-items: center; gap: 14px; min-height: 52px; border-bottom: 1px solid var(--line);
  padding: 6px 0; }
.feed-time { font-family: var(--mono); font-size: 12.5px; color: var(--faint); width: 44px; flex: none; direction: ltr;
  text-align: right; }
.feed-text { font-size: 14px; flex: 1; min-width: 0; line-height: 1.8; }
.feed-src { font-size: 12.5px; color: var(--faint); flex: none; }
.ai-head { display: flex; justify-content: space-between; align-items: center; }
.ai-state { font-size: 12.5px; display: flex; align-items: center; gap: 6px; }

/* ---- server detail -------------------------------------------------------------------------------------------- */
.server-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.server-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.server-title h1 { font-size: 28px; font-weight: 800; }
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.live a { display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: 16px; background: var(--surface);
  border: 1px solid transparent; color: var(--text); text-decoration: none; }
.live a:hover { background: var(--hover); }
.live > div { display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: 16px;
  background: var(--surface); min-width: 0; }
.live-value.small-value { font-size: 20px; }
.live a[aria-current="page"] { border-color: var(--accent); }
.live-label { font-size: 13px; color: var(--muted); }
.live-value { font-size: 26px; font-weight: 800; }
.live-note { font-size: 12px; color: var(--faint); }
/* a chart = the stretched drawing plus its numbers as text around it: unit above the value axis, values on the left
   (each number sits on its line: zero-height boxes spread over the drawing's height), times below */
.chart-box { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 180px auto;
  column-gap: 10px; row-gap: 9px; font-size: 11.5px; color: var(--faint); }
.chart-unit { grid-area: 1 / 1; text-align: right; line-height: 1; min-height: 11px; }
.chart-y { grid-area: 2 / 1; display: flex; flex-direction: column; justify-content: space-between; text-align: right; }
.chart-y span { height: 0; line-height: 0; white-space: nowrap; }
.chart-plot { grid-area: 2 / 2; position: relative; height: 180px; touch-action: pan-y; cursor: crosshair; }
.chart { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-cursor, .chart-pin, .chart-tip { position: absolute; pointer-events: none; }
.chart-cursor { top: 0; bottom: 0; width: 1px; background: var(--faint); }
.chart-pin { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--surface); }
.chart-tip { bottom: calc(100% + 6px); display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 11.5px;
  white-space: nowrap; z-index: 2; }
.chart-tip b { font-size: 13.5px; }
.chart-cursor[hidden], .chart-pin[hidden], .chart-tip[hidden] { display: none; }
.chart-x { grid-area: 3 / 2; display: flex; justify-content: space-between; }
.chart-x span, .bars-axis span { width: 0; display: flex; justify-content: center; white-space: nowrap; }
.chart-x span:first-child, .bars-axis span:first-child { justify-content: flex-start; }
.chart-x span:last-child, .bars-axis span:last-child { justify-content: flex-end; }
@media (max-width: 720px) { .chart-x.dense span:nth-child(even) { visibility: hidden; } }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-grid-x { stroke-dasharray: 2 5; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart-dot { fill: var(--accent); }
.kv { margin: 0; display: grid; grid-template-columns: 110px 1fr; gap: 14px; font-size: 14px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; line-height: 1.8; min-width: 0; overflow-wrap: anywhere; }
.problem { display: flex; gap: 12px; align-items: flex-start; }
.problem .dot { margin-top: 9px; }
.problem-text { font-size: 14px; line-height: 1.8; min-width: 0; }
.problem-sub { display: block; font-size: 12.5px; color: var(--faint); }
.subhead { font-size: 13px; color: var(--faint); }
.divided { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-family: var(--mono); font-size: 12.5px; padding: 4px 10px; border-radius: 8px; background: var(--hover);
  color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.tag { font-size: 12.5px; padding: 3px 10px; border-radius: 8px; background: var(--hover); color: var(--muted); }
.tech > summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 44px; display: flex;
  align-items: center; }
.tech-body { display: flex; flex-direction: column; gap: 20px; margin-top: 8px; }

/* ---- events ------------------------------------------------------------------------------------------------------ */
.events { display: flex; flex-direction: column; gap: 10px; }
.event { background: var(--surface); border-radius: 14px; overflow: hidden; }
.event > summary { list-style: none; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 20px;
  cursor: pointer; }
.event > summary::-webkit-details-marker { display: none; }
.event > summary:hover { background: var(--hover); }
.event-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.event-title { font-size: 15px; font-weight: 700; line-height: 1.7; }
.event-meta { font-size: 12.5px; color: var(--faint); }
.event-state { font-size: 12.5px; font-weight: 700; flex: none; }
.event-body { padding: 4px 20px 22px; display: flex; flex-direction: column; gap: 16px; border-top: 1px solid var(--line); }
.event-block { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; }
.event-label { font-size: 12.5px; font-weight: 700; color: var(--faint); }
.event-label.ai { color: var(--accent); }
.event-ai { font-size: 14.5px; line-height: 2.1; }
.ai-zone { display: contents; }
.ai-run { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; line-height: 1.9; }
.ai-run > .dot { flex: none; align-self: center; }
.ai-engine-text { margin: 0; max-height: 12em; overflow: auto; font-size: 13px; line-height: 1.9; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere; }
.step-row { display: flex; gap: 12px; font-size: 13.5px; }
.step-time { font-family: var(--mono); font-size: 12.5px; color: var(--faint); width: 44px; flex: none; direction: ltr;
  text-align: right; }
.step-text { color: var(--muted); line-height: 1.9; min-width: 0; overflow-wrap: anywhere; }
.approval-title { font-size: 16px; font-weight: 700; line-height: 1.8; }
.approval-body { font-size: 14px; color: var(--muted); line-height: 2; }
.approval-meta { font-size: 12.5px; color: var(--faint); }
.pager { display: flex; justify-content: center; gap: 10px; }

/* ---- topology (knowledge folder) ----------------------------------------------------------------------------- */
.kb { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.kb-nav { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.kb-item { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-height: 56px; padding: 10px 14px;
  border-radius: 12px; color: var(--text); text-decoration: none; }
.kb-item:hover { background: var(--hover); }
.kb-item[aria-current="page"] { background: var(--surface); }
.kb-name { font-family: var(--mono); font-size: 13.5px; font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.kb-what { font-size: 12px; color: var(--faint); }
.doc { flex: 999 1 520px; min-width: 0; background: var(--surface); border-radius: 16px; overflow: hidden; }
.doc-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); }
.doc-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-meta { font-size: 12px; color: var(--faint); }
.doc-note { font-size: 12.5px; color: var(--accent); }
.doc-body { padding: 20px 24px; font-family: var(--mono); font-size: 13px; line-height: 1.85; text-align: left;
  direction: ltr; overflow-x: auto; }
.doc-line { white-space: pre-wrap; padding: 0 6px; border-radius: 4px; min-height: 1.85em; overflow-wrap: anywhere; }
.doc-head { font-weight: 700; }
.doc-dim { color: var(--faint); }
.doc-add { background: var(--add); color: var(--ok); }
.doc-del { background: var(--del); color: var(--bad); }
.doc-files { display: flex; flex-direction: column; gap: 2px; }
.doc-files a { font-family: var(--mono); text-decoration: none; padding: 4px 6px; border-radius: 6px; }
.doc-files a:hover { background: var(--hover); }

/* ---- settings ------------------------------------------------------------------------------------------------ */
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--hover); display: flex; align-items: center;
  justify-content: center; font-weight: 700; flex: none; }
.user-row { display: flex; align-items: center; gap: 14px; min-height: 60px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; padding: 8px 0; }
.user-main { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 2px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form .select { width: auto; min-height: 40px; }
.engine { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border-radius: 10px;
  background: var(--bg); color: var(--text); text-decoration: none; }
.engine:hover { background: var(--hover); }
.engine-order { font-size: 13px; color: var(--faint); width: 18px; flex: none; }
.engine-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.engine-name { font-size: 14px; font-weight: 700; }
.engine-how { font-size: 12px; color: var(--faint); }
.engine-go { font-size: 12.5px; color: var(--accent); flex: none; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid transparent; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--accent); }
.opt input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 0; }
.opt-text { display: flex; flex-direction: column; gap: 2px; }
.opt-title { font-size: 14px; font-weight: 700; }
.opt-sub { font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.audit-row { display: flex; align-items: center; gap: 14px; min-height: 52px; border-bottom: 1px solid var(--line);
  font-size: 14px; padding: 6px 0; }
.audit-time { font-family: var(--mono); font-size: 12.5px; color: var(--faint); flex: none; direction: ltr;
  text-align: right; }
.audit-who { width: 90px; color: var(--muted); flex: none; overflow: hidden; text-overflow: ellipsis; }
.audit-text { flex: 1; min-width: 0; line-height: 1.8; }
.qr { width: 180px; height: 180px; background: #fff; border-radius: 12px; padding: 8px; flex: none; }
.codes { list-style: none; margin: 0; padding: 14px; border-radius: 10px; background: var(--bg); display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; font-family: var(--mono); font-size: 14px;
  direction: ltr; text-align: center; }
.setup-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.secret { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; direction: ltr; text-align: left;
  padding: 10px 12px; border-radius: 10px; background: var(--bg); }

/* dialog (engine setup) — opened by URL, closed by a link back */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 10; }
.dialog { width: 100%; max-width: 720px; background: var(--surface); border-radius: 18px; padding: 28px; display: flex;
  flex-direction: column; gap: 22px; }
.dialog.dialog-sm { max-width: 460px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dialog-head h2 { font-size: 20px; font-weight: 800; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.step { display: flex; gap: 14px; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--hover); color: var(--accent);
  font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.step-title { font-size: 14.5px; font-weight: 700; }
.step-note { font-size: 13px; color: var(--muted); line-height: 1.8; }
.dialog-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 18px;
  border-top: 1px solid var(--line); }

/* ---- login ------------------------------------------------------------------------------------------------------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.auth-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 28px; }
.auth-box.wide { max-width: 600px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.auth-brand span { font-size: 24px; font-weight: 800; }
.auth-card { background: var(--surface); border-radius: 18px; padding: 28px; display: flex; flex-direction: column;
  gap: 18px; }
.auth-card h1 { font-size: 18px; font-weight: 800; }
.auth-card .input { min-height: 46px; font-size: 15px; padding: 0 14px; }
.auth-card .input.ltr { font-family: inherit; }
.otp { min-height: 56px !important; font-family: var(--mono) !important; font-size: 26px !important;
  letter-spacing: 12px; text-align: center; direction: ltr; border-color: var(--accent) !important; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.auth-foot a { text-decoration: none; }
.auth-hint { font-size: 14px; color: var(--muted); line-height: 1.8; text-align: center; }
.theme-text { align-self: center; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0;
  background: transparent; color: var(--faint); font: inherit; font-size: 13px; cursor: pointer; }
.theme-text:hover { color: var(--text); }
.theme-text .when-light { display: none; }
:root[data-theme="light"] .theme-text .when-light { display: inline; }
:root[data-theme="light"] .theme-text .when-dark { display: none; }

/* ---- phone width --------------------------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .side { flex-basis: 100%; width: auto; height: auto; position: static; padding: 12px 12px 8px; gap: 10px;
    border-inline-end: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand foot" "nav nav" "alert alert"; align-items: center; }
  .side-brand { grid-area: brand; }
  .side-foot { grid-area: foot; margin-top: 0; padding: 0; }
  .side-user { display: none; }
  .side-alert { grid-area: alert; margin: 0; }
  .nav { grid-area: nav; flex-direction: row; overflow-x: auto; gap: 2px; padding-bottom: 4px; min-width: 0; }
  .nav a { flex: none; gap: 8px; padding: 0 10px; }
  .page { padding: 24px 16px; gap: 22px; }
  .page-head h1 { font-size: 23px; }
  .search { min-width: 0; flex: 1 1 200px; }
  .head-actions { width: 100%; }
  .kv { grid-template-columns: 90px 1fr; }
  .stat-num { font-size: 34px; }
  .dialog { padding: 20px; }
}

/* late additions */
.page-stack { display: flex; flex-direction: column; gap: 28px; }
.btn-wide { width: 100%; }
.align-start { align-self: flex-start; }
.kv dd.mono { text-align: right; }
.plain-list { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px;
  line-height: 1.9; color: var(--muted); }
.doc-empty { padding: 20px 24px; }
.field.small { font-size: 12.5px; gap: 6px; }
.code { white-space: nowrap; }
.step-text .code, .problem-sub .code, .upd-list .code { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .live { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .live a { padding: 16px; }
  .live-value { font-size: 22px; }
}
a.icon-btn { text-decoration: none; font-size: 20px; line-height: 1; color: var(--text); }
.new-chip { display: inline-block; margin-inline-end: 8px; padding: 0 8px; border-radius: 6px; background: var(--bad);
  color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.8; vertical-align: 2px; }

/* ---- configs list (subscriptions open in place; every config row opens its own page) ---------------------------- */
.cfg-list { background: var(--surface); border-radius: 16px; padding: 8px 10px; }
.cfg-row { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(0, 1.2fr) minmax(0, .9fr) minmax(0, .8fr)
  minmax(0, .8fr) minmax(0, .9fr); gap: 12px; align-items: center; padding: 14px 12px; border-radius: 12px;
  color: var(--text); text-decoration: none; font-size: 13.5px; }
.cfg-head { color: var(--faint); font-size: 12.5px; padding-block: 8px 12px; border-bottom: 1px solid var(--line);
  border-radius: 0; }
a.cfg-row:hover, summary.cfg-row:hover { background: var(--hover); }
.cfg-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cfg-state { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.cfg-name .name-main { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.cfg-name .name-main bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg-name .name-sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg-group { border-bottom: 1px solid var(--line); }
.cfg-group:last-of-type { border-bottom: 0; }
.cfg-group > summary { list-style: none; cursor: pointer; }
.cfg-group > summary::-webkit-details-marker { display: none; }
.cfg-group > summary svg { flex: none; color: var(--faint); transition: transform .15s; }
.cfg-group[open] > summary svg { transform: rotate(-90deg); }
.cfg-children { margin: 0 14px 12px 0; padding-inline-start: 14px; border-inline-start: 2px solid var(--line); }
.cfg-item + .cfg-item { margin-top: 2px; }
.cfg-sub-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 10px 12px 4px; }
.cfg-empty { padding: 18px 12px; }
.seg-wide { margin-bottom: 4px; flex-wrap: wrap; }
@media (max-width: 420px) { .seg-wide a { padding: 0 9px; } }
.rules { display: flex; flex-direction: column; }
.rule { display: grid; grid-template-columns: minmax(0, 2.4fr) repeat(3, minmax(0, 1fr)); gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule.rule-3 { grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); }
.rule:last-child { border-bottom: 0; }
.rule-head { color: var(--faint); font-size: 12.5px; padding-top: 0; }
.rule > span { display: flex; align-items: center; gap: 6px; }
.input.num { width: 76px; min-height: 38px; text-align: center; }
.rule .unit { font-size: 12.5px; color: var(--faint); }
@media (max-width: 640px) { .rule { grid-template-columns: minmax(0, 1fr) repeat(3, 64px); gap: 6px; }
  .input.num { width: 56px; padding: 0 4px; } }
.bars { display: block; width: 100%; height: 28px; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: -2px; }
.chip.kind { font-family: inherit; font-size: 12px; }
.bar.ok { fill: var(--ok); } .bar.warn { fill: var(--warn); } .bar.bad { fill: var(--bad); } .bar.none { fill: var(--hover); }
.bars-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bar-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-start: 8px; }
.bar-key.ok { background: var(--ok); } .bar-key.warn { background: var(--warn); } .bar-key.bad { background: var(--bad); }
.bar-key.none { background: var(--hover); }
.grow { flex: 1 1 220px; }
@media (max-width: 720px) {
  .cfg-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cfg-hide-sm { display: none; }
  .cfg-children { margin-inline-end: 4px; padding-inline-start: 8px; }
}

/* AI connections (D59): the ordered list, its dialog, the automatic-wake picks */
.conn-list { display: flex; flex-direction: column; gap: 8px; }
.conn { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; border-radius: 10px;
  background: var(--bg); flex-wrap: wrap; }
.conn .grip { margin-inline-start: -8px; }
.conn.dragging { background: var(--hover); }
.conn.dragging .grip { cursor: grabbing; color: var(--accent); }
.conn-state { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.conn-actions { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; }
.conn-live, .conn-status { display: flex; flex-direction: column; gap: 14px; }
.conn-status { gap: 6px; align-items: flex-start; }
.pick { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tick { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 12px; border-radius: 10px;
  background: var(--bg); font-size: 13px; cursor: pointer; }
.tick input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); flex: none; }
.push-end { margin-inline-start: auto; }
.stack > .tick { align-self: flex-start; }
@media (max-width: 760px) {  /* name on the first line, then the status, then the buttons */
  .conn { gap: 8px 10px; padding: 10px 12px; }
  .conn .engine-text { flex: 1 1 0; }
  .conn-state, .conn-actions { flex-basis: 100%; margin-inline-start: 0; }
}

/* the connection dialog (D60): status and test on one line, steps, closed extras */
.conn-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: 12px; background: var(--bg); }
.conn-live { gap: 22px; }
details.more { border-top: 1px solid var(--line); padding-top: 14px; }
details.more > summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--muted); list-style: none;
  display: flex; align-items: center; gap: 8px; min-height: 32px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "‹"; display: inline-block; width: 14px; transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(-90deg); }
details.more[open] > summary { margin-bottom: 14px; color: var(--text); }
pre.cmd.small { font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* ---- Settings → AI, the approved layout (D62): four boxes one under another ------------------------------------- */
.ai-page { display: flex; flex-direction: column; gap: 18px; max-width: 900px; }
.ai-box { background: var(--surface); border-radius: 18px; padding: 22px 24px; display: flex; flex-direction: column;
  gap: 18px; }
.ai-box.dim { opacity: .6; }
.ai-box-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-n { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex: none; background: var(--hover); color: var(--accent); font-weight: 800; }
.ai-box-title { display: flex; flex-direction: column; flex: 1 1 260px; min-width: 0; }
.ai-box-title h2 { font-size: 17px; font-weight: 800; }
.ai-sub { font-size: 13px; color: var(--muted); line-height: 1.8; }
.ai-box-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--line); }
.ai-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ai-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); color: var(--text); text-align: start;
  font: inherit; cursor: pointer; min-height: 72px; }
.ai-mode:hover:not(:disabled) { border-color: var(--accent); }
.ai-mode.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--bg)); }
.ai-mode:disabled { cursor: default; opacity: .55; }
.ai-mode.on:disabled { opacity: 1; }
.ai-mode-title { font-size: 15px; font-weight: 800; }
.ai-mode-sub { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.ai-usage { display: flex; flex-direction: column; gap: 6px; flex: 1 1 240px; min-width: 0; }
.ai-usage-row { display: flex; justify-content: space-between; font-size: 13px; }
.ai-bar { display: block; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ai-bar-fill { display: block; height: 6px; border-radius: 99px; background: var(--accent); width: 0; }
.ai-bar-fill.w1 { width: 10%; } .ai-bar-fill.w2 { width: 20%; } .ai-bar-fill.w3 { width: 30%; }
.ai-bar-fill.w4 { width: 40%; } .ai-bar-fill.w5 { width: 50%; } .ai-bar-fill.w6 { width: 60%; }
.ai-bar-fill.w7 { width: 70%; } .ai-bar-fill.w8 { width: 80%; } .ai-bar-fill.w9 { width: 90%; }
.ai-bar-fill.w10 { width: 100%; background: var(--warn); }
.ai-when { display: flex; flex-direction: column; gap: 18px; }
.ai-picks { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ai-picks legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { position: relative; display: inline-flex; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px;
  font-size: 13px; border: 1px solid var(--line); color: var(--muted); }
.chip-check input:checked + span { border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--text); }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-numbers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ai-num { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: var(--bg); }
.ai-num-label { font-size: 12px; color: var(--muted); min-height: 38px; line-height: 1.6; }
.ai-num-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ai-step-btn { width: 34px; height: 34px; flex: none; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; cursor: pointer; }
.ai-step-btn:hover { border-color: var(--accent); }
.ai-num-value { display: flex; align-items: baseline; justify-content: center; gap: 4px; min-width: 0; }
.ai-num-input { width: 3ch; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 800;
  font-size: 16px; text-align: center; padding: 0; }
.ai-num-input:focus { outline: none; border-bottom: 1px solid var(--accent); }
.ai-num-unit { font-size: 12.5px; color: var(--muted); }
.ai-conns { display: flex; flex-direction: column; }
.ai-conn-item { display: flex; flex-direction: column; }
.ai-conn { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--bg);
  border: 1px solid var(--line); flex-wrap: wrap; }
.ai-conn-item.dragging .ai-conn { background: var(--hover); }
.ai-conn-item.dragging .grip { cursor: grabbing; color: var(--accent); }
.ai-conn .grip { margin-inline-start: -6px; }
.ai-mono { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  flex: none; font-family: var(--mono); font-weight: 700; font-size: 15px; }
.ai-mono.claude { background: color-mix(in srgb, #D97757 18%, transparent); color: #C8684A; }
.ai-mono.codex { background: color-mix(in srgb, #2DBEB4 16%, transparent); color: #23968E; }
.ai-mono.loop { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.ai-conn-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; min-width: 0; }
.ai-conn-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 15px; }
.ai-conn-how { font-size: 12.5px; color: var(--faint); }
.ai-conn-state { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; flex: 0 1 210px; }
.ai-conn-actions { display: flex; gap: 8px; margin-inline-start: auto; }
.ai-next { display: flex; align-items: center; gap: 8px; padding: 6px 0; margin-inline-start: 34px; font-size: 12px;
  color: var(--faint); }
.ai-next-line { width: 2px; height: 18px; border-radius: 2px; background: var(--line); }
.ai-conn-item:last-child .ai-next { display: none; }
.ai-runs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-run { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--bg);
  border: 1px solid var(--line); color: var(--text); text-decoration: none; flex-wrap: wrap; }
a.ai-run:hover { border-color: var(--accent); }
.ai-run-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; min-width: 0; }
.ai-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-kind { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 16px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--bg); }
.ai-kind:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--bg)); }
.ai-kind:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-kind-head { display: flex; align-items: center; gap: 12px; }
.ai-kind-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ai-dialog-title { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.ai-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  gap: 8px; }
.ai-step { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  color: var(--text); text-decoration: none; min-height: 60px; }
.ai-step:hover { border-color: var(--accent); }
.ai-step.cur { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ai-step-mark { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex: none; font-size: 13px; font-weight: 800; background: var(--hover); color: var(--muted); }
.ai-step.cur .ai-step-mark { background: var(--accent); color: var(--on-accent); }
.ai-step.done .ai-step-mark { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.ai-step-text { display: flex; flex-direction: column; min-width: 0; }
.ai-step-title { font-weight: 700; font-size: 14px; }
.ai-step-sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-step.done .ai-step-sub { color: var(--ok); }
.ai-step-body { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 16px;
  border: 1px solid var(--line); }
.ai-step-body h3 { font-size: 16px; font-weight: 800; }
.ai-step-nav { display: flex; justify-content: space-between; gap: 10px; padding-top: 6px; }
.ai-ok { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px;
  background: color-mix(in srgb, var(--ok) 9%, transparent); color: var(--text); }
.ai-ok::before { content: "\2713"; color: var(--ok); font-weight: 800; }
.ai-substep { display: flex; align-items: flex-start; gap: 12px; }
.ai-sub-n { width: 26px; height: 26px; border-radius: 50%; flex: none; display: flex; align-items: center;
  justify-content: center; background: var(--hover); color: var(--accent); font-size: 12px; font-weight: 800; }
.ai-substep > .stack { flex: 1; min-width: 0; gap: 8px; }
.stack.grow, .input.grow { flex: 1 1 auto; min-width: 0; }
.ai-report { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; border-radius: 14px; background: var(--bg);
  border: 1px solid var(--line); }
.ai-report-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-report-text { display: flex; flex-direction: column; }
.ai-meta { font-size: 12.5px; color: var(--faint); }
.ai-chain-wrap { display: flex; flex-direction: column; gap: 6px; }
.ai-chain { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-chain-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 12px; font-size: 12.5px;
  border: 1px solid var(--line); }
.ai-chain-item.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 9%, transparent); }
.ai-chain-item.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 9%, transparent); }
.ai-chain-item.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 8%, transparent); }
.ai-chain-item > span { color: var(--muted); }
.ai-chain-arrow { color: var(--faint); }
.ai-report-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .ai-box { padding: 16px; border-radius: 16px; }
  .ai-modes, .ai-kinds { grid-template-columns: minmax(0, 1fr); }
  .ai-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-conn { gap: 8px 10px; padding: 12px; }
  .ai-conn-text { flex: 1 1 0; }
  .ai-conn-state, .ai-conn-actions { flex-basis: 100%; margin-inline-start: 0; }
  .ai-steps { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-step-body { padding: 14px; }
}

/* settings → cloud accounts (D61) */
.cloud { display: flex; flex-direction: column; gap: 20px; }
.cloud-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: none; }
.cloud-dialog { gap: 18px; max-width: 960px; }
.cloud-live, .cloud-slot, .cloud-block { display: flex; flex-direction: column; gap: 10px; }
.cloud-slot { border-top: 1px solid var(--line); padding-top: 14px; }
.cloud-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cloud-list { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.8; }
.cloud-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.cloud-kinds .chip { font-family: inherit; text-decoration: none; color: var(--text); min-height: 32px;
  display: inline-flex; align-items: center; }
.cloud-kinds .chip.on { background: var(--accent); color: var(--on-accent); }
.server-cloud { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); line-height: 1.8; }
@media (max-width: 760px) {
  .cloud .srow { flex-wrap: wrap; }
  .cloud-actions { flex-basis: 100%; }
}
.cloud-table { min-width: 680px; }
.cloud-table td:last-child { min-width: 240px; line-height: 1.7; }

/* ---- LiteLLM (D64): its monogram and the provider picker on its add card ------------------------------------------ */
.ai-mono.litellm { background: color-mix(in srgb, #8B5CF6 16%, transparent); color: #7C4DEB; }
.ai-kind-pick { display: grid; gap: 4px; }
.ai-kind-pick .input { min-height: 34px; padding-block: 4px; }
