/* IAdmin Painel - alinhado visualmente ao site iadmin.ai */

:root, [data-theme="light"] {
  --bg:         #faf7ff;
  --bg-alt:     #ffffff;
  --bg-soft:    #f3edff;

  --p900: #1a0030;
  --p600: #6a0dad;
  --p500: #8020c8;
  --p400: #9b4fff;
  --p300: #7b2fd4;
  --p100: #ede0ff;

  --gold:  #c48f00;
  --gold2: #e0a800;
  --goldS: rgba(180,120,0,.09);

  --b1:   rgba(106,13,173,.18);
  --b2:   rgba(106,13,173,.10);

  --card-bg:      #ffffff;
  --card-hover:   #faf5ff;
  --card-border:  rgba(106,13,173,.12);
  --card-border2: rgba(106,13,173,.3);

  --text-head:  #0f0820;
  --text-body:  rgba(15,8,32,.78);
  --text-muted: rgba(15,8,32,.5);
  --text-dim:   rgba(15,8,32,.32);

  --success: #16a34a;
  --danger:  #dc2626;
  --info:    #2563eb;

  --shadow-sm: 0 1px 2px rgba(15,8,32,.06);
  --shadow:    0 4px 16px rgba(106,13,173,.08);
  --shadow-lg: 0 16px 50px rgba(106,13,173,.14);

  --radius: 14px;
  --radius-lg: 20px;

  --nav-bg: rgba(255,255,255,.85);
}

[data-theme="dark"] {
  --bg:         #07030e;
  --bg-alt:     #0f0820;
  --bg-soft:    #15102b;

  --p900: #1a0030;
  --p600: #6a0dad;
  --p500: #8020c8;
  --p400: #9b4fff;
  --p300: #b97fff;
  --p100: #ede0ff;

  --gold:  #f5c518;
  --gold2: #ffd94a;
  --goldS: rgba(245,197,24,.12);

  --b1:   rgba(155,79,255,.22);
  --b2:   rgba(155,79,255,.10);

  --card-bg:      #0f0820;
  --card-hover:   #160f2e;
  --card-border:  rgba(155,79,255,.14);
  --card-border2: rgba(155,79,255,.28);

  --text-head:  #ffffff;
  --text-body:  rgba(255,255,255,.78);
  --text-muted: rgba(255,255,255,.5);
  --text-dim:   rgba(255,255,255,.32);

  --shadow:    0 8px 30px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);

  --nav-bg: rgba(15,8,32,.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02', 'cv11';
  font-size: 15px;
  line-height: 1.55;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, button { outline: none; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--p400); }

/* ============ LOGIN ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 20%, rgba(155,79,255,.10), transparent 45%),
    radial-gradient(circle at 82% 80%, rgba(245,197,24,.06), transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 48px 44px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeInUp .5s cubic-bezier(.34,1.4,.64,1);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  display: inline-flex;
  align-items: baseline;
  margin-bottom: 28px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 1.25rem;
  letter-spacing: -.02em;
  box-shadow: 0 6px 20px rgba(155,79,255,.35);
}
.logo-text {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.55rem;
  margin-left: 4px;
  color: var(--text-head);
  letter-spacing: -.02em;
}
.login-card h1 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.4rem;
  margin-bottom: 6px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text-head);
}
.login-sub {
  color: var(--text-muted);
  font-size: .92rem;
  margin-bottom: 32px;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 11px;
  color: var(--text-head);
  font-size: .95rem;
  font-family: inherit;
  transition: all .2s;
}
.login-card input::placeholder { color: var(--text-dim); }
.login-card input:focus {
  border-color: var(--p400);
  background: var(--card-bg);
  box-shadow: 0 0 0 4px rgba(155,79,255,.12);
}
.login-card button[type="submit"] {
  margin-top: 8px;
  padding: 14px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  font-weight: 700;
  font-size: .98rem;
  letter-spacing: .2px;
  transition: all .25s;
  box-shadow: 0 6px 20px rgba(155,79,255,.3);
}
.login-card button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(155,79,255,.4);
}
.login-card button[type="submit"]:disabled { opacity: .55; cursor: wait; }
.login-err {
  min-height: 20px;
  color: var(--danger);
  font-size: .85rem;
  margin-top: 4px;
}
.login-back {
  display: inline-block;
  margin-top: 28px;
  color: var(--text-muted);
  font-size: .85rem;
  transition: color .2s;
}
.login-back:hover { color: var(--p400); }

/* ============ APP ============ */
.app {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-alt);
  border-right: 1px solid var(--card-border);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  display: flex;
  align-items: baseline;
  padding: 0 8px 4px;
}
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: .92rem;
  font-weight: 500;
  transition: all .18s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover {
  background: var(--bg-soft);
  color: var(--text-head);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(155,79,255,.12), rgba(155,79,255,.04));
  color: var(--text-head);
  border: 1px solid var(--card-border2);
}
.nav-badge {
  margin-left: auto;
  background: var(--goldS);
  color: var(--gold);
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.sidebar-footer {
  padding-top: 18px;
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-info { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { font-size: .85rem; font-weight: 600; color: var(--text-head); }
.user-email { font-size: .72rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

.main {
  padding: 32px 38px;
  min-width: 0;
  background: var(--bg);
}
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.main-header h1 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text-head);
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(22,163,74,.08);
  border: 1px solid rgba(22,163,74,.22);
  border-radius: 999px;
  color: var(--success);
  font-size: .76rem;
  font-weight: 600;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px rgba(22,163,74,.5);
  animation: livePulse 2s infinite;
}
@keyframes livePulse { 50% { opacity: .35; } }

/* ============ DASHBOARD CARDS — compactos inline ============ */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 1080px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px)  { .cards { grid-template-columns: 1fr; } }
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, border-color .18s, box-shadow .2s;
  overflow: hidden;
  min-width: 0;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--card-border2);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  color: var(--p500);
  transition: all .25s;
  flex-shrink: 0;
}
.card-icon svg { width: 15px; height: 15px; }
.card:hover .card-icon { background: var(--p400); color: #fff; }
.card-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 700;
  background: rgba(22,163,74,.08);
  color: var(--success);
  border: 1px solid rgba(22,163,74,.18);
}
.card-trend.down {
  background: rgba(220,38,38,.08);
  color: var(--danger);
  border-color: rgba(220,38,38,.2);
}
.card-trend.neutral {
  background: var(--bg-soft);
  color: var(--text-dim);
  border-color: var(--card-border);
}
.card-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-value {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--text-head);
}
.card-sub {
  margin-top: 4px;
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-spark {
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 60px; height: 20px;
  opacity: .8;
  pointer-events: none;
}

/* ============ PANELS ============ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.panel h3 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1rem;
  margin-bottom: 16px;
  font-weight: 700;
  color: var(--text-head);
}
.chart-wrap { position: relative; height: 240px; }

/* ============ LEADS LIST (cards) ============ */
.leads-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lead-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: all .18s;
}
.lead-card:hover {
  border-color: var(--card-border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.lead-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  font-family: "Bricolage Grotesque", sans-serif;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(155,79,255,.28);
}
.lead-info { min-width: 0; }
.lead-name {
  font-weight: 700;
  font-size: .98rem;
  color: var(--text-head);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.lead-empresa-badge {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  color: var(--p500);
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
}
.lead-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .8rem;
  color: var(--text-muted);
}
.lead-meta span { display: flex; align-items: center; gap: 5px; }
.lead-meta svg { width: 13px; height: 13px; opacity: .7; }
.lead-stat {
  text-align: center;
  padding: 0 12px;
  border-left: 1px solid var(--card-border);
}
.lead-stat-num {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-head);
  line-height: 1;
}
.lead-stat-lbl {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 600;
}
.lead-when {
  font-size: .76rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}
.lead-when-strong { color: var(--text-head); font-weight: 600; font-size: .82rem; display: block; }

.lead-actions {
  display: flex;
  gap: 6px;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--card-border2);
  color: var(--text-head);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.icon-btn.wa:hover { background: #25d366; color: #fff; border-color: #25d366; }
.icon-btn.chat:hover { background: var(--p400); color: #fff; border-color: var(--p400); }
.icon-btn.copy:hover { background: var(--gold2); color: #fff; border-color: var(--gold2); }
.icon-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Tooltip nativo customizado */
.icon-btn[data-tip] { position: relative; }
.icon-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text-head);
  color: var(--bg-alt);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all .15s;
  box-shadow: 0 4px 14px rgba(15,8,32,.2);
}
.icon-btn[data-tip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-head);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.icon-btn[data-tip]:hover::after,
.icon-btn[data-tip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============ CONVERSAS LIST ============ */
.convs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.conv-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all .15s;
}
.conv-card { cursor: pointer; }
.conv-card:hover {
  border-color: var(--card-border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.conv-card .conv-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.conv-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.conv-icon svg { width: 17px; height: 17px; }
.conv-icon.user { background: rgba(155,79,255,.12); color: var(--p500); }
.conv-icon.assistant { background: rgba(245,197,24,.14); color: var(--gold2); }
.conv-body { min-width: 0; }
.conv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.conv-author {
  font-weight: 700;
  font-size: .85rem;
  color: var(--text-head);
}
.conv-tipo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .66rem;
  font-weight: 600;
  color: var(--text-muted);
}
.conv-tipo-badge svg { width: 10px; height: 10px; }
.conv-msg {
  font-size: .88rem;
  color: var(--text-body);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.conv-when {
  font-size: .74rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

@media (max-width: 800px) {
  .lead-card { grid-template-columns: auto 1fr; gap: 12px; }
  .lead-stat, .lead-when { display: none; }
  .lead-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .conv-card { grid-template-columns: auto 1fr; }
  .conv-when { grid-column: 2; text-align: left; margin-top: 4px; }
}

/* ============ Paginação ============ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.pagination-info {
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.pagination-info strong { color: var(--text-head); font-weight: 700; }
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-head);
  font-size: .86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--p400);
  color: var(--p500);
  background: var(--bg-soft);
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-btn.active {
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  border-color: var(--p400);
  box-shadow: 0 4px 12px rgba(155,79,255,.3);
}
.page-btn.active:hover { color: #fff; }
.page-ellipsis {
  padding: 0 8px;
  color: var(--text-dim);
  font-weight: 700;
}
.page-btn svg { width: 14px; height: 14px; }

/* ============ TOOLBAR + TABLE ============ */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 220px;
  padding: 11px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-head);
  font-size: .9rem;
  font-family: inherit;
  transition: all .18s;
}
.search-input:focus { border-color: var(--p400); box-shadow: 0 0 0 4px rgba(155,79,255,.1); }
.search-input::placeholder { color: var(--text-dim); }

.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 14px 18px;
  text-align: left;
  font-size: .88rem;
  border-bottom: 1px solid var(--card-border);
}
th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
td { color: var(--text-body); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--bg-soft); }
tbody tr:last-child td { border-bottom: none; }
.action-btn {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text-head);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 500;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.action-btn:hover { background: var(--p400); color: #fff; border-color: var(--p400); }
.action-btn + .action-btn { margin-left: 6px; }
.action-btn.wa {
  background: rgba(22,163,74,.08);
  border-color: rgba(22,163,74,.22);
  color: var(--success);
}
.action-btn.wa:hover { background: var(--success); color: #fff; border-color: var(--success); }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  font-size: .9rem;
}

/* ============ CONFIG (seções colapsáveis) ============ */
.config-sections { display: flex; flex-direction: column; gap: 14px; }

.config-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color .15s;
}
.config-section:hover { border-color: var(--card-border2); }

.config-section-head {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.config-section-head:hover { background: var(--bg-soft); }

.config-section-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(155,79,255,.15), rgba(155,79,255,.05));
  color: var(--p500);
  flex-shrink: 0;
  border: 1px solid var(--card-border);
}
.config-section-icon svg { width: 18px; height: 18px; }

.config-section-title {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-head);
  letter-spacing: -.01em;
}
.config-section-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.config-section-titles { flex: 1; min-width: 0; }

.config-section-count {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.config-section-toggle {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: transform .25s;
}
.config-section.open .config-section-toggle { transform: rotate(180deg); }

.config-section-body {
  display: none;
  padding: 6px 22px 22px;
  border-top: 1px solid var(--card-border);
  flex-direction: column;
  gap: 16px;
}
.config-section.open .config-section-body { display: flex; }

.config-field {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: start;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--card-border);
}
.config-field:last-child { border-bottom: none; padding-bottom: 0; }
@media (max-width: 800px) {
  .config-field { grid-template-columns: 1fr; gap: 8px; }
}

.config-field-info { padding-top: 8px; }
.config-field-label {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-head);
}
.config-field-desc {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.config-field-input { display: flex; flex-direction: column; gap: 6px; }
.config-input {
  padding: 11px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  color: var(--text-head);
  font-size: .9rem;
  font-family: inherit;
  width: 100%;
  transition: all .15s;
}
.config-input:focus {
  border-color: var(--p400);
  background: var(--card-bg);
  box-shadow: 0 0 0 3px rgba(155,79,255,.1);
}
textarea.config-input {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
select.config-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239b4fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.config-field-action { display: flex; align-items: flex-start; padding-top: 4px; }
.config-save {
  padding: 10px 18px;
  border: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  font-family: inherit;
  transition: all .2s;
  box-shadow: 0 4px 14px rgba(155,79,255,.25);
  white-space: nowrap;
}
.config-save:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(155,79,255,.35); }
.config-save.saved { background: var(--success); box-shadow: 0 4px 14px rgba(22,163,74,.3); }
.config-save.saving { opacity: .6; cursor: wait; }

/* Upload de imagem */
.config-upload {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.config-upload-preview {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  border: 2px dashed var(--card-border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: border-color .15s;
}
.config-upload-preview:hover { border-color: var(--p400); }
.config-upload-preview img,
.config-upload-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.config-upload-empty {
  color: var(--text-dim);
  font-size: .82rem;
  text-align: center;
  padding: 16px;
}
.config-upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.config-upload-btn {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-head);
  font-size: .8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.config-upload-btn svg { width: 14px; height: 14px; }
.config-upload-btn:hover { border-color: var(--p400); color: var(--p500); background: var(--bg-soft); }
.config-upload-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(220,38,38,.06); }
.config-upload-input { display: none; }
.config-upload-progress {
  font-size: .76rem;
  color: var(--p500);
  font-weight: 600;
}

/* ============ MODAL ============ */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(15,8,32,.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-back.show { display: flex; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card-bg);
  border: 1px solid var(--card-border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h2 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-head);
}
.modal-close {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  color: var(--text-head);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--p400); color: #fff; }
.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 10px;
}
.msg-row {
  padding: 11px 15px;
  border-radius: 12px;
  max-width: 85%;
  font-size: .9rem;
  line-height: 1.5;
}
.msg-row.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--p400), var(--p500));
  color: #fff;
  border-radius: 12px 12px 4px 12px;
  font-weight: 500;
}
.msg-row.assistant {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px 12px 12px 4px;
  color: var(--text-body);
}
.msg-meta {
  font-size: .68rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.msg-row.user .msg-meta { color: rgba(255,255,255,.7); }

/* ============ Modal de Confirmação Perigo ============ */
.confirm-modal { max-width: 440px; }
.confirm-body {
  padding: 28px 28px 20px;
  text-align: center;
}
.confirm-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(220,38,38,.1);
  color: var(--danger);
  display: flex; align-items: center; justify-content: center;
}
.confirm-icon svg { width: 30px; height: 30px; }
.confirm-title {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-head);
  margin-bottom: 8px;
}
.confirm-msg {
  font-size: .92rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.confirm-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn-ghost {
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-head);
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
}
.btn-ghost:hover { background: var(--bg-soft); border-color: var(--card-border2); }
.btn-danger {
  padding: 10px 18px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
  box-shadow: 0 4px 14px rgba(220,38,38,.3);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(220,38,38,.4); }
.btn-primary {
  padding: 10px 18px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, var(--p400), var(--p600));
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
  box-shadow: 0 4px 14px rgba(155,79,255,.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(155,79,255,.4); }

/* ============ Modal Detalhe Conversa ============ */
.detail-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--card-border);
}
.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-meta-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
}
.detail-meta-value {
  font-size: .88rem;
  color: var(--text-head);
  font-weight: 600;
}
.detail-content {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 20px;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--text-head);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.detail-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============ MOBILE ============ */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    padding: 14px 18px;
    gap: 14px;
    align-items: center;
    overflow-x: auto;
  }
  .sidebar-logo { flex-shrink: 0; }
  .nav { flex-direction: row; flex: 1; gap: 4px; }
  .nav-item { padding: 8px 10px; }
  .nav-item span { display: none; }
  .nav-item .nav-badge { display: none; }
  .sidebar-footer { padding-top: 0; border-top: none; padding-left: 14px; border-left: 1px solid var(--card-border); }
  .user-meta { display: none; }
  .main { padding: 22px 18px; }
  .main-header h1 { font-size: 1.35rem; }
  th, td { padding: 10px 12px; font-size: .82rem; }
}
