/* ==========================================================================
   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; }

.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); }

.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 {
    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; }

  /* Only one nav item, and we're always on it — drop it from the bar. */
  .side-nav { display: none; }

  /* 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; }

/* ==========================================================================
   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; }

/* -- 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; }
}
