/* ==========================================================================
   THEME TOKENS + BOOTSTRAP BRIDGE (single source of truth)
   - Keeps your existing --bg/--surface/etc.
   - Maps them into Bootstrap variables so BS components match the theme
   - Removes collisions (custom tooltip renamed, switch sizing scoped)
   ========================================================================== */

/* -----------------------------
   Base theme tokens (default)
   ----------------------------- */
:root {
  /* Base (used if no data-theme set) */
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;

  --text: #0f172a;   /* slate-900 */
  --muted: #475569;  /* slate-600 */
  --border: #d7e1ee;

  --accent: #0f766e;   /* teal-700 */
  --accent-2: #2dd4bf; /* teal-400 */
  --accent-3: #0a524d; /* teal-800 */
  --on-accent: #ffffff;

  --chip-bg: #e8f2ff;
  --chip-text: #0f172a;

  --shadow: 0 10px 28px rgba(2, 6, 23, 0.06);

  --card: var(--surface);
  --ink: var(--text);
  --badge: var(--chip-bg);

  /* Semantic */
  --success-bg: #e8f7f3;
  --success-text: #0f766e;

  --warn-bg: #fff4e5;
  --warn-text: #92400e;

  --danger-bg: #feecec;
  --danger-text: #b91c1c;

  --info-bg: #eaf2ff;
  --info-text: #1e40af;


  /* Chart base hues (DO NOT use text colors) */
  --chart-success-hue: 170deg; /* teal-green */
  --chart-warn-hue:    38deg;  /* amber */
  --chart-danger-hue:  2deg;   /* red */

  /* Chart fills (pleasant, readable, neutral) */
  --chart-keep:    hsl(var(--chart-success-hue) 45% 55%);
  --chart-improve: hsl(var(--chart-warn-hue)    60% 55%);
  --chart-rewrite: hsl(var(--chart-danger-hue)  65% 55%);

  /* Optional strokes */
  --chart-keep-border:    hsl(var(--chart-success-hue) 45% 40%);
  --chart-improve-border: hsl(var(--chart-warn-hue)    60% 40%);
  --chart-rewrite-border: hsl(var(--chart-danger-hue)  65% 40%);

  /* Grid + labels */
  --chart-grid:  color-mix(in srgb, var(--border) 70%, transparent);
  --chart-axis:  var(--muted);
  --chart-label: var(--ink);

  /* -----------------------------
     BOOTSTRAP BRIDGE (IMPORTANT)
     ----------------------------- */
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);

  --bs-secondary-color: var(--muted);
  --bs-tertiary-bg: var(--surface-2);

  --bs-link-color: var(--accent);
  --bs-link-hover-color: color-mix(in srgb, var(--accent) 80%, #000);

  --bs-card-bg: var(--surface);
  --bs-card-border-color: var(--border);

  --bs-primary: var(--accent);

  /* Tooltip (Bootstrap tooltips) */
  --bs-tooltip-bg: #111111;
  --bs-tooltip-color: #f5f5f5;

  /* Bootstrap backdrop */
  --bs-backdrop-bg: #000;
  --bs-backdrop-opacity: 0.25;
}

/* -----------------------------
   Theme variants
   ----------------------------- */
html[data-theme="morning"] {
  --bg: #f6f9ff;
  --surface: #ffffff;
  --surface-2: #edf4ff;

  --text: #0f172a;
  --muted: #475569;
  --border: #d6e3f3;

  --accent: #0f766e;
  --accent-2: #2dd4bf;
  --accent-3: #0a524d;
  --on-accent: #ffffff;

  --chip-bg: #e7f1ff;
  --chip-text: #0f172a;

  --shadow: 0 10px 28px rgba(2, 6, 23, 0.06);
}

html[data-theme="afternoon"] {
  --bg: #f3f7fb;
  --surface: #fbfdff;
  --surface-2: #eaf1f9;

  --text: #0b1220;
  --muted: #475569;
  --border: #d1dbe8;

  --accent: #0b6b66;
  --accent-2: #22c7b9;
  --accent-3: #084945;
  --on-accent: #ffffff;

  --chip-bg: #e6f0ff;
  --chip-text: #0b1220;

  --shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
}

html[data-theme="evening"] {
  /* Cooler “evening” instead of orange/brown */
  --bg: #eef2f7;
  --surface: #f7fbff;
  --surface-2: #e6edf6;

  --text: #0b1220;
  --muted: #4b5563;
  --border: #cdd7e6;

  --accent: #0b5f8a; /* blue-teal */
  --accent-2: #38bdf8; /* sky */
  --accent-3: #084665; /* deeper blue-teal */
  --on-accent: #ffffff;

  --chip-bg: #e0f2fe;
  --chip-text: #0b1220;

  --shadow: 0 8px 22px rgba(2, 6, 23, 0.08);
}

html[data-theme="night"] {
  --bg: #0b1220;        /* deep slate/navy */
  --surface: #0f172a;   /* slate-900 */
  --surface-2: #111c33;

  --text: #e5e7eb;      /* gray-200 */
  --muted: #94a3b8;     /* slate-400 */
  --border: #22304a;

  --accent: #22c7b9;    /* brighter teal for dark */
  --accent-2: #60a5fa;  /* blue highlight option */
  --accent-3: #0f766e;  /* darker teal for dark */
  --on-accent: #062a2a;

  --chip-bg: #111c33;
  --chip-text: #e5e7eb;

  --shadow: 0 10px 26px rgba(0, 0, 0, 0.45);

  --success-bg: rgba(34, 197, 94, 0.12);
  --success-text: #86efac;

  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-text: #fcd34d;

  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-text: #fca5a5;

  --info-bg: rgba(96, 165, 250, 0.14);
  --info-text: #93c5fd;

  --chart-keep:    hsl(var(--chart-success-hue) 35% 45%);
  --chart-improve: hsl(var(--chart-warn-hue)    45% 48%);
  --chart-rewrite: hsl(var(--chart-danger-hue)  50% 48%);

  --chart-grid: color-mix(in srgb, var(--border) 85%, transparent);

  /* Invert Bootstrap tooltip in night */
  --bs-tooltip-bg: #f5f5f5;
  --bs-tooltip-color: #111111;
}

/* ==========================================================================
   Global layout + transitions
   ========================================================================== */

body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--surface-2), var(--bg));
}

:root,
body,
.card,
.chat-bubble,
.chip {
  transition: background-color 350ms ease, color 350ms ease, border-color 350ms ease;
}

header {
  padding: 28px 24px 10px;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
}

.container {
  padding: 10px 24px 40px;
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 20px;
  font-weight: bold;
}

.context-bar {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

/* ==========================================================================
   Theme switch UI
   ========================================================================== */

.theme-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-switch label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.theme-switch select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink);
}

/* ==========================================================================
   Layout (Bootstrap grid)
   ========================================================================== */

.layout {
  align-items: stretch;
}

.sidebar-left-col,
.sidebar-right-col,
.main-col {
  min-width: 0;
}

.sidebar-right-col {
  display: flex;
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: flex-start;
}

.sidebar-left,
.sidebar-right {
  width: 100%;
}

.sidebar-right {
  height: 100%;
  align-self: stretch;
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header-row .card-title {
  margin: 0;
}

.friction-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.friction-actions .btn {
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.1;
}

.sidebar-left.collapsed .nav-header h3 {
  display: none;
}

.layout.sidebar-collapsed .sidebar-left-col {
  display: none;
}

.layout.sidebar-right-collapsed .sidebar-right-col {
  display: none;
}

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

/* ==========================================================================
   Cards + grids
   ========================================================================== */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* ==========================================================================
   Badges / tags
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-3);
  font-size: 12px;
  font-weight: bold;
}

.badge.small {
  font-size: 11px;
  padding: 2px 6px;
}

.badge.positive {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge.neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.badge.negative,
.badge.optout {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge.tone-low {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge.tone-medium {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.badge.tone-high {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 11px;
  margin-top: 4px;
}

/* ==========================================================================
   SMS Intelligence
   - IMPORTANT: do NOT style all "nav a" globally (breaks Bootstrap navs)
   - Scope to your sidebar/cards instead
   ========================================================================== */

/* Legacy nav-list (kept for compatibility) */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-list a {
  margin-right: 0;
  color: var(--accent);
  text-decoration: none;
  font-weight: bold;
}

/* Bootstrap-style sidebar nav links (for ul/li/a .nav-link) */
.sidebar .nav-link,
.sidebar-nav .nav-link {
  padding: 0.35rem 0.25rem;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.sidebar .nav-link:hover,
.sidebar-nav .nav-link:hover {
  text-decoration: underline;
}

.sidebar .nav-link.active,
.sidebar-nav .nav-link.active {
  color: var(--ink);
  background: var(--surface-2);
  border-radius: 8px;
  padding-left: 8px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

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

input,
select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  min-width: 140px;
  background: var(--surface);
  color: var(--ink);
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

.action-link {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
}

.action-link:hover {
  text-decoration: underline;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
.secondary-btn:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

/* Bootstrap form-switch compatibility:
   - Do NOT globally resize .form-check-input (breaks switches/radios)
   - Only tweak the one you care about via a wrapper class */
.form-check.form-switch {
  margin: 0;
}

.form-check-input {
  cursor: pointer;
}

/* Scoped sizing for the Houston toggle (optional) */
.houston-side-bar-toggle .form-check-input {
  width: 2.5rem;
  height: 1.25rem;
}

/* Small spacing helper */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.houston-side-bar-toggle {
  text-align: center;
  margin-bottom: 10px !important;
}

/* Buttons */
button {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: bold;
  cursor: pointer;
}

.secondary-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: bold;
  cursor: pointer;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table-wrap .dataTable {
  width: 100% !important;
}

.dataTables_wrapper {
  width: 100%;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

/* ==========================================================================
   Snippets / explain panels
   ========================================================================== */

.snippet {
  white-space: normal;
  word-break: break-word;
  max-width: 720px;
}

.snippet-collapsible {
  max-height: 140px;
  overflow: hidden;
  position: relative;
}

.snippet-collapsible.expanded {
  max-height: none;
}

.snippet-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.explain-link {
  margin-left: 6px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.explain-evidence-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.explain-evidence-row .muted {
  margin-bottom: 6px;
}

.evidence-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.evidence-group {
  margin-top: 16px;
}

.evidence-panel {
  display: none;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.evidence-row {
  margin-bottom: 8px;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ==========================================================================
   Icons / actions
   ========================================================================== */

.icon-btn {
  border: none;
  background: transparent;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--ink);
  border-radius: 8px;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.icon-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.icon-btn i {
  font-size: 16px;
}

.metric-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
}

.primary-action {
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  padding: 2px 0;
  cursor: pointer;
  font-size: 13px;
  max-height: 32px;
}

.primary-action:hover {
  text-decoration: underline;
}

.actions-menu {
  position: relative;
}

.actions-menu > summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 16px;
  color: var(--ink);
}

.actions-menu > summary::-webkit-details-marker {
  display: none;
}

.actions-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.actions-menu:not([open]) .actions-list {
  display: none;
}

.actions-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.actions-item:hover {
  background: var(--surface-2);
}

/* Action queue column sizing */
.aq-col {
  min-width: 75px;
}

span[data-bs-toggle="tooltip"] {
  cursor: pointer;
}

/* ==========================================================================
   Callouts / notes
   ========================================================================== */

.callout {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--border);
  margin-bottom: 1em;
}

.verdict-bar {
  white-space: normal;
}

.template-select {
  min-height: 48px;
  font-size: 0.98rem;
}

.template-select + .select2-container {
  width: 100% !important;
}

.template-select + .select2-container .select2-selection--single {
  min-height: 48px;
  display: flex;
  align-items: center;
}

.template-select + .select2-container .select2-selection__rendered {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  line-height: 1.3;
}

.note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.empty {
  padding: 12px;
  background: var(--warn-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cta {
  color: var(--accent);
  font-weight: bold;
  text-decoration: none;
}

/* ==========================================================================
   Custom tooltips (RENAMED to avoid Bootstrap .tooltip conflict)
   ========================================================================== */

.help-tooltip {
  position: relative;
  cursor: pointer;
  border-bottom: 1px dotted var(--muted);
}

.help-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: 140%;
  transform: translateX(-50%);
  background: var(--bs-tooltip-bg);
  color: var(--bs-tooltip-color);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding: 8px 10px;
  border-radius: 8px;
  width: max-content;
  max-width: 320px;
  white-space: pre-line;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 60;
}

.help-tooltip:hover::after {
  opacity: 1;
}

/* ==========================================================================
   Chat UI
   ========================================================================== */

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-right .chat-box {
  height: 100%;
}

.sidebar-right .chat-messages {
  min-height: 0;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
}

.message-preview {
  min-height: 115px;
  background: color-mix(in srgb, #f4f5f7 85%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px;
  line-height: 1.5;
}

.chat-input {
  flex: 0 0 auto;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 10px 10px;
}

.chat-input .chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.sidebar-right .chat-input .chat-row {
  flex-wrap: wrap;
}

.sidebar-right .chat-input textarea {
  flex: 1 1 100%;
}

.sidebar-right .chat-input button {
  align-self: flex-end;
}

.chat-input-inline {
  align-items: center;
}

.chat-input textarea {
  width: 100%;
  flex: 1 1 auto;
  min-height: 80px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

.chat-input button {
  width: auto;
  white-space: nowrap;
}

.send-btn {
  width: 50px !important;
  height: 50px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.send-btn-narrow {
  width: 45px !important;
  height: 50px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.send-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn.is-sending {
  opacity: 0.6;
}

.chat-bubble {
  max-width: 900px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 10px 0;
  box-shadow: none;
}

.chat-bubble.user {
  background: var(--surface-2);
}

.chat-bubble.chat-loading {
  border-style: dashed;
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  height: 18px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.4;
  animation: chat-dot-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 0.9; }
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chat-title {
  font-weight: bold;
  font-size: 14px;
}

.chat-section {
  margin-top: 12px;
}

.chat-section h5 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
}

.chat-details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.chat-details summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
}

.chat-prompt {
  border: none;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
}

.houston-intro-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.houston-logo {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  object-fit: contain;
}

/* ==========================================================================
   Modals (custom)
   ========================================================================== */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45) !important;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop .modal {
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 18px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

/* Override Bootstrap modal defaults inside our custom backdrop */
.modal-backdrop .modal {
  display: block;
  position: relative;
  inset: auto;
  height: auto;
}

.modal-wide {
  max-width: 1100px;
  max-height: 80vh;
  overflow: auto;
}

.modal-backdrop .modal h3 {
  margin-top: 0;
}

.modal-backdrop .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* Modal loader */
.modal-loader {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px 0;
}

.modal-loader.active {
  display: flex;
}

/* Spinner */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.2);
  border-top-color: rgba(0, 0, 0, 0.75);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

html[data-theme="night"] .spinner {
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.85);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Scope banner + details
   ========================================================================== */

.scope-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  border-radius: 10px;
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--border);
}

.banner-close {
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
}

#journey-subheader,
#journey-context,
#journey-scope {
  margin-top: 4px;
}

#journey-dynamic {
  margin-top: 8px;
  min-height: 120px;
}

details.card.compact {
  padding: 10px 12px;
}

details.card.compact summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 6px;
}

/* ==========================================================================
   Readability blocks
   ========================================================================== */

.numbers-block {
  white-space: pre-line;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 6px;
}

.readability-scale {
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  line-height: 1.4;
  margin: 6px 0 12px;
}

.readability-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 12px;
  font-size: 14px;
}

.readability-table th,
.readability-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

.readability-table th {
  background: var(--surface-2);
}

.section-spacer {
  height: 12px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer-bar {
  margin-top: 20px;
  padding: 12px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-year {
  font-size: 13px;
}

/* ==========================================================================
   Bar chart
   ========================================================================== */

.bar-chart {
  display: grid;
  gap: 8px;
  background: none;
}

.bar-chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.bar-chart-grid {
  display: block;
  min-height: 260px;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.bar-label {
  font-size: 11px;
  color: var(--muted);
}

/* ==============================
   Decision overview
   ============================== */

.decision-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.decision-kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
}

.decision-kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.decision-kpi-value {
  font-size: 18px;
  font-weight: 700;
}

.decision-kpi--success .decision-kpi-value {
  color: color-mix(in srgb, var(--success-text) 75%, #fff);
}

.decision-kpi--warn .decision-kpi-value {
  color: color-mix(in srgb, var(--warn-text) 75%, #fff);
}

.decision-kpi--danger .decision-kpi-value {
  color: color-mix(in srgb, var(--danger-text) 75%, #fff);
}

.decision-overview {
  height: 140px;
}

.decision-overview-note {
  margin-top: 12px;
}

.timing-col-time {
  width: 17%;
}

pre code.language-text,
pre code[class*="language-"] {
  white-space: pre-wrap;
  word-break: break-word;
}

.executive-takeaway {
  margin-top: 6px;
}

.callout-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--surface-2) 70%, #fff);
  border-radius: 12px;
  padding: 16px;
}

/* ==========================================================================
   Datepicker range helper (unchanged)
   ========================================================================== */

.ui-datepicker-range a {
  background: rgba(30, 96, 124, 0.2) !important;
  border-radius: 999px;
  color: inherit !important;
}

/* smaller + calmer switch for sidebar settings */
#houston-date-toggle.form-check-input {
  width: 2.25rem;
  height: 1.2rem;
  cursor: pointer;
}

/* softer OFF */
#houston-date-toggle.form-check-input:not(:checked) {
  background-color: #e9ecef;
  border-color: #dee2e6;
}

/* softer ON (still Bootstrap primary vibe) */
#houston-date-toggle.form-check-input:checked {
  background-color: rgba(13, 110, 253, 0.75);
  border-color: rgba(13, 110, 253, 0.35);
}

/* ==========================================================================
   Responsive behavior (your existing)
   ========================================================================== */

@media (max-width: 980px) {
  .sidebar {
    position: static;
  }
}

/* ==============================
   Friction tabs
   ============================== */

.friction-tabs {
  margin-top: 16px;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.tab-btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.tab-panel table,
.tab-panel .data-table,
table.data-table {
  width: 100% !important;
}

/* ==============================
   Step breakdown bars
   ============================== */

.step-bars {
  display: grid;
  gap: 10px;
}

.step-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 70px;
  align-items: center;
  gap: 10px;
}

.step-bar-label {
  font-size: 12px;
  color: var(--muted);
}

.step-bar-track {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  height: 18px;
  position: relative;
}

.step-bar-fill {
  height: 100%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  color: var(--on-accent);
  font-size: 11px;
  white-space: nowrap;
}

.step-bar-row.severity-good .step-bar-fill {
  background: var(--chart-keep);
  color: var(--ink);
}

.step-bar-row.severity-warn .step-bar-fill {
  background: var(--chart-improve);
  color: var(--ink);
}

.step-bar-row.severity-bad .step-bar-fill {
  background: var(--chart-rewrite);
  color: var(--ink);
}

.step-bar-value {
  font-weight: 600;
}

.step-bar-rate {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* Keep chat box sizing as you had it */
.card.chat-box {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 620px;
}

.sidebar .nav-link:hover,
.sidebar-nav .nav-link:hover {
  text-decoration: none;
}

.sidebar .nav-link:hover,
.sidebar-nav .nav-link:hover {
  background-color: var(--bg);
}

.spacer {
  margin-top: 0.5em;
  min-height: 10px;
}

.technical-details {
  display: none;
}

body.persona-cto .technical-details {
  display: block;
}

.section-loading {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: var(--panel);
  font-weight: 600;
}

.message-preview.expanded { max-height: none !important; }
