/* ==========================================
   VozPública — App CSS v2
   Glassmorphism dark · Sora + system-ui
   ========================================== */

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

/* ── Design Tokens ── */
:root {
  --bg-primary: #070a12;
  --bg-secondary: #0c1020;
  --bg-tertiary: #121729;
  --bg-card: rgba(18, 23, 41, 0.9);
  --bg-glass: rgba(18, 23, 41, 0.55);
  --border-subtle: rgba(62, 207, 178, 0.08);
  --border-active: rgba(62, 207, 178, 0.28);
  --text-primary: #eef2ff;
  --text-secondary: #8a9bc0;
  --text-tertiary: #4f607e;
  --accent: #3ecfb2;
  --accent-hover: #4fe3c6;
  --accent-glow: rgba(62, 207, 178, 0.12);
  --accent-glow-md: rgba(62, 207, 178, 0.2);
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --purple-glow: rgba(124, 58, 237, 0.14);
  --danger: #f87171;
  --success: #34d399;
  --warning: #fbbf24;
  --info: #60a5fa;
  --sidebar-w: 268px;
  --topbar-h: 54px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.45);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 30px rgba(62,207,178,0.12);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t: 0.22s;
  --font: 'Sora', system-ui, -apple-system, sans-serif;
}

/* ── Light Mode ── */
.light-mode {
  --bg-primary: #f4f7fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #edf1f8;
  --bg-card: rgba(255,255,255,0.9);
  --bg-glass: rgba(255,255,255,0.7);
  --border-subtle: rgba(0,0,0,0.07);
  --border-active: rgba(62,207,178,0.45);
  --text-primary: #0d1526;
  --text-secondary: #3d5275;
  --text-tertiary: #7a90b0;
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.09);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; color: inherit; }
img { max-width: 100%; height: auto; }

/* ── Gradient Text ── */
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--purple-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ══════════════════════
   TOPBAR
   ══════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 16px 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  backdrop-filter: blur(16px);
  gap: 8px;
}

.topbar-menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.topbar-menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--t) var(--ease);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}
.topbar-logo span { color: var(--accent); }
.topbar-logo:hover { opacity: 0.88; text-decoration: none; }
.logo-icon.logo-clean { background: none; box-shadow: none; padding: 0; }
.logo-img-sm { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; }

.topbar-divider { width: 1px; height: 22px; background: var(--border-subtle); flex-shrink: 0; }

.topbar-title {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-btn {
  padding: 6px 10px;
  font-size: 0.76rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.topbar-btn:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-active);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(52,211,153,0.1);
  border: 1px solid rgba(52,211,153,0.2);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--success);
}
.status-badge.ai-active {
  background: var(--accent-glow);
  border-color: var(--border-active);
  color: var(--accent);
}

/* Icon-only topbar button */
.topbar-icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--t) var(--ease);
  flex-shrink: 0;
}
.topbar-icon-btn:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-active);
}

/* Geo state icon wrapper */
.geo-state-svg { margin-bottom: 6px; opacity: 0.9; }

/* Service arrow SVG */
.service-arrow-svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: color var(--t), transform var(--t);
}
.service-item:hover .service-arrow-svg {
  color: var(--accent);
  transform: translateX(3px);
}
.status-dot {
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0%,100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ══════════════════════
   ACCESSIBILITY PANEL
   ══════════════════════ */
.a11y-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 300px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 0 var(--radius-lg);
  padding: 18px;
  z-index: 150;
  transform: translateY(-108%);
  transition: transform 0.3s var(--ease);
  box-shadow: var(--shadow-lg);
}
.a11y-panel[aria-hidden="false"] { transform: translateY(0); }
.a11y-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 14px; }
.a11y-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.a11y-option:last-child { border-bottom: none; }
.a11y-label { font-size: 0.8rem; color: var(--text-secondary); }
.a11y-control { display: flex; align-items: center; gap: 8px; }
.a11y-btn {
  width: 30px; height: 30px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary);
  transition: all var(--t) var(--ease);
}
.a11y-btn:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.a11y-value { font-size: 0.8rem; font-weight: 600; color: var(--accent); min-width: 38px; text-align: center; }

.toggle-switch {
  width: 40px; height: 22px;
  background: var(--bg-tertiary);
  border-radius: 11px;
  position: relative;
  border: 1px solid var(--border-subtle);
  transition: all var(--t) var(--ease);
}
.toggle-switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.toggle-knob {
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
  transition: left var(--t) var(--ease);
}
.toggle-switch[aria-checked="true"] .toggle-knob { left: 20px; }

/* ══════════════════════
   MODALS (Base)
   ══════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.28s var(--ease);
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { font-size: 1.4rem; color: var(--text-tertiary); padding: 4px; transition: color var(--t); }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 18px 22px 22px; overflow-y: auto; }
.setting-group { margin-bottom: 18px; }
.setting-label { display: flex; flex-direction: column; font-size: 0.83rem; font-weight: 600; margin-bottom: 7px; }
.setting-hint { font-size: 0.7rem; font-weight: 400; color: var(--text-tertiary); margin-top: 2px; }
.setting-input-row { display: flex; gap: 7px; }
.setting-input {
  flex: 1;
  padding: 9px 13px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  outline: none;
  transition: border-color var(--t);
}
.setting-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.setting-save-btn {
  padding: 9px 14px;
  background: var(--accent);
  color: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 700;
  transition: background var(--t);
}
.setting-save-btn:hover { background: var(--accent-hover); }
.setting-status { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 5px; }
.modal-note {
  font-size: 0.73rem; color: var(--text-tertiary);
  background: var(--bg-tertiary); padding: 11px 13px;
  border-radius: var(--radius-sm); line-height: 1.55;
}
.guide-modal { max-width: 660px; }
.guide-body { padding: 22px; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.guide-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color var(--t), transform var(--t);
}
.guide-card:hover { border-color: var(--border-active); transform: translateY(-2px); }
.guide-step {
  display: inline-block; padding: 3px 9px;
  background: var(--accent-glow); color: var(--accent);
  font-size: 0.66rem; font-weight: 700; border-radius: var(--radius-sm);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em;
}
.guide-card-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 6px; }
.guide-card-desc { font-size: 0.77rem; color: var(--text-secondary); line-height: 1.55; }

/* ══════════════════════
   GEO MODAL
   ══════════════════════ */
.geo-modal { max-width: 600px; }
.geo-body { padding: 0; overflow-y: auto; max-height: calc(90dvh - 60px); }

.geo-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 36px 28px;
  gap: 10px;
}
.geo-state-icon { font-size: 2.6rem; line-height: 1; }
.geo-state-title { font-size: 1.05rem; font-weight: 700; margin-top: 4px; }
.geo-state-desc { font-size: 0.83rem; color: var(--text-secondary); line-height: 1.55; max-width: 380px; }
.geo-state-hint { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 8px; }

.geo-search-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; margin-top: 8px;
  background: linear-gradient(135deg, var(--accent), #2ab99e);
  color: var(--bg-primary);
  border-radius: var(--radius-xl);
  font-size: 0.9rem; font-weight: 700;
  transition: all var(--t) var(--ease);
  box-shadow: 0 4px 20px var(--accent-glow-md);
}
.geo-search-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 26px var(--accent-glow-md); }

.geo-cep-row { display: flex; gap: 8px; margin-top: 4px; }
.geo-cep-input {
  padding: 9px 14px; background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: var(--font); font-size: 0.85rem;
  outline: none; width: 140px; text-align: center; letter-spacing: 1px;
  transition: border-color var(--t);
}
.geo-cep-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.geo-cep-btn {
  padding: 9px 16px; background: var(--bg-tertiary);
  border: 1px solid var(--border-active); border-radius: var(--radius-sm);
  color: var(--accent); font-size: 0.82rem; font-weight: 600;
  transition: all var(--t);
}
.geo-cep-btn:hover { background: var(--accent-glow); }

/* Loading spinner */
.geo-spinner {
  width: 52px; height: 52px;
  position: relative; margin-bottom: 6px;
}
.geo-spin-ring {
  width: 100%; height: 100%;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Location label */
.geo-location-label {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  background: var(--accent-glow);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem; color: var(--text-secondary);
  flex-shrink: 0;
}
.geo-loc-pin { font-size: 0.9rem; }

/* Filter row */
.geo-filter-row {
  display: flex; gap: 6px;
  padding: 12px 20px 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.geo-filter-row::-webkit-scrollbar { height: 0; }
.geo-filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 0.73rem; font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--t);
  white-space: nowrap;
  background: transparent;
}
.geo-filter-btn.active,
.geo-filter-btn:hover {
  background: var(--accent-glow);
  border-color: var(--border-active);
  color: var(--accent);
}

/* Facility list */
.facility-list { padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.facility-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--t), transform var(--t);
  animation: fadeSlide 0.3s var(--ease) both;
}
.facility-card:hover { border-color: var(--border-active); transform: translateX(3px); }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.facility-icon-wrap {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}
.facility-info { flex: 1; min-width: 0; }
.facility-type-badge {
  display: inline-block;
  padding: 2px 8px; margin-bottom: 4px;
  border-radius: 6px;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em;
  color: white;
  text-transform: uppercase;
}
.facility-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; line-height: 1.3; }
.facility-addr { font-size: 0.72rem; color: var(--text-secondary); line-height: 1.45; }
.facility-phone { font-size: 0.72rem; color: var(--accent); margin-top: 3px; }
.facility-actions { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.facility-link {
  padding: 4px 10px;
  border: 1px solid var(--border-active);
  border-radius: 20px;
  font-size: 0.68rem; font-weight: 600; color: var(--accent);
  text-decoration: none; transition: all var(--t);
}
.facility-link:hover { background: var(--accent-glow); text-decoration: none; }
.facility-distance {
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  white-space: nowrap; flex-shrink: 0; margin-top: 2px;
}
.facility-card[data-hidden="true"] { display: none; }

.geo-osm-credit {
  padding: 10px 20px;
  font-size: 0.66rem; color: var(--text-tertiary);
  text-align: center; border-top: 1px solid var(--border-subtle);
}
.no-facilities {
  text-align: center; padding: 28px 16px;
  font-size: 0.83rem; color: var(--text-secondary);
}

/* ══════════════════════
   APP LAYOUT
   ══════════════════════ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr 270px;
  height: calc(100dvh - var(--topbar-h));
  margin-top: var(--topbar-h);
}

/* ══════════════════════
   SIDEBAR OVERLAY (mobile)
   ══════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ══════════════════════
   SIDEBAR
   ══════════════════════ */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  transition: transform 0.28s var(--ease);
}
.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.new-chat-btn {
  width: 100%; padding: 10px;
  background: linear-gradient(135deg, var(--accent-glow), var(--purple-glow));
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  font-size: 0.82rem; font-weight: 600; color: var(--accent);
  transition: all var(--t) var(--ease);
  letter-spacing: 0.01em;
}
.new-chat-btn:hover {
  background: linear-gradient(135deg, rgba(62,207,178,0.22), rgba(124,58,237,0.22));
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.sidebar-search { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.search-wrapper {
  display: flex; align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  transition: border-color var(--t);
}
.search-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-icon { width: 14px; height: 14px; color: var(--text-tertiary); margin-right: 7px; flex-shrink: 0; }
.search-input {
  flex: 1; background: transparent; border: none;
  font-size: 0.78rem; color: var(--text-primary); outline: none;
  font-family: var(--font);
}
.search-input::placeholder { color: var(--text-tertiary); }

.topics-section { flex: 1; padding: 10px; overflow-y: auto; scroll-behavior: smooth; }
.topics-section::-webkit-scrollbar { width: 4px; }
.topics-section::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 2px; }

.topic-group { margin-bottom: 14px; }
.topic-group-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; padding: 0 2px;
}
.topic-group-title {
  font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-tertiary);
  font-weight: 600;
}
.clear-history-btn {
  font-size: 0.8rem; color: var(--text-tertiary);
  padding: 2px 6px; border-radius: 4px;
  transition: all var(--t);
}
.clear-history-btn:hover { color: var(--danger); background: rgba(248,113,113,0.1); }

.topic-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem; color: var(--text-secondary);
  transition: all var(--t) var(--ease);
  margin-bottom: 1px;
}
.topic-btn:hover { background: var(--accent-glow); color: var(--text-primary); }
.topic-icon { font-size: 0.95rem; flex-shrink: 0; }

/* ── Conversation History ── */
.conv-list { display: flex; flex-direction: column; gap: 2px; min-height: 20px; }
.conv-empty {
  font-size: 0.72rem; color: var(--text-tertiary);
  padding: 6px 4px; font-style: italic;
}
.conv-item {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  transition: all var(--t) var(--ease);
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}
.conv-item:hover { background: var(--accent-glow); border-color: var(--border-subtle); }
.conv-item.active {
  background: var(--accent-glow);
  border-color: var(--border-active);
}
.conv-item-icon { font-size: 0.85rem; flex-shrink: 0; opacity: 0.7; }
.conv-item-body { flex: 1; min-width: 0; }
.conv-item-title {
  font-size: 0.77rem; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.conv-item-meta { font-size: 0.65rem; color: var(--text-tertiary); margin-top: 1px; }
.conv-item-del {
  opacity: 0; padding: 3px 6px;
  border-radius: 4px; font-size: 0.72rem;
  color: var(--text-tertiary); transition: all var(--t);
  flex-shrink: 0;
}
.conv-item:hover .conv-item-del { opacity: 1; }
.conv-item-del:hover { color: var(--danger); background: rgba(248,113,113,0.1); }

/* ── Impact Dashboard ── */
.impact-dashboard {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}
.dash-stats-row {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 6px; margin-bottom: 12px;
}
.dash-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.dash-stat-value {
  font-size: 1.25rem; font-weight: 800;
  color: var(--accent); line-height: 1;
  margin-bottom: 3px;
}
.dash-stat-label { font-size: 0.6rem; color: var(--text-tertiary); text-align: center; font-weight: 500; }

.dash-topics-chart { display: flex; flex-direction: column; gap: 6px; }
.dash-chart-label {
  font-size: 0.65rem; font-weight: 600;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 4px;
}
.dash-bar-row { display: flex; align-items: center; gap: 7px; }
.dash-bar-label {
  font-size: 0.7rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 90px; flex-shrink: 0;
}
.dash-bar-track {
  flex: 1; height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px; overflow: hidden;
}
.dash-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple-light));
  border-radius: 3px;
  transition: width 0.6s var(--ease);
}
.dash-bar-count { font-size: 0.65rem; color: var(--text-tertiary); min-width: 16px; text-align: right; }

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.access-controls { display: flex; flex-direction: column; gap: 5px; }
.access-control-btn {
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.74rem; color: var(--text-secondary);
  transition: all var(--t) var(--ease);
  text-align: left;
}
.access-control-btn:hover {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-active);
}
.access-control-btn.geo-btn {
  background: linear-gradient(135deg, var(--accent-glow), var(--purple-glow));
  border-color: var(--border-active);
  color: var(--accent);
  font-weight: 600;
}
.access-control-btn.geo-btn:hover {
  background: linear-gradient(135deg, rgba(62,207,178,0.2), rgba(124,58,237,0.2));
  transform: translateY(-1px);
}

/* ══════════════════════
   CHAT AREA
   ══════════════════════ */
.chat-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-height: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 28px 36px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

/* ── Welcome Screen ── */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: 52px 28px; min-height: 100%;
}
.welcome-icon {
  font-size: 3.5rem; margin-bottom: 18px;
  animation: floatIcon 3.5s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(62,207,178,0.3));
}
@keyframes floatIcon {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-12px) rotate(2deg); }
}
.welcome-title { font-size: 1.9rem; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.02em; }
.welcome-subtitle {
  font-size: 0.9rem; color: var(--text-secondary);
  max-width: 460px; line-height: 1.65; margin-bottom: 34px;
}
.quick-grid {
  display: grid; grid-template-columns: repeat(2,1fr);
  gap: 10px; max-width: 500px; width: 100%;
}
.quick-card {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 5px; padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: left; transition: all var(--t) var(--ease);
}
.quick-card:hover {
  background: var(--accent-glow);
  border-color: var(--border-active);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.quick-card-icon { font-size: 1.4rem; }
.quick-card-title { font-size: 0.83rem; font-weight: 700; color: var(--text-primary); }
.quick-card-desc { font-size: 0.7rem; color: var(--text-tertiary); line-height: 1.4; }

/* ── Document Analyzer ── */
.doc-analyzer { padding: 28px; display: flex; justify-content: center; }
.doc-analyzer-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); max-width: 480px; width: 100%; overflow: hidden;
}
.doc-analyzer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--bg-tertiary);
  font-size: 0.88rem; font-weight: 600;
}
.doc-close { font-size: 1.2rem; color: var(--text-tertiary); transition: color var(--t); }
.doc-close:hover { color: var(--text-primary); }
.doc-drop-zone {
  padding: 36px 18px; text-align: center;
  border: 2px dashed var(--border-subtle);
  margin: 14px; border-radius: var(--radius-md);
  transition: all var(--t) var(--ease); cursor: pointer;
}
.doc-drop-zone:hover, .doc-drop-zone.drag-active {
  border-color: var(--accent); background: var(--accent-glow);
}
.doc-drop-icon { font-size: 2.2rem; margin-bottom: 10px; }
.doc-drop-text { font-size: 0.85rem; color: var(--text-primary); margin-bottom: 6px; }
.doc-drop-hint { font-size: 0.7rem; color: var(--text-tertiary); }
.doc-preview { padding: 14px; text-align: center; }
.doc-preview img { max-height: 180px; border-radius: var(--radius-sm); margin-bottom: 10px; }
.doc-analyze-btn {
  padding: 11px 22px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white; border-radius: var(--radius-sm);
  font-size: 0.86rem; font-weight: 700;
  transition: all var(--t) var(--ease);
}
.doc-analyze-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-glow-md); }

/* ── Messages ── */
.message {
  display: flex; gap: 10px;
  margin-bottom: 18px;
  animation: msgIn 0.28s var(--ease) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0; margin-top: 2px;
}
.msg-avatar.ai { background: linear-gradient(135deg, var(--accent-glow), var(--purple-glow)); border: 1px solid var(--border-active); }
.msg-avatar.user { background: var(--bg-tertiary); border: 1px solid var(--border-subtle); }
.msg-body { max-width: 700px; }
.message.user .msg-body { align-items: flex-end; }
.msg-header {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 5px;
}
.msg-name { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); }
.msg-time { font-size: 0.65rem; color: var(--text-tertiary); }
.msg-content {
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.86rem; line-height: 1.68;
  color: var(--text-primary);
}
.message.ai .msg-content {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: 4px;
}
.message.user .msg-content {
  background: linear-gradient(135deg, rgba(62,207,178,0.13), rgba(124,58,237,0.13));
  border: 1px solid var(--border-active);
  border-top-right-radius: 4px;
}
.msg-content ul { padding-left: 14px; }
.msg-content li { margin-bottom: 5px; line-height: 1.55; list-style: none; }
.msg-content strong { color: var(--accent); font-weight: 600; }
.msg-content a { color: var(--accent); text-decoration: underline; }

/* CEP card inline */
.cep-card {
  margin-top: 10px; padding: 11px 14px;
  background: rgba(62,207,178,0.07);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-sm);
  font-size: 0.8rem; line-height: 1.55;
}
.cep-card strong { color: var(--accent); }

/* TTS Button */
.msg-tts-btn {
  margin-left: auto; padding: 3px 7px;
  font-size: 0.8rem; color: var(--text-tertiary);
  border-radius: var(--radius-sm); transition: all var(--t);
  display: flex; align-items: center;
}
.msg-tts-btn:hover { color: var(--accent); background: var(--accent-glow); }
.tts-wave { display: flex; align-items: center; gap: 2px; height: 14px; }
.wave-bar {
  width: 2px; height: 100%;
  background: var(--accent); border-radius: 2px;
  animation: waveAnim 0.5s infinite alternate;
}
.wave-bar:nth-child(1) { animation-delay: 0s; height: 40%; }
.wave-bar:nth-child(2) { animation-delay: 0.12s; height: 70%; }
.wave-bar:nth-child(3) { animation-delay: 0.24s; height: 100%; }
.wave-bar:nth-child(4) { animation-delay: 0.36s; height: 55%; }
@keyframes waveAnim { from { transform: scaleY(0.4); } to { transform: scaleY(1); } }

/* Sources + chips */
.msg-sources { margin-top: 6px; font-size: 0.7rem; color: var(--text-tertiary); }
.source-label { font-weight: 600; }
.msg-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.msg-chip {
  padding: 5px 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle); border-radius: 20px;
  font-size: 0.7rem; font-weight: 500; color: var(--text-secondary);
  transition: all var(--t) var(--ease);
}
.msg-chip:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 4px;
  padding: 13px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--text-tertiary); border-radius: 50%;
  animation: typingBounce 1.3s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ══════════════════════
   INPUT AREA
   ══════════════════════ */
.input-area {
  padding: 14px 28px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}
.input-wrapper {
  display: flex; align-items: flex-end; gap: 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  transition: all var(--t) var(--ease);
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.input-wrapper textarea {
  flex: 1; background: transparent; border: none;
  color: var(--text-primary); font-family: var(--font);
  font-size: 0.86rem; line-height: 1.5;
  resize: none; outline: none; max-height: 120px;
}
.input-wrapper textarea::placeholder { color: var(--text-tertiary); }
.input-actions { display: flex; gap: 4px; }
.input-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.95rem; transition: all var(--t) var(--ease);
  color: var(--text-tertiary);
}
.input-btn:hover { background: var(--accent-glow); color: var(--accent); }
.input-btn.send-btn { background: var(--accent); color: var(--bg-primary); font-weight: 800; font-size: 1.1rem; }
.input-btn.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.input-btn.send-btn:not(:disabled):hover { background: var(--accent-hover); transform: translateY(-1px); }
.input-btn.voice-active { background: rgba(248,113,113,0.18); color: var(--danger); animation: voicePulse 1.4s infinite; }
@keyframes voicePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.4); }
  50% { box-shadow: 0 0 0 7px rgba(248,113,113,0); }
}
.input-hint {
  display: flex; justify-content: space-between;
  font-size: 0.65rem; color: var(--text-tertiary);
  margin-top: 7px; padding: 0 3px;
}
.input-hint kbd {
  display: inline-block; padding: 1px 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 3px; font-family: var(--font);
  font-size: 0.6rem;
}

/* ══════════════════════
   RIGHT PANEL
   ══════════════════════ */
.right-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; overflow-y: auto;
  min-height: 0;
}
.right-panel::-webkit-scrollbar { width: 4px; }
.right-panel::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 2px; }
.right-panel-header { padding: 14px; border-bottom: 1px solid var(--border-subtle); }
.right-panel-title { font-size: 0.83rem; font-weight: 700; margin-bottom: 3px; }
.right-panel-sub { font-size: 0.7rem; color: var(--text-tertiary); }
.service-list { flex: 1; padding: 6px; }
.service-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px; border-radius: var(--radius-sm);
  transition: all var(--t) var(--ease); text-decoration: none; margin-bottom: 1px;
}
.service-item:hover { background: var(--accent-glow); text-decoration: none; }
.service-icon { font-size: 1.2rem; }
.service-info { flex: 1; min-width: 0; }
.service-name { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); }
.service-desc { font-size: 0.66rem; color: var(--text-tertiary); }
.service-arrow { font-size: 0.75rem; color: var(--text-tertiary); }
.right-panel-footer { padding: 10px; border-top: 1px solid var(--border-subtle); }
.disclaimer {
  display: flex; align-items: flex-start; gap: 5px;
  font-size: 0.66rem; color: var(--text-tertiary); line-height: 1.5;
}

/* ══════════════════════
   HIGH CONTRAST
   ══════════════════════ */
.high-contrast {
  --bg-primary: #000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #141414;
  --bg-card: #1a1a1a;
  --text-primary: #fff;
  --text-secondary: #ddd;
  --text-tertiary: #999;
  --accent: #00ffaa;
  --border-subtle: rgba(255,255,255,0.18);
  --border-active: rgba(0,255,170,0.5);
}

/* ══════════════════════
   SKELETON LOADER
   ══════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ══════════════════════
   RESPONSIVE
   ══════════════════════ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 240px; }
  .app-layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .right-panel { display: none; }
}

@media (max-width: 760px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: 285px;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.visible { display: block; }
  .topbar-menu-btn { display: flex; }
  .topbar-title { display: none; }
  .topbar-divider { display: none; }
  .topbar-btn { padding: 6px 8px; font-size: 0.7rem; }
  .chat-messages { padding: 16px; }
  .input-area { padding: 10px 14px 14px; }
  .quick-grid { grid-template-columns: 1fr; }
  .welcome-title { font-size: 1.5rem; }
  .guide-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar global ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
