/* Components. Flat panels with hairline borders; no nested cards; states are colour + text/icon, never colour alone. */

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon--lg { width: 20px; height: 20px; }

/* ---------- Panel ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); min-height: 46px; }
.panel__head h2 { font-size: var(--fs-base); }
.panel__body { padding: var(--s4); }
.panel__body--flush { padding: 0; }
.panel__foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-sm); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 32px; padding: 0 var(--s3); border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  font-size: var(--fs-base); font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--accent-press); }
.btn--danger { background: var(--bad-solid); border-color: var(--bad-solid); color: #fff; }
.btn--danger:hover { background: #d8352a; border-color: #d8352a; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--hover); color: var(--text); }
.btn--sm { height: 26px; padding: 0 var(--s2); font-size: var(--fs-sm); }
.btn--icon { width: 32px; padding: 0; }
.btn--block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; }
@media (max-width: 767px) { .btn { height: 44px; padding: 0 var(--s4); } .btn--sm { height: 36px; } .btn--icon { width: 44px; } }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.input, .select {
  height: 32px; width: 100%; padding: 0 var(--s3);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); outline: none; }
.input[aria-invalid="true"] { border-color: var(--bad-solid); }
.field__hint { font-size: var(--fs-sm); color: var(--text-3); }
.field__error { font-size: var(--fs-sm); color: var(--bad); }
@media (max-width: 767px) { .input, .select { height: 44px; } }

/* ---------- Switch ---------- */
.switch {
  position: relative; width: 36px; height: 20px; flex: none; padding: 0;
  border-radius: 20px; border: 0; background: var(--border-strong);
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch[disabled] { opacity: .5; pointer-events: none; }
@media (max-width: 767px) { .switch { width: 48px; height: 28px; } .switch::after { width: 24px; height: 24px; } .switch[aria-checked="true"]::after { transform: translateX(20px); } }

/* ---------- Badges and dots ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 8px; border-radius: 10px; font-size: var(--fs-xs); font-weight: 500; background: var(--idle-bg); color: var(--idle); white-space: nowrap; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--info { background: var(--info-bg); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle-solid); flex: none; }
.dot--ok { background: var(--ok-solid); } .dot--warn { background: var(--warn-solid); } .dot--bad { background: var(--bad-solid); } .dot--info { background: var(--info-solid); }

/* ---------- Banner ---------- */
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--info-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); }
.banner .icon { margin-top: 2px; color: var(--info); }
.banner--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-solid) 40%, var(--border)); } .banner--warn .icon { color: var(--warn); }
.banner--bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad-solid) 40%, var(--border)); } .banner--bad .icon { color: var(--bad); }
.banner__body { flex: 1; min-width: 0; }
.banner__body strong { font-weight: 600; }
.banner__body p { color: var(--text-2); margin-top: 2px; }

/* ---------- Table (dense) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th {
  position: sticky; top: 0; text-align: left; white-space: nowrap;
  padding: 0 var(--s4); height: 34px; background: var(--sunken);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; border-bottom: 1px solid var(--border);
}
.table th[aria-sort] { cursor: pointer; user-select: none; }
.table th[aria-sort]:hover { color: var(--text); }
.table td { padding: 0 var(--s4); height: var(--row-h); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr[data-href], .table tbody tr[tabindex] { cursor: pointer; }
.table td.num, .table th.num { text-align: right; }

/* Phone list rows replace tables */
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); min-height: 56px; border-bottom: 1px solid var(--border); }
.list__item:last-child { border-bottom: 0; }
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 500; }
.list__sub { color: var(--text-2); font-size: var(--fs-sm); }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px var(--s6); margin: 0; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); min-height: 52px; }
.setting:last-child { border-bottom: 0; }
.setting__text { min-width: 0; } .setting__title { font-weight: 500; } .setting__desc { color: var(--text-2); font-size: var(--fs-sm); margin-top: 1px; }

/* ---------- Meter (plain bar, carries a real value) ---------- */
.meter { height: 6px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.meter > i { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left center; transition: transform .5s var(--ease); }
.meter--ok > i { background: var(--ok-solid); } .meter--warn > i { background: var(--warn-solid); } .meter--bad > i { background: var(--bad-solid); }
.metric { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s3); align-items: center; }
.metric .meter { grid-column: 1 / -1; }
.metric__label { color: var(--text-2); } .metric__value { font-weight: 600; }

/* ---------- Tabs and segmented ---------- */
.segmented { display: inline-flex; padding: 2px; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r); }
.segmented button { height: 26px; padding: 0 var(--s3); border: 0; background: transparent; color: var(--text-2); border-radius: 4px; font-size: var(--fs-sm); font-weight: 500; }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
@media (max-width: 767px) { .segmented button { height: 36px; } }
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--border); }
.tabs button { height: 40px; background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-2); font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Menu (popover) ---------- */
.menu { position: fixed; z-index: 80; min-width: 200px; padding: var(--s1); background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.menu__item { display: flex; align-items: center; gap: var(--s3); width: 100%; height: 34px; padding: 0 var(--s3); border: 0; background: transparent; border-radius: var(--r); text-align: left; color: var(--text); }
.menu__item:hover, .menu__item:focus-visible { background: var(--hover); }
.menu__item--danger { color: var(--bad); }
.menu__sep { height: 1px; background: var(--border); margin: var(--s1) 0; }
.menu__label { padding: var(--s2) var(--s3) var(--s1); font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Dialog / sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(8, 12, 18, .5); display: grid; place-items: center; padding: var(--s4); animation: fade var(--dur) var(--ease); }
.dialog { width: min(440px, 100%); max-height: calc(100dvh - 48px); overflow: auto; background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); animation: rise 200ms var(--ease); }
.dialog--wide { width: min(640px, 100%); }
.dialog__head { padding: var(--s4) var(--s5) var(--s2); }
.dialog__body { padding: var(--s2) var(--s5) var(--s4); color: var(--text-2); }
.dialog__foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5) var(--s4); }
@media (max-width: 767px) {
  .overlay { place-items: end stretch; padding: 0; }
  .dialog { width: 100%; max-height: 88dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; box-shadow: var(--shadow-sheet); padding-bottom: var(--safe-b); animation: sheet 260ms var(--ease); }
  .dialog::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; }
  .dialog__foot { flex-direction: column-reverse; } .dialog__foot .btn { width: 100%; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes sheet { from { transform: translateY(100%); } }

/* Drawer (desktop detail panel) */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: min(420px, 100%); background: var(--raised); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: drawer 220ms var(--ease); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.drawer__body { padding: var(--s5); overflow: auto; flex: 1; }
@keyframes drawer { from { transform: translateX(24px); opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 90; right: var(--s5); bottom: var(--s5); display: flex; flex-direction: column; gap: var(--s2); width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); background: var(--raised); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop); animation: rise 200ms var(--ease); }
.toast .icon { margin-top: 2px; }
.toast--ok .icon { color: var(--ok-solid); } .toast--bad .icon { color: var(--bad-solid); } .toast--warn .icon { color: var(--warn-solid); }
@media (max-width: 767px) { .toasts { right: var(--s3); left: var(--s3); width: auto; bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s3)); } }

/* ---------- Skeleton, spinner, empty ---------- */
.skeleton { background: linear-gradient(90deg, var(--sunken) 25%, var(--hover) 37%, var(--sunken) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); min-height: 12px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: grid; justify-items: center; gap: var(--s2); text-align: center; padding: var(--s8) var(--s4); color: var(--text-2); }
.empty .icon { width: 28px; height: 28px; color: var(--text-3); }
.empty strong { color: var(--text); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner { animation: none; } }

/* ---------- Signature: path to the internet ---------- */
.path { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.path__node { position: relative; padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.path__node + .path__node { border-left: 1px solid var(--border); }
.path__node::after { /* link arrow between nodes */
  content: ""; position: absolute; right: -6px; top: 50%; width: 11px; height: 11px; margin-top: -6px;
  background: var(--panel); border-top: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong); transform: rotate(45deg); z-index: 1;
}
.path__node:last-child::after { display: none; }
.path__kind { display: flex; align-items: center; gap: var(--s2); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.path__name { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; }
.path__meta { color: var(--text-2); font-size: var(--fs-sm); }
.path__state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 500; }
.path__node[data-state="ok"] .path__state { color: var(--ok); }
.path__node[data-state="warn"] .path__state { color: var(--warn); }
.path__node[data-state="bad"] .path__state { color: var(--bad); }
.path__node[data-state="warn"] { background: var(--warn-bg); }
.path__node[data-state="bad"] { background: var(--bad-bg); }
.path__node[data-state="warn"]::after { background: var(--warn-bg); } .path__node[data-state="bad"]::after { background: var(--bad-bg); }
.path__note { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); background: var(--warn-bg); display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
@media (max-width: 767px) {
  .path { grid-template-columns: 1fr; }
  .path__node { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "kind state" "name name" "meta meta"; gap: 2px var(--s3); padding: var(--s3) var(--s4); }
  .path__node + .path__node { border-left: 0; border-top: 1px solid var(--border); }
  .path__node::after { right: auto; left: 28px; top: auto; bottom: -6px; margin: 0; transform: rotate(135deg); }
  .path__node { grid-template-areas: "kind state" "name name" "meta meta" "flow flow"; }
  .path__kind { grid-area: kind; } .path__state { grid-area: state; } .path__name { grid-area: name; font-size: var(--fs-md); } .path__meta { grid-area: meta; }
  .path__flow { position: static; grid-area: flow; }
  .path__flow:empty { display: none; }
  .path__note .btn { flex: 1 1 auto; }
}

/* ---------- Chart ---------- */
.chart { position: relative; width: 100%; min-height: 180px; flex: 1; display: block; }
.chart__svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.legend { display: flex; gap: var(--s4); color: var(--text-2); font-size: var(--fs-sm); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* system+alerts */
.usage { display: flex; align-items: center; gap: var(--s3); min-width: 140px; }
.usage .meter { flex: 1; } .usage__pct { width: 3.5ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.chips { list-style: none; margin: 0; padding: var(--s4); display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { display: inline-flex; align-items: center; gap: var(--s3); min-height: 32px; padding: 4px var(--s3); border: 1px solid var(--border); border-radius: var(--r); background: var(--sunken); }
.chip__label { color: var(--text-2); }
.setting[aria-disabled="true"] { opacity: .5; }
.setting[aria-disabled="true"] .switch, .setting[aria-disabled="true"] .segmented, .setting[aria-disabled="true"] .range, .setting[aria-disabled="true"] .btn { pointer-events: none; }
.range-field { display: flex; align-items: center; gap: var(--s3); width: min(300px, 100%); }
.range-field__value { width: 4.5ch; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.range { flex: 1; min-width: 0; height: 28px; margin: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
@media (max-width: 767px) { .range { height: 44px; } .setting--stack { flex-direction: column; align-items: stretch; } .range-field { width: 100%; } }

/* services+logs */
.svc-name { display: inline-flex; align-items: center; gap: var(--s3); min-width: 0; }
.svc-name .icon { color: var(--text-2); width: 18px; height: 18px; }
.svc-name strong { font-weight: 600; }
.addr { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-2); overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.status--ok { color: var(--ok); } .status--bad { color: var(--bad); } .status--warn { color: var(--warn); } .status--idle { color: var(--idle); }
.list__item--svc { align-items: flex-start; }
.list__item--svc > .icon { margin-top: 3px; color: var(--text-2); width: 20px; height: 20px; }
.list__item--svc .list__head { display: flex; align-items: baseline; gap: var(--s1) var(--s3); flex-wrap: wrap; margin-top: var(--s1); }
.list__item--svc .btn { align-self: center; min-width: 96px; }

.toolbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin: var(--s4) 0; }
.toolbar__grow { flex: 1 1 220px; max-width: 360px; min-width: 0; }
.toolbar__spacer { flex: 1; }
.toolbar label.inline { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-2); }
.logblock {
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; margin: 0; padding: var(--s4);
  height: min(60vh, 520px); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--sunken); color: var(--text); user-select: text; -webkit-user-select: text; border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.log-sub { color: var(--text-3); font-size: var(--fs-xs); }
.mono-cell { font-family: var(--mono); font-size: var(--fs-sm); }

.handoff { max-width: 560px; margin: var(--s8) auto; display: flex; flex-direction: column; gap: var(--s5); }
.handoff__head { display: flex; align-items: center; gap: var(--s4); }
.handoff__head > .icon { width: 32px; height: 32px; color: var(--accent-text); }
.handoff__head p { color: var(--text-2); }
.handoff__section h2 { font-size: var(--fs-base); color: var(--text-2); font-weight: 600; margin-bottom: var(--s1); }
.handoff__section p { max-width: 62ch; }
.handoff__dest { padding: var(--s3) var(--s4); background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r); font-family: var(--mono); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.handoff__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
@media (max-width: 767px) {
  .handoff { margin: var(--s4) 0; }
  .handoff__actions { flex-direction: column; } .handoff__actions .btn { width: 100%; }
  .toolbar__grow { max-width: none; flex-basis: 100%; }
}

/* settings+portal */
.settings-form { gap: var(--s4); max-width: 420px; }
.settings-form__actions { display: flex; }
@media (max-width: 767px) { .settings-form { max-width: none; } .settings-form__actions .btn { width: 100%; } }
.segmented--wide { display: flex; } .segmented--wide button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.theme-preview { border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); overflow: hidden; }
.theme-preview__bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); background: var(--panel); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 500; }
.theme-preview__body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s3); }
.theme-preview__body .btn { pointer-events: none; }

/* clients+network */
.banner--ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok-solid) 40%, var(--border)); } .banner--ok .icon { color: var(--ok); }
.toolbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.toolbar .switch-label { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.search { position: relative; flex: 0 1 300px; min-width: 200px; }
.search .icon { position: absolute; left: 10px; top: 50%; margin-top: -8px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 32px; }
@media (max-width: 767px) { .search { flex: 1 1 100%; } .search .input { padding-left: 36px; } }
.list__item[tabindex] { cursor: pointer; }
.list__item[tabindex]:hover { background: var(--hover); }
.list__item[tabindex]:focus-visible { outline-offset: -2px; }
.dialog__body--ink { color: var(--text); }
.dsec { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s4); border-top: 1px solid var(--border); }
.dsec > h3 { font-size: var(--fs-base); }
.dsec > p { color: var(--text-2); font-size: var(--fs-sm); }
.form-row { display: flex; gap: var(--s2); align-items: flex-start; }
.form-row > .field { flex: 1; min-width: 0; }
.form-row > .btn { margin-top: 26px; }
.kv .btn { vertical-align: middle; margin-left: var(--s2); }
.seg-fill { display: flex; width: 100%; max-width: 560px; margin-bottom: var(--s4); }
.seg-fill button { flex: 1; height: auto; min-height: 28px; line-height: 1.2; padding: 5px var(--s2); }
@media (max-width: 767px) { .seg-fill button { min-height: 40px; } }
.signal { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.signal .meter { width: 44px; flex: none; }
.signal__text { color: var(--text-2); font-size: var(--fs-sm); }
.logblock { margin: 0; padding: var(--s3) var(--s4); max-height: 280px; overflow: auto; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r); font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.inline-run { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
@media (max-width: 767px) { .banner { flex-wrap: wrap; } .banner__body { flex-basis: calc(100% - 40px); } .banner > .row { width: 100%; } .banner > .row .btn { flex: 1; } }
.panel__foot a { display: inline-flex; align-items: center; gap: 4px; }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.kv dd .btn { height: 28px; min-width: 28px; vertical-align: middle; }
@media (max-width: 767px) { .form-row { flex-direction: column; align-items: stretch; } .form-row > .btn { width: 100%; margin-top: 0; } }


/* review pass */
.panel__body--flush > .banner { margin: var(--s3) var(--s4); }
.btn--danger-quiet { background: transparent; border-color: color-mix(in srgb, var(--bad-solid) 45%, var(--border-strong)); color: var(--bad); }
.btn--danger-quiet:hover { background: var(--bad-bg); }

/* phone: a setting row lets its control wrap under the text instead of squeezing the text */
@media (max-width: 767px) {
  .setting { flex-wrap: wrap; row-gap: var(--s3); }
  .setting__text { flex: 1 1 14rem; }
  .setting > .btn { flex: 0 0 auto; }
}

/* review pass 2 */
.path__flow { position: absolute; top: var(--s4); right: var(--s5); font-size: var(--fs-xs); color: var(--text-2); white-space: pre; font-variant-numeric: tabular-nums; }
.path__flow:empty { display: none; }
.row-go { display: inline-flex; justify-content: flex-end; }
.table tbody tr:hover .row-go { color: var(--text-2); }
.table td:last-child:has(> .row-go) { width: 32px; padding-right: var(--s3); }
@media (max-width: 767px) {
  .panel__head { flex-wrap: wrap; row-gap: var(--s1); }
  .legend { flex-wrap: wrap; row-gap: 2px; column-gap: var(--s3); }
  .list__sub.truncate { white-space: normal; overflow-wrap: anywhere; }
  .topbar .btn .icon { width: 20px; height: 20px; }
  .topbar { gap: var(--s2); }
  /* must follow the base .path__flow rule above: on phone the figure is a normal grid row, not a corner overlay */
  .path__flow { position: static; grid-area: flow; }
}

/* review pass 3 */
.row-go { display: flex; align-items: center; justify-content: flex-end; height: 100%; color: var(--text-2); }
.row-go .icon { width: 18px; height: 18px; }
.table tbody tr:hover .row-go { color: var(--accent-text); }
.path__flow { font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
.path__node::after { width: 14px; height: 14px; margin-top: -7px; right: -8px; border-top-width: 1.5px; border-right-width: 1.5px; border-color: var(--text-3); }
@media (max-width: 767px) {
  /* even rhythm in the phone top bar: status pill on the left, theme and account on the right */
  .topbar > .topbar__brand { order: 0; }
  .topbar > .topbar__spacer { order: 1; flex: 1; }
  .topbar > .btn--sm { order: 2; }
  .topbar > .btn--icon:not(.only-phone) { order: 3; }
  .topbar > .btn--icon.only-phone { order: 4; }
  .path__node::after { border-color: var(--text-3); }
  .path__flow { color: var(--text-2); }
}

/* phone brand (top-left) */
.topbar__brand { display: none; align-items: center; gap: var(--s2); color: var(--text); font-weight: 600; font-size: var(--fs-md); letter-spacing: -.01em; text-decoration: none; min-width: 0; }
.topbar__brand img { width: 30px; height: 30px; border-radius: 7px; background: #fff; object-fit: contain; padding: 2px; border: 1px solid var(--border); }
.topbar__brand:hover { text-decoration: none; }
@media (max-width: 767px) { .topbar__brand { display: inline-flex; } }

.topbar__brandtext { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar__brandtext strong { font-size: var(--fs-md); font-weight: 600; letter-spacing: -.01em; }
.topbar__brandtext small { font-size: var(--fs-xs); font-weight: 400; color: var(--text-2); white-space: nowrap; }
/* narrowest phones: the status pill keeps its coloured dot and drops the words (aria-label still names the state) */
@media (max-width: 389px) { .topbar .pill-short { display: none !important; } }

/* a setting row followed only by an empty placeholder (e.g. a hidden warning) is the last visible row: no double line */
.setting:has(+ :empty) { border-bottom: 0; }

/* stacked settings (e.g. Volume) are a column: the text must not claim a minimum height from the wrap rule above */
.setting--stack > .setting__text { flex: 0 0 auto; }

/* compact system meters: two columns so the right-hand column (and the chart beside it) is shorter */
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px var(--s6); }

/* ---------- docs ---------- */
.docs { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s8); align-items: start; }
.docs-side { position: sticky; top: calc(var(--bar-h) + var(--s4)); max-height: calc(100dvh - var(--bar-h) - var(--s8)); overflow: auto; display: flex; flex-direction: column; gap: var(--s3); padding-right: var(--s2); }
.docs-search .search-wrap { position: relative; }
.docs-search .search-wrap .icon { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.docs-search .input { padding-left: 34px; }
.docs-toc { display: flex; flex-direction: column; }
.docs-toc__label { font-size: var(--fs-xs); color: var(--text-3); padding: var(--s2) var(--s3); }
.docs-toc__link { display: block; padding: 6px var(--s3); border-radius: var(--r); color: var(--text-2); font-size: var(--fs-sm); text-decoration: none; line-height: 1.35; }
.docs-toc__link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.docs-toc__link--sub { padding-left: var(--s6); font-size: var(--fs-xs); }
.docs-toc__link[aria-current="true"] { background: var(--accent-subtle); color: var(--accent-text); font-weight: 500; }
.docs-main { min-width: 0; max-width: 980px; }
.docs-body { display: flex; flex-direction: column; gap: var(--s10); }
.docs-section { scroll-margin-top: calc(var(--bar-h) + var(--s4)); }
.docs-section > h2 { font-size: var(--fs-xl); padding-bottom: var(--s3); margin-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.docs-section h3 { font-size: var(--fs-md); margin: var(--s6) 0 var(--s2); scroll-margin-top: calc(var(--bar-h) + var(--s4)); }
.docs-section h4 { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin: var(--s4) 0 var(--s2); }
.docs-section p, .docs-section li { max-width: 78ch; line-height: 1.6; }
.docs-section p { margin: 0 0 var(--s3); }
.docs-section ul, .docs-section ol { margin: 0 0 var(--s3); padding-left: var(--s6); }
.docs-section li + li { margin-top: 4px; }
.docs-section code { font-family: var(--mono); font-size: .9em; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 5px; overflow-wrap: anywhere; }
.docs-section .banner { margin: var(--s3) 0; }
.docs-section .banner p { margin: 2px 0 0; }
.docs-table { margin: var(--s3) 0 var(--s4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); }
.docs-table .table td { height: auto; padding: var(--s2) var(--s4); vertical-align: top; line-height: 1.5; }
.docs-table .table th { position: static; }
.docs-table__key { white-space: nowrap; font-weight: 500; }
.codewrap { position: relative; margin: var(--s3) 0 var(--s4); }
.codewrap .btn { position: absolute; top: 6px; right: 6px; z-index: 1; }
.codewrap__lang { position: absolute; top: 10px; left: 14px; font-size: var(--fs-xs); color: var(--text-3); pointer-events: none; }
.codeblock { margin: 0; padding: var(--s8) var(--s4) var(--s3); overflow: auto; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r-lg); font-family: var(--mono); font-size: 12.5px; line-height: 1.55; tab-size: 2; }
.codeblock code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }
.diagram { margin: var(--s3) 0 var(--s4); padding: var(--s4); overflow: auto; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r-lg); font-family: var(--mono); font-size: 12px; line-height: 1.45; }
/* endpoint cards */
.api-group { margin-top: var(--s6); }
.ep { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); margin-top: var(--s2); scroll-margin-top: calc(var(--bar-h) + var(--s4)); }
.ep > summary { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); cursor: pointer; list-style: none; min-height: 44px; }
.ep > summary::-webkit-details-marker { display: none; }
.ep > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(-45deg); transition: transform var(--dur) var(--ease); flex: none; }
.ep[open] > summary::before { transform: rotate(45deg); }
.ep > summary:hover { background: var(--hover); border-radius: var(--r-lg); }
.ep[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.ep__method { flex: none; min-width: 54px; text-align: center; font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: var(--r-sm); background: var(--idle-bg); color: var(--text-2); }
.ep__method--get { background: var(--info-bg); color: var(--info); }
.ep__method--post { background: var(--ok-bg); color: var(--ok); }
.ep__method--get-post { background: var(--warn-bg); color: var(--warn); }
.ep__path { font-family: var(--mono); font-size: 13px; font-weight: 500; background: none !important; border: 0 !important; padding: 0 !important; }
.ep__summary { flex: 1; min-width: 0; color: var(--text-2); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep__body { padding: var(--s2) var(--s4) var(--s4); }
.ep__body .docs-table, .ep__body .codewrap { margin-bottom: var(--s2); }
.ep[hidden], .api-group[hidden], .docs-section[hidden] { display: none; }
@media (max-width: 1099px) { .docs { grid-template-columns: 200px minmax(0, 1fr); gap: var(--s5); } }
@media (max-width: 767px) {
  .docs { grid-template-columns: 1fr; gap: var(--s4); }
  .docs-side { position: static; max-height: none; overflow: visible; padding: 0; }
  .docs-toc { display: none; }
  .ep > summary { flex-wrap: wrap; row-gap: 4px; }
  .ep__summary { flex-basis: 100%; white-space: normal; order: 5; }
  .docs-table__key { white-space: normal; }
  .docs-section > h2 { font-size: var(--fs-lg); }
}

.docs-title { display: flex; align-items: center; gap: var(--s2); }
.docs-title .icon { width: 1.1em; height: 1.1em; color: var(--accent-text); }

/* Access codes */
.ac { display: flex; flex-direction: column; }
.ac__loading { display: grid; place-items: center; padding: var(--s6); }
.ac__row { display: flex; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
.ac__row:first-child { border-top: 0; }
.ac__code { flex: none; min-width: 5.2ch; padding: var(--s2) var(--s3); border-radius: var(--r); background: var(--sunken); border: 1px solid var(--border); font-family: var(--mono); font-size: var(--fs-lg); font-weight: 700; letter-spacing: .18em; text-align: center; color: var(--text); }
.ac__code.is-hidden { color: var(--text-3); }
.ac__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ac__info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac__info .muted { font-size: var(--fs-sm); }
.ac__acts { display: flex; gap: var(--s1); flex: none; }
.ac__created { display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center; }
.ac__big { font-family: var(--mono); font-size: 56px; font-weight: 800; letter-spacing: .22em; padding: var(--s3) var(--s5) var(--s3) calc(var(--s5) + .22em); border-radius: var(--r-lg); background: var(--sunken); border: 1px solid var(--border-strong); color: var(--text); }
@media (max-width: 767px) { .ac__row { flex-wrap: wrap; } .ac__info { flex-basis: 100%; order: 3; } .ac__acts { margin-left: auto; } .ac__big { font-size: 44px; } }

/* A user's Overview has three nodes in the path (no Clients). */
.path.path--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 767px) { .path.path--3 { grid-template-columns: 1fr; } }

/* User management */
.um__avatar { flex: none; }
.um__role { margin-left: var(--s2); vertical-align: 1px; }
.um__cred { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--sunken); border: 1px solid var(--border); }
.um__cred strong { font-size: var(--fs-md); word-break: break-all; }
.um__none .empty { padding: var(--s6) var(--s4); }
