/* =============================================
   CLINICA CRM — Grupo Lopes Dark System
   Background #0f0f0f · Lime #A3E635 · Space Grotesk
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ─── DESIGN TOKENS ──────────────────────────── */
:root {
  /* Sidebar */
  --sb-bg:          #0a0a0a;
  --sb-hover:       #161616;
  --sb-active:      #1a1a1a;
  --sb-border:      rgba(255,255,255,.06);
  --sb-text:        rgba(255,255,255,.38);
  --sb-text-active: #ffffff;

  /* App surfaces */
  --bg:             #0f0f0f;
  --surface:        #161616;
  --surface2:       #1a1a1a;
  --surface3:       #202020;
  --border:         rgba(255,255,255,.07);
  --border2:        rgba(255,255,255,.12);

  /* Brand — Lime Grupo Lopes */
  --lime:           #A3E635;
  --lime-h:         #8fcf1e;
  --lime-dim:       #c6f16a;
  --lime-bg:        rgba(163,230,53,.08);
  --lime-border:    rgba(163,230,53,.20);
  --lime-text:      #0a1400;
  --lime-grad:      linear-gradient(135deg, #bef264 0%, #A3E635 55%, #65a30d 100%);

  /* Text */
  --text:           #f5f5f5;
  --text-2:         #a0a0a0;
  --text-3:         #606060;
  --text-dim:       #3a3a3a;

  /* Status palette */
  --c-novo:         #60a5fa;
  --c-novo-bg:      rgba(96,165,250,.10);
  --c-novo-soft:    rgba(96,165,250,.15);
  --c-conv:         #fbbf24;
  --c-conv-bg:      rgba(251,191,36,.10);
  --c-conv-soft:    rgba(251,191,36,.15);
  --c-agend:        #a78bfa;
  --c-agend-bg:     rgba(167,139,250,.10);
  --c-agend-soft:   rgba(167,139,250,.15);
  --c-real:         #34d399;
  --c-real-bg:      rgba(52,211,153,.10);
  --c-real-soft:    rgba(52,211,153,.15);
  --c-cancel:       #f87171;
  --c-cancel-bg:    rgba(248,113,113,.10);
  --c-cancel-soft:  rgba(248,113,113,.15);

  /* Geometry */
  --r:      10px;
  --r-sm:    7px;
  --r-xs:    5px;
  --r-pill: 999px;

  /* Shadows */
  --sh-xs:   0 1px 3px rgba(0,0,0,.4);
  --sh-sm:   0 2px 8px rgba(0,0,0,.5);
  --sh:      0 4px 20px rgba(0,0,0,.55);
  --sh-lg:   0 12px 40px rgba(0,0,0,.65);
  --sh-modal:0 24px 64px rgba(0,0,0,.75);
  --sh-lime: 0 4px 18px rgba(163,230,53,.22);

  /* Type */
  --font:   'Space Grotesk', system-ui, sans-serif;
  --mono:   'DM Mono', monospace;
  --sb-w:   220px;
}

/* ─── RESET ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  letter-spacing: -.01em;
}
a { color: var(--lime); text-decoration: none; }
small {
  font-size: 11.5px; color: var(--text-2);
  display: block; margin-top: 5px; line-height: 1.5;
}
small a { color: var(--lime); }
strong { font-weight: 600; }

#app { display: flex; height: 100vh; }

/* =============================================
   SIDEBAR
   ============================================= */
#sidebar {
  width: var(--sb-w);
  min-width: var(--sb-w);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sb-border);
}

.logo-icon {
  width: 34px; height: 34px;
  background: var(--lime-grad);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--lime-text);
  flex-shrink: 0;
  box-shadow: var(--sh-lime);
  font-family: var(--font);
}

.logo-info { display: flex; flex-direction: column; overflow: hidden; }
.logo-name {
  font-size: 13px; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logo-sub {
  font-size: 9.5px; color: var(--sb-text);
  font-weight: 500; margin-top: 1px;
  letter-spacing: .06em; text-transform: uppercase;
}

.nav-list { list-style: none; padding: 10px 8px; flex: 1; }
.nav-list li + li { margin-top: 1px; }

.nav-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: none; background: transparent;
  color: var(--sb-text);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; border-radius: var(--r-sm);
  transition: background .12s, color .12s;
  text-align: left;
}
.nav-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; flex-shrink: 0;
  opacity: .5; transition: opacity .12s;
}
.nav-btn:hover { background: var(--sb-hover); color: rgba(255,255,255,.7); }
.nav-btn:hover svg { opacity: .8; }

.nav-btn.active {
  background: var(--lime-bg);
  color: var(--lime);
  font-weight: 600;
  border: 1px solid var(--lime-border);
}
.nav-btn.active svg { stroke: var(--lime); opacity: 1; }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sb-border);
}

.followup-indicator {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--sb-text); font-weight: 500;
}

.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-real); flex-shrink: 0;
}
.dot.pulse { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.7); }
}

/* =============================================
   MAIN CONTENT
   ============================================= */
#main {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#page-title {
  font-size: 14px; font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}

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

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--lime-grad);
  color: var(--lime-text);
  border: none; border-radius: var(--r-sm);
  padding: 8px 16px;
  font-size: 12.5px; font-weight: 700; font-family: var(--font);
  cursor: pointer;
  transition: filter .14s, box-shadow .14s, transform .1s;
  box-shadow: var(--sh-lime);
  letter-spacing: -.01em;
}
.btn-primary svg { stroke: var(--lime-text); fill: none; }
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 22px rgba(163,230,53,.32); }
.btn-primary:active { transform: scale(.97); }

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 500; font-family: var(--font);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.btn-outline:hover { border-color: var(--lime-border); color: var(--lime); background: var(--lime-bg); }

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* =============================================
   PAGES
   ============================================= */
.page { display: none; flex: 1; overflow-y: auto; padding: 20px; }
.page.active { display: flex; flex-direction: column; }

/* =============================================
   DASHBOARD
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 14px 12px;
  cursor: pointer;
  transition: border-color .14s, transform .12s, box-shadow .14s;
  box-shadow: var(--sh-xs);
  display: flex; flex-direction: column; gap: 10px;
}
.stat-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
}

.stat-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.stat-icon.all    { background: var(--surface3); color: var(--text-2); }
.stat-icon.novo   { background: var(--c-novo-bg);   color: var(--c-novo); }
.stat-icon.conv   { background: var(--c-conv-bg);   color: var(--c-conv); }
.stat-icon.agend  { background: var(--c-agend-bg);  color: var(--c-agend); }
.stat-icon.real   { background: var(--c-real-bg);   color: var(--c-real); }
.stat-icon.cancel { background: var(--c-cancel-bg); color: var(--c-cancel); }

.stat-info { display: flex; flex-direction: column; }
.stat-num {
  font-size: 24px; font-weight: 700;
  color: var(--text); line-height: 1;
  letter-spacing: -.04em;
}
.stat-label {
  font-size: 11px; font-weight: 500;
  color: var(--text-2); margin-top: 4px;
}

/* ─── FUNIL ──────────────────────────────────── */
.funnel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--sh-xs);
}

.funnel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.funnel-header h3 {
  font-size: 12px; font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: .07em;
}
.funnel-rate {
  font-family: var(--mono);
  font-size: 12px; font-weight: 500;
  color: var(--lime); background: var(--lime-bg);
  border: 1px solid var(--lime-border);
  border-radius: var(--r-pill);
  padding: 3px 10px;
}

.funnel-stages { display: flex; flex-direction: column; gap: 9px; }

.funnel-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px 48px;
  align-items: center;
  gap: 10px;
}
.funnel-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.funnel-bar-wrap {
  height: 6px; background: var(--surface3); border-radius: var(--r-pill); overflow: hidden;
}
.funnel-bar {
  height: 100%; border-radius: var(--r-pill);
  transition: width .6s cubic-bezier(.22,1,.36,1);
  opacity: .85;
}
.funnel-count {
  font-size: 13px; font-weight: 700; color: var(--text);
  text-align: right;
  font-family: var(--mono);
}
.funnel-conv {
  font-size: 11px; font-weight: 600;
  text-align: right;
  font-family: var(--mono);
}

/* ─── DASH ROW ───────────────────────────────── */
.dash-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; flex: 1;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--sh-xs);
  display: flex; flex-direction: column; gap: 12px;
}

.dash-card h3 {
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: .07em;
}

.followup-list { display: flex; flex-direction: column; gap: 4px; }

.followup-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.followup-item:hover { background: var(--surface2); border-color: var(--border); }

.fi-name { font-size: 13px; font-weight: 600; color: var(--text); }
.fi-time { font-size: 11px; color: var(--text-2); margin-top: 1px; }
.fi-badge {
  margin-left: auto; flex-shrink: 0;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--r-pill);
}

/* =============================================
   KANBAN TOOLBAR
   ============================================= */
.kanban-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding-bottom: 12px; flex-shrink: 0;
}

.kanban-filters {
  display: flex; align-items: center; gap: 8px; flex: 1;
}

.kanban-search-input { flex: 1; max-width: 280px; }
.kanban-filter-select { max-width: 160px; }

.kanban-toolbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.btn-view-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 12px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all .12s;
}
.btn-view-toggle:hover { border-color: var(--border2); color: var(--text); }
.btn-view-toggle.active {
  background: var(--lime-bg);
  border-color: var(--lime-border);
  color: var(--lime); font-weight: 600;
}
.btn-export { flex-shrink: 0; }

/* =============================================
   KANBAN
   ============================================= */
#page-kanban { padding: 14px 14px 0; overflow: hidden; }
#page-kanban.active {
  display: flex; flex-direction: column;
  height: calc(100vh - 54px);
}

#kanban-view { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.kanban-board {
  display: flex; gap: 8px;
  flex: 1; overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-col {
  display: flex; flex-direction: column;
  width: 256px; min-width: 256px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.col-header {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}

.col-dot {
  width: 7px; height: 7px;
  border-radius: 50%; flex-shrink: 0;
}
.col-header.novo   .col-dot { background: var(--c-novo); }
.col-header.conv   .col-dot { background: var(--c-conv); }
.col-header.agend  .col-dot { background: var(--c-agend); }
.col-header.real   .col-dot { background: var(--c-real); }
.col-header.cancel .col-dot { background: var(--c-cancel); }

.col-title {
  flex: 1;
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em;
}

.col-count {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-pill);
}

.col-cards {
  flex: 1; overflow-y: auto;
  padding: 7px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 48px;
}
.col-cards.sortable-over {
  background: var(--lime-bg);
  outline: 2px dashed var(--lime-border);
  outline-offset: -4px;
  border-radius: var(--r-sm);
}

.btn-add-card {
  width: 100%; padding: 8px;
  border: none; background: transparent;
  color: var(--text-dim);
  font-size: 12px; font-weight: 500; font-family: var(--font);
  cursor: pointer;
  transition: color .12s, background .12s;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-add-card:hover { color: var(--lime); background: var(--lime-bg); }

/* ─── LEAD CARDS ─────────────────────────────── */
.lead-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 11px;
  cursor: grab;
  transition: border-color .14s, transform .1s, box-shadow .14s;
  box-shadow: var(--sh-xs);
  user-select: none;
}
.lead-card:hover {
  border-color: var(--border2);
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
}
.lead-card.sortable-ghost { opacity: .25; transform: rotate(2deg); }
.lead-card.sortable-chosen {
  cursor: grabbing;
  box-shadow: var(--sh);
  border-color: var(--lime-border);
  transform: scale(1.02) rotate(.5deg);
}

.card-top {
  display: flex; align-items: flex-start; gap: 8px;
  margin-bottom: 7px;
}

.card-avatar {
  width: 28px; height: 28px;
  border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: #fff;
}

.card-info { flex: 1; min-width: 0; }
.card-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-phone { font-size: 10.5px; color: var(--text-2); margin-top: 1px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.card-tag {
  font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: var(--r-pill);
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--text-2);
}

.card-footer { display: flex; align-items: center; justify-content: space-between; }
.card-time { font-size: 10px; color: var(--text-3); font-weight: 500; }

.card-followup-badge {
  display: flex; align-items: center; gap: 3px;
  background: var(--c-cancel-bg); color: var(--c-cancel);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: var(--r-pill);
  border: 1px solid rgba(248,113,113,.2);
}

/* ─── LIST VIEW ──────────────────────────────── */
#list-view { flex: 1; overflow: auto; }

.leads-table-wrap { min-width: 700px; }

.leads-table {
  width: 100%; border-collapse: collapse;
}

.leads-table thead th {
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: .07em;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}

.table-row {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.table-row:hover { background: var(--surface); }

.leads-table tbody td {
  padding: 10px 12px;
  font-size: 12.5px; color: var(--text-2);
  vertical-align: middle;
}

.table-patient {
  display: flex; align-items: center; gap: 8px;
}
.table-name { font-size: 13px; font-weight: 600; color: var(--text); }
.table-phone { font-family: var(--mono); font-size: 12px; }
.table-time { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.table-empty {
  text-align: center; color: var(--text-3);
  padding: 32px 16px !important; font-size: 13px;
}

/* ─── STATUS PILLS ───────────────────────────── */
.status-pill {
  display: inline-block;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 9px; border-radius: var(--r-pill);
}
.status-pill.status-novo_lead   { background: var(--c-novo-bg);   color: var(--c-novo); }
.status-pill.status-conversando { background: var(--c-conv-bg);   color: var(--c-conv); }
.status-pill.status-agendada    { background: var(--c-agend-bg);  color: var(--c-agend); }
.status-pill.status-realizada   { background: var(--c-real-bg);   color: var(--c-real); }
.status-pill.status-cancelada   { background: var(--c-cancel-bg); color: var(--c-cancel); }

/* =============================================
   CONVERSATIONS
   ============================================= */
#page-conversations { padding: 0; overflow: hidden; }
#page-conversations.active {
  display: flex; flex-direction: column;
  height: calc(100vh - 54px);
}

.chat-layout { display: flex; flex: 1; overflow: hidden; }

.chat-sidebar {
  width: 264px; min-width: 264px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}

.chat-sidebar-header {
  padding: 11px;
  border-bottom: 1px solid var(--border);
}

.input-search {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px; font-family: var(--font);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.input-search:focus {
  border-color: var(--lime-border);
  box-shadow: 0 0 0 3px rgba(163,230,53,.10);
  background: var(--surface);
}
.input-search::placeholder { color: var(--text-3); }

.conv-list {
  flex: 1; overflow-y: auto;
  padding: 5px;
  display: flex; flex-direction: column; gap: 1px;
}

.conv-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .1s;
  border: 1px solid transparent;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active {
  background: var(--lime-bg);
  border-color: var(--lime-border);
}

.conv-avatar {
  width: 34px; height: 34px;
  border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}

.conv-info { flex: 1; min-width: 0; }
.conv-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-last {
  font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.conv-time { font-size: 10px; color: var(--text-3); flex-shrink: 0; }

.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-header {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-avatar {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--surface3);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}

.chat-lead-name { font-size: 14px; font-weight: 700; color: var(--text); }
.chat-lead-phone { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.chat-header-actions { margin-left: auto; }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 9px;
  background: var(--bg);
}

.chat-empty {
  margin: auto; color: var(--text-3);
  font-size: 13px; font-weight: 500; text-align: center;
}

.msg-bubble { max-width: 66%; display: flex; flex-direction: column; }
.msg-bubble.sent   { align-self: flex-end; align-items: flex-end; }
.msg-bubble.recv,
.msg-bubble.ai     { align-self: flex-start; align-items: flex-start; }

.msg-ai-badge {
  font-size: 10px; font-weight: 700;
  color: var(--lime); margin-bottom: 3px;
  font-family: var(--mono);
}

.msg-text {
  padding: 9px 13px; border-radius: 12px;
  font-size: 13px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
}
.msg-bubble.sent .msg-text {
  background: var(--lime-grad); color: var(--lime-text);
  border-bottom-right-radius: 3px;
  box-shadow: var(--sh-lime);
}
.msg-bubble.recv .msg-text {
  background: var(--surface); color: var(--text);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border);
}
.msg-bubble.ai .msg-text {
  background: var(--lime-bg); color: var(--text);
  border: 1px solid var(--lime-border);
  border-bottom-left-radius: 3px;
}

.msg-time { font-size: 10px; color: var(--text-3); margin-top: 4px; font-weight: 500; }

.chat-input-row {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.ai-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2); flex-shrink: 0;
}

.chat-text-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px; font-family: var(--font);
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.chat-text-input:focus {
  border-color: var(--lime-border);
  box-shadow: 0 0 0 3px rgba(163,230,53,.10);
  background: var(--surface);
}
.chat-text-input:disabled { opacity: .35; cursor: not-allowed; }
.chat-text-input::placeholder { color: var(--text-3); }

.btn-send {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--lime-grad); border: none; color: var(--lime-text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter .14s, transform .1s;
  flex-shrink: 0; box-shadow: var(--sh-lime);
}
.btn-send svg { stroke: var(--lime-text); fill: none; }
.btn-send:hover { filter: brightness(1.1); }
.btn-send:active { transform: scale(.93); }
.btn-send:disabled { opacity: .2; cursor: not-allowed; pointer-events: none; }

/* =============================================
   AGENDA
   ============================================= */
.agenda-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}

.agenda-filters { display: flex; gap: 5px; }

.btn-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 6px 13px;
  font-size: 12px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all .12s;
}
.btn-filter:hover { border-color: var(--border2); color: var(--text); }
.btn-filter.active {
  background: var(--lime-bg);
  border-color: var(--lime-border);
  color: var(--lime); font-weight: 700;
}

.agenda-list { display: flex; flex-direction: column; gap: 7px; }

.appt-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 13px 16px;
  transition: border-color .14s, transform .1s, box-shadow .14s;
  cursor: pointer; box-shadow: var(--sh-xs);
}
.appt-card:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

.appt-date-block {
  display: flex; flex-direction: column; align-items: center;
  background: var(--lime-bg);
  border: 1px solid var(--lime-border);
  border-radius: var(--r-sm);
  padding: 7px 11px; min-width: 50px; text-align: center;
}
.appt-day   { font-size: 20px; font-weight: 700; color: var(--lime); line-height: 1; }
.appt-month { font-size: 10px; font-weight: 700; color: var(--lime); text-transform: uppercase; letter-spacing: .07em; opacity: .8; }

.appt-info { flex: 1; }
.appt-name      { font-size: 14px; font-weight: 700; color: var(--text); }
.appt-specialty { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.appt-time      { font-size: 12px; color: var(--c-agend); font-weight: 600; margin-top: 3px; }

.appt-actions { display: flex; gap: 6px; }

/* =============================================
   CONFIG
   ============================================= */
.config-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }

.config-tabs {
  list-style: none;
  display: flex; flex-direction: column; gap: 2px;
  width: 178px; flex-shrink: 0;
}

.config-tab {
  width: 100%; text-align: left;
  padding: 8px 12px;
  border: none; background: transparent;
  color: var(--text-2);
  font-size: 12.5px; font-weight: 500; font-family: var(--font);
  cursor: pointer; border-radius: var(--r-sm);
  transition: background .1s, color .1s;
}
.config-tab:hover { background: var(--surface2); color: var(--text); }
.config-tab.active {
  background: var(--lime-bg);
  border: 1px solid var(--lime-border);
  color: var(--lime); font-weight: 700;
}

.config-content { flex: 1; overflow-y: auto; }
.config-panel { display: none; }
.config-panel.active { display: block; }
.config-panel h2 {
  font-size: 17px; font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 18px; color: var(--text);
}

.api-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--sh-xs);
}
.api-section h3 { font-size: 13px; font-weight: 700; margin-bottom: 13px; color: var(--text); }

/* ─── FORMS ──────────────────────────────────── */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-2); letter-spacing: .01em;
}

.input-field {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px; font-family: var(--font); font-weight: 400;
  outline: none; width: 100%;
  transition: border-color .14s, box-shadow .14s;
}
.input-field:focus {
  border-color: var(--lime-border);
  box-shadow: 0 0 0 3px rgba(163,230,53,.10);
  background: var(--surface);
}
.input-field:hover:not(:focus) { border-color: var(--border2); }
.input-field::placeholder { color: var(--text-3); }
.input-field option { background: var(--surface2); color: var(--text); }
textarea.input-field { resize: vertical; line-height: 1.55; }
.btn-save { margin-top: 4px; }

/* ─── LIST EDITOR ─────────────────────────────── */
.list-editor { display: flex; flex-direction: column; gap: 12px; }
.list-add-row { display: flex; gap: 8px; }
.list-add-row .input-field { flex: 1; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px 11px 4px 12px;
  font-size: 12px; font-weight: 500; color: var(--text);
  box-shadow: var(--sh-xs);
}
.tag-remove {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
  transition: color .12s; display: flex; align-items: center;
}
.tag-remove:hover { color: var(--c-cancel); }

/* ─── TOGGLE ──────────────────────────────────── */
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.toggle-label { position: relative; cursor: pointer; flex-shrink: 0; }
.toggle-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: block; width: 38px; height: 21px;
  background: var(--surface3); border-radius: var(--r-pill);
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s; position: relative;
}
.toggle-track::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--text-3); transition: transform .2s, background .2s;
}
.toggle-label input:checked + .toggle-track { background: var(--lime-bg); border-color: var(--lime-border); }
.toggle-label input:checked + .toggle-track::after { transform: translateX(17px); background: var(--lime); }

/* ─── CHECKBOXES ──────────────────────────────── */
.checkbox-group { display: flex; flex-direction: column; gap: 9px; }
.checkbox-group label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer;
}
.checkbox-group input[type=checkbox] { accent-color: var(--lime); width: 14px; height: 14px; }

/* ─── INFO BOX ────────────────────────────────── */
.info-box {
  background: var(--lime-bg);
  border: 1px solid var(--lime-border);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: 12px; color: var(--text-2); line-height: 1.65;
}
.info-box strong { color: var(--lime); }

/* =============================================
   MODALS
   ============================================= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  box-shadow: var(--sh-modal);
  display: flex; flex-direction: column;
  max-height: 90vh; overflow: hidden;
  width: 100%;
  animation: slideUp .2s cubic-bezier(.32,.72,0,1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-lead { max-width: 820px; }
.modal-sm   { max-width: 450px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}
.modal-header h2 {
  font-size: 15px; font-weight: 700;
  letter-spacing: -.025em; color: var(--text);
}

.modal-close {
  background: var(--surface3); border: 1px solid var(--border);
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-2);
  cursor: pointer; transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--c-cancel-bg); color: var(--c-cancel); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}

/* ─── LEAD DETAIL ─────────────────────────────── */
.lead-detail-layout {
  display: grid; grid-template-columns: 1fr 192px; gap: 18px;
}
.lead-detail-side { display: flex; flex-direction: column; gap: 10px; }

.lead-info-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px;
  display: flex; flex-direction: column; align-items: center;
  gap: 9px; text-align: center;
}

.lead-avatar-big {
  width: 62px; height: 62px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
}

.lead-meta {
  font-size: 11px; color: var(--text-2);
  line-height: 2.1; width: 100%; text-align: left;
}

.lead-actions-panel { display: flex; flex-direction: column; gap: 6px; }
.btn-action {
  width: 100%; padding: 8px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-2);
  font-size: 12px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all .12s; text-align: left;
}
.btn-action:hover { background: var(--surface3); border-color: var(--border2); }
.btn-action.btn-whatsapp:hover { border-color: rgba(52,211,153,.3); color: var(--c-real); background: var(--c-real-bg); }
.btn-action.btn-calendar:hover { border-color: rgba(167,139,250,.25); color: var(--c-agend); background: var(--c-agend-bg); }
.btn-action.btn-danger:hover   { border-color: rgba(248,113,113,.25); color: var(--c-cancel); background: var(--c-cancel-bg); }

/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 11px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-lg);
  opacity: 0; transform: translateY(8px) scale(.97);
  transition: all .2s cubic-bezier(.32,.72,0,1);
  pointer-events: none; max-width: 300px; color: var(--text);
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.success { border-left: 3px solid var(--c-real); }
.toast.error   { border-left: 3px solid var(--c-cancel); }
.toast.info    { border-left: 3px solid var(--lime); }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 12px; color: var(--text-3);
  font-size: 12px; font-weight: 500; text-align: center; gap: 7px;
}
.empty-state .empty-icon { font-size: 24px; opacity: .35; }

/* =============================================
   SCROLLBARS
   ============================================= */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ─── ADMIN INFO / LOGOUT ─────────────────────── */
.admin-info {
  margin-top: 9px;
  display: flex; align-items: center; justify-content: space-between; gap: 7px;
}
.admin-email {
  font-size: 10px; color: var(--sb-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.btn-logout {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid rgba(255,255,255,.1);
  color: var(--sb-text); border-radius: var(--r-xs);
  padding: 4px 8px; font-size: 11px; font-family: var(--font);
  cursor: pointer; transition: background .12s, color .12s;
  white-space: nowrap; flex-shrink: 0;
}
.btn-logout:hover { background: rgba(248,113,113,.12); color: #fca5a5; border-color: rgba(248,113,113,.25); }

/* ─── FOCUS ───────────────────────────────────── */
:focus-visible { outline: 2px solid var(--lime-border); outline-offset: 2px; }
