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

/* ================================
   Reset & Base
================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #F0F2F5;
  --surface:      #FFFFFF;
  --surface-2:    #F8F9FB;
  --border:       #E4E7EC;
  --border-light: #F0F2F5;
  --text:         #101828;
  --text-muted:   #667085;
  --text-light:   #98A2B3;
  --primary:      #1F93FF;
  --primary-dark: #1677cc;
  --primary-glow: rgba(31,147,255,.15);
  --success:      #12B76A;
  --warning:      #F79009;
  --purple:       #7F56D9;
  --danger:       #F04438;
  --header-h:     58px;
  --filter-h:     50px;
  --shadow-xs:    0 1px 2px rgba(16,24,40,.05);
  --shadow-sm:    0 1px 3px rgba(16,24,40,.1), 0 1px 2px rgba(16,24,40,.06);
  --shadow-md:    0 4px 8px -2px rgba(16,24,40,.1), 0 2px 4px -2px rgba(16,24,40,.06);
  --shadow-lg:    0 12px 16px -4px rgba(16,24,40,.08), 0 4px 6px -2px rgba(16,24,40,.03);
  --shadow-xl:    0 20px 24px -4px rgba(16,24,40,.08), 0 8px 8px -4px rgba(16,24,40,.03);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --col-w:        295px;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ================================
   Header
================================ */
.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  z-index: 100;
}

.header-left  { display: flex; align-items: center; min-width: 200px; }
.header-center { flex: 1; display: flex; justify-content: center; }
.header-right { display: flex; align-items: center; gap: 10px; min-width: 280px; justify-content: flex-end; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}

/* Inbox selector */
.inbox-selector { display: flex; align-items: center; gap: 8px; }
.inbox-selector label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.inbox-selector select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 30px 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  min-width: 200px;
  transition: border-color .2s;
}
.inbox-selector select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* Search */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  transition: all .2s;
}
.search-box:focus-within {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-box input { border: none; background: none; font-size: 13px; color: var(--text); outline: none; width: 150px; }
.search-box input::placeholder { color: var(--text-light); }

/* Refresh button */
.btn-refresh {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
}
.btn-refresh:hover { background: var(--primary-glow); border-color: var(--primary); }
.btn-refresh:hover svg path { fill: var(--primary); }
.btn-refresh.spinning svg { animation: spin .7s linear infinite; }

/* Status badge */
.status-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-light); flex-shrink: 0; }
.status-badge.connected .status-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(18,183,106,.18); animation: pulse-dot 2s infinite; }
.status-badge.connected .status-text { color: var(--success); }
.status-badge.error .status-dot { background: var(--danger); }
.status-badge.error .status-text { color: var(--danger); }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 3px rgba(18,183,106,.18); } 50% { box-shadow: 0 0 0 5px rgba(18,183,106,.06); } }

/* ================================
   Filters Bar
================================ */
.filters-bar {
  height: var(--filter-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.filter-group select {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 26px 4px 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  cursor: pointer;
  transition: border-color .2s;
}
.filter-group select:focus { outline: none; border-color: var(--primary); }
.filter-stats { margin-left: auto; font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* KPI bar — fica inline na filters-bar, empurrado para a direita */
.kpi-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 10px;
  height: 34px;
  flex-shrink: 0;
}
.kpi-item {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
  padding: 0 8px;
}
.kpi-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 16px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1;
}
.kpi-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}
.kpi-warn   .kpi-value { color: #B54708; }
.kpi-danger .kpi-value { color: var(--danger); }
.kpi-purple .kpi-value { color: var(--purple); }

/* Pulsa vermelho quando há conversas com +24h */
.kpi-danger.kpi-alert .kpi-value {
  animation: kpi-pulse 1.5s ease-in-out infinite;
}
@keyframes kpi-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ================================
   Board
================================ */
.board-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px 24px;
  /* garante que o container ocupa o resto da tela */
  min-height: 0;
}

.board {
  display: flex;
  gap: 14px;
  height: 100%;
  min-width: max-content;
  align-items: stretch;  /* colunas esticam para ocupar toda a altura */
}

/* ================================
   Column
================================ */
.column {
  width: var(--col-w);
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
  /* usa altura total do board */
  height: 100%;
  overflow: hidden;
  transition: box-shadow .2s;
}
.column:hover { box-shadow: var(--shadow-sm); }

.column-header {
  padding: 13px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--col-color, var(--primary));
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.6) 0%, rgba(255,255,255,0) 100%);
}
.column-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 13px; color: var(--text);
  letter-spacing: -0.1px;
}
.column-icon { font-size: 15px; line-height: 1; }

.column-count {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 24px; text-align: center;
  letter-spacing: .2px;
}
.badge-blue   { background: #EFF8FF; color: #1849A9; }
.badge-yellow { background: #FFFAEB; color: #B54708; }
.badge-purple { background: #F4F3FF; color: #5925DC; }
.badge-green  { background: #ECFDF3; color: #027A48; }
.badge-label  { background: #F8F9FB; color: #344054; border: 1px solid #E4E7EC; }

.column-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;   /* crucial para que o flex-child respeite overflow */
  scrollbar-width: thin;
  scrollbar-color: #D0D5DD transparent;
}
.column-body::-webkit-scrollbar { width: 4px; }
.column-body::-webkit-scrollbar-thumb { background: #D0D5DD; border-radius: 4px; }
.column-body::-webkit-scrollbar-track { background: transparent; }
.column-body.drag-over {
  background: linear-gradient(180deg, var(--primary-glow) 0%, transparent 100%);
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
  border-radius: 8px;
}

/* ================================
   Card
================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-accent, var(--primary));
  border-radius: var(--radius-sm);
  padding: 11px 12px 10px 11px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow-xs);
  user-select: none;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #C8D5E8;
}
.card.dragging {
  opacity: .55;
  box-shadow: var(--shadow-xl);
  transform: rotate(1.5deg) scale(1.03);
  border-color: var(--primary);
}

/* Card header */
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px; gap: 8px;
}
.card-id {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  padding: 1px 6px; border-radius: 4px;
}
.card-channel {
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 10px;
  background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .3px;
}

/* Tempo sem resposta no header do card */
.card-waiting {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  letter-spacing: .2px;
}
.card-waiting--ok {
  background: #d1fae5; color: #065f46;
}
.card-waiting--warn {
  background: #fef3c7; color: #92400e;
}
.card-waiting--danger {
  background: #fee2e2; color: #991b1b;
  animation: pulse-warn 2s ease-in-out infinite;
}
@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50%       { opacity: .65; }
}

/* Contact */
.card-contact {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 8px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  overflow: hidden;
}
.avatar img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.contact-phone { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* Preview */
.card-preview {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 10px;
}

/* Footer */
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.card-time { font-size: 11px; color: var(--text-light); font-weight: 500; }
.card-labels { display: flex; gap: 4px; flex-wrap: wrap; }
.label-chip {
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 10px;
  letter-spacing: .1px;
}
.card-agent {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-muted); font-weight: 500;
}
.agent-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: white;
  flex-shrink: 0;
}

/* ================================
   Skeleton Loading
================================ */
.loading-skeleton { display: flex; flex-direction: column; gap: 8px; }
.skeleton-card {
  background: linear-gradient(90deg, #F2F4F7 25%, #E8EAED 50%, #F2F4F7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
  height: 110px;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ================================
   Modal
================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,24,40,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 620px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalIn .2s cubic-bezier(.16,1,.3,1);
  border: 1px solid var(--border);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(12px); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs); transition: all .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  flex: 1; overflow-y: auto;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 18px;
}

.modal-info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.info-item { display: flex; flex-direction: column; gap: 3px; }
.info-label { font-size: 10px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .6px; }
.info-value { font-size: 13px; color: var(--text); font-weight: 500; }

.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-action {
  padding: 7px 14px; border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: all .15s; display: flex; align-items: center; gap: 6px;
}
.btn-action:hover { background: var(--bg); border-color: #C8D5E8; }
.btn-action.btn-resolve { background: var(--success); color: white; border-color: var(--success); }
.btn-action.btn-resolve:hover { background: #0DA060; }
.btn-action.btn-reopen  { background: var(--primary); color: white; border-color: var(--primary); }
.btn-action.btn-reopen:hover  { background: var(--primary-dark); }
.btn-action.btn-open-cw { background: var(--surface-2); }

.messages-section h3 {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px;
}
.messages-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 220px; overflow-y: auto;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px; border: 1px solid var(--border);
}

.message-bubble {
  padding: 8px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.5;
  max-width: 80%; word-break: break-word;
}
.message-bubble.incoming { background: white; border: 1px solid var(--border); border-bottom-left-radius: 3px; align-self: flex-start; }
.message-bubble.outgoing { background: #EFF8FF; border: 1px solid #B2DDFF; border-bottom-right-radius: 3px; align-self: flex-end; text-align: right; }
.message-bubble.activity { background: #FFFAEB; border: 1px solid #FEF0C7; text-align: center; font-style: italic; font-size: 11px; align-self: center; max-width: 100%; color: var(--text-muted); border-radius: 20px; }
.message-time { font-size: 10px; color: var(--text-light); margin-top: 3px; }
.loading-text { font-size: 13px; color: var(--text-muted); text-align: center; padding: 20px; }

.quick-reply { display: flex; gap: 8px; align-items: flex-end; }
.quick-reply textarea {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; font-family: inherit; resize: none;
  transition: border-color .2s; background: var(--surface-2);
}
.quick-reply textarea:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-glow); }
.btn-send {
  background: var(--primary); color: white; border: none;
  border-radius: var(--radius-sm); padding: 10px 18px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all .15s; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.btn-send:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* ================================
   Toast Notifications
================================ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 2000;
}
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm);
  color: white; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: toastIn .3s cubic-bezier(.16,1,.3,1);
  display: flex; align-items: center; gap: 8px;
  min-width: 220px; max-width: 340px;
  backdrop-filter: blur(4px);
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--primary); }
.toast.warning { background: var(--warning); color: #1f2937; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px) scale(.95); } to { opacity: 1; transform: none; } }

/* ================================
   Empty State
================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 36px 16px; color: var(--text-muted); gap: 10px; text-align: center;
}
.empty-state svg { opacity: .25; }
.empty-state p { font-size: 12px; font-weight: 500; }

/* ================================
   Animations
================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ================================
   Scrollbar Global
================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #D0D5DD; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ================================
   View Tabs (Kanban / CEO)
================================ */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.view-tab {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.view-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.view-tab.active {
  background: var(--primary);
  color: #fff;
}

.view-tabs-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 8px;
  flex-shrink: 0;
}

/* ================================
   CEO / Radar de Conversas
================================ */
.ceo-container {
  flex: 1;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px;
  background: var(--bg);
}

.ceo-container > * + * { margin-top: 20px; }

/* Banner diário */
.rd-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(31,147,255,.06);
  border: 1px solid rgba(31,147,255,.2);
  border-radius: var(--radius);
  padding: 14px 20px;
}
.rd-banner-left { display: flex; align-items: center; gap: 12px; }
.rd-banner-icon {
  width: 38px; height: 38px;
  background: rgba(31,147,255,.15);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.rd-banner-title { font-size: 13px; font-weight: 600; color: var(--text); }
.rd-banner-date  { font-size: 11px; color: var(--text-muted); }
.rd-banner-stats { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.rd-banner-stat  { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.rd-ic { font-size: 14px; }
.rd-ic.danger  { color: var(--danger); }
.rd-ic.warning { color: var(--warning); }
.rd-ic.primary { color: var(--primary); }
.rd-muted { color: var(--text-muted); font-size: 12px; }

/* Stats 4 cards */
.rd-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.rd-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-xs);
}
.rd-stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.rd-stat-icon-danger  { background: rgba(240,68,56,.1);  color: var(--danger); }
.rd-stat-icon-primary { background: rgba(31,147,255,.1); color: var(--primary); }
.rd-stat-icon-warning { background: rgba(247,144,9,.1);  color: var(--warning); }
.rd-stat-icon-chart2  { background: rgba(18,183,106,.1); color: var(--success); }
.rd-stat-value {
  font-size: 26px; font-weight: 800;
  color: var(--text); line-height: 1;
}
.rd-stat-suffix { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-left: 2px; }
.rd-stat-label  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Main grid 2/3 + 1/3 */
.rd-main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  min-height: 0;
  align-items: start;
}
.rd-sidebar { display: flex; flex-direction: column; gap: 18px; }

/* Card genérico */
.rd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.rd-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Conversation list */
.rd-conv-card { display: flex; flex-direction: column; min-height: 0; }
.rd-conv-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 14px 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.rd-conv-tab {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.rd-conv-tab:hover { color: var(--text); }
.rd-conv-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.rd-conv-list { overflow-y: auto; max-height: 420px; min-height: 0; }
.rd-conv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
  cursor: default;
}
.rd-conv-row:hover { background: var(--surface-2); }
.rd-conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rd-conv-name-row { display: flex; align-items: center; gap: 6px; }
.rd-conv-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.rd-conv-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-unread {
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--primary); color: #fff;
  border-radius: 99px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rd-conv-preview { font-size: 12px; color: var(--text-muted); padding-left: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-conv-agent { font-weight: 600; color: var(--text); }
.rd-conv-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rd-conv-time-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.rd-conv-time { font-size: 11px; color: var(--text-light); width: 38px; text-align: right; flex-shrink: 0; }
.rd-empty { padding: 32px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* Badges */
.rd-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.rd-badge-danger  { background: rgba(240,68,56,.12);  color: var(--danger);  border-color: rgba(240,68,56,.25); }
.rd-badge-warning { background: rgba(247,144,9,.12);  color: var(--warning); border-color: rgba(247,144,9,.25); }
.rd-badge-primary { background: rgba(31,147,255,.12); color: var(--primary); border-color: rgba(31,147,255,.25); }
.rd-badge-success { background: rgba(18,183,106,.12); color: var(--success); border-color: rgba(18,183,106,.25); }
.rd-badge-muted   { background: var(--surface-2);    color: var(--text-muted); border-color: var(--border); }

/* Stacked bar */
.rd-stacked-bar {
  display: flex; height: 10px; border-radius: 99px; overflow: hidden;
  margin: 14px 16px 0;
}
.rd-legend {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px;
}
.rd-legend-row { display: flex; align-items: center; justify-content: space-between; }
.rd-legend-left { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); }
.rd-legend-right { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.rd-legend-total {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

/* Response time chart */
.rd-chart-wrap { padding: 8px 4px 4px; height: 196px; overflow: hidden; }
.rd-chart-wrap svg { display: block; }

/* Pending items */
.rd-pending-list { display: flex; flex-direction: column; }
.rd-pending-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  transition: background .12s;
}
.rd-pending-row:last-child { border-bottom: none; }
.rd-pending-row:hover { background: var(--surface-2); cursor: pointer; }
.rd-conv-row { cursor: pointer; }
.rd-pending-left { flex: 1; min-width: 0; }
.rd-pending-title { font-size: 13px; font-weight: 500; color: var(--text); }
.rd-pending-group { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.rd-pending-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ================================
   Executive Report Card (Supabase)
================================ */
.rd-report-card {
  margin-top: 20px;
}
.rd-report-body {
  font-size: 13px;
  line-height: 1.7;
  color: #94a3b8;
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.rd-report-body::-webkit-scrollbar { width: 4px; }
.rd-report-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.rd-report-body h4 {
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 18px 0 6px;
  padding-top: 10px;
  border-top: 1px solid #1e293b;
}
.rd-report-body h4:first-child { border-top: none; margin-top: 0; }
.rd-report-body li {
  list-style: none;
  padding-left: 12px;
  position: relative;
  font-size: 13px;
  color: #94a3b8;
  margin: 4px 0;
  line-height: 1.55;
}
.rd-report-body li::before { content: "›"; position: absolute; left: 0; color: #475569; }
.rd-report-body strong { color: #cbd5e1; }
.rd-report-body hr { border: none; border-top: 1px solid #1e293b; margin: 14px 0; }
.rd-report-body p { margin: 4px 0; }
#btn-reload-report:hover { color: #e2e8f0 !important; border-color: #475569 !important; }

/* ================================
   Responsive
================================ */
@media (max-width: 900px) {
  .rd-main-grid { grid-template-columns: 1fr; }
  .rd-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .rd-conv-list { max-height: 300px; }
}
@media (max-width: 768px) {
  .header-center { display: none; }
  .search-box input { width: 100px; }
  :root { --col-w: 265px; }
  .rd-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ceo-container { padding: 16px; }
  .rd-conv-list { max-height: 260px; }
  .rd-conv-meta { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
}
