/* HostBridge console — "Option A" control-plane design system.
   Light-first neutral slate, one blue accent, dark mode via data-theme or
   the OS preference. No inline styles anywhere: CSP is style-src 'self'. */
@font-face { font-family: "Geist"; src: url("fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #F8F9FA; --surface: #FFFFFF; --surface-2: #F3F4F6; --hover: #F1F3F5;
  --border: #E4E4E7; --border-strong: #D4D4D8;
  --text: #18181B; --text-2: #52525B; --text-muted: #71717A;
  --accent: #2563EB; --accent-soft: rgba(37,99,235,.08);
  --green: #16A34A; --green-soft: rgba(22,163,74,.10);
  --amber: #D97706; --amber-soft: rgba(217,119,6,.12);
  --red: #DC2626; --red-soft: rgba(220,38,38,.10);
  --blue: #2563EB; --gray: #A1A1AA;
  --on-primary: #FFFFFF;
  --backdrop: rgba(24,24,27,.28);
  --shadow-pop: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -6px rgba(0,0,0,.12);
  --shadow-modal: 0 16px 40px rgba(0,0,0,.14);
  --shadow-drawer: -8px 0 30px rgba(0,0,0,.08);
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, "Roboto Mono", monospace;
  --radius: 6px; --radius-lg: 8px; --radius-pill: 9999px;
  --ctl-h: 30px; --ctl-h-lg: 34px;
  --sidebar-w: 224px; --topbar-h: 48px; --page-w: 1680px; --gutter: 24px;
  --dur-1: 120ms; --dur-2: 180ms; --ease-out: cubic-bezier(.16,1,.3,1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0D10; --surface: #111318; --surface-2: #181B22; --hover: #1D212A;
  --border: rgba(255,255,255,.08); --border-strong: rgba(255,255,255,.15);
  --text: #F4F4F5; --text-2: #A1A1AA; --text-muted: #8B8B94;
  --accent: #3B82F6; --accent-soft: rgba(59,130,246,.14);
  --green: #22C55E; --green-soft: rgba(34,197,94,.14);
  --amber: #F59E0B; --amber-soft: rgba(245,158,11,.15);
  --red: #EF4444; --red-soft: rgba(239,68,68,.14);
  --blue: #3B82F6; --gray: #71717A;
  --on-primary: #0B0D10;
  --backdrop: rgba(0,0,0,.6);
  --shadow-pop: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -8px rgba(0,0,0,.6);
  --shadow-modal: 0 20px 50px rgba(0,0,0,.6);
  --shadow-drawer: -12px 0 36px rgba(0,0,0,.45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #0B0D10; --surface: #111318; --surface-2: #181B22; --hover: #1D212A;
    --border: rgba(255,255,255,.08); --border-strong: rgba(255,255,255,.15);
    --text: #F4F4F5; --text-2: #A1A1AA; --text-muted: #8B8B94;
    --accent: #3B82F6; --accent-soft: rgba(59,130,246,.14);
    --green: #22C55E; --green-soft: rgba(34,197,94,.14);
    --amber: #F59E0B; --amber-soft: rgba(245,158,11,.15);
    --red: #EF4444; --red-soft: rgba(239,68,68,.14);
    --blue: #3B82F6; --gray: #71717A;
    --on-primary: #0B0D10;
    --backdrop: rgba(0,0,0,.6);
    --shadow-pop: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -8px rgba(0,0,0,.6);
    --shadow-modal: 0 20px 50px rgba(0,0,0,.6);
    --shadow-drawer: -12px 0 36px rgba(0,0,0,.45);
  }
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 13px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 3px; }
code, .mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
code { background: var(--surface-2); border-radius: 4px; padding: 1px 4px; }
kbd { font: 500 11px/1 var(--mono); padding: 2px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
h1 { font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -.3px; margin: 0; }
h2 { font-size: 13px; line-height: 20px; font-weight: 600; margin: 0 0 12px; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-muted); }
.small { font-size: 12px; line-height: 16px; }
.medium { font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -40px; z-index: 100; color: var(--accent); background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }
.skip:focus { top: 8px; box-shadow: var(--focus-ring); outline: none; }

/* ------------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); }
.sidebar > .brand { height: var(--topbar-h); padding: 0 14px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 13.5px; letter-spacing: -.2px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 5px; background: var(--text); display: inline-grid; place-items: center; flex: none; }
.brand-mark::after { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--surface); }
.side-nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-group + .nav-group { margin-top: 6px; }
.nav-group-label { font-size: 11px; font-weight: 500; color: var(--text-muted); padding: 10px 8px 4px; text-transform: uppercase; letter-spacing: .04em; }
.nav-item { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border-radius: var(--radius); color: var(--text-2); font-weight: 500;
  transition: background-color var(--dur-1), color var(--dur-1); }
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] svg { color: var(--text); }
.nav-item svg { flex: none; color: var(--text-muted); }
.nav-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: var(--radius); }
.nav-label { flex: 1; min-width: 0; }
.nav-badge { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: var(--radius-pill); background: var(--amber-soft); color: var(--amber); }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: grid; gap: 6px; font-size: 12px; }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.foot-row .env { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); padding: 0 var(--gutter); display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
.crumb-root { color: var(--text-muted); }
.crumb-sep { color: var(--border-strong); }
.crumb-current { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.cmdk-trigger { height: var(--ctl-h); min-width: 240px; padding: 0 10px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text-muted); font: 400 12px/1 var(--font); }
.cmdk-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.cmdk-trigger:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cmdk-trigger kbd { margin-left: auto; }
.icon-btn { width: var(--ctl-h); height: var(--ctl-h); flex: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2);
  display: inline-grid; place-items: center; cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1); list-style: none; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Account + generic popover menu (<details> works without JS) */
.account, .mobile-nav { position: relative; }
.account > summary, .mobile-nav > summary { list-style: none; }
.account > summary::-webkit-details-marker, .mobile-nav > summary::-webkit-details-marker { display: none; }
.avatar-btn { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl-h); padding: 0 8px 0 4px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2); }
.avatar-btn:hover { background: var(--hover); }
.avatar-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.avatar { width: 20px; height: 20px; border-radius: 4px; background: var(--text); color: var(--surface); font: 600 10px/1 var(--mono); display: inline-grid; place-items: center; }
.who { font-size: 12px; font-weight: 500; color: var(--text); }
.role-tag { font: 500 10px/1 var(--mono); color: var(--text-muted); }
.chev { transition: transform var(--dur-2) var(--ease-out); }
.account[open] .chev { transform: rotate(180deg); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); }
.mobile-menu { left: 0; right: auto; min-width: 220px; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-name { font-weight: 500; overflow-wrap: anywhere; }
.menu-role { font-size: 12px; color: var(--text-2); text-transform: capitalize; }
.menu-item { display: flex; align-items: center; width: 100%; min-height: 32px; padding: 0 10px; border: 0; border-radius: var(--radius); background: transparent;
  color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.menu form { margin: 6px 0 0; border-top: 1px solid var(--border); padding-top: 6px; }
.menu-theme { margin: 4px 0; padding: 6px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; }
.seg { display: inline-grid; grid-template-columns: repeat(3, 1fr); padding: 2px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 8px; border-radius: 4px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg input:focus-visible + span { box-shadow: var(--focus-ring); }
.mobile-nav { display: none; }

/* Plain-HTTP banner */
.banner { display: flex; gap: 8px; align-items: flex-start; padding: 8px var(--gutter); background: var(--amber-soft); color: var(--text); font-size: 12.5px; border-bottom: 1px solid var(--border); }
.banner .dot { margin-top: 5px; }

/* Signed-out pages: plain top bar */
.no-shell .topbar { position: static; }

/* ------------------------------------------------------------------ layout */
main { width: 100%; max-width: var(--page-w); margin: 0 auto; padding: 20px var(--gutter) 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head > div { min-width: 0; }
.lede { color: var(--text-2); margin: 2px 0 0; font-size: 12.5px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-2 > * { min-width: 0; }
.section { margin-top: 32px; }
.spacer-sm { height: 8px; }

/* Cards (Option A "panel") */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card-tight { padding: 0; overflow-x: auto; }
.auth-wrap { min-height: calc(100vh - var(--topbar-h)); display: grid; place-items: center; padding: 40px 16px; max-width: none; }
.auth-card { width: 100%; max-width: 380px; box-shadow: var(--shadow-pop); }
.auth-card h1 { margin-bottom: 4px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; font-weight: 500; color: var(--text-muted); padding: 9px 14px; background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-1); }
.table tbody tr:hover { background: var(--hover); }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table td.mono, .table td .mono { word-break: break-all; }
.table td.nowrap { white-space: nowrap; word-break: normal; overflow-wrap: normal; overflow: hidden; text-overflow: ellipsis; }
.table, .pill, .nav-badge { font-variant-numeric: tabular-nums; }
.empty { padding: 40px 24px; text-align: center; color: var(--text-2); }

/* Status dot + label */
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; font-size: 12px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; background: var(--gray); }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.orange { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.blue { background: var(--blue); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.gray { background: var(--gray); }

/* Pills / tags */
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 4px; font: 500 11px/1 var(--mono);
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.count, .pill.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.pill.blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Buttons */
.btn { font: 500 12.5px/1 var(--font); height: var(--ctl-h); padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-1), color var(--dur-1), border-color var(--dur-1), transform var(--dur-1) var(--ease-out); }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:active:not([disabled]) { transform: scale(.98); }
.btn-outline { background: var(--surface); }
.btn-primary { background: var(--text); color: var(--on-primary); border-color: var(--text); }
.btn-primary:hover { background: var(--text); opacity: .88; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: transparent; }
.btn-lg { height: var(--ctl-h-lg); padding: 0 14px; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* Busy submit button (app.js): label hides, spinner shows, width kept */
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--text-2); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn-primary.is-busy::after { border-color: var(--on-primary); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(1turn); } }
.btn.copied { color: var(--green); }
.copy-fallback { font-size: 12px; color: var(--text-2); }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 12.5px; color: var(--text); font-weight: 500; }
.hint { font-size: 12px; line-height: 16px; color: var(--text-2); }
.input, select.input, textarea.input { font: 400 13px/20px var(--font); width: 100%; height: var(--ctl-h-lg); padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); transition: border-color var(--dur-1), box-shadow var(--dur-1); }
textarea.input { height: auto; min-height: 96px; padding: 8px 10px; font-family: var(--mono); font-size: 12px; resize: vertical; }
.input::placeholder { color: var(--text-muted); }
.input:hover:not(:focus):not(:disabled) { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { height: var(--ctl-h); width: auto; font-size: 12.5px; }
.input.search { width: 240px; padding-left: 30px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2371717A' stroke-width='1.5'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E") no-repeat 10px 50% / 13px; }
select.input option { background: var(--surface); color: var(--text); }
/* Number fields (port, days): no browser spin buttons */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; color: var(--text); }
.check input { margin-top: 3px; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.form-actions .btn { height: var(--ctl-h-lg); }

/* Notices. Errors stay inline; success notices (data-autohide) float as a toast. */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); margin-bottom: 16px; color: var(--text); overflow-wrap: anywhere; }
.notice .dot { margin-top: 6px; }
.notice[role="alert"] { background: var(--red-soft); border-color: transparent; }
.notice.flush { margin: 0; }
.notice[data-autohide] { position: fixed; right: 20px; bottom: 20px; z-index: 70; max-width: min(440px, calc(100vw - 40px)); margin: 0;
  background: var(--text); color: var(--surface); border-color: transparent; box-shadow: var(--shadow-modal); font-weight: 500;
  animation: toast-in var(--dur-2) var(--ease-out); transition: opacity var(--dur-2), transform var(--dur-2); }
.notice[data-autohide] code { background: transparent; color: inherit; }
.notice.leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Definition list */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Secret reveal / code */
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret code { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; font: 400 12px/1.5 var(--mono); margin: 0; }

/* Diff */
.diff td.field-name { white-space: nowrap; width: 1%; color: var(--text-2); }
.diff td.old { color: var(--text-muted); }
.diff td.old > span { color: var(--red); background: var(--red-soft); text-decoration: line-through; padding: 1px 4px; border-radius: 3px; }
.diff td.new > span { background: var(--green-soft); color: var(--green); padding: 1px 4px; border-radius: 3px; }

/* Filter tabs (segmented) */
.tabs { display: inline-flex; gap: 2px; margin-bottom: 12px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tabs a { color: var(--text-2); padding: 0 10px; height: 26px; display: inline-flex; align-items: center; border-radius: 4px; font-weight: 500; font-size: 12px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="true"] { background: var(--surface-2); color: var(--text); }

/* Toolbar above lists */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.filters { margin-bottom: 12px; }

/* ----------------------------------------------------------------- dialogs */
dialog { border: 1px solid var(--border-strong); padding: 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-modal); max-width: 440px; width: calc(100% - 32px);
  color: var(--text); background: var(--surface); text-align: start; white-space: normal; overflow-wrap: anywhere; overflow-x: hidden; }
dialog.wide { max-width: 560px; }
dialog h2 { font-size: 15px; margin-bottom: 6px; }
dialog .form-actions { justify-content: flex-end; }
dialog::backdrop { background: var(--backdrop); }
dialog[open] { animation: pop var(--dur-2) var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* Drawer: a <dialog> pinned to the right edge */
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: 540px; max-width: 100vw; padding: 0; border: 0; border-left: 1px solid var(--border);
  border-radius: 0; box-shadow: var(--shadow-drawer); overflow: hidden; }
dialog.drawer[open] { display: flex; flex-direction: column; animation: slide-in var(--dur-2) var(--ease-out); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.eyebrow { font: 500 10.5px/1 var(--mono); color: var(--text-muted); letter-spacing: .05em; text-transform: uppercase; }
.drawer-title { margin: 6px 0 0; font: 600 16px/1.3 var(--mono); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; display: grid; gap: 16px; align-content: start; }
.drawer-body .card { padding: 16px; }
.inspector { display: grid; gap: 16px; }
.drawer-loading { color: var(--text-muted); }

/* Command palette */
dialog.cmdk { margin-top: 14vh; padding: 0; max-width: 560px; overflow: hidden; }
.cmdk-input-wrap { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.cmdk-input-wrap input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: 400 14px/1.4 var(--font); outline: none; }
.cmdk-results { list-style: none; margin: 0; padding: 6px; max-height: 340px; overflow-y: auto; }
.cmdk-results a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--text); }
.cmdk-results a:hover { text-decoration: none; background: var(--hover); }
.cmdk-results [aria-selected="true"] a { background: var(--surface-2); }
.cmdk-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-sub { color: var(--text-muted); font: 400 11.5px/1 var(--mono); }
.cmdk-kind { font: 500 10.5px/1 var(--mono); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.cmdk-empty { padding: 20px; text-align: center; color: var(--text-muted); }

/* ------------------------------------------------------------------- hosts */
.group-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--surface);
  border: 1px solid var(--border); color: var(--text); font-size: 12px; font-weight: 500; }
.chip:hover { background: var(--hover); text-decoration: none; }
.chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.group { scroll-margin-top: 64px; }
.group > summary { list-style: none; }
.group > summary::-webkit-details-marker { display: none; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 2px 0 8px; cursor: pointer; width: fit-content; border-radius: var(--radius); }
.group-head:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.group-head .chev { color: var(--text-muted); transform: rotate(-90deg); }
.group[open] .group-head .chev { transform: none; }
.group-name { font-weight: 600; }
.host-name { font-weight: 500; color: var(--text); }
a.host-name:hover { text-decoration: underline; }
.lat { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--mono); color: var(--text-2); white-space: nowrap; }
.lat .dot { width: 6px; height: 6px; box-shadow: none; }
@media (min-width: 900px) {
  /* Same column widths in every group so the tables line up. Percentages, so they
     always add up whatever the width; long addresses end in an ellipsis. */
  .group .table { table-layout: fixed; }
  .group .table th.col-name { width: 24%; }
  .group .table th.col-port { width: 8%; }
  .group .table th.col-user { width: 13%; }
  .group .table th.col-auth { width: 11%; }
  .group .table th.col-status { width: 17%; }
  .group .table th.actions { width: 84px; }
}
}
.group .table td { padding-top: 12px; padding-bottom: 12px; }
.group .table .host-name { font-weight: 600; }
.group .table td.c-dim { color: var(--text-2); }
.group .table td[data-label="Port"], .group .table td[data-label="Auth"], .group .table td[data-label="User"] { white-space: nowrap; overflow-wrap: normal; word-break: normal; }

/* Host detail */
.detail-grid { align-items: start; }
@media (min-width: 1200px) {
  .detail-grid { grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); }
  .detail-grid > .side { position: sticky; top: calc(var(--topbar-h) + 20px); display: grid; gap: 16px; }
}
.mono-h { font-family: var(--mono); letter-spacing: -.4px; }
.spark { display: block; width: 100%; height: 36px; color: var(--accent); }
.spark .bar { fill: currentColor; opacity: .55; }
.spark .bar.slow { fill: var(--amber); opacity: .9; }
.spark .bar.fail { fill: var(--red); opacity: .9; }
.lat-stats { display: flex; gap: 24px; margin-bottom: 10px; }
.lat-stats .v { font: 600 18px/1.2 var(--mono); }
.lat-stats .k { font-size: 11.5px; color: var(--text-muted); }

/* --------------------------------------------------------------- approvals */
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.queue { list-style: none; margin: 0; padding: 0; }
.queue li + li { border-top: 1px solid var(--border); }
.queue a { display: grid; gap: 4px; padding: 12px 14px; color: var(--text); }
.queue a:hover { background: var(--hover); text-decoration: none; }
.queue a[aria-current="page"] { background: var(--surface-2); }
.queue-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.queue-meta { font-size: 12px; color: var(--text-muted); }
.pane-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pane-head h2 { font-size: 15px; margin: 0; }
.pane-body { padding: 16px 20px; display: grid; gap: 12px; }
.pane-body .notice { margin: 0; }
.pane-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg); }
.pane-actions .btn { height: var(--ctl-h-lg); }
.pager { margin-top: 12px; }

/* ------------------------------------------------------------------- audit */
.audit-row > td { padding: 0; }
.audit-row details > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) 100px 16px; gap: 12px; align-items: center; padding: 10px 14px; }
.audit-row details > summary::-webkit-details-marker { display: none; }
.audit-row details > summary:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.audit-row details[open] > summary { background: var(--surface-2); }
.audit-row .chev { color: var(--text-muted); transform: rotate(-90deg); }
.audit-row details[open] .chev { transform: none; }
.audit-head { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) 100px 16px; gap: 12px; padding: 9px 14px;
  font-size: 11.5px; font-weight: 500; color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); }
.audit-detail { padding: 4px 14px 14px; background: var(--surface-2); }
.audit-detail .dl { grid-template-columns: 120px 1fr; font-size: 12px; }
.audit-list > div + div { border-top: 1px solid var(--border); }
.audit-list .cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------- bulk add */
.bulk-rows { display: grid; gap: 10px; }
.bulk-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 14px 2px; }
.bulk-row.has-error { border-color: var(--red); }
.bulk-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; margin-bottom: 4px; }
.bulk-num { font-size: 12px; font-weight: 500; color: var(--text-2); }
.bulk-remove { height: 26px; font-size: 12px; }
.bulk-error { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; font-size: 12.5px; }
.bulk-main { display: grid; gap: 0 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bulk-main > * { min-width: 0; }
.bulk-main .field { margin-bottom: 10px; gap: 4px; }
.bulk-main .field label, .bulk-main .label { font-size: 11.5px; color: var(--text-2); }
.bulk-key-hint { height: var(--ctl-h-lg); display: flex; align-items: center; }
.bulk-extra { margin-bottom: 10px; }
.bulk-extra .field { margin-bottom: 8px; }
.bulk-switch { gap: 4px 16px; }
.bulk-switch .check { padding: 4px 0; }
.bulk-enable { max-width: 420px; margin-top: 8px; }
.bulk-more { margin: 0 0 8px; }
.bulk-more > summary { cursor: pointer; width: fit-content; font-size: 12.5px; color: var(--text-2); padding: 4px 0 8px; border-radius: var(--radius); }
.bulk-more > summary:hover { color: var(--text); }
.bulk-more > summary:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.bulk-more .field { align-content: start; }
.bulk-more textarea.input { min-height: 88px; height: 88px; }
.bulk-extra textarea.input { min-height: 96px; }
.bulk-actions { justify-content: space-between; }
@media (min-width: 769px) { .bulk-main { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1100px) {
  .bulk-main { grid-template-columns: 136px minmax(0, 1fr) minmax(0, 1.3fr) 76px minmax(0, 1fr) minmax(0, 1fr) 112px minmax(0, 1fr); }
}
.errlist { margin: 4px 0 0; padding-left: 18px; }

/* --------------------------------------------------------------- utilities */
.intro { margin: 0 0 20px; }
.narrow { max-width: 520px; }
.narrow-lg { max-width: 860px; }
.flush { margin: 0; }
.h-sm { font-size: 18px; margin-bottom: 6px; }
.gap-top { margin-top: 14px; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .split > .pane { order: -1; }
  .pane-placeholder { display: none; }
  .audit-head { display: none; }
  .audit-row details > summary { display: flex; flex-wrap: wrap; gap: 2px 10px; }
  .audit-row .c-action { order: -2; flex: 1 0 calc(100% - 110px); }
  .audit-row .c-out { order: -1; }
  .audit-row .chev { order: -1; }
  .audit-row .c-time, .audit-row .c-actor, .audit-row .c-target { font-size: 11.5px; color: var(--text-muted); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .cmdk-trigger { min-width: 0; width: var(--ctl-h); padding: 0; justify-content: center; background: var(--surface); color: var(--text-2); }
  .cmdk-trigger-label, .cmdk-trigger kbd { display: none; }
  .crumb-root, .crumb-sep { display: none; }
}
@media (max-width: 768px) {
  :root { --gutter: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .who, .role-tag { display: none; }
  .icon-btn, .avatar-btn, .cmdk-trigger { min-width: 40px; min-height: 40px; }
  .input.search { width: 100%; }
  /* Stacked rows: label column on the left, value wraps on the right. Block
     layout (not flex) so pills and long values can never widen the table. */
  .table.responsive, .table.responsive tbody, .table.responsive tr { display: block; width: 100%; }
  .table.responsive { table-layout: auto; }
  .table.responsive thead { display: none; }
  .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive td { display: block; position: relative; min-height: 26px; padding: 4px 0 4px 104px; border: 0; width: auto; text-align: left; white-space: normal; }
  .table.responsive td::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 96px; color: var(--text-muted); font: 400 12px/18px var(--font); }
  .table.responsive td .pill { margin: 2px 0; }
  .table.responsive td.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .table.responsive td.actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding: 10px 0 0; width: auto; text-align: left; }
  .table.responsive td.actions::before { content: none; }
  .table.responsive td.actions form.inline { display: inline-flex; }
  .diff.responsive td.field-name { width: auto; font-weight: 500; color: var(--text); padding-left: 0; }
  .diff.responsive td.field-name::before { content: none; }
  .notice[data-autohide] { left: 16px; right: 16px; bottom: 16px; }
}
/* Wide tables (many columns + actions) stack earlier, while the sidebar is showing. */
@media (max-width: 1180px) {
  .table.responsive-lg, .table.responsive-lg tbody, .table.responsive-lg tr { display: block; width: 100%; }
  .table.responsive-lg { table-layout: auto; }
  .table.responsive-lg thead { display: none; }
  .table.responsive-lg tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive-lg tbody tr:last-child { border-bottom: 0; }
  .table.responsive-lg td { display: block; position: relative; min-height: 26px; padding: 4px 0 4px 104px; border: 0; width: auto; text-align: left; white-space: normal; }
  .table.responsive-lg td::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 96px; color: var(--text-muted); font: 400 12px/18px var(--font); }
  .table.responsive-lg td .pill { margin: 2px 0; }
  .table.responsive-lg td.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .table.responsive-lg td.actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding: 10px 0 0; width: auto; text-align: left; }
  .table.responsive-lg td.actions::before { content: none; }
  .table.responsive-lg td.actions form.inline { display: inline-flex; }
}
@media (max-width: 400px) { .brand-word { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
