/* ═══════════════════════════════════════════════════════════
   GNP Cotizador — Light Minimal Theme
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:           #f5f6f8;
  --surface:      #ffffff;
  --surface-2:    #f0f1f4;
  --border:       #e2e4e9;
  --border-hover: #c8cad1;

  --text:         #1a1d23;
  --text-muted:   #6b7280;
  --text-subtle:  #9ca3af;

  --accent:       #1d4ed8;
  --accent-light: #eff6ff;
  --accent-hover: #1e40af;

  --green:        #16a34a;
  --accent-green: #16a34a;
  --accent-yellow: #d97706;
  --green-light:  #f0fdf4;
  --red:          #dc2626;
  --red-light:    #fef2f2;
  --yellow:       #d97706;
  --yellow-light: #fffbeb;

  --gnp-blue:     #003366;
  --gnp-orange:   #ff6b00;

  --sidebar-width: 290px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Layout ────────────────────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gnp-blue);
  border-radius: var(--radius-sm);
  color: white;
  flex-shrink: 0;
}

.brand-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.section-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 600;
  margin-bottom: 8px;
}

/* ─── User Badge ────────────────────────────────────────── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.user-badge-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-badge-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge-email {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-subtle);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.user-logout-btn:hover { color: var(--red); }

#admin-link {
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
  text-decoration: none;
}

#admin-link:hover { color: var(--accent); }

/* ─── Sessions section (in sidebar) ────────────────────── */
.sessions-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  overflow: hidden;
}

.sessions-section .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.btn-new-session-side {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.btn-new-session-side:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.session-item {
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-item:hover { background: var(--surface-2); }
.session-item.active { background: var(--accent-light); }

.session-item-info { flex: 1; min-width: 0; }

.session-item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item.active .session-item-name { color: var(--accent); }

.session-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.btn-delete-session {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}

.session-item:hover .btn-delete-session { opacity: 1; }
.btn-delete-session:hover { color: var(--red); }

.session-state-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.session-state-badge.s-active {
  background: var(--yellow-light);
  color: var(--yellow);
  animation: badge-pulse 1.5s ease-in-out infinite;
}

.session-state-badge.s-quoting {
  background: var(--accent-light);
  color: var(--accent);
  animation: badge-pulse 1.5s ease-in-out infinite;
}

.session-state-badge.s-done {
  background: var(--green-light);
  color: var(--green);
}

.session-state-badge.s-error {
  background: var(--red-light);
  color: var(--red);
}

@keyframes badge-pulse { 0%,100%{opacity:1} 50%{opacity:0.45} }

/* ─── Pipeline ──────────────────────────────────────────── */
.pipeline-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.pipeline-step.active {
  background: var(--accent-light);
  border-color: #bfdbfe;
}

.pipeline-step.active .step-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

.pipeline-step.completed {
  background: var(--green-light);
  border-color: #bbf7d0;
}

.pipeline-step.error {
  background: var(--red-light);
  border-color: #fecaca;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.step-icon { font-size: 1rem; flex-shrink: 0; }
.step-info { display: flex; flex-direction: column; }

.step-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

.step-desc {
  font-size: 0.625rem;
  color: var(--text-muted);
}

.pipeline-connector {
  width: 2px;
  height: 8px;
  background: var(--border);
  margin-left: 18px;
  transition: background 0.2s;
}

.pipeline-connector.active { background: var(--accent); }

/* ─── Usage Counter ─────────────────────────────────────── */
.usage-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.usage-counter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.usage-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.usage-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.usage-currency {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.usage-details { display: flex; flex-direction: column; gap: 4px; }

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

.usage-label { font-size: 0.6875rem; color: var(--text-muted); }

.usage-value {
  font-size: 0.6875rem;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─── Rules Summary ─────────────────────────────────────── */
.rules-section {
  padding: 12px 14px;
  flex-shrink: 0;
}

.rules-summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 160px;
  overflow-y: auto;
}

.rules-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 6px;
}

.rule-item {
  font-size: 0.75rem;
  color: var(--text);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

.rule-item:last-child { border-bottom: none; }

.rule-badge {
  display: inline-block;
  font-size: 0.6rem;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 600;
  margin-right: 5px;
}

.rule-badge.allowed { background: var(--green-light); color: var(--green); }
.rule-badge.blocked { background: var(--red-light); color: var(--red); }

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ─── Chat Panel ────────────────────────────────────────── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  font-size: 0.625rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  border: 1px solid var(--border);
}

.status-badge.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: #bfdbfe;
  animation: badgePulse 2s ease-in-out infinite;
}

.status-badge.done {
  background: var(--green-light);
  color: var(--green);
  border-color: #bbf7d0;
}

.status-badge.error {
  background: var(--red-light);
  color: var(--red);
  border-color: #fecaca;
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ─── Chat Messages ─────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 78%;
  animation: messageIn 0.25s ease-out;
}

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

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.message-user .message-avatar {
  background: var(--gnp-blue);
  border-color: var(--gnp-blue);
  color: white;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.55;
}

.message-assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.message-user .message-bubble {
  background: var(--gnp-blue);
  color: white;
}

.message-bubble p { margin-bottom: 6px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul { padding-left: 18px; margin: 6px 0; }
.message-bubble li { margin-bottom: 3px; font-size: 0.84375rem; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-subtle);
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ─── Upload Zone ───────────────────────────────────────── */
.upload-zone {
  padding: 0 20px;
  margin-bottom: 6px;
}

.upload-zone-inner {
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  background: var(--surface);
}

.upload-zone-inner:hover,
.upload-zone-inner.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.upload-zone-inner p { font-size: 0.8125rem; }
.upload-hint { font-size: 0.6875rem; color: var(--text-subtle); }

.upload-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-weight: 500;
}

.upload-type-selector {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: center;
}

/* ─── Chat Input ────────────────────────────────────────── */
.chat-input-area {
  padding: 10px 20px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.quick-replies {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.quick-reply-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-hover);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.quick-reply-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.08);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

#chat-input::placeholder { color: var(--text-subtle); }

.btn-send {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gnp-blue);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.btn-send:hover { background: #002855; }
.btn-send:active { transform: scale(0.95); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--gnp-blue);
  color: white;
  border-color: var(--gnp-blue);
}

.btn-primary:hover { background: #002855; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-hover); }

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-hover); }

/* ─── Results Panel ─────────────────────────────────────── */
.results-panel {
  position: absolute;
  inset: 0;
  background: var(--surface);
  z-index: 10;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.results-header h2 { font-size: 0.9375rem; font-weight: 600; }

.btn-close-x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-close-x:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.results-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.result-igualada-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1.5px solid #16a34a;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  color: #15803d;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
}
.result-igualada-badge svg { flex-shrink: 0; color: #16a34a; }
.result-igualada-primas {
  margin-left: auto;
  font-weight: 500;
  font-size: 12px;
  color: #166534;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.result-card h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent);
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.84375rem;
}

.result-row:last-child { border-bottom: none; }
.result-label { color: var(--text-muted); }
.result-value { font-weight: 600; color: var(--text); }

.premium-highlight {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gnp-blue);
  text-align: center;
  padding: 14px 0;
}

/* ─── Pre-chat selection panel ──────────────────────── */
.chat-panel.pre-chat-active .chat-messages,
.chat-panel.pre-chat-active .upload-zone,
.chat-panel.pre-chat-active .chat-input-area { display: none; }

.pre-chat-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  flex: 1;
  padding: 40px 24px;
}

.pre-chat-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 420px;
}

.pre-chat-step.hidden { display: none; }

.pre-chat-question {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin: 0;
  letter-spacing: -0.02em;
}

.pre-chat-btn-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.pre-chat-big-btn {
  flex: 1;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.pre-chat-big-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  box-shadow: var(--shadow-md);
}

.pre-chat-big-btn.selected {
  background: var(--gnp-blue);
  border-color: var(--gnp-blue);
  color: white;
}

/* ─── Inline message action chips ──────────────────────── */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.action-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.action-chip:hover {
  background: var(--accent);
  color: white;
}

/* ─── Renovation choice buttons ─────────────────────────── */
.msg-choices {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.choice-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  background: white;
  color: var(--accent);
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.choice-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.choice-btn:active {
  transform: translateY(0);
}

/* ─── History Section (kept for compat, not shown) ─────── */
.history-section { display: none; }

/* ─── Hamburger button ───────────────────────────────────── */
.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: background 0.2s;
}
.btn-hamburger:hover span { background: var(--accent); }

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 49;
}
.sidebar-overlay.visible { display: block; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .btn-hamburger { display: flex; }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 50;
    transition: left 0.3s;
    box-shadow: var(--shadow-md);
    width: min(290px, 80vw);
    min-width: 0;
  }
  .sidebar.open { left: 0; }

  .top-right-actions { top: 10px; right: 10px; gap: 6px; }
  .btn-top-action, .btn-report-error { padding: 5px 9px; font-size: 11px; }

  .chat-header { padding: 10px 14px; }

  .chat-input-area { padding: 10px 12px; }
  .chat-input textarea { font-size: 15px; }

  .message { max-width: 96%; }
  .message-content { font-size: 0.875rem; }

  .results-grid { grid-template-columns: 1fr 1fr; }

  .pre-chat-btn-row { flex-wrap: wrap; }
}

/* ─── Top-right action buttons ──────────────────────────── */
.top-right-actions {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-top-action,
.btn-report-error {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition: border-color .15s, color .15s;
  font-family: inherit;
  color: var(--text-muted);
}
.btn-top-action:hover { border-color: var(--accent); color: var(--accent); }
.btn-report-error:hover { border-color: #fca5a5; color: #e53e3e; }

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 20px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.modal-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.modal-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.modal-textarea:focus { border-color: var(--accent); }
.modal-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.modal-input:focus { border-color: var(--accent); }
.file-drop-area {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: border-color .15s;
}
.file-drop-area:hover { border-color: var(--accent); }
