/* ==========================================================================
   StreamCreator — Theo-WebBot cosmic restyle
   Deep-navy surfaces, violet/blue accents, gradient primary buttons, glow
   focus rings, sidebar dashboard layout. Inter body + JetBrains Mono mono.
   ========================================================================== */

:root {
  /* Surfaces (Theo-WebBot bg-0..bg-3 / line tokens) */
  --bg-0: #07070d;
  --bg-1: #0d0e18;
  --bg-2: #161827;
  --bg-3: #1f2236;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --fg: #ececf2;
  --fg-muted: #9094a8;
  --fg-dim: #6e7287;

  /* Brand accents */
  --accent: #7c5cff;
  --accent-2: #4ea1ff;
  --accent-glow: rgba(124, 92, 255, 0.45);

  /* Status */
  --danger: #ff6b7a;
  --warn: #ffb648;
  --ok: #5ddc97;

  /* Legacy aliases used throughout existing components */
  --bg: var(--bg-0);
  --bg2: var(--bg-2);
  --muted: var(--fg-muted);
  --border: var(--line-strong);

  /* Typography + shape */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.85),
            0 6px 20px -10px rgba(0, 0, 0, 0.6);
  --sidebar-w: 230px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(78, 161, 255, 0.12), transparent 60%),
    var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: #82bdff; }
hr { border: 0; border-top: 1px solid var(--line); }
code {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--fg);
}

/* The `hidden` HTML attribute is `display: none` by UA default, but several
   of our component rules set explicit display values — restore the intent. */
[hidden] { display: none !important; }

/* -- Dashboard shell ------------------------------------------------------ */
body.dash-page {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: rgba(8, 9, 17, 0.85);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  backdrop-filter: blur(10px);
  z-index: 10;
}
.brand-link {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}
.brand-mark { font-size: 22px; line-height: 1; }
.brand-name { font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { color: var(--accent-2); font-weight: 500; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--fg); opacity: 0.82;
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .12s, opacity .12s, border-color .12s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); opacity: 1; color: var(--fg); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.18), rgba(78, 161, 255, 0.08));
  opacity: 1;
  border-color: rgba(124, 92, 255, 0.35);
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; flex: 0 0 22px; }
/* Highlighted nav pages: warm tint + left accent bar so they stand out. */
.nav-item.highlight {
  background: linear-gradient(90deg, rgba(255, 182, 72, 0.16), rgba(255, 182, 72, 0.03));
  border-color: rgba(255, 182, 72, 0.4);
  opacity: 1;
}
.nav-item.highlight:hover { background: linear-gradient(90deg, rgba(255, 182, 72, 0.24), rgba(255, 182, 72, 0.06)); }
.nav-item.highlight.active { border-color: rgba(255, 182, 72, 0.7); }
.nav-item .nav-star { margin-left: auto; font-size: 12px; flex: 0 0 auto; }

/* Admin: emoji quick-pick palette + highlight affordances on page cards. */
.icon-palette { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 0 10px; }
.icon-palette button {
  font-size: 18px; line-height: 1; padding: 4px 6px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; cursor: pointer;
}
.icon-palette button:hover { border-color: var(--accent); }
.checkbox-row { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; margin: 0; }
.entity-highlight { border-color: rgba(255, 182, 72, 0.45); box-shadow: 0 0 0 1px rgba(255, 182, 72, 0.15); }
.badge-star { background: rgba(255, 182, 72, 0.16); border-color: rgba(255,182,72,0.4); }

.sidebar-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 6px 4px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  font-size: 12px;
  color: var(--fg-muted);
}
.sidebar-foot form { margin: 0; }
.sidebar-foot form button {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  padding: 6px 10px;
  font-size: 12px;
}
.sidebar-foot form button:hover { background: rgba(255, 255, 255, 0.04); }

/* Hamburger for the phone top-bar nav — hidden on desktop / the icon rail. */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  font-size: 16px; line-height: 1;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.04); }

.dash-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.dash-main::-webkit-scrollbar { width: 10px; }
.dash-main::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.dash-main > main {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

/* -- Buttons + inputs ----------------------------------------------------- */
button, .btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #8767ff 0%, #6a4af0 100%);
  color: #fff;
  box-shadow: 0 6px 24px -10px var(--accent-glow);
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px -10px var(--accent-glow);
}
button:active, .btn:active { transform: translateY(0); }
button:disabled, .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

button.primary { background: linear-gradient(180deg, #8767ff 0%, #6a4af0 100%); color: #fff; }

button.secondary,
.btn.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line-strong);
  box-shadow: none;
  font-weight: 500;
}
button.secondary:hover,
.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.04);
  transform: none;
}

button.danger,
.btn.danger {
  background: transparent;
  color: #ffb7be;
  border: 1px solid rgba(255, 107, 122, 0.4);
  box-shadow: none;
}
button.danger:hover,
.btn.danger:hover {
  background: rgba(255, 107, 122, 0.10);
  color: #ffd0d5;
  transform: none;
}

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-1);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}
input[type="checkbox"], input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="file"] {
  padding: 6px 8px;
  font-size: 0.85rem;
  color: var(--fg-muted);
}
input[type="file"]::file-selector-button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  color: var(--fg);
  border-radius: 8px;
  padding: 5px 10px;
  margin-right: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
}
input[type="file"]::file-selector-button:hover { background: rgba(255, 255, 255, 0.07); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  padding: 0;
  border: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -7px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #8767ff, #6a4af0);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #8767ff, #6a4af0);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
}

label {
  display: block;
  margin: 0.6rem 0 0.4rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-weight: 500;
}
label input, label select, label textarea { margin-top: 0.3rem; }

progress {
  width: 100%;
  height: 4px;
  border: none;
  border-radius: 999px;
  background: var(--bg-1);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--bg-1); }
progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* -- Cards ---------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, rgba(22, 24, 39, 0.7), rgba(13, 14, 24, 0.7));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.card h1, .card h2 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.2px;
  font-weight: 600;
}

/* -- Stream page layout --------------------------------------------------- */
.stream-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1rem;
}
.preview-pane video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
}
.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  align-items: center;
}
.controls select { flex: 1; min-width: 180px; }
.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--fg);
  font-size: 0.9rem;
}

/* -- Badges --------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.idle,
.badge.pending,
.badge.cancelled,
.badge.finished {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg-muted);
  border-color: var(--line);
}
.badge.live,
.badge.running {
  background: rgba(93, 220, 151, 0.10);
  color: var(--ok);
  border-color: rgba(93, 220, 151, 0.4);
}
.badge.live::before,
.badge.running::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: badge-pulse 1.6s ease-in-out infinite;
}
.badge.failed {
  background: rgba(255, 107, 122, 0.10);
  color: var(--danger);
  border-color: rgba(255, 107, 122, 0.4);
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* -- Chat pane ------------------------------------------------------------ */
.chat-pane {
  display: flex;
  flex-direction: column;
  /* match the main viewport so the chat doesn't push the page over */
  height: calc(100dvh - 96px);
  max-height: 720px;
  padding-bottom: 1rem;
}
.chat-pane header { margin-bottom: 0.6rem; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem;
  background: rgba(10, 11, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: var(--font-mono);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.chat-log::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; }
.chat-log .msg { padding: 0.18rem 0.25rem; border-radius: 4px; }
.chat-log .msg .user { color: var(--accent-2); font-weight: 600; margin-right: 0.4rem; }
.chat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.chat-form input { flex: 1; }

/* -- Tables --------------------------------------------------------------- */
.videos {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(10, 11, 20, 0.45);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.videos th, .videos td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.videos th {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}
.videos tbody tr:last-child td { border-bottom: 0; }
.videos tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* -- Twitch category search ---------------------------------------------- */
.results {
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-top: 0.35rem;
}
.results .opt {
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.results .opt:hover {
  background: rgba(124, 92, 255, 0.18);
  color: var(--fg);
}

/* -- Status text ---------------------------------------------------------- */
.help { color: var(--fg-muted); font-size: 0.85rem; }
.status { color: var(--fg-muted); margin-left: 0.5rem; font-size: 0.85rem; }
.status.ok { color: var(--ok); }
.status.busy { color: var(--accent); }
.status.error { color: var(--danger); }
.save-row { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }

/* -- Voice-change toggle row ---------------------------------------------- */
.vc-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  color: var(--fg);
  font-size: 0.88rem;
  cursor: pointer;
}
.vc-toggle input { margin: 0; }
.vc-toggle .status { margin-left: auto; }

/* -- Stream error banner -------------------------------------------------- */
.stream-error {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0.6rem 0;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 107, 122, 0.08);
  border: 1px solid rgba(255, 107, 122, 0.4);
  border-radius: 10px;
  color: #ffb7be;
  font-size: 0.9rem;
}
.stream-error span { flex: 1; word-break: break-word; }
.stream-error button { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* -- Credentials report --------------------------------------------------- */
.creds-report {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 0.85rem;
}
.creds-report .creds-line { padding: 0.18rem 0; word-break: break-word; }
.creds-report .creds-line.ok { color: var(--ok); }
.creds-report .creds-line.error { color: var(--danger); }
.creds-report.busy { color: var(--accent); }

/* -- Mix controls --------------------------------------------------------- */
.mix-controls {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}
.mix-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0;
  color: var(--fg);
  font-size: 0.85rem;
}
.mix-row .mix-label { min-width: 110px; color: var(--fg-muted); }
.mix-row input[type="range"] { flex: 1; }
.mix-row .mix-readout {
  min-width: 44px;
  text-align: right;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.mix-controls button { margin-top: 0.35rem; }

/* -- Push-to-talk --------------------------------------------------------- */
.ptt-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.ptt-row select { flex: 1; min-width: 0; }
.ptt-btn {
  width: 100%;
  padding: 1.1rem;
  font-size: 1.05rem;
  font-weight: 600;
  user-select: none;
  touch-action: none;
}
.ptt-btn.active {
  background: linear-gradient(180deg, #ff7a8a, #d04654);
  color: #fff;
  border-color: rgba(255, 107, 122, 0.55);
  box-shadow: 0 8px 24px -10px rgba(255, 107, 122, 0.6);
}
.ptt-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* -- Login page ----------------------------------------------------------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card .brand {
  color: var(--fg);
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.login-card .brand-sub { color: var(--accent-2); font-weight: 500; }
.login-card label { text-align: left; }
.login-card button { width: 100%; margin-top: 0.75rem; }
.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
  text-align: left;
}

/* -- Page-specific tweaks ------------------------------------------------- */
.library-page,
.schedule-page,
.settings-page { display: flex; flex-direction: column; gap: 1rem; }
.settings-page .card h2 + p.help { margin-top: -0.35rem; margin-bottom: 0.6rem; }
.settings-page button { margin-top: 0.6rem; margin-right: 0.4rem; }

/* -- Responsive ----------------------------------------------------------- */
@media (max-width: 1000px) {
  .stream-grid { grid-template-columns: 1fr; }
  .chat-pane { height: 60vh; max-height: none; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .brand-name { display: none; }
  .sidebar-foot { flex-direction: column; gap: 6px; }
  .sidebar-foot form button,
  .sidebar-foot #btn-open-pw { padding: 5px 8px; }
  .dash-main > main { padding: 18px 14px 60px; }
}

/* -- Phone layout (≤600px) -----------------------------------------------
   Sidebar collapses into a sticky top bar; content stacks single-column.
   Placed AFTER the 860px block so it wins the cascade on phones (both
   queries match at this width). Desktop is entirely unaffected. */
@media (max-width: 600px) {
  /* Stack the shell: bar on top, scrolling content below. */
  body.dash-page { flex-direction: column; }

  .sidebar {
    position: relative;        /* anchor for the dropdown overlay */
    width: auto;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  /* Full brand wordmark in the bar (the 860px rule hides it). */
  .brand-link {
    border-bottom: none;
    margin-bottom: 0;
    padding: 0;
  }
  .brand-name { display: inline; }

  /* The page links live behind the hamburger now (there can be many granted
     pages). Hidden until the bar gets `.nav-open`, then they drop down as a
     full-width overlay below the bar — without disturbing the top row. */
  .nav-toggle { display: inline-flex; }
  .side-nav { display: none; }
  .sidebar.nav-open .side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: 100%; left: 0; right: 0;
    padding: 10px 12px;
    background: rgba(8, 9, 17, 0.98);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.45);
    max-height: 72vh;
    overflow-y: auto;
    z-index: 30;
  }
  /* Labels were hidden by the 860px icon-rail rule — show them in the dropdown. */
  .sidebar.nav-open .nav-item span:not(.nav-icon) { display: inline; }
  .sidebar.nav-open .nav-item { padding: 11px 12px; }

  /* Account actions hug the right edge; the "Signed in" label is noise here. */
  .sidebar-foot {
    flex-direction: row;
    gap: 8px;
    margin: 0 0 0 auto;
    padding: 0;
    border-top: none;
  }
  .sidebar-foot > span { display: none; }

  .dash-main > main { padding: 14px 12px 56px; }

  /* Single full-width column for tiles + system stats. */
  .tile-grid { grid-template-columns: 1fr; gap: 12px; }
  .tile { min-height: 0; }
  .sys-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Comfortable tap targets on the tile action row. */
  .tile-actions button { min-height: 40px; padding: 8px 10px; }

  /* Near-fullscreen logs/password dialogs on a phone. */
  dialog.modal,
  dialog.modal.modal-wide {
    width: 96vw;
    max-width: 96vw;
    min-width: 0;
    max-height: 92dvh;
  }
  .logs-body { max-height: 78dvh; }
}

/* The 🔑 button in the sidebar footer matches the logout button styling. */
.sidebar-foot #btn-open-pw {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: none;
}
.sidebar-foot #btn-open-pw:hover { background: rgba(255, 255, 255, 0.04); transform: none; }

/* Change-password modal (also reusable for future dialogs). */
dialog.modal {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--fg);
  padding: 0;
  min-width: 360px;
  max-width: min(90vw, 480px);
  box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
dialog.modal form { padding: 22px 22px 18px; display: grid; gap: 12px; margin: 0; }
dialog.modal h3 { margin: 0 0 4px; font-size: 18px; }
dialog.modal label { margin: 0; }
dialog.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
dialog.modal .error { color: var(--danger); font-size: 0.85rem; margin: 0; }
dialog.modal textarea {
  width: 100%; min-height: 45vh; resize: vertical;
  font: inherit; line-height: 1.5; padding: 10px;
  box-sizing: border-box;
}

/* ==========================================================================
   OverviewApp dashboard-specific tiles + system stats + logs modal.
   ========================================================================== */

/* -- App tiles ------------------------------------------------------------ */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tile {
  background: linear-gradient(180deg, rgba(28, 30, 50, 0.7), rgba(13, 14, 24, 0.7));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 168px;
  transition: border-color .15s ease, transform .08s ease, box-shadow .15s ease;
}
.tile:hover {
  border-color: rgba(124, 92, 255, 0.4);
  box-shadow: 0 10px 30px -16px var(--accent-glow);
  transform: translateY(-1px);
}
.tile.absent { opacity: 0.6; }
.tile-head { display: flex; align-items: center; gap: 10px; }
.tile-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(124, 92, 255, 0.12);
  border: 1px solid rgba(124, 92, 255, 0.25);
  font-size: 20px;
  line-height: 1;
}
.tile-label-wrap { flex: 1; min-width: 0; }
.tile-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.tile-label:hover { color: var(--accent-2); }
.tile-sub {
  display: block;
  font-size: 11px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile-meta {
  font-size: 11px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}
.tile-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}
.tile-actions button {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
}

/* Badge variants used by the tiles. The base .badge from style.css already
   covers .running, .failed, .pending — extend it with the docker-specific
   states. */
.badge.exited,
.badge.absent,
.badge.dead { background: rgba(255, 107, 122, 0.10); color: var(--danger); border-color: rgba(255, 107, 122, 0.4); }
.badge.exited::before,
.badge.absent::before,
.badge.dead::before { content: none; }
.badge.restarting,
.badge.starting { background: rgba(255, 182, 72, 0.12); color: var(--warn); border-color: rgba(255, 182, 72, 0.4); }
.badge.created,
.badge.paused  { background: rgba(255, 255, 255, 0.04); color: var(--fg-muted); border-color: var(--line); }
.badge.healthy { background: rgba(93, 220, 151, 0.10); color: var(--ok); border-color: rgba(93, 220, 151, 0.4); }
.badge.healthy::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.badge.unhealthy { background: rgba(255, 107, 122, 0.10); color: var(--danger); border-color: rgba(255, 107, 122, 0.4); }

/* -- System stats card --------------------------------------------------- */
.sys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.sys-stat {
  background: rgba(10, 11, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.sys-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 600;
}
.sys-value {
  font-size: 1.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  margin: 4px 0 8px;
  color: var(--fg);
}
.sys-stat progress { height: 6px; }
.sys-sub {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}

/* -- Wide logs modal ----------------------------------------------------- */
dialog.modal.modal-wide {
  width: min(95vw, 1100px);
  max-width: 95vw;
  min-width: 0;
  padding: 0;
}
.logs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.logs-head h3 { margin: 0; font-size: 16px; font-family: var(--font-mono); }
.logs-head-actions { display: flex; gap: 8px; }
.logs-head-actions button { padding: 5px 12px; font-size: 12px; }
.logs-body {
  margin: 0;
  padding: 14px 18px 18px;
  max-height: 70vh;
  overflow: auto;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg-0);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.logs-body::-webkit-scrollbar { width: 10px; height: 10px; }
.logs-body::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.logs-body.empty { color: var(--fg-dim); font-style: italic; }

/* ==========================================================================
   CustomerAccess additions — entity cards (users/pages), permission lists,
   portal page body, multi-item phone nav.
   ========================================================================== */

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warn);
  border: 1px solid rgba(255, 182, 72, 0.4);
  border-radius: 6px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }

/* -- Entity cards (users + pages lists) ----------------------------------- */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.entity-card {
  background: linear-gradient(180deg, rgba(28, 30, 50, 0.7), rgba(13, 14, 24, 0.7));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.entity-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  background: none;
}
.entity-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entity-icon { font-size: 18px; line-height: 1; }
.entity-email { margin: -4px 0 0; overflow: hidden; text-overflow: ellipsis; }
.entity-actions { display: flex; gap: 8px; margin-top: auto; }
.entity-disabled { opacity: 0.55; }

a.entity-link { color: var(--fg); transition: border-color .12s, transform .08s; }
a.entity-link:hover {
  color: var(--fg);
  border-color: rgba(124, 92, 255, 0.45);
  transform: translateY(-1px);
}

.badge-off {
  background: rgba(255, 107, 122, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 122, 0.35);
}

/* -- Chips (granted-page tags) --------------------------------------------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg);
  background: rgba(124, 92, 255, 0.14);
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.chip-muted {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
  color: var(--fg-dim);
}

/* -- Forms: checkbox rows + permission fieldset ---------------------------- */
.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--fg);
  cursor: pointer;
}
.check-row input[type="checkbox"] { margin: 0; }
.check-row .help { margin-left: auto; font-family: var(--font-mono); font-size: 11px; }

.perm-set {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px 12px;
  margin: 0;
}
.perm-set legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 6px;
}
.perm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.danger-ghost { color: var(--danger) !important; border-color: rgba(255, 107, 122, 0.4) !important; }
.danger-ghost:hover { background: rgba(255, 107, 122, 0.08) !important; }

.mono-slug { font-family: var(--font-mono); font-size: 12px; margin: -4px 0 0; }
.empty-note { margin-top: 18px; }

/* -- Portal page body ------------------------------------------------------ */
.page-body { margin-top: 14px; }
.page-body-text {
  white-space: pre-wrap;       /* operator-entered placeholder text keeps its line breaks */
  overflow-wrap: anywhere;
  line-height: 1.6;
  font-size: 15px;
}

/* -- Phone (≤600px): keep the multi-item nav usable ------------------------
   The base sheet hides .side-nav in the top bar (OverviewApp has one nav
   item). Here the nav IS the product — wrap it to a horizontal scroll row
   under the brand/account bar instead. */
@media (max-width: 600px) {
  .sidebar { flex-wrap: wrap; }
  .side-nav {
    display: flex;
    flex-direction: row;
    order: 3;
    width: 100%;
    overflow-x: auto;
    gap: 6px;
    padding: 8px 0 2px;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-item { white-space: nowrap; padding: 7px 11px; flex: 0 0 auto; }
  /* Undo the 860px icon-rail rule — labels matter on the phone bar. */
  .nav-item span:not(.nav-icon) { display: inline; }

  .entity-grid { grid-template-columns: 1fr; gap: 12px; }
  .entity-actions button { min-height: 40px; flex: 1; }
  .page-head h1 { font-size: 20px; }
}

/* ==========================================================================
   Bot dashboard page (portal) + admin grant dropdowns.
   ========================================================================== */

.badge-kind {
  background: rgba(78, 161, 255, 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(78, 161, 255, 0.35);
}

.bot-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }

/* -- Status box ------------------------------------------------------------ */
.status-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.status-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.status-label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.status-icon { font-size: 16px; }
.status-pill { min-width: 110px; text-align: center; justify-content: center; }
.status-pill.pill-ok {
  background: rgba(93, 220, 151, 0.12);
  color: var(--ok);
  border: 1px solid rgba(93, 220, 151, 0.4);
}
.status-pill.pill-bad {
  background: rgba(255, 107, 122, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 122, 0.35);
}
.status-note { margin: 12px 0 0; }

/* -- Responses box ----------------------------------------------------------- */
.resp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 0; padding: 0; background: none; margin-bottom: 8px;
}
.resp-head h2 { margin: 0; }
.tab-row {
  display: flex; gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.tab-row .tab {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--fg-muted);
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 999px;
}
.tab-row .tab:hover { transform: none; color: var(--fg); }
.tab-row .tab.active {
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.35), rgba(78, 161, 255, 0.25));
  color: #fff;
}

.resp-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.resp-item {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(124, 92, 255, 0.07);
  border: 1px solid rgba(124, 92, 255, 0.18);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-width: 720px;
}
.resp-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-dim); }
.resp-text { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }

/* -- Responses + Transcription row ----------------------------------------- */
.bot-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .bot-row { grid-template-columns: 1fr; } }

/* -- Live Transcription box ------------------------------------------------ */
.tx-item.triggered {
  border-color: rgba(93, 220, 151, 0.5);
  background: rgba(93, 220, 151, 0.08);
}
.tx-speaker { font-weight: 600; color: var(--fg); }
.tx-badge {
  display: inline-block; margin-left: 6px; font-size: 10px;
  color: var(--ok);
  border: 1px solid rgba(93, 220, 151, 0.4);
  border-radius: 999px;
  padding: 0 6px;
  vertical-align: middle;
}

/* -- Personality box ---------------------------------------------------------- */
.bot-personality-card textarea {
  width: 100%;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  min-height: 160px;
}
.save-note { color: var(--ok); margin: 8px 0 0; }

/* -- Admin: per-grant bot dropdown ------------------------------------------- */
.perm-row { display: flex; flex-direction: column; gap: 6px; }
.bot-pick-wrap { padding-left: 24px; }
.bot-pick { width: 100%; font-size: 13px; padding: 7px 10px; }
.bot-pick-missing { font-size: 12px; }

@media (max-width: 600px) {
  .resp-list { max-height: 50dvh; }
  .status-pill { min-width: 96px; }
}

/* -- Memories page ----------------------------------------------------------- */
.mem-add-form { display: flex; gap: 10px; margin: 12px 0 14px; }
.mem-add-form input { flex: 1; min-width: 0; }
.mem-list { display: flex; flex-direction: column; gap: 8px; }
.mem-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.mem-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.mem-text .mem-edit-input { width: 100%; }
.mem-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.mem-actions button { padding: 6px 12px; font-size: 13px; }

@media (max-width: 600px) {
  .mem-item { flex-direction: column; align-items: stretch; gap: 8px; }
  .mem-actions button { flex: 1; min-height: 38px; }
}

/* ==========================================================================
   Home dashboard — bot head, Core Systems, Voice Profiles (+ admin editor).
   ========================================================================== */

/* -- Bot head card ---------------------------------------------------------- */
.bot-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bot-head-icon { font-size: 34px; line-height: 1; }
.bot-head-name h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.bot-head-name .help { display: block; margin-top: 1px; }
.bot-head-pills { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

/* -- Mode chip (shared portal + admin colors) -------------------------------- */
.mode-chip {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  border-radius: 999px; padding: 4px 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05); color: var(--fg);
}
.mode-chip.mode-training       { background: rgba(255, 182, 72, 0.14);  border-color: rgba(255, 182, 72, 0.5);  color: #ffb648; }
.mode-chip.mode-limited_action { background: rgba(255, 199, 107, 0.10); border-color: rgba(255, 107, 122, 0.5); color: #ff8a6b; }
.mode-chip.mode-worker         { background: rgba(78, 161, 255, 0.14);  border-color: rgba(78, 161, 255, 0.5);  color: #4ea1ff; }
.mode-chip.mode-full_access    { background: rgba(93, 220, 151, 0.14);  border-color: rgba(93, 220, 151, 0.5);  color: #5ddc97; }

/* -- Indicators (shared) ------------------------------------------------------ */
.sys-ind {
  width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px;
  background: var(--bg-3); border: 1px solid var(--line-strong);
}
.sys-ind.ind-on {
  background: var(--ok); border-color: rgba(93, 220, 151, 0.8);
  box-shadow: 0 0 8px rgba(93, 220, 151, 0.7);
  animation: ind-breathe 2.4s ease-in-out infinite;
}
.sys-ind.ind-off { background: rgba(255, 107, 122, 0.35); border-color: rgba(255, 107, 122, 0.4); }
@keyframes ind-breathe {
  0%, 100% { box-shadow: 0 0 5px rgba(93, 220, 151, 0.5); }
  50%      { box-shadow: 0 0 11px rgba(93, 220, 151, 0.95); }
}

/* -- Core Systems grid -------------------------------------------------------- */
.core-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.core-item {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.core-item.on { border-color: rgba(93, 220, 151, 0.3); }
.core-item.off { opacity: 0.75; }
.core-name { font-size: 13.5px; font-weight: 500; flex: 1; min-width: 0; }
.core-state {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em;
  color: var(--fg-dim);
}
.core-item.on .core-state { color: var(--ok); }

/* -- Voice Profiles ------------------------------------------------------------ */
.vp-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.vp-entry {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color .3s, opacity .3s;
  opacity: 0.7;
}
.vp-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, #8767ff, #4ea1ff);
}
.vp-name { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }

/* Equalizer bars — frozen in standby, dancing when Voice Profile is active. */
.vp-wave { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 18px; }
.vp-wave i { width: 3px; height: 4px; border-radius: 2px; background: var(--fg-dim); }
.vp-active .vp-entry { opacity: 1; border-color: rgba(124, 92, 255, 0.35); }
.vp-active .vp-entry .vp-wave i {
  background: linear-gradient(180deg, #8767ff, #4ea1ff);
  animation: vp-eq 1.1s ease-in-out infinite;
}
.vp-active .vp-entry .vp-wave i:nth-child(1) { animation-delay: 0s; }
.vp-active .vp-entry .vp-wave i:nth-child(2) { animation-delay: 0.18s; }
.vp-active .vp-entry .vp-wave i:nth-child(3) { animation-delay: 0.32s; }
.vp-active .vp-entry .vp-wave i:nth-child(4) { animation-delay: 0.5s; }
@keyframes vp-eq {
  0%, 100% { height: 4px; }
  50%      { height: 16px; }
}
.vp-active .vp-avatar { box-shadow: 0 0 14px rgba(124, 92, 255, 0.55); }

/* -- Admin: dashboards editor --------------------------------------------------- */
.dash-bot-pick { max-width: 360px; display: block; margin: 14px 0 16px; }
.dash-section { margin-bottom: 14px; }
.dash-section h2 { margin-top: 0; }
.mode-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.mode-opt {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.mode-opt input { margin: 0; }
.mode-opt.mode-training.selected       { background: rgba(255, 182, 72, 0.14);  border-color: rgba(255, 182, 72, 0.6);  color: #ffb648; box-shadow: 0 0 12px rgba(255, 182, 72, 0.25); }
.mode-opt.mode-limited_action.selected { background: rgba(255, 138, 107, 0.12); border-color: rgba(255, 107, 122, 0.6); color: #ff8a6b; box-shadow: 0 0 12px rgba(255, 107, 122, 0.25); }
.mode-opt.mode-worker.selected         { background: rgba(78, 161, 255, 0.14);  border-color: rgba(78, 161, 255, 0.6);  color: #4ea1ff; box-shadow: 0 0 12px rgba(78, 161, 255, 0.25); }
.mode-opt.mode-full_access.selected    { background: rgba(93, 220, 151, 0.14);  border-color: rgba(93, 220, 151, 0.6);  color: #5ddc97; box-shadow: 0 0 12px rgba(93, 220, 151, 0.25); }

.sys-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px; margin-top: 8px;
}
.sys-toggle {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; cursor: pointer; font-size: 13.5px; font-weight: 500;
}
.sys-toggle.on { border-color: rgba(93, 220, 151, 0.3); }
.sys-toggle input { margin: 0; }
.sys-toggle .sys-name { flex: 1; }

@media (max-width: 600px) {
  .core-grid { grid-template-columns: 1fr 1fr; }
  .core-state { display: none; }
  .bot-head-pills { margin-left: 0; width: 100%; }
  .sys-toggles { grid-template-columns: 1fr; }
}

/* Custom-system remove button (admin Dashboards editor). */
.sys-toggle .sys-del {
  background: transparent; border: 0; box-shadow: none;
  color: var(--fg-dim); font-size: 15px; line-height: 1;
  padding: 2px 6px; border-radius: 6px;
}
.sys-toggle .sys-del:hover { color: var(--danger); background: rgba(255, 107, 122, 0.1); transform: none; }

/* Admin user modal: current-password recovery row. */
.pw-current {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.pw-current code { flex: 1; min-width: 0; overflow-wrap: anywhere; background: none; border: 0; padding: 0; }
.pw-current button { padding: 4px 10px; font-size: 12px; box-shadow: none; }

/* -- Connector page ------------------------------------------------------------ */
.cn-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.cn-status { font-size: 13px; }
.cn-status.ok { color: var(--ok); }
.cn-status.err { color: var(--danger); }
.cn-settings { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
@media (max-width: 600px) {
  .cn-actions button { flex: 1; min-height: 42px; }
  .cn-status { width: 100%; }
}

/* -- Usage dashboard ------------------------------------------------------------ */
.usage-windows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.usage-card {
  background: linear-gradient(180deg, rgba(28, 30, 50, 0.7), rgba(13, 14, 24, 0.7));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
}
.usage-card h3 {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--fg-muted);
}
.usage-stat { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.usage-num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--ok); }
.usage-cap { font-size: 12px; color: var(--fg-muted); }
.usage-rows { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--fg-muted); }
.usage-rows strong { color: var(--fg); font-weight: 600; }

.usage-table-wrap { overflow-x: auto; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.usage-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-dim);
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--line-strong);
}
.usage-table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 600px) {
  .usage-windows { grid-template-columns: 1fr 1fr; gap: 10px; }
  .usage-num { font-size: 21px; }
}

/* -- Audit logs page ------------------------------------------------------------- */
.log-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.log-filters select { max-width: 220px; }
.log-table td { vertical-align: top; }
.mono-cell { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.log-detail { color: var(--fg-muted); font-size: 12.5px; overflow-wrap: anywhere; }
.log-table tr.log-bad td { color: var(--danger); }
@media (max-width: 600px) {
  .log-table .log-detail { min-width: 140px; }
}

/* Custom modes — operator-picked color via --mode-c (admin pills + portal chip). */
.mode-chip.mode-custom {
  color: var(--mode-c);
  border-color: color-mix(in srgb, var(--mode-c) 55%, transparent);
  background: color-mix(in srgb, var(--mode-c) 14%, transparent);
}
.mode-opt.mode-custom.selected {
  color: var(--mode-c);
  border-color: color-mix(in srgb, var(--mode-c) 60%, transparent);
  background: color-mix(in srgb, var(--mode-c) 14%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--mode-c) 28%, transparent);
}
.mode-opt .sys-del { margin-left: 2px; }
.mode-color-pick {
  width: 46px; height: 38px; padding: 3px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--bg-2); cursor: pointer;
}

/* -- Portal notification banners (outlined cards, inset via <main> padding) - */
.portal-banners { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.portal-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
  font-size: 14px; line-height: 1.5; color: var(--fg);
}
.portal-banner .nt-body { flex: 1; min-width: 0; word-wrap: break-word; white-space: pre-wrap; }
.portal-banner .nt-body :first-child { margin-top: 0; }
.portal-banner .nt-body :last-child { margin-bottom: 0; }
.banner-dismiss {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 2px; opacity: 0.65; flex: 0 0 auto;
}
.banner-dismiss:hover { opacity: 1; }
/* Colored banner boxes (portal banners + admin previews share the .banner-*
   classes). Each color is a soft gradient that drifts slowly, with the box
   border, a faint colored glow, and a readable color-matched text tint. The
   compound selectors beat the base .portal-banner/.notif-item color+border. */
@keyframes nt-drift {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
.portal-banner[class*="banner-"], .notif-item[class*="banner-"] {
  background-repeat: no-repeat;
  background-size: 220% 220%;
  animation: nt-drift 9s ease-in-out infinite alternate;
}
@media (prefers-reduced-motion: reduce) {
  .portal-banner[class*="banner-"], .notif-item[class*="banner-"] { animation: none; }
}
.portal-banner.banner-yellow, .notif-item.banner-yellow {
  border-color: var(--warn); color: #ffd9a3;
  background-image: linear-gradient(115deg, rgba(255,182,72,0.26), rgba(255,182,72,0.05) 48%, rgba(255,182,72,0.22));
  box-shadow: 0 2px 16px rgba(255, 182, 72, 0.10);
}
.portal-banner.banner-red, .notif-item.banner-red {
  border-color: var(--danger); color: #ff9ba6;
  background-image: linear-gradient(115deg, rgba(255,107,122,0.26), rgba(255,107,122,0.05) 48%, rgba(255,107,122,0.22));
  box-shadow: 0 2px 16px rgba(255, 107, 122, 0.10);
}
.portal-banner.banner-blue, .notif-item.banner-blue {
  border-color: var(--accent-2); color: #a9d3ff;
  background-image: linear-gradient(115deg, rgba(78,161,255,0.26), rgba(78,161,255,0.05) 48%, rgba(78,161,255,0.22));
  box-shadow: 0 2px 16px rgba(78, 161, 255, 0.10);
}
.portal-banner.banner-green, .notif-item.banner-green {
  border-color: var(--ok); color: #9fe9c2;
  background-image: linear-gradient(115deg, rgba(93,220,151,0.26), rgba(93,220,151,0.05) 48%, rgba(93,220,151,0.22));
  box-shadow: 0 2px 16px rgba(93, 220, 151, 0.10);
}

/* Inline text-color palette (notification editor + rendered cards) */
.nt-default { color: inherit; }
.nt-red   { color: var(--danger); }
.nt-green { color: var(--ok); }
.nt-blue  { color: var(--accent-2); }
.nt-amber { color: var(--warn); }

/* -- Connector maintenance note + disabled connect ------------------------- */
.cn-maint-note { display: block; margin-top: 8px; font-size: 13px; color: var(--warn); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* -- Admin maintenance card ------------------------------------------------ */
.maint-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.maint-msg { flex: 1; min-width: 220px; }

/* -- Admin notification rich-text editor ----------------------------------- */
.notif-add-form { display: flex; flex-direction: column; gap: 8px; }
.notif-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rt-btn, .rt-color {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-2); color: var(--fg); cursor: pointer; font-size: 14px;
}
.rt-btn:hover, .rt-color:hover { border-color: var(--accent); }
.rt-sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.rt-color { font-weight: 700; }
.notif-editor {
  min-height: 96px; max-height: 320px; overflow-y: auto;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--fg); font-size: 14px; line-height: 1.5;
  white-space: pre-wrap;   /* keep multiple spaces + blank lines while typing */
}
.notif-editor:focus { outline: none; border-color: var(--accent); }
.notif-editor:empty::before { content: attr(data-placeholder); color: var(--fg-dim); }
.notif-add-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.notif-color-pick { display: flex; align-items: center; gap: 8px; }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
}
.notif-item-body { flex: 1; min-width: 0; word-wrap: break-word; white-space: pre-wrap; }
.notif-del, .notif-edit {
  background: none; border: none; color: var(--fg-muted); cursor: pointer;
  font-size: 16px; line-height: 1; flex: 0 0 auto;
}
.notif-del:hover { color: var(--danger); }
.notif-edit:hover { color: var(--accent-2); }

/* -- Guides: shared rich-body rendering (portal + admin editor) ------------- */
/* Font-size + color classes applied by the editor as <span class="gz-* gc-*">.
   Defined once so the editor preview and the portal render look identical. */
.gz-sm { font-size: 0.82em; }
.gz-md { font-size: 1em; }
.gz-lg { font-size: 1.3em; }
.gz-xl { font-size: 1.7em; }
.gc-default { color: var(--fg); }
.gc-pink  { color: #ff5fa2; }
.gc-blue  { color: var(--accent-2); }
.gc-green { color: var(--ok); }
.gc-yellow{ color: var(--warn); }
.gc-red   { color: var(--danger); }

.rich-body { line-height: 1.6; color: var(--fg); word-wrap: break-word; }
.rich-body :first-child { margin-top: 0; }
.rich-body :last-child { margin-bottom: 0; }
.rich-body h2 { font-size: 1.4rem; margin: 1.1rem 0 0.5rem; }
.rich-body h3 { font-size: 1.15rem; margin: 1rem 0 0.4rem; }
.rich-body h4 { font-size: 1rem; margin: 0.9rem 0 0.3rem; color: var(--fg-muted); }
.rich-body p { margin: 0.5rem 0; }
.rich-body ul, .rich-body ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.rich-body li { margin: 0.25rem 0; }
.rich-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 0.5rem 0; display: block; }
.rich-body pre {
  background: var(--bg-1); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.86rem; margin: 0.6rem 0;
}
.rich-body code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--bg-3); padding: 1px 5px; border-radius: 5px;
}
.rich-body pre code { background: none; padding: 0; }
.rich-body blockquote {
  margin: 0.6rem 0; padding: 4px 14px; border-left: 3px solid var(--accent);
  color: var(--fg-muted);
}
/* Animated link hover so end users can tell it's clickable. */
.rich-body a {
  color: var(--accent-2); position: relative; text-decoration: none;
  background-image: linear-gradient(var(--accent-2), var(--accent-2));
  background-size: 0% 2px; background-repeat: no-repeat;
  background-position: left 100%;
  transition: background-size 0.28s ease, color 0.2s ease;
}
.rich-body a:hover { color: var(--accent); background-size: 100% 2px; }

/* -- Portal: guide (FAQ) accordion ----------------------------------------- */
.guide-list { display: flex; flex-direction: column; gap: 10px; }
.guide-item {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-2); overflow: hidden;
}
.guide-q {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: none; border: none; cursor: pointer;
  color: var(--fg); font-size: 1.02rem; font-weight: 600; text-align: left;
}
.guide-q:hover { background: rgba(255, 255, 255, 0.03); }
.guide-q-text { flex: 1; min-width: 0; }
.guide-chev { color: var(--fg-muted); transition: transform 0.25s ease; }
.guide-item.open .guide-chev { transform: rotate(180deg); }
.guide-a {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
}
.guide-item.open .guide-a { grid-template-rows: 1fr; }
.guide-a-inner { overflow: hidden; padding: 0 16px; }
.guide-item.open .guide-a-inner { padding: 0 16px 16px; }

/* -- Admin: guides editor -------------------------------------------------- */
.guide-head-actions { display: flex; align-items: center; gap: 10px; }
.guide-select {
  min-width: 220px; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--fg);
}
.guide-topics { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.guide-topic-edit { padding: 14px; }
.guide-topic-top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.guide-heading {
  flex: 1; min-width: 0; height: 38px; padding: 0 12px; font-size: 1rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--fg);
}
.guide-topic-ctl { display: flex; gap: 6px; flex: 0 0 auto; }
.guide-topic-ctl button { min-width: 34px; height: 34px; padding: 0; }
.guide-toolbar { margin-bottom: 8px; }
.rt-size {
  height: 30px; padding: 0 6px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-2); color: var(--fg); cursor: pointer;
}
.rt-colors { display: inline-flex; gap: 4px; align-items: center; }
.rt-color { width: 22px; min-width: 22px; height: 22px; padding: 0; border-radius: 50%; }
.guide-body-edit {
  min-height: 120px; max-height: 480px; overflow-y: auto;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.guide-body-edit:focus { outline: none; border-color: var(--accent); }
