:root {
  --bg: #0d1117;
  --panel: #141a22;
  --panel-2: #1a2330;
  --muted: #9aa4b2;
  --text: #e6edf3;
  --accent: #4f8cff;
  --accent-2: #12b981;
  --danger: #f87171;
  --border: #1f2a37;
}

* { box-sizing: border-box; }


.table tbody tr:hover,
.table tbody tr:focus-within {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.table tbody tr:hover td,
.table tbody tr:focus-within td {
  font-weight: 600;
  
}

.table tbody tr:hover td:first-child,
.table tbody tr:focus-within td:first-child {
  border-left: 3px solid #5cc8ff;
  padding-left: 12px;
}


body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #1a2330 0%, #0d1117 55%);
  color: var(--text);
  font-size: 13px; /* antes não tinha */
  line-height: 1.4;
}

.app .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #10151d;
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 18px; }

.nav button {
  margin-right: 8px;
  background: #131b26;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.nav button:hover { border-color: var(--accent); }

.user { display: flex; align-items: center; gap: 10px; }
.user button {
  background: #131b26;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  height: calc(100vh - 90px);
  overflow: auto;
}

.content {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-height: calc(100vh - 90px);
}

.softphone h3 { margin-top: 0; }
.softphone input {
  width: 100%;
  margin: 8px 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f151d;
  color: var(--text);
}

.row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a25;
  color: var(--text);
  cursor: pointer;
}
.btn.green { background: #123c2c; border-color: #1c5a43; color: #d1fae5; }
.btn.red { background: #3b1414; border-color: #6a1f1f; color: #fecaca; }

.dtmf-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.dtmf-key {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111926;
  color: var(--text);
  cursor: pointer;
}
.dtmf-key:hover { border-color: var(--accent); }

.incoming {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f151d;
}

.log {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  max-height: 200px;
  overflow: auto;
}

.view { display: block; }
.hidden { display: none !important; }

.panorama-wrap {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0f151d;
}

.panorama-frame {
  width: 100%;
  min-height: calc(100vh - 240px);
  height: calc(100vh - 240px);
  border: 0;
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.filters input, .filters select {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f151d;
  color: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
}
.table th { color: var(--muted); font-weight: 600; }

.mini {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #111926;
  color: var(--text);
  cursor: pointer;
}
.mini.danger { border-color: #6a1f1f; color: #fecaca; }

.pager { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.summary {
  padding: 8px 12px;
  background: #0f151d;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 12px;
}

.reminder-banner {
  padding: 8px 12px;
  background: #3b2614;
  border: 1px solid #6b3f1b;
  border-radius: 8px;
  margin-bottom: 8px;
}

.badge.warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f59e0b;
  color: #111;
  font-weight: 700;
  font-size: 11px;
}

.badge.email-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #4f8cff;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
}

.mini.email-btn {
  border-color: #4f8cff;
  color: #4f8cff;
  font-weight: 600;
}

.email-item { transition: background 0.15s; }
.email-item:hover { background: rgba(79, 140, 255, 0.06); }
.email-unread { background: rgba(79, 140, 255, 0.08); }
.email-unread:hover { background: rgba(79, 140, 255, 0.14); }

.wrap { white-space: normal; }

.admin-only { display: none; }
.role-admin .admin-only { display: inline-block; }

.card {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}

/* SweetAlert2 - sem scroll interno */
.swal2-container { 
  align-items: flex-start !important;
  overflow-y: auto !important;
  padding-top: 24px !important;
}
.swal2-popup { 
  border-radius: 12px !important; 
  width: min(760px, 96vw) !important;
  max-width: 96vw !important;
  max-height: none !important;
  padding: 24px 28px !important;
}
.swal2-html-container { 
  text-align: left !important;
  max-height: none !important;
  overflow: visible !important;
}
.swal2-input, .swal2-textarea, .swal2-select {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* Somente o modal do Diário um pouco maior */
.swal2-popup.swal-diario {
  width: min(820px, 96vw) !important;
  padding: 28px 32px !important;
}
.swal2-popup.swal-diario .swal2-input,
.swal2-popup.swal-diario .swal2-textarea,
.swal2-popup.swal-diario .swal2-select {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 20% -10%, #1a2330 0%, #0d1117 55%);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 { margin: 0 0 8px; }
.login-card p { margin: 0 0 16px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f151d;
  color: var(--text);
}
.login-card button {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1b2330;
  color: var(--text);
  cursor: pointer;
}
.login-card .error { color: #fca5a5; margin-top: 8px; }


/* Alinha melhor selects e inputs do SweetAlert */
.swal2-popup .swal2-input,
.swal2-popup .swal2-select,
.swal2-popup select {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.swal2-popup .swal2-input::placeholder {
  color: #888;
}

.swal2-popup.mt5-popup {
  width: min(1100px, 96vw);
  padding: 14px;
}

.mt5-modal {
  color: #525252;
  
}

.mt5-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mt5-title {
  font-size: 16px;
  font-weight: 700;
  color: #494c64;
}

.mt5-sub {
  color: var(--muted);
  font-size: 12px;
}

.mt5-status {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0f151d;
  font-size: 12px;
  color: var(--muted);
}

.mt5-status.ok {
  border-color: #1c5a43;
  color: #d1fae5;
  background: #123c2c;
}

.mt5-tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.mt5-tab {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a25;
  color: var(--text);
  cursor: pointer;
}

.mt5-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
  font-weight: 700;
}

.mt5-panel {
  margin-top: 8px;
}

.mt5-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.mt5-card {
  background: #0f151d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.mt5-label {
  font-size: 11px;
  color: var(--muted);
}

.mt5-value {
  font-size: 14px;
  font-weight: 600;
  color: aliceblue;
}

.mt5-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mt5-muted {
  color: var(--muted);
  font-size: 12px;
}

#mt5-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mt5-toast {
  background: #1f1f1f;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  max-width: 320px;
}

.mt5-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mt5-toast.success { border-left: 4px solid #2ecc71; }
.mt5-toast.error { border-left: 4px solid #e74c3c; }
.mt5-toast.warning { border-left: 4px solid #f1c40f; color: #111; background: #fff5cc; }
.mt5-toast.info { border-left: 4px solid #3498db; }

.mt5-section {
  margin-top: 12px;
}

.mt5-section-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

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

.mt5-table th,
.mt5-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.mt5-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border);
}

.mt5-tag.buy {
  background: rgb(13 100 28 / 83%);
  color: #d1fae5;
  border-color: #1c5a43;
}

.mt5-tag.sell {
  background: rgb(248 113 113);
  color: #fecaca;
  border-color: #6a1f1f;
}

.mt5-mini {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #111926;
  color: var(--text);
  cursor: pointer;
}

.mt5-history-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
  font-weight: 700;
}

.mt5-mini.danger {
  border-color: #6a1f1f;
  color: #fecaca;
}

.mt5-empty {
  color: var(--muted);
  padding: 8px 0;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
  margin: 6px 0;
  font-size: 12px;
  color: var(--text);
}

.perm-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Popups SweetAlert em 75% */
.swal2-popup {
  width: 65vw !important;
  max-width: 65vw !important;
}

@media (max-width: 900px) {
  .swal2-popup {
    width: 95vw !important;
    max-width: 95vw !important;
  }

  .panorama-frame {
    min-height: calc(100vh - 280px);
    height: calc(100vh - 280px);
  }
}

/* Popup MT5 (mantém igual) */
.swal2-popup.mt5-popup {
  width: 65vw;
  max-width: 75vw;
  padding: 14px;
}


.mt5-title {
    color: #474a52;
}

/* ── Kanban de registros ──────────────────────────── */
.swal2-popup.swal-kanban {
  width: min(92vw, 1100px) !important;
  max-width: 1100px !important;
  padding: 16px !important;
}

.kboard {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  min-height: 180px;
  align-items: flex-start;
}

.kcol {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  background: #f1f5f9;
}

.kcol-head {
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e2e8f0;
  letter-spacing: 0.02em;
}

.kcol-count {
  background: #64748b;
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

.kcol-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  overflow-y: auto;
  max-height: 440px;
  min-height: 60px;
}

.kcard {
  background: #fff;
  border-radius: 8px;
  padding: 9px 11px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  cursor: default;
}

.kcard-date {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 5px;
  font-weight: 600;
}

.kcard-note {
  font-size: 12px;
  color: #1e293b;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.kcard-next {
  font-size: 11px;
  color: #15803d;
  margin-top: 7px;
  font-weight: 600;
}

.kcol-empty {
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  padding: 20px 0;
}

/* column accent colours */
.kcol:nth-child(1) .kcol-head { background: #fee2e2; color: #991b1b; }
.kcol:nth-child(1) .kcol-count { background: #ef4444; }
.kcol:nth-child(2) .kcol-head { background: #fef9c3; color: #854d0e; }
.kcol:nth-child(2) .kcol-count { background: #ca8a04; }
.kcol:nth-child(3) .kcol-head { background: #dcfce7; color: #166534; }
.kcol:nth-child(3) .kcol-count { background: #16a34a; }
.kcol:nth-child(4) .kcol-head { background: #e2e8f0; color: #374151; }

@media (max-width: 700px) {
  .kboard { flex-direction: column; }
  .kcol { flex: none; width: 100%; }
}

/* ── Email Kanban ─────────────────────────────────── */
.email-kanban {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-top: 16px;
}
.email-col {
  flex: 1;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  min-width: 0;
}
.email-col-header {
  background: #1e40af;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.email-col:nth-child(1) .email-col-header { background: #0369a1; }
.email-col:nth-child(2) .email-col-header { background: #065f46; }
.email-col-header .badge { background: rgba(255,255,255,0.3); color:#fff; font-size:11px; padding:2px 7px; border-radius:10px; }
.email-list { padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 72vh; overflow-y: auto; }
.email-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow 0.15s;
  font-size: 13px;
}
.email-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.email-card.email-unread { border-left: 3px solid #2563eb; background: #eff6ff; }
.email-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.email-card-date { font-size: 11px; color: #64748b; }
.email-reply-btn { font-size: 11px; padding: 2px 8px; margin-left: auto; background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.email-reply-btn:hover { background: #dbeafe; }
.email-card-agent { font-size: 11px; background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 8px; }
.email-card-who { display: block; font-size: 12px; color: #475569; margin-bottom: 2px; }
.email-card-client { display: block; font-size: 11px; color: #7c3aed; margin-bottom: 4px; }
.email-card-subject { font-weight: 600; color: #1e293b; }
.email-card-body { margin-top: 8px; padding-top: 8px; border-top: 1px solid #e2e8f0; font-size: 12px; color: #374151; white-space: pre-wrap; word-break: break-word; }
.email-empty { text-align: center; color: #94a3b8; padding: 24px 0; font-size: 13px; }
@media (max-width: 700px) { .email-kanban { flex-direction: column; } }
.email-pager { display:flex; align-items:center; justify-content:center; gap:8px; padding:8px; font-size:13px; color:#475569; }
.pager-btn { background:#e2e8f0; border:none; border-radius:4px; padding:2px 10px; cursor:pointer; font-size:15px; }
.pager-btn:disabled { opacity:0.4; cursor:default; }
.pager-btn.active { background:#2563eb; color:#fff; font-weight:600; }

/* ── Resumo da Mesa ────────────────────────────────── */
.ds-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.ds-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  user-select: none;
}
.ds-date-label {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}
.ds-user-label {
  font-size: 13px;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.ds-gen-at {
  font-size: 11px;
  color: #94a3b8;
  margin-left: auto;
}
.ds-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 26px;
  border-radius: 13px;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  padding: 0 8px;
  white-space: nowrap;
}
.ds-score-good { background: #16a34a; }
.ds-score-mid  { background: #ca8a04; }
.ds-score-low  { background: #dc2626; }
.ds-overall {
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
  margin-bottom: 10px;
}
.ds-alert-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: #991b1b;
  margin-bottom: 12px;
}
.ds-kanban {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.ds-col {
  flex: 1;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  min-width: 0;
}
.ds-col-title {
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
  color: #fff;
}
.ds-col-contacted .ds-col-title  { background: #15803d; }
.ds-col-no-contact .ds-col-title { background: #b45309; }
.ds-section { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ds-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  padding: 4px 6px;
}
.ds-client-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}
.ds-contacted  { border-left: 3px solid #16a34a; }
.ds-no-contact { border-left: 3px solid #d97706; }
.ds-client-name {
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  margin-bottom: 4px;
}
.ds-status-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-bottom: 4px;
}
.ds-tag-call    { background: #dcfce7; color: #15803d; }
.ds-tag-email   { background: #dbeafe; color: #1d4ed8; }
.ds-tag-chat    { background: #ede9fe; color: #6d28d9; }
.ds-client-meta {
  color: #475569;
  margin-bottom: 4px;
  line-height: 1.5;
}
.ds-note-quality {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 4px;
}
.ds-nq-boa     { background: #dcfce7; color: #15803d; }
.ds-nq-vaga    { background: #fef9c3; color: #854d0e; }
.ds-nq-ausente { background: #fee2e2; color: #991b1b; }
.ds-client-cw {
  font-size: 11px;
  color: #6d28d9;
  background: #ede9fe;
  padding: 2px 8px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 4px;
}
.ds-client-assessment {
  font-size: 12px;
  color: #334155;
  font-style: italic;
  margin-top: 4px;
}
.ds-probable-reason {
  font-size: 12px;
  color: #78350f;
  margin-bottom: 2px;
}
.ds-recommendation {
  font-size: 12px;
  color: #1d4ed8;
  font-style: italic;
}
.ds-bottom {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  font-size: 12px;
  color: #64748b;
}
.ds-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 32px 0;
}
.ds-empty-col {
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 16px;
}
@media (max-width: 700px) {
  .ds-kanban { flex-direction: column; }
  .ds-col { width: 100%; }
}
/* Expand / collapse */
.ds-card-body { transition: none; }
.ds-card.ds-collapsed .ds-card-body { display: none; }
.ds-card.ds-collapsed .ds-toggle-icon { transform: rotate(-90deg); }
.ds-toggle-icon { font-size: 11px; color: #94a3b8; transition: transform 0.15s; margin-left: 4px; }
.ds-tag-status { background: #f1f5f9; color: #475569; }

.ds-regen-btn {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 10px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
}
.ds-regen-btn:hover { background: #e2e8f0; }
.ds-regen-btn:disabled { opacity: 0.5; cursor: wait; }
.ds-delete-btn {
  margin-left: 4px;
  font-size: 13px;
  padding: 2px 7px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #991b1b;
  cursor: pointer;
}
.ds-delete-btn:hover { background: #fecaca; }
.ds-writing-issue {
  font-size: 11px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 6px;
  padding: 3px 8px;
  margin: 3px 0;
}
.ds-feedback-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.6;
  padding: 4px 6px;
}
.ds-user-info-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 14px;
  color: #1e40af;
  font-size: 13.5px;
  line-height: 1.5;
}
.role-admin .non-admin-only { display: none !important; }

/* Channel tags por cliente */
.ds-channel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0 8px;
}
.ds-ch-tag {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}
.ds-ch-tag.ds-ch-wa { background: #dcfce7; border-color: #86efac; color: #166534; }
.ds-ch-tag.ds-ch-email { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.ds-ch-tag.ds-ch-phone { background: #faf5ff; border-color: #d8b4fe; color: #6b21a8; }
.ds-ch-tag.ds-ch-absent { background: #f8fafc; border-color: #e2e8f0; color: #94a3b8; }
.ds-wa-context {
  font-size: 12.5px;
  color: #166534;
  background: #f0fdf4;
  border-left: 3px solid #4ade80;
  padding: 6px 10px;
  margin: 5px 0;
  border-radius: 0 6px 6px 0;
  line-height: 1.5;
}
.ds-wa-label { font-weight: 600; margin-right: 4px; }
.ds-email-summary {
  font-size: 12px;
  color: #1e40af;
  background: #eff6ff;
  border-left: 3px solid #60a5fa;
  padding: 5px 10px;
  margin: 4px 0;
  border-radius: 0 6px 6px 0;
}
.ds-tactics {
  font-size: 12px;
  color: #92400e;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding: 6px 10px;
  margin: 5px 0;
  border-radius: 0 6px 6px 0;
  line-height: 1.5;
}
.ds-agent-failures {
  font-size: 12px;
  color: #991b1b;
  background: #fef2f2;
  border-left: 3px solid #f87171;
  padding: 6px 10px;
  margin: 5px 0;
  border-radius: 0 6px 6px 0;
  line-height: 1.5;
  font-weight: 500;
}
.ds-next-msg {
  background: #f0f9ff;
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 6px 0;
}
.ds-next-msg-label {
  font-size: 11px;
  font-weight: 600;
  color: #0369a1;
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ds-next-msg-text {
  font-size: 12.5px;
  color: #0c4a6e;
  line-height: 1.6;
  white-space: pre-wrap;
}
.ds-followup {
  font-size: 12px;
  color: #4338ca;
  background: #eef2ff;
  border-left: 3px solid #818cf8;
  padding: 6px 10px;
  margin: 5px 0;
  border-radius: 0 6px 6px 0;
  line-height: 1.6;
}

/* =============================================
   ASSISTENTE IA
   ============================================= */

/* Remove content padding/scroll when IA view is active */
main.content:has(#view-ia:not(.hidden)) {
  padding: 0;
  overflow: hidden;
  border-radius: 0;
}

.ia-layout {
  display: flex;
  height: calc(100vh - 90px);
  gap: 0;
  overflow: hidden;
}

/* --- Sidebar --- */
.ia-sidebar {
  width: 240px;
  min-width: 200px;
  background: #0f1520;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ia-sidebar-header {
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ia-sidebar-header h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ia-btn-new {
  width: 100%;
  padding: 7px 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ia-btn-new:hover { opacity: 0.85; }

.ia-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.ia-conv-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.ia-conv-item {
  padding: 9px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 2px 6px;
  transition: background 0.12s;
}
.ia-conv-item:hover { background: rgba(255,255,255,0.05); }
.ia-conv-item.active { background: rgba(79,140,255,0.15); }

.ia-conv-item-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ia-conv-item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* --- Main area --- */
.ia-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
}

.ia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: #10151d;
  min-height: 50px;
}

.ia-conv-title-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ia-btn-danger {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.ia-btn-danger:hover { background: rgba(248,113,113,0.1); }

/* --- Messages --- */
.ia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ia-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 10px;
  color: var(--muted);
  padding: 40px 20px;
}

.ia-welcome-icon {
  font-size: 42px;
  line-height: 1;
}

.ia-welcome-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.ia-welcome-sub {
  font-size: 13px;
  color: var(--muted);
  max-width: 360px;
  line-height: 1.6;
  margin: 0;
}

.ia-welcome-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  max-width: 420px;
}

.ia-example {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.ia-example:hover {
  border-color: var(--accent);
  background: rgba(79,140,255,0.07);
}

/* --- Chat messages --- */
.ia-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 4px;
}

.ia-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}

.ia-msg-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.ia-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.ia-msg-user .ia-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ia-msg-assistant .ia-msg-bubble {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ia-msg-loading .ia-msg-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  min-width: 60px;
  max-width: 360px;
}

/* Animated loading dots */
.ia-dot {
  width: 7px;
  height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: ia-bounce 1.2s infinite ease-in-out;
}
.ia-dot:nth-child(2) { animation-delay: 0.2s; }
.ia-dot:nth-child(3) { animation-delay: 0.4s; }
.ia-loading-status {
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
  font-style: italic;
  min-width: 0;
  transition: opacity 0.4s;
}

@keyframes ia-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* --- Badges --- */
.ia-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ia-badge-analysis {
  background: rgba(79,140,255,0.15);
  color: #7db5ff;
  border: 1px solid rgba(79,140,255,0.3);
}

.ia-badge-confirm {
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.3);
}

.ia-badge-denied {
  background: rgba(248,113,113,0.15);
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.3);
}

.ia-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
}

/* --- Email confirm box --- */
.ia-email-confirm {
  margin: 0 24px 10px;
  background: #1a2a1a;
  border: 1px solid #2d6a2d;
  border-radius: 10px;
  padding: 14px 16px;
}

.ia-email-confirm-title {
  font-size: 13px;
  font-weight: 700;
  color: #4ade80;
  margin-bottom: 8px;
}

.ia-ec-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
  font-size: 12px;
}

.ia-ec-row strong {
  color: var(--muted);
  min-width: 80px;
}

.ia-ec-list {
  color: var(--text);
  flex: 1;
}

.ia-ec-body {
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
  margin-top: 4px;
}

.ia-email-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.ia-email-confirm-actions button {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.ia-email-confirm-actions button:first-child {
  background: #16a34a;
  color: #fff;
}
.ia-email-confirm-actions button:last-child {
  background: rgba(248,113,113,0.2);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.4);
}
.ia-email-confirm-actions button:hover { opacity: 0.85; }

/* --- Input area --- */
.ia-input-area {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: #10151d;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.ia-input-area.drag-over { border: 2px dashed var(--accent); border-radius: 8px; background: rgba(79,140,255,0.06); }

/* Drop overlay */
.ia-drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(15,21,32,0.85);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ia-input-area.drag-over .ia-drop-overlay { display: flex; }
.ia-drop-icon { font-size: 32px; }
.ia-drop-text { font-size: 14px; color: var(--accent); font-weight: 600; }

/* Thumbnail da imagem anexada */
.ia-file-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.ia-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ia-file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s;
}
.ia-file-label:hover { border-color: var(--accent); color: var(--text); }

.ia-file-name {
  font-size: 12px;
  color: var(--accent);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ia-file-clear {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  line-height: 1;
}

.ia-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ia-input-row textarea {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 10px 12px;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  line-height: 1.5;
  transition: border-color 0.15s;
  overflow-y: auto;
}
.ia-input-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.ia-input-row textarea::placeholder { color: var(--muted); }

.ia-send-btn {
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s;
  align-self: flex-end;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ia-send-btn:hover { opacity: 0.85; }
.ia-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Scrollbar para ia-messages e ia-conv-list */
.ia-messages::-webkit-scrollbar,
.ia-conv-list::-webkit-scrollbar { width: 4px; }
.ia-messages::-webkit-scrollbar-track,
.ia-conv-list::-webkit-scrollbar-track { background: transparent; }
.ia-messages::-webkit-scrollbar-thumb,
.ia-conv-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Markdown styles inside chat bubbles */
.ia-md-h1 { display: block; font-size: 15px; font-weight: 700; color: var(--text); margin: 4px 0 2px; }
.ia-md-h2 { display: block; font-size: 14px; font-weight: 700; color: var(--text); margin: 4px 0 2px; }
.ia-md-h3 { display: block; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 2px; }
.ia-md-num { color: var(--accent); font-weight: 600; }
.ia-md-code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 12px; }

.ia-table {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
  font-size: 12px;
}
.ia-table th, .ia-table td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
}
.ia-table th {
  background: rgba(79,140,255,0.12);
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ia-table tr:nth-child(even) td { background: rgba(255,255,255,0.03); }
.ia-table tr:hover td { background: rgba(255,255,255,0.06); }

/* Generated image */
.ia-image-wrap {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
}
.ia-image {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}
.ia-image-dl {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  align-self: flex-start;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  transition: background 0.15s;
}
.ia-image-dl:hover { background: rgba(79,140,255,0.1); }

.ia-doc-wrap {
  margin: 12px 0;
}
.ia-doc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #0b3d91, #4f8cff);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  transition: filter 0.15s, transform 0.15s;
}
.ia-doc-link:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Dashboard — próximos contatos */
.dash-reminders-wrap { margin-top: 20px; }
.dash-reminders-title { font-size: 13px; font-weight: 600; color: var(--accent); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .5px; }
.dash-reminders-list { display: flex; flex-direction: column; gap: 6px; max-width: 480px; }
.dash-reminder { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-radius: 7px; border-left: 3px solid var(--accent); font-size: 13px; }
.dash-reminder.overdue { border-left-color: var(--danger); }
.dash-rem-time { color: var(--muted); min-width: 115px; font-size: 12px; }
.dash-rem-name { font-weight: 600; flex: 1; }
.dash-rem-num { color: var(--muted); font-size: 12px; }

/* Chart wrapper */
.ia-chart-wrap {
  background: #0f1520;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 10px 0;
  max-width: 520px;
}

/* Botão de memórias no sidebar da IA */
.ia-btn-mem {
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
}
.ia-btn-mem:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.ia-btn-mem.active { background: rgba(79,140,255,0.12); border-color: var(--accent); color: var(--accent); }

/* Painel de memórias */
.ia-memory-panel {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}
.ia-memory-panel::-webkit-scrollbar { width: 4px; }
.ia-memory-panel::-webkit-scrollbar-track { background: transparent; }
.ia-memory-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.ia-mem-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.ia-mem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.ia-mem-count {
  font-size: 11px;
  color: var(--muted);
}
.ia-mem-clear-all {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 5px;
  font-size: 10px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.ia-mem-clear-all:hover { background: rgba(248,113,113,0.1); }

.ia-mem-item {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}
.ia-mem-item:hover { background: rgba(255,255,255,0.03); }

.ia-mem-key {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ia-mem-val {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ia-mem-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.ia-mem-cat {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ia-mem-del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.ia-mem-del:hover { color: var(--danger); background: rgba(248,113,113,0.1); }
