/* ========================================
   BRI — Beacon RunBook Intelligence
   Theme System (light default, dark toggle)
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary-blue: #3B86F2;
  --primary-blue-button: #3182ce;
  --primary-green: #77D860;
  --secondary-blue: #455FE6;
  --secondary-green: #56B348;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --transition: 0.2s ease;
  --chat-width: 760px;
  --glow-blue: rgba(59, 134, 242, 0.25);

  /* Light theme (default) */
  --bg-dark: #f8f9fb;
  --bg-deeper: #ffffff;
  --bg-card: #ffffff;
  --slate: #c4ccd8;
  --text-primary: #1a1e26;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --border-color: rgba(0,0,0,0.08);
  --border-color-solid: #e2e5ea;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-dark: #1A1E26;
  --bg-deeper: #12151a;
  --bg-card: #2a2e38;
  --slate: #414D66;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0ad;
  --text-muted: #6b7280;
  --border-color: rgba(255,255,255,0.06);
  --border-color-solid: #2a2f3a;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-blue);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: #5a9ef5;
  text-decoration: none;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}

/* Firefox thin scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}
[data-theme="dark"] * {
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ========================================
   SIDEBAR (replaces navbar)
   ======================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 255px;
  height: 100vh;
  background: var(--bg-deeper);
  border-right: 1px solid var(--border-color-solid);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.sidebar-top {
  padding: 20px 16px 12px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 16px;
}
.sidebar-brand img {
  width: 200px;
  height: auto;
  opacity: 0.9;
}
.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background: #e8913a;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-new-chat:hover {
  background: #d97b1e;
  box-shadow: 0 2px 12px rgba(232, 145, 58, 0.3);
  color: #fff;
  text-decoration: none;
}
.btn-new-chat svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.sidebar-search {
  padding: 4px 12px 0;
  flex-shrink: 0;
}
.sidebar-search__wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-search__icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar-search__input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-dark);
  border: 1px solid var(--border-color-solid);
  border-radius: 8px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.sidebar-search__input:focus {
  border-color: var(--primary-blue);
}
.sidebar-search__input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-bottom {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--border-color);
  text-decoration: none;
}
.sidebar-link svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---- Main content ---- */
.main-content {
  min-height: 100vh;
}
.main-content.has-sidebar {
  margin-left: 255px;
  width: calc(100% - 255px);
  min-height: 100vh;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn--primary {
  background: var(--primary-blue-button);
  color: #fff;
}
.btn--primary:hover {
  background: #2b76e2;
  box-shadow: 0 2px 12px rgba(59, 134, 242, 0.3);
}

.btn--outline {
  background: transparent;
  border: 1px solid rgba(59, 134, 242, 0.3);
  color: var(--primary-blue);
}
.btn--outline:hover {
  background: rgba(59, 134, 242, 0.08);
  border-color: rgba(59, 134, 242, 0.5);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 10px;
}
.btn--ghost:hover {
  color: var(--text-primary);
  background: var(--border-color);
}

/* Icon buttons */
.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 18px;
  font-family: inherit;
}
.btn--icon:hover {
  color: var(--text-primary);
  background: var(--border-color);
}
.btn--icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =====================
   ROLE SELECT PAGE
   ===================== */
.role-select-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 60px 32px 80px;
}

.role-select-header {
  text-align: center;
  margin-bottom: 56px;
}

.role-select-header .bri-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.role-select-header .bri-logo img {
  height: 32px;
  opacity: 0.9;
}
.role-select-header .bri-logo-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.role-select-header h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.role-select-header .subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 400;
}

.tier-section {
  margin-bottom: 40px;
}
.tier-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  padding-left: 4px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.role-grid form {
  display: flex;
}

.role-card {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  font-size: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.role-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(59,134,242,0.06), transparent 60%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.role-card:hover {
  border-color: rgba(59,134,242,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1), 0 0 0 1px rgba(59,134,242,0.15);
}
.role-card:hover::before {
  opacity: 1;
}

.role-card--dimmed {
  opacity: 0.45;
}
.role-card--dimmed:hover {
  opacity: 0.7;
}

.role-card-indicator {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-green);
  box-shadow: 0 0 8px rgba(119, 216, 96, 0.4);
}

.role-card-icon {
  font-size: 28px;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.role-card-name {
  font-size: 16px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.role-card-desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
  position: relative;
  z-index: 1;
}

/* Tier badges */
.tier-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
}
.tier-badge--tier-1 {
  background: rgba(59, 134, 242, 0.12);
  color: var(--primary-blue);
}
.tier-badge--tier-2 {
  background: rgba(69, 95, 230, 0.12);
  color: #7b8ef8;
}
.tier-badge--tier-3 {
  background: rgba(119, 216, 96, 0.12);
  color: var(--primary-green);
}
.tier-badge--cross-tier {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
}
[data-theme="dark"] .tier-badge--cross-tier {
  background: rgba(255, 255, 255, 0.06);
}

/* =====================
   CHAT PAGE
   ===================== */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Chat topbar removed — role now in sidebar */

/* ---- History items in sidebar ---- */
.history-section-label {
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0;
  margin: 1px 8px;
  border-radius: 6px;
  transition: background var(--transition);
}
.history-item:hover {
  background: var(--border-color);
}

.history-item__link {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.history-item__link:hover {
  text-decoration: none;
}

.history-item__title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Three-dot menu button */
.history-item__menu-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  margin-right: 4px;
}
.history-item:hover .history-item__menu-btn {
  opacity: 1;
}
.history-item__menu-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
}
[data-theme="dark"] .history-item__menu-btn:hover {
  background: rgba(255,255,255,0.08);
}

/* Dropdown menu */
.history-item__menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 4px;
  z-index: 100;
  background: var(--bg-deeper);
  border: 1px solid var(--border-color-solid);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px;
  min-width: 140px;
}
.history-item__menu.is-open {
  display: block;
}

.history-menu__action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-primary);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.history-menu__action:hover {
  background: rgba(0,0,0,0.04);
}
[data-theme="dark"] .history-menu__action:hover {
  background: rgba(255,255,255,0.06);
}
.history-menu__action svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.history-menu__action--delete {
  color: #dc2626;
}
.history-menu__action--delete svg {
  color: #dc2626;
}
.history-menu__action--delete:hover {
  background: rgba(220, 38, 38, 0.06);
}

.history-empty {
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Star button — hidden until hover on desktop */
.history-item__star-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.history-item:hover .history-item__star-btn,
.history-item__star-btn--active {
  opacity: 1;
}

/* Drag state */
.history-item.is-dragging {
  opacity: 0.4;
}
.history-list--starred .history-item {
  cursor: grab;
}
.history-list--starred .history-item:active {
  cursor: grabbing;
}

/* Feedback button on assistant messages */
.message-actions {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
}
.feedback-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.feedback-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}
.feedback-btn--submitted {
  color: #ef4444;
  opacity: 1 !important;
}
.feedback-btn--submitted svg {
  fill: #ef4444;
  stroke: #ef4444;
}

/* Feedback popover */
.feedback-popover {
  display: none;
  position: fixed;
  z-index: 500;
  width: 260px;
  background: var(--bg-deeper);
  border: 1px solid var(--border-color-solid);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.feedback-popover.is-visible {
  display: block;
}
.feedback-popover__body {
  padding: 12px;
}
.feedback-popover__body textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
}
.feedback-popover__body textarea:focus {
  outline: none;
  border-color: rgba(239, 68, 68, 0.4);
}
.feedback-popover__body textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}
.feedback-popover__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.feedback-popover__actions .btn--primary {
  background: #ef4444;
}
.feedback-popover__actions .btn--primary:hover {
  background: #dc2626;
}

/* ---- Messages container ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 16px;
  display: flex;
  flex-direction: column;
}

.chat-messages-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---- Welcome state (centered layout) ---- */

/* When in welcome mode, the whole page is a centered column */
.chat-page--welcome {
  justify-content: center;
}

/* Messages area shrinks to fit welcome content, no scroll */
.chat-page--welcome .chat-messages {
  flex: 0 0 auto;
  overflow: visible;
  padding-bottom: 0;
}

/* Input area loses its bottom-pinned padding and centers with the rest */
.chat-page--welcome .chat-input-area {
  padding-bottom: 80px;
}

/* Welcome greeting */
.welcome-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px 16px;
}

.welcome-icon {
  display: none;
}
.welcome-ai-logo {
  display: none;
}

.welcome-state h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0;
  letter-spacing: -0.2px;
}
.welcome-state p {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 400px;
  margin-bottom: 0;
}

/* ---- Message bubbles ---- */
.message {
  font-size: 14.5px;
  line-height: 1.65;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: messageIn 0.25s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Both user and assistant: left-aligned with avatar */
.message--user,
.message--assistant {
  align-self: flex-start;
  display: flex;
  gap: 14px;
  max-width: 100%;
  padding: 0;
}

.message-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.message-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* User message content — light bubble */
.message--user .message-content {
  background: rgba(59,134,242,0.08);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
[data-theme="dark"] .message--user .message-content {
  background: rgba(59,134,242,0.12);
}

.message-content {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
}

/* Markdown in assistant messages */
.message--assistant .message-content h1,
.message--assistant .message-content h2,
.message--assistant .message-content h3 {
  margin: 16px 0 8px;
  font-weight: 600;
  color: var(--text-primary);
}
.message--assistant .message-content h1 { font-size: 18px; }
.message--assistant .message-content h2 { font-size: 16px; }
.message--assistant .message-content h3 { font-size: 15px; }

.message--assistant .message-content p {
  margin: 4px 0;
}

.message--assistant .message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  color: var(--text-primary);
}
[data-theme="dark"] .message--assistant .message-content code {
  background: rgba(255, 255, 255, 0.06);
  color: #d4d4d8;
}

.message--assistant .message-content pre {
  background: var(--bg-deeper);
  border: 1px solid var(--border-color-solid);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
}
.message--assistant .message-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}

.message--assistant .message-content ul,
.message--assistant .message-content ol {
  padding-left: 24px;
  margin: 8px 0;
}
.message--assistant .message-content li {
  margin: 4px 0;
  margin-left: 24px;
  list-style-position: outside;
}
.message--assistant .message-content ul li,
.message--assistant .message-content ol li {
  margin-left: 0;
}

.message--assistant .message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
}
.message--assistant .message-content th,
.message--assistant .message-content td {
  border: 1px solid var(--border-color-solid);
  padding: 8px 12px;
  text-align: left;
}
.message--assistant .message-content th {
  background: rgba(59,134,242,0.08);
  font-weight: 600;
  color: var(--text-primary);
}
.message--assistant .message-content td {
  background: rgba(0,0,0,0.01);
}
[data-theme="dark"] .message--assistant .message-content td {
  background: rgba(255,255,255,0.02);
}
.message--assistant .message-content tr:hover td {
  background: rgba(0,0,0,0.03);
}
[data-theme="dark"] .message--assistant .message-content tr:hover td {
  background: rgba(255,255,255,0.04);
}

.message--assistant .message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message--assistant .message-content em {
  font-style: italic;
  color: var(--text-secondary);
}

/* Runbook content badge */
.runbook-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary-green);
  margin-bottom: 6px;
  display: block;
}

/* ---- Input area ---- */
.chat-input-area {
  flex-shrink: 0;
  padding: 0 40px 24px;
  background: var(--bg-dark);
}

.chat-input-center {
}

/* Input container — wraps textarea AND pills */
.chat-input-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 2px solid #e8913a;
  border-radius: 12px;
  padding: 15px 20px 10px;
  box-shadow: 0px 4px 18px 0px rgba(183,183,183,0.25);
  background: var(--bg-deeper);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-container:focus-within {
  border-color: #d97b1e;
  box-shadow: 0 0 0 1px #d97b1e, 0px 4px 18px 0px rgba(183,183,183,0.25);
}
[data-theme="dark"] .chat-input-container {
  border-color: #e8913a;
  box-shadow: 0px 4px 18px 0px rgba(0,0,0,0.35);
}
[data-theme="dark"] .chat-input-container:focus-within {
  border-color: #d97b1e;
  box-shadow: 0 0 0 1px #d97b1e, 0px 4px 18px 0px rgba(0,0,0,0.35);
}

/* Bottom row inside input container: pills on left, send button on right */
.chat-input-bottom {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: 8px;
}

/* Pills area — grows to fill, pushes send button to the right */
.pills-area {
  flex: 1;
  min-width: 0;
}

/* Textarea + send button on the same line */
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* Chat input (textarea) */
.chat-input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  line-height: 1.5;
  max-height: 120px;
}
.chat-input::placeholder {
  color: var(--text-muted);
}

/* Send button */
.btn--send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #e8913a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
}
.btn--send:hover {
  background: #d97b1e;
  box-shadow: 0 2px 10px rgba(232,145,58,0.35);
}
.btn--send svg {
  width: 18px;
  height: 18px;
  fill: none;
}

/* Loading indicator */
.loading-indicator {
  display: flex;
  gap: 5px;
  padding: 16px 0;
  max-width: var(--chat-width);
  margin: 0 auto;
  padding-left: 42px; /* align with assistant message content */
}
.loading-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-blue);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.loading-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.loading-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ---- Pills ---- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 8px;
  font-size: 12px;
  flex-wrap: wrap;
}
.breadcrumb-link {
  color: var(--text-muted);
  transition: color var(--transition);
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.breadcrumb-link:hover {
  color: var(--primary-blue);
  background: rgba(59,134,242,0.08);
  text-decoration: none;
}
.breadcrumb-sep {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 10px;
}
.breadcrumb-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.content-snippet {
  background: rgba(119,216,96,0.05);
  border-left: 2px solid var(--primary-green);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
}

.pill {
  padding: 6px 14px;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  color: var(--text-secondary);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
}
.pill:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background: rgba(59,134,242,0.04);
}

.pill-chevron {
  font-size: 16px;
  font-weight: 600;
  margin-left: 2px;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.pill--branch:hover .pill-chevron {
  opacity: 1;
}

.pill--back {
  background: var(--bg-card);
  border-color: var(--border-color-solid);
  color: var(--text-secondary);
}
.pill--back:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background: rgba(59,134,242,0.04);
}

.pill--more {
  background: var(--bg-card);
  border-color: var(--border-color-solid);
  color: var(--text-muted);
  font-weight: 400;
}
.pill--more:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background: rgba(59,134,242,0.04);
}

/* ---- Question-driven decision tree ---- */
.question-card {
  background: var(--bg-card);
  border-left: 3px solid var(--primary-blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 0 0 10px;
}
.question-card__text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}

.known-issue-alert {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 0 0 10px;
  font-size: 12px;
  color: #f59e0b;
  line-height: 1.5;
}
.known-issue-alert strong {
  font-weight: 600;
}

.pill--answer {
  background: rgba(59, 134, 242, 0.08);
  border-color: rgba(59, 134, 242, 0.3);
  color: var(--primary-blue);
  font-weight: 600;
}
.pill--answer:hover {
  background: rgba(59, 134, 242, 0.15);
  border-color: rgba(59, 134, 242, 0.5);
  color: #2b76e2;
}

.action-result {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.6;
}
.action-result--resolve {
  border-left: 3px solid var(--primary-green);
  background: rgba(119, 216, 96, 0.06);
}
.action-result--escalate {
  border-left: 3px solid #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}

/* Hidden pills (shown when "More" is clicked) */
.pills-overflow {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
}
.pills-overflow.is-visible {
  display: flex;
}

/* ---- Guidance Levels ---- */

/* HIGH guidance: pills above textarea, bigger */
.guidance-high .chat-input-bottom {
  order: -1;
  padding-top: 0;
  padding-bottom: 8px;
}
.guidance-high .chat-input-row {
  order: 1;
}
.guidance-high .pill {
  padding: 8px 18px;
  font-size: 14px;
}

/* MEDIUM/LOW guidance: pills toggle */
.pills-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-top: 4px;
}

.pills-toggle-btn {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #e8913a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}
.pills-toggle-btn:hover {
  background: #d97b1e;
}
.pills-toggle-btn svg {
  width: 10px;
  height: 10px;
  transition: transform 0.2s ease;
}
/* Collapsed: chevron points down (default). Expanded: points up */
.pills-toggle-btn--active svg {
  transform: rotate(180deg);
}

.pills-toggle-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.pills-area--collapsed {
  display: none !important;
}

/* LOW guidance: pills are subtle */
.guidance-low .pill {
  padding: 5px 12px;
  font-size: 12px;
  opacity: 0.7;
}
.guidance-low .pill:hover {
  opacity: 1;
}

/* ---- "View All" overlay (high guidance) ---- */
.pills-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
}
.pills-overlay.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pills-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pills-overlay__panel {
  position: relative;
  z-index: 1;
  width: 560px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  animation: overlayIn 0.25s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

@keyframes overlayIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pills-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}
.pills-overlay__header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.pills-overlay__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition: all var(--transition);
}
.pills-overlay__close:hover {
  color: var(--text-primary);
  background: var(--border-color);
}

.pills-overlay__body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pills-overlay__body .pill {
  text-align: left;
  white-space: normal;
  padding: 10px 16px;
  font-size: 14px;
  border-radius: var(--radius);
}

/* ---- Mobile header (hidden on desktop) ---- */
.mobile-header {
  display: none;
}
.sidebar-backdrop {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  /* Body is a flex column when it has a sidebar (chat pages only) */
  body:has(.has-sidebar) {
    height: 100%;
    overflow: hidden;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  /* Sidebar becomes a slide-over drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  /* Backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
  }
  .sidebar-backdrop.is-visible {
    display: block;
    animation: fadeIn 0.2s ease;
  }

  /* Main content full width */
  .main-content.has-sidebar {
    margin-left: 0;
    width: 100%;
  }

  /* Mobile header — in flex flow, not fixed */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 48px;
    flex-shrink: 0;
    background: var(--bg-deeper);
    border-bottom: 1px solid var(--border-color-solid);
    z-index: 100;
  }
  .mobile-header__hamburger,
  .mobile-header__new {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
  }
  .mobile-header__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
  }

  /* Sidebar: show star and menu buttons always on mobile (no hover) */
  .history-item__star-btn,
  .history-item__menu-btn {
    opacity: 1;
  }

  /* Prevent iOS auto-zoom on input focus (requires >= 16px) */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Main content fills remaining space */
  .main-content.has-sidebar {
    flex: 1;
    margin-left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  .chat-page,
  .chat-page--welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: flex-start;
    min-height: 0;
  }

  .chat-page--welcome .chat-messages {
    flex: 1;
    overflow-y: auto;
  }
  .chat-page--welcome .chat-input-area {
    padding-bottom: 6px;
  }

  /* Messages: the ONLY scrollable area */
  .chat-messages {
    padding: 12px 8px 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }
  .chat-input-area {
    padding: 0 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
  }
  .chat-input-center {
    gap: 6px;
  }
  .chat-input-container {
    padding: 10px 10px 6px;
    border-radius: 10px;
    min-width: 0;
    max-width: 100%;
  }

  /* Avatars */
  .message-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }
  .message-avatar img {
    width: 28px;
    height: 28px;
  }
  .message {
    gap: 8px;
  }

  /* Messages */
  .message {
    font-size: 13px;
    line-height: 1.5;
  }
  .message--user .message-content,
  .message--assistant .message-content {
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .message--user .message-content {
    padding: 8px 12px;
    font-size: 13px;
  }
  .chat-messages-inner {
    gap: 12px;
  }

  /* Tables and code blocks scroll horizontally */
  .message-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .message-content table {
    min-width: 500px;
    font-size: 12px;
    white-space: nowrap;
  }
  .message-content th,
  .message-content td {
    padding: 6px 8px !important;
    white-space: nowrap;
  }
  /* Allow first column to wrap since it has longer text */
  .message-content td:first-child,
  .message-content th:first-child {
    white-space: normal;
    min-width: 150px;
  }
  .message-content pre {
    overflow-x: auto;
  }

  /* Pills — compact for mobile */
  .pill {
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 10px;
    white-space: normal;
    line-height: 1.3;
  }
  .pill-chevron {
    font-size: 12px;
  }
  .pills-row {
    gap: 4px;
  }
  .pills-area {
    padding-top: 6px;
  }

  /* Question cards / known issues compact */
  .question-card {
    padding: 10px 12px;
    margin: 0 0 6px;
  }
  .question-card__text {
    font-size: 13px;
  }
  .known-issue-alert {
    padding: 6px 10px;
    font-size: 11px;
    margin: 0 0 6px;
  }
  .breadcrumbs {
    font-size: 11px;
    padding: 0 0 4px;
  }

  /* Send button */
  .btn--send {
    width: 30px;
    height: 30px;
  }
  .btn--send svg {
    width: 14px;
    height: 14px;
  }

  /* Action results compact */
  .action-result {
    padding: 10px 12px;
    font-size: 13px;
  }
  .runbook-badge {
    font-size: 9px;
  }

  /* Welcome */
  .welcome-state h2 {
    font-size: 17px;
  }

  /* Role select */
  .role-grid {
    grid-template-columns: 1fr;
  }
  .role-select-page {
    padding: 30px 16px 40px;
  }
  .role-select-header h1 {
    font-size: 24px;
  }
}

/* =====================
   CONTENT ADMIN
   ===================== */
.admin-back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--primary-blue);
  text-decoration: none;
  margin-bottom: 16px;
  font-weight: 500;
}
.admin-back-link:hover {
  text-decoration: underline;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color-solid);
  background: var(--bg-deeper);
}
.editor-topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.editor-role-select {
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.admin-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.admin-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.admin-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* Filters */
.admin-filters {
  margin-bottom: 20px;
}
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.filter-row select {
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  color: var(--text-primary);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.filter-row select:focus {
  outline: none;
  border-color: rgba(59, 134, 242, 0.4);
}

/* Table */
.admin-table-wrap {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color-solid);
}
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.admin-table tbody tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}
[data-theme="dark"] .admin-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.row--inactive td {
  opacity: 0.45;
}
.cell-reason {
  color: var(--text-primary);
  max-width: 300px;
}
.cell-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}

/* Override diff row — sits below its parent row with no gap */
tr:has(+ .row--diff) td {
  border-bottom: none;
}
.row--diff td {
  padding: 0 12px 12px !important;
  border-bottom: 1px solid var(--border-color);
}
.override-diff {
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.diff-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-right: 6px;
}
.override-diff__old {
  color: #f87171;
  text-decoration: line-through;
  opacity: 0.7;
}
.override-diff__new {
  color: var(--primary-green);
}
.override-diff__section {
  color: var(--text-muted);
  font-style: italic;
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.type-badge--change_contact { background: rgba(59, 134, 242, 0.12); color: var(--primary-blue); }
.type-badge--add_known_issue { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.type-badge--remove_known_issue { background: rgba(119, 216, 96, 0.12); color: var(--primary-green); }
.type-badge--edit_step { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.type-badge--add_note { background: rgba(59, 134, 242, 0.12); color: var(--primary-blue); }
.type-badge--change_sla { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.type-badge--change_severity { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

/* Status dots */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot--active { background: var(--primary-green); box-shadow: 0 0 6px rgba(119, 216, 96, 0.4); }
.status-dot--inactive { background: var(--text-muted); opacity: 0.4; }
.status-dot--expired { background: #ef4444; opacity: 0.6; }

.row--expired td { opacity: 0.5; }
.expired-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.btn--danger { color: #ef4444; }
.btn--danger:hover { color: #f87171; background: rgba(239, 68, 68, 0.08); }

.admin-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Feedback count badge */
.feedback-count-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Feedback cards */
.feedback-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.feedback-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}
.feedback-card__role {
  background: rgba(59, 134, 242, 0.1);
  color: var(--primary-blue);
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 11px;
}
.feedback-card__user {
  color: var(--text-secondary);
  font-weight: 500;
}
.feedback-card__date {
  color: var(--text-muted);
  margin-left: auto;
}
.feedback-card__comment {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.5;
}
.feedback-card__comment--empty {
  color: var(--text-muted);
  font-style: italic;
}
.feedback-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.feedback-card__message {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-dark);
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
}
.feedback-card__meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Feedback tabs */
.feedback-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color-solid);
  padding-bottom: 0;
}
.feedback-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.feedback-tab:hover {
  color: var(--text-primary);
  text-decoration: none;
}
.feedback-tab--active {
  color: var(--text-primary);
  border-bottom-color: var(--primary-blue);
  font-weight: 600;
}
.feedback-tab__badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  color: #fff;
}
.feedback-tab__badge--red {
  background: #ef4444;
}
.feedback-tab__badge--green {
  background: var(--primary-green);
}
.feedback-tabs__spacer {
  flex: 1;
}

.feedback-card--resolved {
  border-color: var(--primary-green);
}
.feedback-resolved-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary-green);
  background: rgba(119, 216, 96, 0.1);
  padding: 1px 8px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.feedback-card__resolution {
  background: rgba(119, 216, 96, 0.06);
  border-left: 3px solid var(--primary-green);
  padding: 8px 12px;
  margin: 8px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Override Form */
.override-form {
  max-width: 640px;
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="datetime-local"],
.form-group textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition);
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 134, 242, 0.08);
}
.form-group textarea {
  resize: vertical;
  min-height: 60px;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.4;
}

.form-help {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 20px;
  align-items: flex-end;
}
.form-row .form-group {
  flex: 1;
}

.form-group--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 0;
}
.form-group--checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-blue);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Role editor grid (on override list page) */
.role-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 40px;
}
.role-editor-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.role-editor-card:hover {
  border-color: rgba(59, 134, 242, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  text-decoration: none;
}
.role-editor-card__icon { font-size: 24px; }
.role-editor-card__name { font-size: 15px; font-weight: 600; }
.role-editor-card__tier { font-size: 12px; color: var(--text-muted); }

.admin-section { margin-top: 40px; }
.admin-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* =====================
   INLINE EDITOR PAGE
   ===================== */
.editor-page {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Content column */
.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 80px;
  position: relative;
}
.editor-content__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
.editor-content__header h2 {
  font-size: 22px;
  font-weight: 700;
}

.editor-overrides-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(59, 134, 242, 0.06);
  border: 1px solid rgba(59, 134, 242, 0.15);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
}
.editor-overrides-bar__count {
  color: var(--primary-blue);
  font-weight: 600;
}

/* Rendered runbook */
.editor-runbook {
  max-width: 760px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}
.editor-runbook h1 { font-size: 20px; font-weight: 700; margin: 28px 0 12px; }
.editor-runbook h2 { font-size: 17px; font-weight: 600; margin: 24px 0 10px; color: var(--primary-blue); }
.editor-runbook h3 { font-size: 15px; font-weight: 600; margin: 20px 0 8px; }
.editor-runbook p { margin: 6px 0; }
.editor-runbook ul, .editor-runbook ol { padding-left: 24px; margin: 8px 0; }
.editor-runbook li { margin: 4px 0; }
.editor-runbook table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.editor-runbook th, .editor-runbook td { border: 1px solid var(--border-color-solid); padding: 8px 12px; text-align: left; }
.editor-runbook th { background: rgba(59,134,242,0.08); font-weight: 600; }
.editor-runbook td { background: rgba(0,0,0,0.01); }
[data-theme="dark"] .editor-runbook td { background: rgba(255,255,255,0.02); }
.editor-runbook blockquote {
  border-left: 3px solid var(--primary-blue);
  padding: 8px 14px;
  margin: 10px 0;
  background: rgba(59, 134, 242, 0.04);
  color: var(--text-secondary);
  font-size: 13px;
}
.editor-runbook code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', monospace;
}
[data-theme="dark"] .editor-runbook code {
  background: rgba(255, 255, 255, 0.06);
}
.editor-runbook hr {
  border: none;
  border-top: 1px solid var(--border-color-solid);
  margin: 20px 0;
}

/* Text selection hint */
.editor-runbook::selection,
.editor-runbook *::selection {
  background: rgba(59, 134, 242, 0.3);
}

/* Feedback section in editor */
.editor-feedback-section {
  max-width: 760px;
  margin: 48px auto 0;
  padding-top: 32px;
  border-top: 1px solid var(--border-color-solid);
}
.editor-feedback-section h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.editor-feedback-section .admin-subtitle {
  margin-bottom: 16px;
}
.editor-feedback-section .feedback-card__question {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-dark);
  padding: 8px 12px;
  border-radius: var(--radius);
  line-height: 1.4;
}

/* Feedback section badge on headings */
.feedback-section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  margin-left: 8px;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s;
}
.feedback-section-badge:hover {
  background: #dc2626;
}

/* Feedback modal */
.feedback-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
}
.feedback-modal.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}
.feedback-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
}
.feedback-modal__panel {
  position: relative;
  z-index: 1;
  width: 640px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-deeper);
  border: 1px solid var(--border-color-solid);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.feedback-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.feedback-modal__header h3 {
  font-size: 16px;
  font-weight: 600;
}
.feedback-modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  padding: 4px 8px;
  border-radius: 6px;
}
.feedback-modal__close:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.04);
}
.feedback-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 24px;
}
.feedback-modal__body .feedback-card {
  margin-bottom: 16px;
}

/* Accordion for AI response in feedback */
.feedback-card__details {
  margin-top: 8px;
}
.feedback-card__details summary {
  font-size: 12px;
  color: var(--primary-blue);
  cursor: pointer;
  font-weight: 500;
}
.feedback-card__details summary:hover {
  text-decoration: underline;
}
.feedback-card__details .feedback-card__message {
  margin-top: 8px;
  max-height: 400px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-dark);
  padding: 14px 16px;
  border-radius: var(--radius);
}
.feedback-card__details .feedback-card__message h1,
.feedback-card__details .feedback-card__message h2,
.feedback-card__details .feedback-card__message h3 {
  margin: 12px 0 6px;
  font-weight: 600;
}
.feedback-card__details .feedback-card__message h2 { font-size: 15px; }
.feedback-card__details .feedback-card__message h3 { font-size: 14px; }
.feedback-card__details .feedback-card__message p { margin: 4px 0; }
.feedback-card__details .feedback-card__message ul,
.feedback-card__details .feedback-card__message ol {
  padding-left: 20px;
  margin: 6px 0;
}
.feedback-card__details .feedback-card__message li { margin: 3px 0; }
.feedback-card__details .feedback-card__message strong { font-weight: 600; }
.feedback-card__details .feedback-card__message code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
[data-theme="dark"] .feedback-card__details .feedback-card__message code {
  background: rgba(255,255,255,0.08);
}
.feedback-card__details .feedback-card__message table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12px;
}
.feedback-card__details .feedback-card__message th,
.feedback-card__details .feedback-card__message td {
  border: 1px solid var(--border-color-solid);
  padding: 6px 10px;
  text-align: left;
}
.feedback-card__details .feedback-card__message th {
  background: rgba(59,134,242,0.06);
  font-weight: 600;
}

/* Resolve form in feedback modal */
.feedback-resolve {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.feedback-resolve__input {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  border-radius: 6px;
  color: var(--text-primary);
  outline: none;
}
.feedback-resolve__input:focus {
  border-color: var(--primary-blue);
}
.feedback-resolve__input::placeholder {
  color: var(--text-muted);
  opacity: 0.4;
}

/* Override count badge */
.editor-override-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-blue);
  background: rgba(59, 134, 242, 0.1);
  padding: 3px 10px;
  border-radius: 10px;
}

/* Slide-out panel */
.editor-panel {
  width: 0;
  overflow: hidden;
  background: var(--bg-deeper);
  border-left: 1px solid var(--border-color-solid);
  transition: width 0.25s ease;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.editor-panel.is-open {
  width: 420px;
}

.editor-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.editor-panel__header h3 {
  font-size: 15px;
  font-weight: 600;
}
.editor-panel__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
}
.editor-panel__close:hover { color: var(--text-primary); }

.editor-panel__body {
  flex-shrink: 0;
  padding: 16px 20px;
  overflow-y: auto;
}
.editor-panel__body .form-group {
  margin-bottom: 14px;
}
.editor-panel__body .form-group label {
  font-size: 12px;
  margin-bottom: 4px;
}
.editor-panel__body select,
.editor-panel__body input,
.editor-panel__body textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
}
.editor-panel__body textarea { resize: vertical; min-height: 50px; }
.editor-panel__body select:focus,
.editor-panel__body input:focus,
.editor-panel__body textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
}
.editor-panel__body .form-actions {
  margin-top: 16px;
  padding-top: 12px;
}

/* Override items in panel */
.editor-panel__overrides {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}
.editor-panel__overrides h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.editor-panel__empty {
  font-size: 13px;
  color: var(--text-muted);
}

.editor-override-item {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.editor-override-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.editor-override-item__actions {
  display: flex;
  gap: 4px;
}
.editor-override-item__reason {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.editor-override-item__meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.btn--sm {
  padding: 4px 8px;
  font-size: 11px;
}

/* Overridden content annotations */
.has-override {
  background: rgba(119, 216, 96, 0.06) !important;
  border-left: 3px solid var(--primary-green) !important;
}
.has-override:hover {
  background: rgba(119, 216, 96, 0.12) !important;
}
.override-value {
  color: var(--primary-green);
  font-weight: 600;
}
.override-original {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.6;
  margin-top: 2px;
}
.has-override .edit-pencil {
  stroke: var(--primary-green);
}

/* Editable cells and lines */
.editable-cell,
.editable-line {
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.editable-cell:hover,
.editable-line:hover {
  background: rgba(59, 134, 242, 0.06) !important;
}

.edit-pencil {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  stroke: var(--primary-blue);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.editable-cell:hover .edit-pencil,
.editable-line:hover .edit-pencil {
  opacity: 0.7;
}

.editable-line {
  padding-right: 24px;
  border-radius: 4px;
}

/* Popover type label */
.popover__type-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-right: 4px;
}

/* Heading action buttons in popover */
.popover__heading-actions {
  padding: 8px;
}

/* Override detail in panel */
.editor-override-item__detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ---- Contextual Popover ---- */
.popover-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 499;
}
.popover-backdrop.is-visible {
  display: block;
}
.popover {
  position: fixed;
  z-index: 500;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border-color-solid);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  display: none;
  transform: none;
}
.popover.is-visible {
  display: block;
  animation: popIn 0.15s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover__label {
  padding: 12px 16px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.popover__actions {
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
}
.popover__action {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.popover__action:hover {
  background: rgba(59, 134, 242, 0.1);
  color: var(--primary-blue);
}

.popover__selected {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  line-height: 1.4;
}
.popover__find-text {
  color: var(--primary-blue);
  font-weight: 600;
}

.popover__field {
  padding: 8px 16px 0;
}
.popover__field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.popover__field input,
.popover__field textarea,
.popover__field select {
  width: 100%;
  background: var(--bg-deeper);
  border: 1px solid var(--border-color-solid);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}
.popover__field input::placeholder,
.popover__field textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.4;
}
.popover__field textarea {
  resize: vertical;
  min-height: 36px;
}
.popover__field input:focus,
.popover__field textarea:focus,
.popover__field select:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.popover__field--row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 16px 12px;
}
.popover__field--row input[type="datetime-local"] {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px;
}
