:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2e38;
  --text: #e8e8ec;
  --muted: #9aa1ad;
  --accent: #4f8cff;
  --error: #ff6b6b;
  --success: #4fd18b;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
}

.brand { font-weight: 600; }

/* --- Persistent left sidebar (added 2026-08-10, Oliver's Grok-console
   screenshots as the layout reference) — present on every authenticated
   page. .app-shell/.app-main are the two-column flex wrapper from
   base.html; agent-specific pages nest their own .agent-header/.tab-row
   (below) inside .app-main, sidebar-only pages (agents_list.html,
   dashboard.html) just put .content directly inside it. --- */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.sidebar-brand {
  font-weight: 600;
  font-size: 14px;
  padding: 0 10px 18px;
  color: var(--text);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 8px;
  margin-bottom: 2px;
}
.sidebar-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.sidebar-link.active { color: var(--text); background: rgba(79, 140, 255, 0.14); font-weight: 600; }
.sidebar-icon { font-size: 13px; width: 16px; text-align: center; }
.sidebar-spacer { flex: 1; }
.sidebar-link-muted { font-size: 13px; }

.app-main {
  flex: 1;
  min-width: 0;
}

/* --- New nav layout (2026-08-10, matches the reference screenshot: back
   row, tenant title + Live badge, tab row below) --- */
.agent-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px 0;
}

.back-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
}
.back-link {
  color: var(--muted);
  font-size: 14px;
}
.back-link.disabled { cursor: not-allowed; opacity: 0.6; }

.header-utility-links a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 18px;
  font-size: 13px;
}
.header-utility-links a:hover { color: var(--accent); }

.agent-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
}
.agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, #6ee7b7, #0e6b4f 70%);
}
.agent-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.agent-subtitle {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--success);
  background: rgba(79, 209, 139, 0.12);
  border-radius: 10px;
  padding: 2px 9px 2px 7px;
}
.live-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.tab-row {
  display: flex;
  gap: 4px;
}
.tab-row .tab {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
}
.tab-row .tab.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}
.tab-row .tab:not(.active):not(.disabled):hover { color: var(--text); }
.tab-row .tab.disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Live-testen overlay widget --- */
.live-test-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  border-radius: 24px;
  padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.live-test-overlay {
  position: fixed;
  right: 24px;
  bottom: 88px;
  width: 380px;
  height: 520px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 40;
}
.live-test-overlay.hidden { display: none; }

.lto-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lto-t1 { font-size: 15px; font-weight: 600; color: #fff; }
.lto-t2 { font-size: 12px; color: var(--muted); }
.lto-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
  margin-right: 6px;
}
.lto-dot.live { background: var(--success); }
.lto-header-actions { display: flex; gap: 4px; }
.lto-icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}
.lto-icon-btn:hover { color: var(--text); }

.lto-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lto-row { display: flex; gap: 8px; align-items: flex-start; }
.lto-row.user { flex-direction: row-reverse; }
.lto-avatar {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-top: 2px;
  background: radial-gradient(circle at 35% 30%, #6ee7b7, #0e6b4f 70%);
}
.lto-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.lto-row.agent .lto-bubble { background: #17171a; color: #eee; border-top-left-radius: 3px; }
.lto-row.user .lto-bubble { background: #234b8f; color: #fff; border-top-right-radius: 3px; }
.lto-bubble.interim { opacity: 0.55; font-style: italic; }
.lto-empty { color: #666; font-size: 12.5px; text-align: center; margin-top: 30px; }

.lto-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.lto-input-row input {
  flex: 1;
  margin: 0;
  background: #151517;
  border: 1px solid #2c2c30;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13.5px;
}
.lto-talk-btn {
  border-radius: 20px;
  padding: 8px 16px;
  white-space: nowrap;
  background: #2a2a2e;
  color: #ccc;
}
.lto-talk-btn.active { background: #d64545; color: #fff; }

.content {
  max-width: 780px;
  margin: 32px auto;
  padding: 0 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

input[type=text], input[type=password], select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  background: #0d0f13;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

textarea { resize: vertical; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.checkbox-row input { width: auto; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 12px;
}
legend { color: var(--muted); font-size: 13px; padding: 0 6px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
button:hover { opacity: 0.9; }

.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--error); font-size: 14px; }
.success { color: var(--success); font-size: 14px; }

.upload-row { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }

.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table th, .doc-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

/* --- Voice Agents list page (added 2026-08-10) --- */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.page-header-row h1 { margin-bottom: 0; }

.agent-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.agent-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
}
.agent-card:hover { border-color: var(--accent); }
.agent-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, #6ee7b7, #0e6b4f 70%);
}
.agent-card-body { flex: 1; min-width: 0; }
.agent-card-name { font-size: 15px; font-weight: 600; }
.agent-card-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.hidden { display: none; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 320px;
}
.login-box h1 { font-size: 18px; margin-top: 0; }
