/* admin-console — restored "old look" on the current 4-panel markup.
 *
 * Faithful visual port of the old console:
 *   - vendored Inter (UI) + JetBrains Mono (data); NO CDN.
 *   - monochrome white/gray palette (no accent beyond #ededed).
 *   - LEFT SIDEBAR (220px) via #shell grid; #topnav is the left column.
 *
 * Wrapping fix: table cells no longer `word-break: break-all`. Identifier-ish
 * columns get `white-space: nowrap` and each .data-table scrolls horizontally
 * inside its panel rather than shattering words mid-character.
 */

/* --- self-hosted fonts (woff2 vendored; no CDN) --- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-variable.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-variable.woff2") format("woff2");
}

:root {
  --bg:             #0a0a0a;
  --surface:        #111111;
  --text:           #ffffff;
  --accent:         #ededed;

  --surface-raised: #181818;
  --border:         #262626;
  --text-dim:       #8a8a8a;
  --ok:             #22c55e;
  --warn:           #f59e0b;
  --down:           #ef4444;

  --font-ui:   "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --gap:    16px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, pre, .mono { font-family: var(--font-data); }

a { color: var(--accent); text-decoration: none; }

/* Thin dark scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar       { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-track { background: transparent; }

/* Generic input/select */
input, select {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font-ui);
  outline: none;
}
input:focus, select:focus { border-color: rgba(255,255,255,0.14); }
input::placeholder         { color: var(--text-dim); }

/* ---------------------------------------------------------------------------
 * LOGIN GATE — Adam-style light card (scoped; governance shell stays dark)
 * --------------------------------------------------------------------------- */
#login-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #f6f9fc; z-index: 999;
  padding: 24px;
  color-scheme: light;
}
#login-gate[hidden] { display: none; }

#login-box {
  width: 100%; max-width: 400px;
  background: #ffffff;
  border: 1px solid #e6ebf1;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 4px 24px rgba(10,34,64,.10), 0 1px 4px rgba(10,34,64,.06);
  text-align: center;
  display: flex; flex-direction: column; gap: 0;
}

#login-logo {
  height: 44px; width: auto;
  margin: 0 auto 22px;
  display: block;
}

#login-title {
  font-family: var(--font-ui);
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  color: #0A2240;
  margin: 0 0 6px;
}

#login-sub {
  font-size: 14px; color: #64748d;
  margin: 0 0 26px;
}

/* Wrap the three inputs in a form-like flow */
#login-box form,
#login-box > input,
#login-box > button { margin-bottom: 0; }

#login-username,
#login-password,
#login-office-key {
  display: block; width: 100%; box-sizing: border-box;
  font-family: var(--font-ui); font-size: 15px;
  padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid #dbe3ec; border-radius: 6px;
  background: #ffffff; color: #061b31;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
#login-username:focus,
#login-password:focus,
#login-office-key:focus {
  border-color: #0B7A8A;
  box-shadow: 0 0 0 3px rgba(11,122,138,.15);
}
#login-username::placeholder,
#login-password::placeholder,
#login-office-key::placeholder { color: #aab4c0; }

#login-submit {
  display: block; width: 100%; box-sizing: border-box;
  margin-top: 4px; padding: 11px;
  border: 0; border-radius: 6px;
  background: #0B7A8A; color: #fff;
  font-family: var(--font-ui); font-weight: 600; font-size: 15px;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(50,50,93,.11), 0 1px 2px rgba(0,0,0,.08);
  transition: background .15s;
}
#login-submit:hover    { background: #096574; }
#login-submit:disabled { opacity: 0.45; cursor: not-allowed; }

.login-backend-down {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
}
.login-backend-down[hidden] { display: none; }
.login-backend-down strong { display: block; margin-bottom: 4px; }
.login-backend-down p { margin: 0; }

#login-err {
  margin-top: 12px; padding: 10px 12px;
  background: #fdecef; border: 1px solid #df1b41;
  border-radius: 6px; color: #df1b41;
  font-size: 13px; text-align: center;
}
#login-err[hidden] { display: none; }

/* ---------------------------------------------------------------------------
 * SHELL LAYOUT — left sidebar (220px) + main content
 * --------------------------------------------------------------------------- */
#shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}
#shell[hidden] { display: none; }

/* --- Left sidebar (the old #nav look; markup is #topnav) --- */
#topnav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

#nav-brand {
  padding: 0 8px 20px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.nav-tab:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.nav-tab.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-weight: 600;
}
.nav-tab[hidden] { display: none; }
.nav-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--ok);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 700;
}
.nav-tab-badge[hidden] { display: none; }

.workflows-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.workflow-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.workflow-card:hover {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.18);
}
.workflow-card--running {
  border-color: rgba(255, 255, 255, 0.16);
}
.workflow-card--selected.workflow-card--running {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
}
.workflow-card--paused {
  border-color: rgba(255, 255, 255, 0.16);
}
.workflow-card--selected.workflow-card--paused {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
}
.workflow-status {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: lowercase;
}
.btn-fire--danger {
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--down);
}
.btn-fire--danger:hover {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.08);
}
.nav-tab--live {
  /* retained for old caches; no pulse / green chrome */
}
.workflow-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.workflow-card-slug {
  font-family: var(--font-data);
  font-size: 14px;
  font-weight: 600;
}
.workflow-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-dim);
}
.workflow-card-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workflow-console {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
}
.workflow-console[hidden] { display: none; }
.workflow-console-log {
  min-height: 280px;
  max-height: min(60vh, 640px);
}

/* Push the health dot to the bottom of the sidebar */
#nav-spacer { flex: 1 1 auto; }

/* Logout button in the sidebar — subtle, below nav-spacer */
.btn-logout {
  display: block;
  width: calc(100% - 16px);
  margin: 0 8px;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.btn-logout:hover {
  background: rgba(239,68,68,0.08);
  color: var(--down);
  border-color: rgba(239,68,68,0.3);
}

.btn-clinic-console {
  display: block;
  width: calc(100% - 16px);
  margin: 0 8px 8px;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.btn-clinic-console:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.2);
}
.btn-clinic-console[hidden] { display: none; }

#health-dot {
  align-self: flex-start;
  margin: 12px 10px 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
#health-dot.ok  { background: var(--ok); }
#health-dot.err { background: var(--down); }

/* --- Main content area --- */
#app {
  padding: 24px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------------------
 * PANELS
 * --------------------------------------------------------------------------- */
.panel { min-width: 0; }
.panel[hidden] { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.panel-header .portal-export-btn { margin-left: auto; }

/* Export control — subtle on the dark governance shell (portal.css defaults are light). */
body:not(.portal-active) .portal-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}
body:not(.portal-active) .portal-export-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}
body:not(.portal-active) .portal-export-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.25);
  outline-offset: 2px;
}
body:not(.portal-active) .portal-export-icon {
  opacity: 0.72;
}
body:not(.portal-active) .portal-export-btn:hover .portal-export-icon {
  opacity: 1;
}
.panel-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * BUTTONS
 * --------------------------------------------------------------------------- */
.btn-sm {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.1s, background 0.1s;
}
.btn-sm:hover {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
}
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border, #334);
  color: var(--text, #e8eef5);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-fire {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.1s, background 0.1s;
}
/* Flex parents (.fleet-drawer-actions) can keep [hidden] children visible
   unless author CSS forces display:none (same pattern as .portal-tab[hidden]). */
.btn-fire[hidden] { display: none !important; }
.btn-fire:hover {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
}
.btn-fire:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-fire.accepted { border-color: rgba(34,197,94,0.5);  color: var(--ok);   }
.btn-fire.error    { border-color: rgba(239,68,68,0.5);  color: var(--down); }

/* ---------------------------------------------------------------------------
 * ERROR BANNER
 * --------------------------------------------------------------------------- */
.err-banner {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.35);
  color: #f2b8b8;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.err-banner[hidden] { display: none; }

/* ---------------------------------------------------------------------------
 * DATA TABLE — wraps in a horizontally-scrollable container (wrapping fix)
 * --------------------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  /* WRAPPING FIX: horizontal scroll instead of mid-word shattering. The table
     is display:block so overflow-x applies to the element itself. */
  display: block;
  overflow-x: auto;
}
.data-table thead, .data-table tbody { display: table; width: 100%; }

.data-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
  font-family: var(--font-data);
  font-size: 12px;
  /* WRAPPING: never split a word. Wrap ONLY at spaces; a too-long single word
     overflows and the table (.data-table, overflow-x:auto) scrolls instead of
     breaking the word across lines. */
  overflow-wrap: normal;
  word-break: keep-all;
}
.data-table tr:hover td { background: rgba(255,255,255,0.03); }
.data-table td a {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

/* Identifier-ish columns must not wrap at all — they scroll with the table.
 *   fleet:     slug | status | kind | age | probed | counts
 *   knowledge: path | area | status | authority | last updated | access
 *   carriers:  id | slug | display name | plan type | status | AMD codes
 * The first column (slug/path/id) and timestamp/code columns stay on one line. */
#fleet-table td:nth-child(1),   /* slug */
#fleet-table td:nth-child(4),   /* age */
#kn-table    td:nth-child(1),   /* path */
#kn-table    td:nth-child(5),   /* last updated */
#carr-table  td:nth-child(1),   /* id */
#carr-table  td:nth-child(2),   /* slug */
#carr-table  td:nth-child(6) {  /* AMD codes */
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * STATUS / KIND / KNOWLEDGE / CARRIER BADGES
 * --------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-data);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-live     { background: rgba(34,197,94,0.14);  color: var(--ok);   }
.badge-active   { background: rgba(34,197,94,0.14);  color: var(--ok);   }
.badge-stale    { background: rgba(245,158,11,0.14); color: var(--warn); }
.badge-warn     { background: rgba(245,158,11,0.14); color: var(--warn); }
.badge-down     { background: rgba(239,68,68,0.14);  color: var(--down); }
.badge-inactive { background: rgba(239,68,68,0.14);  color: var(--down); }
.badge-idle     { background: rgba(138,138,138,0.12); color: var(--text-dim); }
.badge-unknown  { background: rgba(138,138,138,0.12); color: var(--text-dim); }
.badge-promoted { background: rgba(237,237,237,0.10); color: var(--accent);   }
.badge-draft    { background: rgba(138,138,138,0.12); color: var(--text-dim); }

/* ---------------------------------------------------------------------------
 * SUMMARY BAR (carriers)
 * --------------------------------------------------------------------------- */
.summary-bar {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.summary-bar span { white-space: nowrap; }
.summary-bar b { color: var(--text); font-family: var(--font-data); }

/* ---------------------------------------------------------------------------
 * EMPTY MESSAGE
 * --------------------------------------------------------------------------- */
.empty-msg {
  color: var(--text-dim);
  padding: 12px 0;
  font-size: 13px;
}
.empty-msg[hidden] { display: none; }

/* ---------------------------------------------------------------------------
 * FLEET INSPECTOR DRAWER — click row → detail + live log
 * --------------------------------------------------------------------------- */
.fleet-row { cursor: pointer; }
.fleet-row:hover { background: rgba(255,255,255,0.04); }
.fleet-row:focus-visible {
  outline: 1px solid rgba(255,255,255,0.35);
  outline-offset: -1px;
}

.fleet-drawer {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.fleet-drawer[hidden] { display: none; }

.fleet-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.fleet-drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fleet-drawer-header h3 {
  margin: 0;
  font-size: 16px;
  font-family: var(--font-data);
  font-weight: 600;
}
.fleet-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
  color: var(--ok);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.fleet-live-badge[hidden] { display: none; }
.fleet-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: fleet-live-pulse 1.6s ease-out infinite;
}
@keyframes fleet-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.fleet-drawer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.fleet-drawer-meta {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-data);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.fleet-console {
  display: flex;
  flex-direction: column;
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #070707;
}
.fleet-console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #141414 0%, #0e0e0e 100%);
  border-bottom: 1px solid var(--border);
}
.fleet-console-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fleet-console-hint {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-data);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fleet-drawer-log {
  margin: 0;
  flex: 1;
  min-height: 240px;
  max-height: 52vh;
  overflow: auto;
  padding: 8px 0;
  font-family: var(--font-data), ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.45;
}
.fleet-log-line {
  display: grid;
  grid-template-columns: 76px 64px minmax(0, 1fr);
  gap: 10px;
  padding: 5px 12px;
  align-items: start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.fleet-log-line:hover {
  background: rgba(255, 255, 255, 0.03);
}
.fleet-log-ts {
  color: #5c5c5c;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fleet-log-kind {
  display: inline-block;
  width: fit-content;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #121212;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.fleet-log-msg {
  color: #cfcfcf;
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
}
.fleet-log-line--phase .fleet-log-kind {
  border-color: rgba(237, 237, 237, 0.28);
  color: #ededed;
}
.fleet-log-line--amd .fleet-log-kind {
  border-color: rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}
.fleet-log-line--ok .fleet-log-kind,
.fleet-log-line--done .fleet-log-kind {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--ok);
}
.fleet-log-line--ok .fleet-log-msg,
.fleet-log-line--done .fleet-log-msg {
  color: #bbf7d0;
}
.fleet-log-line--warn .fleet-log-kind {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warn);
}
.fleet-log-line--warn .fleet-log-msg {
  color: #fde68a;
}
.fleet-log-line--error .fleet-log-kind {
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--down);
}
.fleet-log-line--error .fleet-log-msg {
  color: #fecaca;
}
.fleet-log-line--ui .fleet-log-kind {
  border-color: rgba(237, 237, 237, 0.28);
  color: #d4d4d4;
}
.fleet-log-line--sep {
  grid-template-columns: 1fr;
  margin: 6px 8px;
  padding: 8px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.fleet-log-line--sep .fleet-log-msg {
  color: #a3a3a3;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.fleet-log-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}
@media (max-width: 720px) {
  .fleet-log-line {
    grid-template-columns: 56px 52px minmax(0, 1fr);
    gap: 6px;
    padding: 6px 10px;
  }
  .fleet-log-ts { font-size: 10px; }
}

/* ---------------------------------------------------------------------------
 * ACTIVITY PANEL — per-service run blocks
 * --------------------------------------------------------------------------- */
.svc-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
  overflow: hidden;
}
.svc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.svc-slug {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-data);
  font-size: 13px;
  white-space: nowrap;
}
.svc-body { padding: 12px 16px; }
.svc-run-result {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-data);
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  display: block;
  overflow-x: auto;
}
.runs-table thead, .runs-table tbody { display: table; width: 100%; }
.runs-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  padding: 5px 8px;
  white-space: nowrap;
}
.runs-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-data);
  /* wrap only at spaces; never split a word (table scrolls on overflow) */
  overflow-wrap: normal;
  word-break: keep-all;
}
.runs-table td.ts { color: var(--text-dim); white-space: nowrap; }
.runs-empty {
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 0;
}

/* ---------------------------------------------------------------------------
 * KNOWLEDGE CONTENT VIEWER (body viewer — pre-wrap is intentional here)
 * --------------------------------------------------------------------------- */
#kn-content-viewer {
  margin-top: var(--gap);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#kn-content-viewer[hidden] { display: none; }
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-raised);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}
/* The path is a single spaceless token: keep it on ONE line (never split the
   word across lines); if too long it ellipsizes at the end, not mid-word. */
#kn-content-path {
  font-family: var(--font-data);
  font-size: 12px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#kn-content-body {
  padding: 14px;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  background: var(--bg);
  font-family: var(--font-data);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  /* Body viewer: wrap at whitespace only (pre-wrap keeps words intact); a very
     long token overflows and scrolls rather than being split across lines. */
  white-space: pre-wrap;
  overflow-wrap: normal;
}

/* ---------------------------------------------------------------------------
 * FILTER ROWS (knowledge + carriers)
 * --------------------------------------------------------------------------- */
#kn-filter-row, #carr-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
#kn-area-filter, #kn-status-filter, #carr-status-filter {
  min-width: 120px;
  font-size: 13px;
}
#kn-search, #carr-search {
  min-width: 180px;
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
 * FLAGS PANEL — role permissions matrix + per-provider toggles
 * --------------------------------------------------------------------------- */
.flags-section {
  margin-bottom: 28px;
  min-width: 0;
}
.flags-section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.flags-section-toolbar .flags-section-title {
  margin: 0;
}
.flags-section-toolbar .portal-export-btn {
  margin: 0;
  flex-shrink: 0;
}
.flags-section-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.panel-lede {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 14px;
  max-width: 52rem;
}
.panel-lede code {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--accent);
}

.role-perms-scroll {
  overflow: auto;
  max-height: min(72vh, 720px);
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.role-perms-scroll:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.22);
  outline-offset: 2px;
}
.role-perms-scroll::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
.role-perms-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.role-perms-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.role-perms-scroll .role-perms-table {
  display: table;
  width: max-content;
  min-width: 100%;
  overflow: visible;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}
.role-perms-scroll .role-perms-table thead,
.role-perms-scroll .role-perms-table tbody {
  display: table-row-group;
  width: auto;
}
.role-perms-table th.role-perms-cap-col,
.role-perms-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
  min-width: 11rem;
  max-width: 18rem;
  box-shadow: 1px 0 0 var(--border);
}
.role-perms-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-raised);
}
.role-perms-table thead th.role-perms-cap-col {
  z-index: 3;
}
.role-perms-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}
.role-perms-table tr:hover td:first-child {
  background: #141414;
}
.role-perms-table td:nth-child(1) {
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  white-space: normal;
  line-height: 1.35;
}
.role-perms-table th.role-perms-role-col {
  font-size: 10px;
  letter-spacing: 0.03em;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  padding-bottom: 8px;
}
.role-perms-table th:not(:first-child),
.role-perms-table td:not(:first-child) {
  text-align: center;
  white-space: nowrap;
  min-width: 7.25rem;
  padding-left: 8px;
  padding-right: 8px;
}
.role-perms-hint {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-data);
}
.perm-yes {
  color: var(--ok);
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.perm-no {
  color: var(--text-dim);
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.perm-flag {
  color: var(--warn);
  font-family: var(--font-data);
  font-size: 11px;
}
.perm-flag code {
  font-size: 10px;
  color: var(--warn);
}

.flags-provision {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
#flags-username, #users-username, #roles-create-name {
  min-width: 180px;
  font-size: 13px;
  font-family: var(--font-data);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
}
#flags-username:focus, #users-username:focus, #roles-create-name:focus {
  outline: none;
  border-color: rgba(255,255,255,0.25);
}
#users-role, .users-role-select, .role-perm-select, #roles-create-copy {
  font-size: 13px;
  font-family: var(--font-data);
  min-width: 140px;
}
.roles-create-copy-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.role-perm-select {
  width: 100%;
  min-width: 6.5rem;
  max-width: 12rem;
  font-size: 11px;
  box-sizing: border-box;
}
.role-perms-table .flag-toggle {
  justify-content: center;
}
.users-revoke-btn {
  font-size: 12px;
  color: var(--down);
  border-color: rgba(239,68,68,0.35);
}
.users-revoke-btn:hover {
  border-color: rgba(239,68,68,0.6);
  background: rgba(239,68,68,0.08);
}
.flags-provision-msg {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-data);
}
.flags-provision-msg.ok { color: var(--ok); }

#flags-table td:nth-child(1) { /* username */
  white-space: nowrap;
  font-family: var(--font-data);
}
.flags-username {
  font-weight: 500;
}

.flag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.flag-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--ok);
  cursor: pointer;
}
.flag-toggle input[type="checkbox"]:disabled {
  cursor: wait;
  opacity: 0.5;
}
.flag-toggle-label {
  font-family: var(--font-data);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  min-width: 1.5rem;
}
.flag-toggle input[type="checkbox"]:checked + .flag-toggle-label {
  color: var(--ok);
}

/* ---------------------------------------------------------------------------
 * TOPOLOGY PANEL — Cytoscape graph + Flow Explorer
 * Monochrome palette matching the restored look; graph canvas fills the
 * available width; sidebar detail panel is pinned to the right.
 * --------------------------------------------------------------------------- */

/* Sub-tab toggle buttons */
.topo-subtab {
  font-size: 12px;
  padding: 5px 10px;
}
.topo-subtab.active {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: var(--text);
}

/* Window picker */
.topo-window-select {
  font-size: 12px;
  padding: 5px 8px;
  min-width: 80px;
}

/* Status bar (node/edge count + window) */
.topo-status-bar {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-data);
  margin-bottom: 10px;
  min-height: 18px;
}

/* -- Topology graph layout: canvas + sidebar -- */
#topo-layout {
  display: flex;
  gap: 12px;
  height: 520px;
  min-height: 320px;
}

#topo-cy {
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#topo-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-y: auto;
}

.topo-sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.topo-placeholder {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0;
  line-height: 1.5;
}

/* Node detail fields */
.topo-node-info { display: flex; flex-direction: column; gap: 8px; }
.topo-field {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.topo-fk {
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.topo-fv {
  color: var(--text);
  font-family: var(--font-data);
  font-size: 11px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -- Flow Explorer: card grid -- */
.topo-flow-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 4px 0 16px;
}

.topo-flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 200px;
  max-width: 280px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  flex: 1 1 200px;
}
.topo-flow-card:hover {
  border-color: rgba(255,255,255,0.2);
  background: var(--surface-raised);
}
.topo-flow-card--running {
  animation: workflow-card-breathe 2.4s ease-in-out infinite;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.06);
}
.topo-flow-card--running .tfc-title::after {
  content: " RUNNING";
  margin-left: 8px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ok);
  font-weight: 700;
}

.tfc-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-data);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tfc-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 8px;
  /* allow two lines then ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tfc-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-data);
}

/* -- Flow detail view -- */
.topo-flow-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.topo-flow-detail-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font-data);
}

#topo-flow-layout {
  display: flex;
  gap: 12px;
  height: 520px;
  min-height: 320px;
}

#topo-flow-cy {
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#topo-flow-panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-y: auto;
}

.topo-fp-placeholder {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0;
  line-height: 1.5;
}

/* Flow panel content sections */
.topo-fp-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.topo-fp-kind {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-data);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  background: rgba(138,138,138,0.12);
  color: var(--text-dim);
}
.topo-kind-start,
.topo-kind-end {
  background: rgba(99,91,255,0.15);
  color: #a8a4ff;
}
.topo-fp-section { margin-top: 10px; }
.topo-fp-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.topo-fp-desc {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}
.topo-fp-code {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.topo-fp-calls {
  list-style: none;
  padding: 0;
  margin: 0;
}
.topo-fp-calls li {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 0;
}
