/* ═══════════════════════════════════════════════════════════════════════
   xdex · bridge — "Deep Space Ops" UI
   Shared stylesheet for /console (API host) and / (admin host).
   Themeable via [data-theme="dark"|"light"] on <html> (set pre-paint by the
   inline bootstrap in each HTML shell; toggled at runtime by common.js).
   Every legacy class name (ct-*, st-*, at-*, pf-*) is preserved — the page
   JS renders fixed markup and must keep working untouched.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b19;
  --bg-2: #0b1024;
  --bg-inset: #0a0f24;
  --surface: rgba(18, 25, 54, 0.72);
  --surface-solid: #121a38;
  --surface-2: rgba(30, 40, 78, 0.55);
  --hover: rgba(91, 115, 255, 0.10);
  --border: #26305a;
  --border-soft: #1a2244;
  --text: #e9edfb;
  --text-2: #9aa6cc;
  --text-3: #6b76a0;
  --primary: #5b73ff;
  --primary-strong: #7c8cff;
  --accent: #20c2ff;
  --grad: #4d63e6;
  --grad-soft: rgba(91,115,255,0.14);
  --ok: #2dd4a7;   --ok-bg: rgba(45,212,167,0.15);   --ok-bd: rgba(45,212,167,0.32);
  --warn: #f5b544; --warn-bg: rgba(245,181,68,0.15); --warn-bd: rgba(245,181,68,0.32);
  --danger: #f4647d; --danger-bg: rgba(244,100,125,0.15); --danger-bd: rgba(244,100,125,0.34);
  --shadow: 0 14px 44px rgba(0,0,0,0.5);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.35);
  --glow: 0 0 0 1px rgba(91,115,255,0.4), 0 10px 34px rgba(74,99,255,0.20);
  --ring: 0 0 0 3px rgba(91,115,255,0.38);
  --sb: #2b3768;
  --aurora:
    radial-gradient(ellipse 80% 55% at 86% -8%, rgba(74,99,255,0.22), transparent 60%),
    radial-gradient(ellipse 72% 55% at 6% 108%, rgba(32,194,255,0.14), transparent 62%);
  --grain: 0.05;
  --code-color: #b8c4ff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2fb;
  --bg-2: #e4eaf7;
  --bg-inset: #f5f8fe;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.6);
  --hover: rgba(74, 99, 255, 0.07);
  --border: #d6ddef;
  --border-soft: #e5ebf7;
  --text: #131c3d;
  --text-2: #4c577a;
  --text-3: #8993b6;
  --primary: #3f52e0;
  --primary-strong: #4a63ff;
  --accent: #0ea5d9;
  --grad: #3f52e0;
  --grad-soft: rgba(74,99,255,0.10);
  --ok: #0f9d76;   --ok-bg: rgba(16,163,120,0.12);   --ok-bd: rgba(16,163,120,0.28);
  --warn: #bd7710; --warn-bg: rgba(189,119,16,0.13); --warn-bd: rgba(189,119,16,0.30);
  --danger: #d43d58; --danger-bg: rgba(212,61,88,0.11); --danger-bd: rgba(212,61,88,0.28);
  --shadow: 0 14px 34px rgba(31,45,90,0.14);
  --shadow-sm: 0 4px 14px rgba(31,45,90,0.10);
  --glow: 0 0 0 1px rgba(74,99,255,0.32), 0 10px 28px rgba(74,99,255,0.15);
  --ring: 0 0 0 3px rgba(74,99,255,0.28);
  --sb: #c4cee6;
  --aurora:
    radial-gradient(ellipse 80% 55% at 86% -10%, rgba(74,99,255,0.14), transparent 60%),
    radial-gradient(ellipse 72% 55% at 4% 110%, rgba(32,194,255,0.12), transparent 62%);
  --grain: 0.035;
  --code-color: #3f52e0;
}

/* Fonts */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
}

/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

html { height: 100%; }

body {
  font-family: var(--font-ui);
  background-color: var(--bg);
  background-image: var(--aurora);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  /* Fixed app shell: the window itself never scrolls — only inner regions do
     (console tool list, the active tab's content, log/session panels). */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fine film grain — sits behind content (content is z-index:1). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--sb) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--sb); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--primary); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

a { color: inherit; }

/* ── Header bar (glassy, gradient hairline) ───────────────────── */
.app-header {
  position: relative;
  z-index: 5;
  background: color-mix(in srgb, var(--bg-2) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 22px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}
.app-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--primary) 22%, var(--accent) 78%, transparent);
  opacity: 0.6;
}

/* Brand lockup */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  border-radius: 10px;
  padding: 4px 6px 4px 4px;
  margin-left: -4px;
  transition: transform 0.15s ease;
}
.brand:hover { transform: translateY(-1px); }
.brand-mark {
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(10,27,89,0.5), 0 0 0 1px rgba(91,115,255,0.25);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; gap: 2px; }
.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-xdex {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.brand-dot { color: var(--text-3); font-weight: 400; margin: 0 5px; }
.brand-tag {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Page title — sits to the right of the brand lockup (e.g. "Admin", "Console") */
.hdr-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  padding-left: 16px;
  border-left: 1px solid var(--border);
  line-height: 1;
}

/* Header right cluster */
.hdr-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ── Tab buttons ──────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 2px; height: 100%; align-items: stretch; }

.tab-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 10px; right: 10px;
  height: 2.5px;
  background: var(--grad);
  border-radius: 3px 3px 0 0;
}
.tab-btn:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ── Environment badge ────────────────────────────────────────── */
.env-badge {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.09em;
  padding: 4px 10px;
  border-radius: 6px;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.env-badge.env-blue { background: #3b82f6; }
.env-badge.env-green { background: #10b981; }
.env-badge.env-amber { background: #f59e0b; color: #422006; }
.env-badge.env-red { background: #ef4444; }

/* ── Profile dropdown ─────────────────────────────────────────── */
.profile-mount { position: relative; }

.pf-button {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid transparent; cursor: pointer; padding: 3px;
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s;
}
.pf-button:hover { background: var(--hover); border-color: var(--border); }
.pf-button:focus-visible { outline: none; box-shadow: var(--ring); }

.pf-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--grad); color: #fff; font-weight: 700;
  position: relative;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent);
}
.pf-avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.pf-avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.pf-avatar .pf-photo { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.pf-initials { line-height: 1; }

.pf-menu {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 288px; background: var(--surface);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 8px; z-index: 1000;
  animation: pop 0.14s ease;
  transform-origin: top right;
}
.pf-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; }
.pf-id { min-width: 0; }
.pf-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-email { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-role { display: inline-block; margin-top: 7px; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; padding: 2px 9px; border-radius: 5px; }
.pf-role-admin { background: var(--grad-soft); color: var(--primary-strong); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent); }
.pf-role-user { background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.pf-sep { height: 1px; background: var(--border-soft); margin: 4px 6px; }

.pf-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  text-align: left; text-decoration: none; padding: 10px; border-radius: 8px;
  transition: background 0.12s;
}
.pf-item:hover { background: var(--hover); }
.pf-item svg { flex-shrink: 0; color: var(--text-3); }
.pf-signout { color: var(--danger); }
.pf-signout svg { color: var(--danger); }

/* Theme control inside the dropdown */
.pf-theme { padding: 8px 10px 6px; }
.pf-theme-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.pf-theme-seg { display: flex; gap: 4px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.pf-seg-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 4px; border: none; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-2); font-family: inherit; font-size: 11.5px; font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.pf-seg-btn svg { width: 14px; height: 14px; }
.pf-seg-btn:hover { color: var(--text); }
.pf-seg-btn.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.pf-seg-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── Content panels ───────────────────────────────────────────── */
.app-body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-content { display: none; flex: 1; min-height: 0; overflow: auto; padding: 32px; }
.tab-content.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════════════════
   Console tab — full-bleed request builder
   ═══════════════════════════════════════════════════════════════ */
.console-tab.active { padding: 0; overflow: hidden; }

.console-tab .ct-container { display: flex; height: 100%; min-height: 0; }
.console-tab .ct-sidebar { width: 340px; border-right: 1px solid var(--border-soft); overflow: hidden; background: var(--surface-2); flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; }
.console-tab .ct-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; min-height: 0; }
.console-tab .ct-controls { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.console-tab .ct-control-row { display: flex; flex-direction: column; gap: 6px; }
.console-tab .ct-control-row label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.console-tab select, .console-tab input[type=text] { background: var(--bg-inset); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 13px; font-family: inherit; flex: 1; transition: border-color 0.15s, box-shadow 0.15s; }
.console-tab select:focus, .console-tab input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.console-tab .ct-search-wrap { display: flex; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.console-tab .ct-search-wrap input[type=text] { border: none; background: transparent; border-radius: 0; flex: 1; }
.console-tab .ct-search-wrap:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.console-tab .ct-search-wrap input[type=text]:focus { box-shadow: none; }
.console-tab .ct-search-wrap .ct-btn { border: none; border-left: 1px solid var(--border); border-radius: 0; background: var(--surface-2); padding: 8px 14px; font-size: 12px; }
.console-tab .ct-search-wrap .ct-btn:hover { background: var(--hover); }
.console-tab .ct-tool-list { padding: 4px 8px; flex: 1; overflow-y: auto; }
.console-tab .ct-tool-item { padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); transition: background 0.1s, color 0.1s; border: 1px solid transparent; }
.console-tab .ct-tool-item:hover { background: var(--hover); color: var(--text); }
.console-tab .ct-tool-item.active { background: var(--grad-soft); color: var(--text); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.console-tab .ct-tool-item .ct-tool-desc { font-size: 11px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console-tab .ct-tool-item.active .ct-tool-desc { color: var(--primary-strong); }
.console-tab .ct-site-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.console-tab .ct-editor-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.console-tab .ct-editor-header { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface-2); flex-wrap: wrap; }
.console-tab .ct-editor-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.console-tab .ct-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.console-tab .ct-btn { padding: 7px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.12s; }
.console-tab .ct-btn:hover { border-color: var(--primary); background: var(--hover); transform: translateY(-1px); }
.console-tab .ct-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.console-tab .ct-btn-primary { background: var(--grad); border-color: transparent; color: #fff; }
.console-tab .ct-btn-primary:hover { box-shadow: var(--glow); filter: brightness(1.06); }
.console-tab .ct-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }
.console-tab .ct-btn-success { background: var(--ok); border-color: transparent; color: #04140e; }
.console-tab .ct-btn-success:hover { filter: brightness(1.08); box-shadow: 0 8px 24px color-mix(in srgb, var(--ok) 40%, transparent); }
.console-tab .ct-btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.console-tab .ct-btn-danger:hover { filter: brightness(1.06); }
.console-tab .ct-btn-sm { padding: 5px 12px; font-size: 11px; }
.console-tab .ct-btn-link { background: transparent; border: none; color: var(--text-3); font-size: 11px; cursor: pointer; padding: 4px 8px; font-family: inherit; text-decoration: underline; text-transform: none; letter-spacing: normal; font-weight: 500; }
.console-tab .ct-btn-link:hover { color: var(--text); }
.console-tab .ct-panels { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.console-tab .ct-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.console-tab .ct-panel + .ct-panel { border-left: 1px solid var(--border-soft); }
.console-tab .ct-panel-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 9px 16px; border-bottom: 1px solid var(--border-soft); background: var(--surface-2); display: flex; justify-content: space-between; align-items: center; }
.console-tab .ct-panel-label-group { display: flex; gap: 12px; align-items: center; }
.console-tab .ct-args-actions { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: normal; }
.console-tab textarea { flex: 1; background: var(--bg-inset); color: var(--text); border: none; padding: 16px; font-family: var(--font-mono); font-size: 13px; resize: none; line-height: 1.55; }
.console-tab textarea:focus { outline: none; }
.console-tab .ct-response-meta { padding: 9px 16px; border-top: 1px solid var(--border-soft); font-size: 11px; color: var(--text-3); background: var(--surface-2); display: flex; gap: 16px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.console-tab .ct-response-meta .ct-status { font-weight: 700; }
.console-tab .ct-response-meta .ct-status.ok { color: var(--ok); }
.console-tab .ct-response-meta .ct-status.err { color: var(--danger); }
.console-tab .ct-curl-box { background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 8px 16px; font-family: var(--font-mono); font-size: 12px; color: var(--text-2); white-space: pre-wrap; word-break: break-all; max-height: 120px; overflow-y: auto; display: none; }
.console-tab .ct-curl-box.visible { display: block; }
.console-tab .ct-envelope-preview { background: var(--bg-2); color: var(--text-2); border-bottom: 1px solid var(--border-soft); padding: 12px 16px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; max-height: 35%; overflow-y: auto; margin: 0; }
.console-tab .ct-var-panel { border-top: 1px solid var(--border-soft); background: var(--surface-2); padding: 8px 16px; max-height: 160px; overflow-y: auto; }
.console-tab .ct-var-panel-title { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.console-tab .ct-var-row { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.console-tab .ct-var-row label { font-size: 12px; color: var(--primary-strong); font-family: var(--font-mono); min-width: 140px; }
.console-tab .ct-var-row input { background: var(--bg-inset); border: 1px solid var(--border); color: var(--text); padding: 5px 8px; border-radius: 6px; font-size: 12px; font-family: inherit; flex: 1; }
.console-tab .ct-var-row input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.console-tab .ct-var-count { color: var(--accent); font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: normal; }
.console-tab .ct-field-panel { border-top: 1px solid var(--border-soft); background: var(--surface-2); padding: 8px 16px; max-height: 200px; overflow-y: auto; }
.console-tab .ct-field-panel-title { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.console-tab .ct-field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; flex-wrap: wrap; }
.console-tab .ct-field-name { font-size: 12px; color: var(--text); font-family: var(--font-mono); min-width: 120px; }
.console-tab .ct-field-badge { font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 700; display: inline-block; }
.console-tab .ct-field-badge.type { background: var(--grad-soft); color: var(--primary-strong); }
.console-tab .ct-field-badge.required { background: var(--danger-bg); color: var(--danger); }
.console-tab .ct-field-badge.optional { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.console-tab .ct-field-default { font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }
.console-tab .ct-field-enum { display: flex; gap: 4px; flex-wrap: wrap; margin-left: 128px; margin-top: 2px; margin-bottom: 4px; }
.console-tab .ct-field-enum-chip { font-size: 10px; padding: 2px 8px; border-radius: 4px; background: var(--grad-soft); color: var(--primary-strong); cursor: pointer; font-family: var(--font-mono); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.console-tab .ct-field-enum-chip:hover { background: var(--hover); color: var(--text); }
.console-tab .ct-empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 14px; padding: 32px; text-align: center; }
.console-tab .ct-loading { opacity: 0.5; pointer-events: none; }
.console-tab .ct-header-inputs { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.console-tab .ct-header-inputs .ct-hdr-row { display: flex; gap: 8px; align-items: center; }
.console-tab .ct-header-inputs label { font-size: 11px; color: var(--text-3); min-width: 110px; font-weight: 600; }
.console-tab .ct-header-inputs input { background: var(--bg-inset); border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: 12px; font-family: var(--font-mono); flex: 1; }
.console-tab .ct-header-inputs input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.console-tab .ct-modal-overlay { position: fixed; inset: 0; background: rgba(4,7,20,0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 9998; display: flex; align-items: center; justify-content: center; }
.console-tab .ct-modal { background: var(--surface); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 380px; max-width: 90%; box-shadow: var(--shadow); animation: pop 0.16s ease; }
.console-tab .ct-modal h3 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.console-tab .ct-modal-desc { font-size: 12px; color: var(--text-2); margin-bottom: 16px; line-height: 1.55; }
.console-tab .ct-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ═══════════════════════════════════════════════════════════════
   Status tab — dashboard
   ═══════════════════════════════════════════════════════════════ */
.status-tab { padding: 28px !important; overflow-y: auto !important; }

.status-tab .st-container { max-width: 1200px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 18px; }

.status-tab .st-bar { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: center; background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 14px; padding: 16px 22px; box-shadow: var(--shadow-sm); }
.status-tab .st-bar-item { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.status-tab .st-bar-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-right: 9px; font-weight: 700; }

.status-tab .st-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.status-tab .st-card { background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-sm); transition: border-color 0.2s, box-shadow 0.2s; }
.status-tab .st-card:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--glow); }
.status-tab .st-card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.status-tab .st-card-title::before { content: ""; width: 3px; height: 13px; border-radius: 3px; background: var(--grad); }

.status-tab .st-badge { display: inline-block; padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; width: fit-content; letter-spacing: 0.04em; background: var(--surface-2); color: var(--text-2); }

.status-tab .st-stat { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.status-tab .st-detail { font-size: 12px; color: var(--text-2); }

.status-tab .st-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.status-tab .st-metric { background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 10px; padding: 13px; display: flex; flex-direction: column; gap: 6px; }
.status-tab .st-metric-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); font-weight: 600; }
.status-tab .st-metric-value { font-size: 19px; font-weight: 800; color: var(--primary-strong); font-variant-numeric: tabular-nums; }

.status-tab .st-sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.status-tab .st-site-chip { background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 10px; padding: 11px 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; transition: border-color 0.15s; }
.status-tab .st-site-chip:hover { border-color: var(--border); }
.status-tab .st-site-name { font-size: 13px; font-weight: 600; color: var(--text); }
.status-tab .st-site-count { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.status-tab .st-dep-badge { font-size: 11px; font-weight: 700; padding: 3px 9px 3px 8px; border-radius: 6px; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.status-tab .st-dep-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-tab .st-dep-badge.ok { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-bd); }
.status-tab .st-dep-badge.ok::before { animation: pulse 2.4s ease-in-out infinite; }
.status-tab .st-dep-badge.warn { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-bd); }
.status-tab .st-dep-badge.err { background: var(--danger-bg); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-bd); }

.status-tab .st-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.status-tab .st-table thead { background: var(--bg-inset); }
.status-tab .st-table th { padding: 9px 12px; text-align: left; font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.status-tab .st-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); }
.status-tab .st-table tbody tr:hover { background: var(--hover); }
.status-tab .st-truncate { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); }
.status-tab .st-time { white-space: nowrap; color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }

.status-tab .st-error-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.status-tab .st-error-item { display: flex; gap: 10px; font-size: 12px; padding: 9px 11px; background: var(--bg-inset); border-left: 3px solid var(--text-3); border-radius: 8px; align-items: center; }
.status-tab .st-error-item:has(.error) { border-left-color: var(--danger); }
.status-tab .st-error-item:has(.warning) { border-left-color: var(--warn); }

.status-tab .st-error-level { font-weight: 700; text-transform: uppercase; font-size: 10px; padding: 2px 7px; border-radius: 4px; flex-shrink: 0; }
.status-tab .st-error-level.error { background: var(--danger); color: #fff; }
.status-tab .st-error-level.warning { background: var(--warn); color: #2a1a02; }
.status-tab .st-error-time { color: var(--text-3); min-width: 75px; flex-shrink: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.status-tab .st-error-logger { color: var(--text-3); min-width: 60px; max-width: 100px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-family: var(--font-mono); }
.status-tab .st-error-msg { color: var(--text-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-tab .st-empty { color: var(--text-3); font-style: italic; padding: 18px; text-align: center; }
.status-tab .st-error-box { background: var(--danger-bg); border: 1px solid var(--danger-bd); border-radius: 10px; padding: 16px; color: var(--danger); font-size: 13px; }
.status-tab .st-footer { font-size: 11px; color: var(--text-3); text-align: right; padding-top: 12px; border-top: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════════════════════
   Admin tab — admin panel
   ═══════════════════════════════════════════════════════════════ */
.admin-tab { padding: 28px !important; overflow-y: auto !important; }

.admin-tab .at-container { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; width: 100%; }

.admin-tab .at-header { display: flex; justify-content: space-between; align-items: center; }
.admin-tab .at-header-left { display: flex; align-items: center; gap: 12px; }
.admin-tab .at-header-title { font-size: 18px; font-weight: 800; color: var(--text); }
.admin-tab .at-role-badge { font-size: 10.5px; font-weight: 800; padding: 3px 10px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-tab .at-role-admin { background: var(--grad-soft); color: var(--primary-strong); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent); }
.admin-tab .at-role-viewer { background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }

.admin-tab .at-form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.admin-tab .at-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.admin-tab .at-input { background: var(--bg-inset); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 13px; font-family: inherit; width: 100%; transition: border-color 0.15s, box-shadow 0.15s; }
.admin-tab .at-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.admin-tab .at-btn { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.12s; }
.admin-tab .at-btn:hover { border-color: var(--primary); background: var(--hover); transform: translateY(-1px); }
.admin-tab .at-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.admin-tab .at-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.admin-tab .at-btn-primary { background: var(--grad); border-color: transparent; color: #fff; }
.admin-tab .at-btn-primary:hover { box-shadow: var(--glow); filter: brightness(1.06); }
.admin-tab .at-btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.admin-tab .at-btn-danger:hover { filter: brightness(1.06); }
.admin-tab .at-btn-sm { padding: 5px 12px; font-size: 11px; }
.admin-tab .at-btn-block { width: 100%; }
.admin-tab .at-btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.admin-tab .at-btn-ghost:hover { color: var(--text); background: var(--hover); }

.admin-tab .at-section { background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); transition: border-color 0.2s, box-shadow 0.2s; }
.admin-tab .at-section:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.admin-tab .at-user-cell { display: flex; align-items: center; gap: 10px; }
.admin-tab .at-user-avatar { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); }
.admin-tab .at-user-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.admin-tab .at-avatar-initials { line-height: 1; }
.admin-tab .at-user-card { display: flex; align-items: center; gap: 12px; background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.admin-tab .at-user-card .at-user-avatar { width: 40px; height: 40px; font-size: 14px; }
.admin-tab .at-role-opts { display: flex; flex-direction: column; gap: 10px; }
.admin-tab .at-role-opt { display: flex; align-items: flex-start; gap: 10px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.admin-tab .at-role-opt:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.admin-tab .at-role-opt:has(input:checked) { border-color: var(--primary); background: var(--grad-soft); }
.admin-tab .at-role-opt input { margin-top: 3px; accent-color: var(--primary); }
.admin-tab .at-role-opt-title { font-size: 14px; font-weight: 700; color: var(--text); }
.admin-tab .at-notice { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 36px; max-width: 520px; margin: 40px auto; text-align: center; box-shadow: var(--shadow-sm); }
.admin-tab .at-notice-title { font-size: 17px; font-weight: 800; color: var(--text); }
.admin-tab .at-section-body { padding: 0; }
.admin-tab .at-section-body code, .admin-tab .at-section-body .at-mono { background: var(--bg-inset); padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--code-color); font-family: var(--font-mono); }
.admin-tab .at-section-body p { padding: 16px 16px 0; }
.admin-tab .at-section-body .at-form-group, .admin-tab .at-section-body > .at-btn, .admin-tab .at-section-body .at-empty { margin-left: 16px; margin-right: 16px; }
.admin-tab .at-section-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 16px; border-bottom: 1px solid var(--border-soft); gap: 12px; flex-wrap: wrap; }
.admin-tab .at-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.admin-tab .at-section-title::before { content: ""; width: 3px; height: 13px; border-radius: 3px; background: var(--grad); }
.admin-tab .at-section-actions { display: flex; gap: 8px; }

.admin-tab .at-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-tab .at-table thead { background: var(--bg-inset); }
.admin-tab .at-table th { padding: 10px 14px; text-align: left; font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.admin-tab .at-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); vertical-align: middle; }
.admin-tab .at-table tbody tr:last-child td { border-bottom: none; }
.admin-tab .at-table tbody tr:hover { background: var(--hover); }

.admin-tab .at-config-key { font-family: var(--font-mono); font-size: 12px; color: var(--text); white-space: nowrap; }
.admin-tab .at-config-value { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tab .at-config-category { font-size: 11px; color: var(--text-3); }
.admin-tab .at-config-input { background: var(--bg-inset); border: 1px solid var(--primary); color: var(--text); padding: 5px 8px; border-radius: 6px; font-size: 12px; font-family: var(--font-mono); width: 100%; }
.admin-tab .at-config-input:focus { outline: none; box-shadow: var(--ring); }
.admin-tab .at-inline-actions { display: flex; gap: 4px; margin-top: 4px; }

.admin-tab .at-key-prefix { font-family: var(--font-mono); font-size: 12px; background: var(--bg-inset); padding: 2px 8px; border-radius: 5px; color: var(--text); }
.admin-tab .at-badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-tab .at-badge-active { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-bd); }
.admin-tab .at-badge-revoked { background: var(--danger-bg); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger-bd); }
.admin-tab .at-badge-expired { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-bd); }

.admin-tab .at-audit-action { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 6px; background: var(--bg-inset); color: var(--text-2); white-space: nowrap; font-family: var(--font-mono); }
.admin-tab .at-audit-time { font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.admin-tab .at-pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.admin-tab .at-page-info { font-size: 11px; color: var(--text-3); }
.admin-tab .at-page-btns { display: flex; gap: 8px; }

.admin-tab .at-modal-overlay { position: fixed; inset: 0; background: rgba(4,7,20,0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 9998; display: flex; align-items: center; justify-content: center; }
.admin-tab .at-modal { background: var(--surface); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 480px; max-width: 90%; box-shadow: var(--shadow); animation: pop 0.16s ease; }
.admin-tab .at-modal-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.admin-tab .at-modal-body { font-size: 13px; color: var(--text-2); line-height: 1.55; margin-bottom: 16px; }
.admin-tab .at-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.admin-tab .at-key-display { background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: var(--font-mono); font-size: 13px; color: var(--text); word-break: break-all; user-select: all; margin-bottom: 8px; }
.admin-tab .at-key-warning { font-size: 11px; color: var(--warn); margin-bottom: 12px; }

.admin-tab .at-create-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-soft); align-items: center; }
.admin-tab .at-create-form .at-input { flex: 1; padding: 6px 10px; }

.admin-tab #at-toast { position: fixed; bottom: 24px; right: 24px; padding: 11px 20px; border-radius: 10px; color: #fff; font-size: 13px; font-weight: 600; z-index: 9999; transition: opacity 0.3s; opacity: 0; pointer-events: none; box-shadow: var(--shadow); }

.admin-tab .at-loading { color: var(--text-3); font-size: 13px; padding: 28px; text-align: center; }
.admin-tab .at-empty { color: var(--text-3); font-style: italic; padding: 28px; text-align: center; font-size: 13px; }
.admin-tab .at-muted { color: var(--text-3); }
.admin-tab .at-mono { font-family: var(--font-mono); }

/* File Exchange tab — reuses .at-* (section carries admin-tab); a few extras. */
.filex-tab .fx-controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; padding: 16px; }
.filex-tab .fx-controls .at-form-group { margin-bottom: 0; }
.filex-tab .fx-controls #fx-app { min-width: 240px; }
.filex-tab .fx-controls #fx-tenant { width: 160px; }
.filex-tab .fx-drop { padding: 0 16px 16px; font-size: 12px; }
.filex-tab .fx-drop:empty { display: none; }
.filex-tab .fx-check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 8px 0 16px; color: var(--text-2); }
.filex-tab .fx-check input { accent-color: var(--primary); }
.admin-tab textarea.at-input { resize: vertical; line-height: 1.5; min-height: 68px; }

/* ═══════════════════════════════════════════════════════════════
   Log Monitor + Sessions — shared "monitor" chrome
   ═══════════════════════════════════════════════════════════════ */
.logs-tab, .sessions-tab { padding: 28px !important; overflow: hidden !important; }
/* Fill the tab, pin the toolbar, and let only the panel (list/table) scroll. */
.mon-container { max-width: 1200px; margin: 0 auto; width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; }

.mon-toolbar {
  flex-shrink: 0;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.mon-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); display: flex; align-items: center; gap: 8px; margin-right: 4px; }
.mon-title::before { content: ""; width: 3px; height: 13px; border-radius: 3px; background: var(--grad); }
.mon-count { font-size: 11px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mon-spacer { flex: 1; }
.mon-select, .mon-search {
  height: 34px; box-sizing: border-box;
  background: var(--bg-inset); border: 1px solid var(--border); color: var(--text);
  padding: 0 11px; border-radius: 9px; font-size: 12.5px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.mon-search { min-width: 180px; }
.mon-search::placeholder { color: var(--text-3); }
/* Custom chevron + no native appearance so selects match the flat inputs beside
   them (native selects render an OS chevron/box that clashes with the theme). */
.mon-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 30px;
  background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 11px;
}
:root[data-theme="dark"] .mon-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239aa6cc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
:root[data-theme="light"] .mon-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234c577a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
.mon-search:hover { border-color: var(--primary); }
.mon-search:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* Each labelled select is a single "filter token": an inset uppercase label chip
   joined to a borderless select. The token owns the border, hover and focus ring
   so label + value read as one unit instead of a loose caption beside a control. */
.mon-field {
  display: inline-flex; align-items: stretch; height: 34px; box-sizing: border-box;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 9px;
  overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s;
}
.mon-field:hover { border-color: var(--primary); }
.mon-field:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.mon-field label {
  display: inline-flex; align-items: center; padding: 0 10px; white-space: nowrap;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); background: var(--surface-2); border-right: 1px solid var(--border);
}
.mon-field .mon-select {
  height: 100%; border: none; border-radius: 0; background-color: transparent; padding-left: 11px;
}
.mon-field .mon-select:hover, .mon-field .mon-select:focus { border: none; box-shadow: none; }

/* Enhanced select: hide the native control, show the themed trigger in its place
   so the whole dropdown (including the open list) follows the theme. */
.mon-field.mon-enhanced .mon-select { display: none; }
.mon-trigger {
  display: inline-flex; align-items: center; height: 100%; cursor: pointer;
  border: none; background-color: transparent; color: var(--text);
  font-family: inherit; font-size: 12.5px; white-space: nowrap;
  padding: 0 30px 0 11px;
  background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 11px;
}
.mon-trigger:focus { outline: none; }
:root[data-theme="dark"] .mon-trigger { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239aa6cc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
:root[data-theme="light"] .mon-trigger { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%234c577a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }

/* Portaled option list — themed, replaces the OS-default dropdown. */
.mon-menu {
  position: fixed; z-index: 10001; max-height: 300px; overflow-y: auto;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 5px; font-size: 12.5px; color: var(--text);
  animation: mon-menu-in 0.12s ease;
}
@keyframes mon-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.mon-opt {
  padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  transition: background 0.1s;
}
.mon-opt.active { background: var(--hover); }
.mon-opt.selected { color: var(--primary-strong); font-weight: 600; }
.mon-opt.selected.active { background: var(--grad-soft); }
@media (prefers-reduced-motion: reduce) { .mon-menu { animation: none; } }

/* Keep toolbar buttons the same height as the controls they sit beside. */
.mon-toolbar .at-btn { height: 34px; box-sizing: border-box; display: inline-flex; align-items: center; }

.mon-panel {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.mon-group + .mon-group { border-top: 1px solid var(--border-soft); }
.mon-group-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--bg-inset); cursor: pointer; user-select: none;
  font-size: 12px; font-weight: 700; color: var(--text); border-bottom: 1px solid var(--border-soft);
}
.mon-group-head:hover { background: var(--hover); }
.mon-group-caret { width: 12px; height: 12px; color: var(--text-3); transition: transform 0.15s; }
.mon-group.collapsed .mon-group-caret { transform: rotate(-90deg); }
.mon-group.collapsed .mon-group-body { display: none; }
.mon-group-count { font-size: 11px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mon-group-name { font-family: var(--font-mono); }
.mon-empty { padding: 40px; text-align: center; color: var(--text-3); font-style: italic; }

/* Log rows */
.log-row { display: flex; gap: 12px; align-items: baseline; padding: 9px 16px; font-size: 12px; border-bottom: 1px solid var(--border-soft); }
.log-row:last-child { border-bottom: none; }
.log-row:hover { background: var(--hover); }
.log-level { font-weight: 700; text-transform: uppercase; font-size: 9.5px; padding: 2px 7px; border-radius: 4px; flex-shrink: 0; letter-spacing: 0.04em; }
.log-level.error, .log-level.critical { background: var(--danger); color: #fff; }
.log-level.warning { background: var(--warn); color: #2a1a02; }
.log-level.info { background: var(--grad-soft); color: var(--primary-strong); }
.log-level.debug { background: var(--surface-2); color: var(--text-3); }
.log-time { color: var(--text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 11px; }
.log-logger { color: var(--text-2); flex-shrink: 0; font-family: var(--font-mono); font-size: 11px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-msg { color: var(--text); flex: 1; word-break: break-word; }

/* Sessions table reuses .st-table look inside a mon-panel */
.mon-panel .st-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mon-panel .st-table thead { background: var(--bg-inset); }
.mon-panel .st-table th { padding: 10px 14px; text-align: left; font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.mon-panel .st-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); }
.mon-panel .st-table tbody tr:last-child td { border-bottom: none; }
.mon-panel .st-table tbody tr:hover { background: var(--hover); }
.mon-panel .st-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Utility: alert boxes ─────────────────────────────────────── */
.alert-info { background: var(--grad-soft); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); color: var(--primary-strong); padding: 12px 16px; border-radius: 10px; font-size: 13px; }
.alert-success { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok); padding: 12px 16px; border-radius: 10px; font-size: 13px; }
.alert-error { background: var(--danger-bg); border: 1px solid var(--danger-bd); color: var(--danger); padding: 12px 16px; border-radius: 10px; font-size: 13px; }

/* ── Logs tab: sub-view switch (API Calls | Log Monitor) ──────── */
.lg-switch { flex-shrink: 0; display: inline-flex; gap: 4px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 10px; padding: 3px; align-self: flex-start; }
.lg-seg-btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 16px; border: none; background: transparent; color: var(--text-3); font-size: 12px; font-weight: 600; font-family: inherit; border-radius: 7px; cursor: pointer; transition: color 0.15s, background 0.15s; }
.lg-seg-btn:hover { color: var(--text-2); }
.lg-seg-btn.active { background: var(--grad-soft); color: var(--primary-strong); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent); }
.lg-subview { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.lg-subview[hidden] { display: none; }

/* API Calls: message-ID cell + copy affordance */
.ac-mono { font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ac-id-cell { display: inline-flex; align-items: center; gap: 6px; }
.ac-copy { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: none; background: transparent; color: var(--text-3); border-radius: 5px; cursor: pointer; transition: color 0.12s, background 0.12s; }
.ac-copy:hover { color: var(--primary); background: var(--hover); }
.ac-copy svg { width: 13px; height: 13px; }
.ac-row { cursor: pointer; }
.ac-dur { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.ac-loadmore { padding: 14px; text-align: center; border-top: 1px solid var(--border-soft); }

/* API Calls: detail modal */
.admin-tab .at-modal.at-modal-wide { width: 720px; }
.ac-props { display: grid; grid-template-columns: 150px 1fr; gap: 7px 16px; font-size: 12.5px; margin: 4px 0 14px; }
.ac-props dt { color: var(--text-3); font-weight: 600; }
.ac-props dd { color: var(--text); margin: 0; word-break: break-word; font-family: var(--font-mono); font-size: 11.5px; }
.ac-section-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin: 14px 0 6px; }
.ac-json { background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: var(--font-mono); font-size: 11.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; margin: 0; }
.ac-idbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ac-idbar .at-key-display { flex: 1; min-width: 240px; margin-bottom: 0; }

/* API Calls: capture status chip (toolbar) */
.ac-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-inset); color: var(--text-3); font-size: 11.5px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s, background .15s; }
.ac-chip svg { width: 9px; height: 9px; flex-shrink: 0; }
.ac-chip:hover { color: var(--text); border-color: var(--border); }
.ac-chip-off svg { color: var(--text-3); }
.ac-chip-on { color: var(--danger); border-color: var(--danger-bd); background: var(--danger-bg); }
.ac-chip-on svg { color: var(--danger); animation: pulse 2s ease-in-out infinite; }

/* API Calls: round-trip sections in the detail modal */
.ac-entry { border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; background: var(--surface-2); }
.ac-entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ac-entry-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ac-entry-dur { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.ac-collapse { border-top: 1px solid var(--border-soft); }
.ac-collapse:first-of-type { border-top: none; }
.ac-sum, .ac-erp-sum { display: flex; align-items: center; gap: 8px; padding: 7px 2px; cursor: pointer; list-style: none; user-select: none; }
.ac-sum::-webkit-details-marker, .ac-erp-sum::-webkit-details-marker { display: none; }
.ac-caret { width: 12px; height: 12px; flex-shrink: 0; color: var(--text-3); transition: transform .15s; }
details[open] > .ac-sum > .ac-caret, details[open] > .ac-erp-sum > .ac-caret { transform: rotate(90deg); }
.ac-sum-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); }
.ac-sum-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); background: var(--bg-inset); border-radius: 6px; padding: 1px 7px; }
.ac-sum-body { padding: 2px 0 8px; }

.ac-json-wrap { position: relative; }
.ac-json-copy { position: absolute; top: 6px; right: 6px; z-index: 1; background: var(--surface-solid); }
.ac-json-dim { color: var(--text-2); opacity: 0.85; }
.ac-trunc { font-size: 11.5px; color: var(--warn, var(--danger)); background: var(--bg-inset); border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; margin: 0 0 6px; }

.ac-erp { border: 1px solid var(--border-soft); border-radius: 8px; margin-bottom: 6px; overflow: hidden; }
.ac-erp-sum { padding: 7px 10px; background: var(--bg-inset); }
.ac-erp-method { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; color: var(--primary-strong); min-width: 44px; }
.ac-erp-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ac-erp-body { padding: 8px 10px; }
.ac-erp-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin: 6px 0 4px; }
.ac-erp-lbl:first-child { margin-top: 0; }

/* API Calls: capture control panel */
.ac-cap-intro { font-size: 12.5px; color: var(--text-2); line-height: 1.5; margin-bottom: 6px; }
.ac-cap-empty { padding: 14px; }
.ac-cap-table td { vertical-align: top; }
.ac-cap-app { font-family: var(--font-mono); font-size: 11px; color: var(--primary-strong); }
.ac-cap-app-all { color: var(--text-3); }
.ac-cap-rnote { font-size: 11px; color: var(--text-3); margin-top: 2px; font-style: italic; }
.ac-cap-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 12px; background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 10px; }
.ac-cap-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-3); font-weight: 600; }
.ac-cap-field > span { text-transform: uppercase; letter-spacing: 0.04em; font-size: 9.5px; }
.ac-cap-field .mon-select, .ac-cap-field .mon-search { min-width: 130px; }
.ac-cap-field.ac-cap-note { flex: 1; min-width: 180px; }
.ac-cap-field.ac-cap-note .mon-search { width: 100%; }
.ac-cap-msg { font-size: 12px; min-height: 16px; }
.ac-cap-msg-ok { color: var(--success, var(--primary-strong)); }
.ac-cap-msg-err { color: var(--danger); }

/* Fix: enhanceSelect adds .mon-enhanced to the select's parent (our .ac-cap-field
   label, which is not a .mon-field), so the canonical hide rule at line ~660 never
   matches. Mirror it here so the native <select> is hidden behind the themed one. */
.ac-cap-field.mon-enhanced .mon-select { display: none; }

/* Capture: tool picker (populated from the selected site) */
.ac-cap-tools { margin-top: 10px; padding: 12px; background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 10px; }
.ac-cap-tools-empty { font-size: 12px; color: var(--text-3); }
.ac-cap-tools-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.ac-cap-tools-hint { font-size: 11px; color: var(--text-3); }
.ac-cap-tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; max-height: 190px; overflow: auto; }
.ac-cap-tool { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); cursor: pointer; font-family: var(--font-mono); }
.ac-cap-tool.ac-cap-tool-all { font-family: inherit; font-weight: 600; }
.ac-cap-tool input { accent-color: var(--primary); cursor: pointer; }
.ac-cap-tool input:disabled { cursor: default; }
.ac-cap-tool input:disabled + span { color: var(--text-3); }
.ac-cap-tools-cell { font-size: 11.5px; }

.ac-cap-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 12px; }
.ac-cap-actions .ac-cap-msg { flex: 1; margin: 0; }

/* ── Motion ───────────────────────────────────────────────────── */
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* One orchestrated page-load moment: admin sections stagger in.
   NOTE: deliberately NOT applied to Status/Logs/Sessions — those re-render on
   a poll every few seconds, and re-triggering the entrance would flash. */
.admin-tab.active .at-section,
.admin-tab.active .at-notice { animation: fadeUp 0.4s ease both; }
.admin-tab.active .at-container > *:nth-child(1) { animation-delay: 0.02s; }
.admin-tab.active .at-container > *:nth-child(2) { animation-delay: 0.07s; }
.admin-tab.active .at-container > *:nth-child(3) { animation-delay: 0.12s; }
.admin-tab.active .at-container > *:nth-child(4) { animation-delay: 0.17s; }
.admin-tab.active .at-container > *:nth-child(n+5) { animation-delay: 0.22s; }

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

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .console-tab .ct-container { flex-direction: column; }
  .console-tab .ct-sidebar { width: 100%; max-height: 42vh; border-right: none; border-bottom: 1px solid var(--border); }
  .console-tab .ct-panels { flex-direction: column; }
  .console-tab .ct-panel + .ct-panel { border-left: none; border-top: 1px solid var(--border-soft); }
  .console-tab .ct-panel textarea { min-height: 180px; }
  .status-tab .st-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  /* Header becomes multi-row: brand + actions on row 1, the tab bar drops to
     its own full-width row and WRAPS so no tab is ever clipped. */
  .app-header { padding: 8px 14px; gap: 8px 12px; height: auto; min-height: 56px; flex-wrap: wrap; align-items: center; }
  .brand-tag { display: none; }
  .brand-name { font-size: 16px; }
  .hdr-title { font-size: 14px; padding-left: 10px; }
  .tab-bar { order: 5; flex-basis: 100%; width: 100%; height: auto; flex-wrap: wrap; align-items: center; gap: 2px; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
  .tab-btn.active::after { left: 8px; right: 8px; }
  .tab-content { padding: 18px; }
  .console-tab.active { padding: 0; }
  .status-tab, .admin-tab, .logs-tab, .sessions-tab { padding: 18px !important; }
  .mon-toolbar .mon-spacer { display: none; }
  .mon-search { min-width: 0; flex: 1; }
  .mon-panel { overflow-x: auto; }
  .mon-panel .st-table { min-width: 520px; }
  .status-tab .st-metrics { grid-template-columns: repeat(2, 1fr); }
  .status-tab .st-sites-grid { grid-template-columns: 1fr; }
  .status-tab .st-error-logger { display: none; }
  .admin-tab .at-section-body { overflow-x: auto; }
  .admin-tab .at-table { min-width: 560px; }
  .pf-menu { width: 260px; }
}

@media (max-width: 600px) {
  /* Reclaim row-1 space (the active tab conveys context on phones). */
  .hdr-title { display: none; }
  /* Log Monitor: let each entry wrap so the message gets its own full-width
     line instead of being squeezed into a sliver. */
  .logs-tab .log-row { flex-wrap: wrap; align-items: center; gap: 3px 8px; padding: 10px 14px; }
  .logs-tab .log-logger { max-width: 60vw; }
  .logs-tab .log-msg { flex-basis: 100%; }
  /* Toolbar filters go full-width and stack cleanly. */
  .mon-toolbar .mon-field { flex: 1 1 46%; }
  .mon-toolbar .mon-field .mon-select { flex: 1; }
  .mon-search { flex-basis: 100%; }
}
