/* ============================================
   MELIUS DASHBOARD — Design System
   Paleta: Pantone 642C / 7695C / 5395C / Black 6C
   Font: SF Pro (sistema Apple)
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paleta Melius */
  --c-black:    #101820;   /* PANTONE BLACK 6C */
  --c-navy:     #081F2C;   /* PANTONE 5395C */
  --c-mid:      #7BA7BC;   /* PANTONE 7695C */
  --c-light:    #D1DDE6;   /* PANTONE 642C */
  --c-white:    #F4F7F9;

  /* Superfícies */
  --bg:         #0B1A24;
  --surface:    #0E2233;
  --surface2:   #132B3F;
  --border:     rgba(123, 167, 188, 0.12);
  --border-hover: rgba(123, 167, 188, 0.28);

  /* Texto */
  --text:       #EFF4F7;
  --text-muted: #7BA7BC;
  --text-dim:   rgba(209, 221, 230, 0.5);

  /* Semáforos */
  --green:      #30D158;   /* Apple green */
  --yellow:     #FFD60A;   /* Apple yellow */
  --red:        #FF453A;   /* Apple red */
  --blue:       #0A84FF;   /* Apple blue */

  /* Fontes — SF Pro nativo no Mac */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", Menlo, Monaco, monospace;

  /* Espaçamentos */
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOGIN
   ============================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-black);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(123,167,188,0.08) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 48px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.login-logo span b {
  color: var(--c-mid);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus {
  border-color: var(--c-mid);
}

.form-group input::placeholder {
  color: var(--text-dim);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--c-mid);
  color: var(--c-black);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
  letter-spacing: -0.2px;
}

.btn-primary:hover {
  background: var(--c-light);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.login-error {
  background: rgba(255, 69, 58, 0.1);
  border: 1px solid rgba(255, 69, 58, 0.3);
  color: #FF6B63;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-navy);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.sidebar-logo .logo-text b { color: var(--c-mid); }

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  border: 1px solid transparent;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

.nav-item.active {
  background: rgba(123, 167, 188, 0.12);
  color: var(--c-light);
  border-color: rgba(123, 167, 188, 0.2);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
  display: none;
}

.nav-badge.visible { display: block; }

.sidebar-footer {
  padding: 16px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  background: var(--c-mid);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-black);
  flex-shrink: 0;
}

.sidebar-user .user-info .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-user .user-info .role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
  text-align: center;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* MAIN */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-date {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-alert-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.topbar-alert-btn:hover { border-color: var(--border-hover); color: var(--text); }

.alert-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  display: none;
}

.alert-dot.visible { display: block; }

/* PAGE CONTENT */
.page {
  padding: 28px;
  display: none;
}

.page.active { display: block; }

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.page-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   GRID + CARDS
   ============================================ */

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-hover); }

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1;
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.card-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 99px;
}

.card-trend.up { background: rgba(48,209,88,0.12); color: var(--green); }
.card-trend.down { background: rgba(255,69,58,0.12); color: var(--red); }
.card-trend.neutral { background: rgba(255,214,10,0.12); color: var(--yellow); }

/* ============================================
   HEALTH SCORE
   ============================================ */

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  cursor: pointer;
}

.health-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-dot.green { background: var(--green); box-shadow: 0 0 8px rgba(48,209,88,0.4); }
.health-dot.yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(255,214,10,0.4); }
.health-dot.red { background: var(--red); box-shadow: 0 0 8px rgba(255,69,58,0.4); }

.health-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.health-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.health-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: 0.3px;
}

.health-tag.ok { background: rgba(48,209,88,0.1); color: var(--green); }
.health-tag.warn { background: rgba(255,214,10,0.1); color: var(--yellow); }
.health-tag.bad { background: rgba(255,69,58,0.1); color: var(--red); }

/* ============================================
   FUNIL DE TRÁFEGO
   ============================================ */

.funil-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 600px;
}

.funil-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.funil-step::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}

.funil-step.alcance::before { background: var(--c-light); }
.funil-step.mensagens::before { background: var(--c-mid); }
.funil-step.conversoes::before { background: var(--green); }

.funil-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.funil-numero {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: var(--text);
  line-height: 1;
}

.funil-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.funil-arrow {
  text-align: center;
  color: var(--border);
  font-size: 18px;
  padding: 2px 0;
}

/* Conversões com benchmark */
.funil-benchmark {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.funil-bench-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.funil-bench-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.funil-bench-value {
  font-size: 13px;
  font-weight: 700;
}

.funil-bench-value.real { color: var(--text); }
.funil-bench-value.market { color: var(--c-mid); }
.funil-bench-value.up { color: var(--green); }
.funil-bench-value.down { color: var(--red); }

.funil-bar-bg {
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  margin-top: 8px;
  overflow: hidden;
}

.funil-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--c-mid);
  transition: width 0.8s ease;
}

.funil-bar-fill.above { background: var(--green); }

/* ============================================
   ANÁLISE IA
   ============================================ */

.ai-block {
  background: var(--surface);
  border: 1px solid rgba(123, 167, 188, 0.2);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 20px;
  position: relative;
}

.ai-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ai-block-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-mid);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.ai-dot {
  width: 6px;
  height: 6px;
  background: var(--c-mid);
  border-radius: 50%;
  animation: pulse-ai 2s infinite;
}

@keyframes pulse-ai {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.btn-refresh {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-refresh:hover { border-color: var(--c-mid); color: var(--c-mid); }

.ai-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.ai-footer {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 12px;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--c-mid);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   ALERTAS
   ============================================ */

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all var(--transition);
}

.alert-item:hover { border-color: var(--border-hover); }

.alert-item.critico { border-left: 3px solid var(--red); }
.alert-item.aviso { border-left: 3px solid var(--yellow); }
.alert-item.info { border-left: 3px solid var(--blue); }

.alert-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
}

.alert-icon.critico { background: rgba(255,69,58,0.1); }
.alert-icon.aviso { background: rgba(255,214,10,0.1); }

.alert-titulo {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.alert-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   APROVAÇÕES
   ============================================ */

.aprovacoes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.aprov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.aprov-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }

.aprov-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}

.aprov-body {
  padding: 14px 16px;
}

.aprov-cliente {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.aprov-titulo {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

.aprov-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  margin-top: 8px;
}

.aprov-status.pendente { background: rgba(255,214,10,0.1); color: var(--yellow); }
.aprov-status.aprovado { background: rgba(48,209,88,0.1); color: var(--green); }
.aprov-status.ajuste { background: rgba(255,69,58,0.1); color: var(--red); }

.aprov-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-sm {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-sm.aprovar:hover { border-color: var(--green); color: var(--green); background: rgba(48,209,88,0.08); }
.btn-sm.ajuste:hover { border-color: var(--red); color: var(--red); background: rgba(255,69,58,0.08); }

/* ============================================
   DEMANDAS
   ============================================ */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .kanban-board { grid-template-columns: 1fr; }
}

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kanban-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-count {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-dim);
}

.kanban-cards {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.kanban-card {
  display: block;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition);
}

.kanban-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.kanban-card-titulo {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
}

.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.kanban-card-data {
  color: var(--text-dim);
}

.kanban-card-tipo {
  margin-top: 5px;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.status-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ============================================
   FINANCEIRO
   ============================================ */

.fin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.fin-row:last-child { border-bottom: none; }

.fin-label { font-size: 14px; color: var(--text); }
.fin-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.fin-val { font-size: 15px; font-weight: 700; color: var(--text); }
.fin-val.danger { color: var(--red); }
.fin-val.success { color: var(--green); }

/* ============================================
   CLIENTE SELECTOR
   ============================================ */

.cliente-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  min-width: 200px;
}

.cliente-select:focus { border-color: var(--c-mid); }

.period-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

/* ============================================
   DIVIDER + SEÇÕES
   ============================================ */

.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 28px 0;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 10px;
  opacity: 0.4;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-mid); }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

/* ============================================
   TRÁFEGO — GRID DE CLIENTES
   ============================================ */

.trafego-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.trafego-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.trafego-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.trafego-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trafego-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.trafego-card-saldo {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}

.trafego-card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 6px;
}

.trafego-card-badge.ativo { background: rgba(16,185,129,0.15); color: #34d399; }
.trafego-card-badge.inativo { background: rgba(239,68,68,0.12); color: #f87171; }
.trafego-card-badge.zaproi { background: rgba(124,58,237,0.15); color: #a78bfa; margin-left: 4px; }

/* ============================================
   MODAL TRÁFEGO
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
  padding: 0;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* ZapROI block */
.zaproi-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.zaproi-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.zaproi-stat:last-child { border-bottom: none; }

.zaproi-stat-label { color: var(--text-muted); }
.zaproi-stat-value { font-weight: 600; color: var(--text); }
.zaproi-stat-value.green { color: #34d399; }
.zaproi-stat-value.purple { color: #a78bfa; }

.zaproi-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ============================================
   CLIENTES — CRM GLASSMORPHISM
   ============================================ */

.clientes-lista-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.cliente-lista-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  width: 100%;
}

.cliente-lista-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.cliente-lista-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.cliente-lista-nome {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.cliente-lista-seg {
  font-size: 12px;
  color: var(--text-muted);
}

.cliente-lista-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cliente-lista-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--border);
  color: var(--text-dim);
}

/* Botão voltar */
.btn-voltar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 20px;
}

.btn-voltar:hover { border-color: var(--border-hover); color: var(--text); }

/* Layout CRM */
.crm-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

/* Glass card base */
.glass-card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 20px;
  transition: border-color var(--transition);
}

.glass-card:hover { border-color: rgba(255,255,255,0.14); }

/* Sidebar CRM */
.crm-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 80px;
}

.crm-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.crm-avatar {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  background: #22c55e;
  box-shadow: 0 8px 24px rgba(34,197,94,0.35);
}

.crm-nome {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.crm-segmento {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 10px;
}

.crm-status-badge {
  display: inline-block;
  margin: 0 auto;
  padding: 3px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(34,197,94,0.15);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,0.25);
}

.crm-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Contatos */
.crm-contato {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.crm-contato:last-child { border-bottom: none; }

.crm-contato-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.crm-contato-info { flex: 1; min-width: 0; }
.crm-contato-nome { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-contato-cargo { font-size: 11px; color: var(--text-muted); }

/* Tags */
.crm-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.crm-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(124,58,237,0.12);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.2);
}

/* Meta contas */
.crm-meta-conta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.crm-meta-conta:last-child { border-bottom: none; }
.crm-meta-conta-nome { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.crm-meta-conta-saldo { color: var(--accent); font-weight: 700; font-size: 11px; flex-shrink: 0; }

/* KPIs */
.crm-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.crm-kpi {
  text-align: center;
  padding: 16px 12px;
}

.crm-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.crm-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.crm-kpi-sub {
  font-size: 10px;
  color: var(--text-muted);
}

/* Main CRM */
.crm-main { display: flex; flex-direction: column; gap: 16px; }

/* Funil por conta */
.crm-funils-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.crm-funil-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 16px;
}

.crm-funil-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Calendário */
.crm-cal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.crm-cal-item:last-child { border-bottom: none; }

.crm-cal-tipo {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}

.crm-cal-titulo {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-cal-status {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  flex-shrink: 0;
}

.crm-cal-data { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }

/* Notas / Timeline */
.crm-nota-input-wrap {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.crm-nota-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 14px;
  resize: none;
  min-height: 60px;
  font-family: inherit;
  transition: border-color var(--transition);
}

.crm-nota-input:focus { outline: none; border-color: var(--border-hover); }
.crm-nota-input::placeholder { color: var(--text-dim); }

.crm-timeline { display: flex; flex-direction: column; gap: 10px; }

.crm-nota {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
}

.crm-nota-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}

.crm-nota-body { flex: 1; }
.crm-nota-texto { font-size: 13px; color: var(--text); line-height: 1.5; }
.crm-nota-data { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* Status chips calendário */
.status-Publicado { background: rgba(16,185,129,0.15); color: #34d399; }
.status-Em-andamento { background: rgba(245,158,11,0.15); color: #fbbf24; }
.status-Ideias { background: rgba(107,114,128,0.15); color: #9ca3af; }
.status-Tráfego-ativo { background: rgba(59,130,246,0.15); color: #60a5fa; }

@media (max-width: 1100px) {
  .crm-layout { grid-template-columns: 1fr; }
  .crm-sidebar { position: static; }
  .crm-kpis { grid-template-columns: repeat(2, 1fr); }
  .crm-funils-grid { grid-template-columns: 1fr; }
}
