:root {
  --sidebar-bg: #0f1629;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(99,102,241,0.18);
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-light: #eef2ff;
  --accent-border: #c7d2fe;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}

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

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 210px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
}
.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo { font-size: 22px; }
.sidebar-title { color: #e2e8f0; font-size: 13px; font-weight: 600; line-height: 1.35; }

.nav-items { padding: 8px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  border: none; border-radius: 8px;
  background: transparent; color: rgba(255,255,255,0.6);
  cursor: pointer; font-size: 13.5px; text-align: left;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: rgba(255,255,255,0.9); }
.nav-item.active { background: var(--sidebar-active); color: #ffffff; font-weight: 500; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px; color: rgba(255,255,255,0.35);
  line-height: 1.5;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.view { display: none; flex: 1; flex-direction: column; height: 100%; overflow: hidden; }
.view.active { display: flex; }

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header h1 { font-size: 16px; font-weight: 600; }
.chat-header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.clear-btn {
  padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface);
  color: var(--text-muted); cursor: pointer; font-size: 12px;
  transition: all 0.12s;
}
.clear-btn:hover { border-color: var(--border-strong); color: var(--text); }

.messages {
  flex: 1; overflow-y: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 20px;
  scroll-behavior: smooth;
}

/* Welcome screen */
.welcome {
  margin: auto; text-align: center;
  max-width: 520px; padding: 40px 20px;
}
.welcome-icon { font-size: 48px; margin-bottom: 16px; }
.welcome h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.welcome p { color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }
.example-questions { display: flex; flex-direction: column; gap: 8px; }
.example-q {
  padding: 10px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface);
  color: var(--text); cursor: pointer; text-align: left;
  font-size: 13px; transition: all 0.12s;
}
.example-q:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Messages */
.message { display: flex; flex-direction: column; max-width: 82%; }
.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; max-width: 88%; }

.message-bubble {
  padding: 11px 15px; border-radius: 12px; line-height: 1.6;
}
.message.user .message-bubble {
  background: var(--accent); color: white;
  border-radius: 12px 12px 4px 12px;
}
.message.assistant .message-bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px; box-shadow: var(--shadow-sm);
}

/* Markdown in assistant bubbles */
.message.assistant .message-bubble p { margin-bottom: 8px; }
.message.assistant .message-bubble p:last-child { margin-bottom: 0; }
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3 { margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.message.assistant .message-bubble h1:first-child,
.message.assistant .message-bubble h2:first-child,
.message.assistant .message-bubble h3:first-child { margin-top: 0; }
.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol { padding-left: 20px; margin: 6px 0; }
.message.assistant .message-bubble li { margin-bottom: 3px; }
.message.assistant .message-bubble code {
  background: #f1f5f9; padding: 1px 5px; border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace; font-size: 12px;
}
.message.assistant .message-bubble pre {
  background: #f1f5f9; padding: 12px; border-radius: 8px;
  overflow-x: auto; margin: 10px 0;
}
.message.assistant .message-bubble pre code { background: none; padding: 0; }
.message.assistant .message-bubble strong { font-weight: 600; }
.message.assistant .message-bubble blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px; color: var(--text-muted); margin: 8px 0;
}

/* Filter badge */
.message-filter {
  font-size: 11px; color: #4338ca;
  padding: 3px 9px; background: #eef2ff;
  border: 1px solid #c7d2fe; border-radius: 4px;
  margin-bottom: 5px; align-self: flex-start;
}

/* Sources */
.sources-toggle {
  font-size: 12px; color: var(--text-muted);
  cursor: pointer; margin-top: 7px;
  padding: 4px 8px; background: none;
  border: 1px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; gap: 5px;
  transition: all 0.12s;
}
.sources-toggle:hover { color: var(--accent); border-color: var(--accent); }
.sources-toggle.open { color: var(--accent); border-color: var(--accent-border); background: var(--accent-light); }

.sources-list {
  margin-top: 6px; padding: 10px 12px;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; display: none; min-width: 340px;
}
.sources-list.open { display: block; }

.source-item {
  display: flex; align-items: baseline; gap: 6px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.source-item:last-child { border-bottom: none; padding-bottom: 0; }
.source-item a { color: var(--accent); text-decoration: none; word-break: break-all; flex: 1; }
.source-item a:hover { text-decoration: underline; }
.source-badge {
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: var(--border); color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
}
.source-date { color: var(--text-light); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 5px; padding: 13px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px; box-shadow: var(--shadow-sm);
  align-self: flex-start; width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px; background: var(--text-light);
  border-radius: 50%; animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-5px); }
}

/* Chat input */
.chat-input-area {
  padding: 14px 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chat-input-container {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 8px 10px;
  transition: border-color 0.15s;
}
.chat-input-container:focus-within { border-color: var(--accent); }
#chat-input {
  flex: 1; border: none; background: transparent;
  resize: none; font-size: 14px; font-family: inherit;
  color: var(--text); max-height: 140px; line-height: 1.55; outline: none;
}
#send-btn {
  border: none; background: var(--accent); color: white;
  width: 34px; height: 34px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.12s;
}
#send-btn:hover:not(:disabled) { background: var(--accent-dark); }
#send-btn:disabled { background: var(--border); cursor: not-allowed; }
.input-hint { font-size: 11px; color: var(--text-light); margin-top: 6px; text-align: right; }

/* ── Browse ──────────────────────────────────────────────────────────────── */
.browse-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.browse-header h1 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.browse-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.browse-filters input,
.browse-filters select {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; background: white;
  color: var(--text); outline: none; transition: border-color 0.12s;
}
.browse-filters input { width: 200px; }
.browse-filters input:focus,
.browse-filters select:focus { border-color: var(--accent); }
.doc-count { color: var(--text-muted); font-size: 12px; margin-left: auto; }

.browse-table-wrapper { flex: 1; overflow: auto; }
.browse-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.browse-table thead { position: sticky; top: 0; z-index: 2; }
.browse-table th {
  background: var(--surface); border-bottom: 2px solid var(--border);
  padding: 10px 12px; text-align: left; font-weight: 600;
  color: var(--text-muted); cursor: pointer; white-space: nowrap;
  user-select: none;
}
.browse-table th:hover { color: var(--accent); }
.sort-arrow { font-size: 10px; opacity: 0.5; }
.browse-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.browse-table tr:hover td { background: var(--accent-light); }
.browse-table td.filename-cell {
  font-family: 'SF Mono', Menlo, monospace; font-size: 11.5px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.source-tag {
  display: inline-block; padding: 2px 7px;
  border-radius: 4px; font-size: 11px; font-weight: 500;
}
.src-ecode360      { background: #dbeafe; color: #1e40af; }
.src-youtube       { background: #fee2e2; color: #991b1b; }
.src-hbgica        { background: #d1fae5; color: #065f46; }
.src-municipal_code{ background: #ede9fe; color: #5b21b6; }
.src-direct        { background: #fef9c3; color: #854d0e; }
.src-dced_act47    { background: #ffedd5; color: #9a3412; }
.src-pa_statutes   { background: #dcfce7; color: #166534; }
.src-munstats      { background: #fce7f3; color: #9d174d; }

.open-link { color: var(--accent); text-decoration: none; font-size: 16px; }
.open-link:hover { opacity: 0.7; }
.table-loading { text-align: center; color: var(--text-muted); padding: 40px; }

/* ── Sessions ────────────────────────────────────────────────────────────── */
.sessions-layout { display: flex; height: 100%; overflow: hidden; }
.sessions-sidebar {
  width: 280px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; background: var(--surface);
}
.sessions-header { padding: 16px; border-bottom: 1px solid var(--border); }
.sessions-header h2 { font-size: 15px; font-weight: 600; }
.sessions-list { flex: 1; overflow-y: auto; }
.list-loading { padding: 16px; color: var(--text-muted); font-size: 13px; }

.session-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.session-item:hover { background: var(--accent-light); }
.session-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }
.session-item-date { font-size: 12px; font-weight: 600; color: var(--text); }
.session-item-preview {
  font-size: 12px; color: var(--text-muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.session-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.session-empty { color: var(--text-muted); text-align: center; padding: 80px 20px; }

.session-qa { margin-bottom: 28px; }
.session-q {
  font-weight: 600; color: var(--text);
  padding: 10px 14px; background: var(--accent-light);
  border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0;
  margin-bottom: 10px; font-size: 14px;
}
.session-a {
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  line-height: 1.65; font-size: 13px; white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}

/* ── Add Content ─────────────────────────────────────────────────────────── */
.add-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.add-header h1 { font-size: 16px; font-weight: 600; }
.add-header p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.add-content { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.add-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.add-section h2 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.section-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

.url-input-row { display: flex; gap: 8px; }
.url-input-row input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.12s;
}
.url-input-row input:focus { border-color: var(--accent); }

button.primary, .url-input-row button, .rebuild-btn {
  padding: 8px 16px; background: var(--accent); color: white;
  border: none; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background 0.12s;
}
button.primary:hover, .url-input-row button:hover, .rebuild-btn:hover { background: var(--accent-dark); }
button:disabled, .rebuild-btn:disabled { background: var(--border); cursor: not-allowed; color: var(--text-muted); }

.drop-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: all 0.15s; background: var(--bg);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: var(--accent-light);
}
.drop-zone-content { pointer-events: none; }
.drop-zone-content p { color: var(--text-muted); margin-top: 10px; font-size: 13px; }
.drop-hint { font-size: 12px; margin-top: 4px !important; }
.file-label { color: var(--accent); cursor: pointer; text-decoration: underline; pointer-events: all; }

.status-msg { margin-top: 10px; font-size: 12.5px; min-height: 18px; line-height: 1.5; }
.status-msg.success { color: #059669; }
.status-msg.error   { color: #dc2626; }
.status-msg.info    { color: var(--text-muted); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Auth sidebar elements ───────────────────────────────────────────────── */
.credit-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  background: rgba(99,102,241,0.2); color: #a5b4fc;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  margin-top: 6px;
}
.credit-chip.zero { background: rgba(220,38,38,0.2); color: #fca5a5; }

.sidebar-account-email {
  font-size: 11px; color: rgba(255,255,255,0.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 4px;
}
.sidebar-user {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logout-btn {
  width: 100%; padding: 5px 10px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 11px; text-align: left;
  transition: all 0.12s;
}
.sidebar-logout-btn:hover { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); }

.nav-item.auth-only { display: none; }
.nav-item.anon-only { display: flex; }

/* ── Login / Register view ───────────────────────────────────────────────── */
.auth-view { flex-direction: row; }

.auth-brand {
  width: 42%; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 44px;
  color: rgba(255,255,255,0.85);
}
.auth-brand-logo { font-size: 36px; margin-bottom: 16px; }
.auth-brand-title {
  font-size: 26px; font-weight: 700; line-height: 1.2;
  color: #e2e8f0; margin-bottom: 14px;
}
.auth-brand-sub {
  font-size: 14px; line-height: 1.6;
  color: rgba(255,255,255,0.55); margin-bottom: 28px;
}
.auth-brand-features {
  list-style: none; display: flex; flex-direction: column; gap: 10px;
}
.auth-brand-features li {
  font-size: 13px; color: rgba(255,255,255,0.6);
  padding-left: 20px; position: relative;
}
.auth-brand-features li::before {
  content: '✓'; position: absolute; left: 0;
  color: #a5b4fc; font-weight: 700;
}

.auth-panel {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 48px 52px; background: var(--surface); overflow-y: auto;
}

.auth-tabs {
  display: flex; gap: 0; margin-bottom: 28px;
  border-bottom: 2px solid var(--border);
}
.auth-tab {
  padding: 8px 20px 10px; border: none; background: none;
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.12s; font-weight: 500;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.auth-form { display: flex; flex-direction: column; gap: 16px; max-width: 320px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.3px; text-transform: uppercase; }
.auth-form input[type="email"],
.auth-form input[type="password"] {
  padding: 10px 13px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 14px; outline: none;
  transition: border-color 0.12s; font-family: inherit;
  background: var(--bg);
}
.auth-form input:focus { border-color: var(--accent); background: var(--surface); }
.auth-submit {
  padding: 11px; background: var(--accent); color: white;
  border: none; border-radius: 7px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: background 0.12s;
  margin-top: 4px; width: 100%;
}
.auth-submit:hover { background: var(--accent-dark); }
.auth-submit:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
.auth-error { color: #dc2626; font-size: 12px; min-height: 16px; }

/* ── Buy Credits view ────────────────────────────────────────────────────── */
.buy-view {
  flex: 1; overflow-y: auto; padding: 32px;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
}
.buy-header { text-align: center; }
.buy-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.buy-header p { color: var(--text-muted); font-size: 14px; }
.buy-balance {
  font-size: 16px; font-weight: 600; margin-top: 12px;
  color: var(--accent);
}

.product-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.product-card {
  width: 170px; border: 2px solid var(--border);
  border-radius: 12px; padding: 20px 16px; text-align: center;
  cursor: pointer; transition: all 0.15s; background: var(--surface);
}
.product-card:hover { border-color: var(--accent); background: var(--accent-light); }
.product-card.selected { border-color: var(--accent); background: var(--accent-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.product-card .pc-qty { font-size: 28px; font-weight: 700; color: var(--accent); }
.product-card .pc-label { font-size: 13px; color: var(--text-muted); margin: 4px 0 10px; }
.product-card .pc-price { font-size: 18px; font-weight: 700; color: var(--text); }

.payment-form-area {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
}
.payment-form-area h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
#card-container { min-height: 90px; margin-bottom: 16px; }
.pay-btn {
  width: 100%; padding: 11px; background: var(--accent); color: white;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 15px; font-weight: 600; transition: background 0.12s;
}
.pay-btn:hover:not(:disabled) { background: var(--accent-dark); }
.pay-btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
.pay-status { margin-top: 12px; font-size: 13px; min-height: 18px; }
.pay-status.success { color: #059669; }
.pay-status.error   { color: #dc2626; }
.pay-status.info    { color: var(--text-muted); }

/* ── Question History view ───────────────────────────────────────────────── */
.history-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.history-header h1 { font-size: 16px; font-weight: 600; }
.history-header p  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.history-table-wrapper { flex: 1; overflow: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table thead { position: sticky; top: 0; z-index: 2; }
.history-table th {
  background: var(--surface); border-bottom: 2px solid var(--border);
  padding: 10px 12px; text-align: left; font-weight: 600;
  color: var(--text-muted); white-space: nowrap;
}
.history-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.history-table tr:hover td { background: #f8fafc; }
.history-table .q-text { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refund-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
}
.refund-badge.pending  { background: #fef3c7; color: #92400e; }
.refund-badge.granted  { background: #d1fae5; color: #065f46; }
.refund-badge.denied   { background: #fee2e2; color: #991b1b; }

.flag-link {
  font-size: 11px; color: var(--text-muted); cursor: pointer;
  background: none; border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px;
  transition: all 0.12s; white-space: nowrap;
}
.flag-link:hover { color: #dc2626; border-color: #fca5a5; background: #fff5f5; }
.flag-link.flagged { color: #92400e; border-color: #fde68a; background: #fef9c3; cursor: default; }

/* Refund button on chat bubbles */
.bubble-flag-btn {
  font-size: 12px; color: var(--text-muted); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; margin-top: 8px;
  align-self: flex-start; transition: all 0.12s;
}
.bubble-flag-btn:hover { color: #b45309; border-color: #fcd34d; background: #fffbeb; }
.bubble-flag-btn.flagged {
  color: #92400e; border-color: #fde68a; background: #fef9c3;
  cursor: default;
}

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: 12px;
  padding: 28px; width: 420px; max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.modal-icon { font-size: 22px; padding-top: 1px; }
.modal-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.modal-credit-note {
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 7px; padding: 9px 13px;
  font-size: 13px; color: #166534; margin-bottom: 14px;
}
.modal-label { font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.3px; display: block; margin-bottom: 6px; }
.modal-textarea {
  width: 100%; min-height: 90px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; font-family: inherit; resize: vertical; outline: none;
  transition: border-color 0.12s;
}
.modal-textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modal-cancel {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 6px;
  background: none; cursor: pointer; font-size: 13px; color: var(--text-muted);
  transition: all 0.12s;
}
.modal-cancel:hover { border-color: var(--border-strong); color: var(--text); }
.modal-submit {
  padding: 8px 18px; border: none; border-radius: 6px;
  background: #dc2626; color: white; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: background 0.12s;
}
.modal-submit:hover:not(:disabled) { background: #b91c1c; }
.modal-submit:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ── About view ──────────────────────────────────────────────────────────── */
.about-view {
  flex: 1; overflow-y: auto; padding: 48px 60px;
  max-width: 780px;
}
.about-view h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.about-view h2 { font-size: 17px; font-weight: 700; margin: 32px 0 10px; color: var(--text); }
.about-view h3 { font-size: 14px; font-weight: 700; margin: 20px 0 6px; color: var(--text); }
.about-view p  { font-size: 14px; line-height: 1.75; color: #334155; margin-bottom: 14px; }
.about-view ul, .about-view ol { padding-left: 22px; margin-bottom: 14px; }
.about-view li { font-size: 14px; line-height: 1.75; color: #334155; margin-bottom: 4px; }
.about-view strong { color: var(--text); font-weight: 600; }
.about-view em { color: var(--text-muted); font-style: italic; }
.about-view blockquote {
  border-left: 3px solid var(--accent); margin: 20px 0;
  padding: 10px 20px; background: var(--accent-light); border-radius: 0 8px 8px 0;
}
.about-view blockquote p { color: #1e40af; margin: 0; font-style: italic; }
.about-view hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.about-view code {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; font-size: 12px; font-family: monospace;
}

/* ── Welcome logo ────────────────────────────────────────────────────────── */
.welcome-skyline {
  width: 148px; margin: 0 auto 20px;
}
.welcome-skyline img { width: 100%; height: auto; display: block; }

/* ── Splash overlay ──────────────────────────────────────────────────────── */
.splash-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.65); z-index: 2000;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.splash-overlay.open { display: flex; }

.splash-card {
  background: #07101f;
  border-radius: 16px; overflow: hidden;
  width: calc(100% - 32px); max-width: 500px; max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55), 0 0 0 1px rgba(99,102,241,0.22);
  animation: splash-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes splash-in {
  from { transform: scale(0.9) translateY(16px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

.splash-skyline {
  display: flex; align-items: center; justify-content: center;
  padding: 28px 28px 20px;
  background: #020810; flex-shrink: 0;
}
.splash-skyline img { width: 96px; height: auto; display: block; }

.splash-body { padding: 28px 32px 32px; }

.splash-badge {
  display: inline-block; padding: 3px 11px; border-radius: 20px;
  background: rgba(99,102,241,0.22); color: #a5b4fc;
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; margin-bottom: 14px;
  border: 1px solid rgba(99,102,241,0.35);
}

.splash-title {
  font-size: 26px; font-weight: 700; line-height: 1.15;
  color: #f0f4ff; margin-bottom: 8px;
}

.splash-tagline {
  font-size: 14px; line-height: 1.65;
  color: rgba(255,255,255,0.5); margin-bottom: 24px;
}

.splash-features { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }

.splash-feature {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
}
.splash-feature-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.splash-feature-title { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.9); margin-bottom: 4px; }
.splash-feature-desc { font-size: 12.5px; line-height: 1.55; color: rgba(255,255,255,0.5); }
.splash-feature-desc strong { color: rgba(255,255,255,0.82); font-weight: 600; }

.splash-cta {
  width: 100%; padding: 13px 0;
  background: #6366f1; color: white;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.2px;
}
.splash-cta:hover { background: #4f46e5; transform: translateY(-1px); }
.splash-cta:active { transform: translateY(0); }
