/* ============================================================
   Central de Atendimento Inteligente — Estilos Globais
   Tema: Dark industrial-refined / Electric teal accent
   Fontes: Syne (headings) + DM Sans (body)
   ============================================================ */

/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ── Variáveis CSS ─────────────────────────────────────────── */
:root {
  /* Cores primárias */
  --c-bg:          #0d1117;
  --c-surface:     #161b22;
  --c-surface-2:   #1e2530;
  --c-surface-3:   #252d3a;
  --c-border:      #2a3241;
  --c-border-light:#344155;

  /* Texto */
  --c-text:        #e6edf3;
  --c-text-muted:  #8b949e;
  --c-text-faint:  #484f58;

  /* Accent — electric teal */
  --c-accent:      #00c9a7;
  --c-accent-dim:  rgba(0, 201, 167, .12);
  --c-accent-glow: rgba(0, 201, 167, .25);
  --c-accent-dark: #009e84;

  /* Semânticas */
  --c-success:     #3fb950;
  --c-warning:     #d29922;
  --c-error:       #f85149;
  --c-info:        #58a6ff;

  /* Etapas do funil */
  --c-stage-new:         #6366f1;
  --c-stage-identifying: #f59e0b;
  --c-stage-qualified:   #10b981;
  --c-stage-forwarded:   #3b82f6;
  --c-stage-lost:        #ef4444;

  /* Layout */
  --sidebar-w:     240px;
  --topbar-h:      56px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  /* Sombras */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.6);
  --shadow-glow:0 0 24px var(--c-accent-glow);

  /* Tipografia */
  --font-display: 'Syne', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Transições */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  180ms;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: .9375rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-accent); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--c-accent-dark); }

img { max-width: 100%; display: block; }

button { cursor: pointer; font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbar customizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--c-surface); }
::-webkit-scrollbar-thumb { background: var(--c-border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-muted); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: hidden;
  position: relative;
}

/* Grade decorativa de fundo */
.login-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--c-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .35;
  pointer-events: none;
}

/* Orbes de fundo */
.login-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: .18;
}
.login-orb--1 {
  width: 500px; height: 500px;
  background: var(--c-accent);
  top: -180px; right: -120px;
}
.login-orb--2 {
  width: 360px; height: 360px;
  background: #6366f1;
  bottom: -120px; left: -80px;
}

.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: fadeUp .5s var(--ease) both;
}

.login-card {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(0,201,167,.06);
}

/* Cabeçalho do card */
.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
  font-size: 3rem;
  display: block;
  margin-bottom: .75rem;
  filter: drop-shadow(0 0 16px var(--c-accent-glow));
  animation: floatLogo 4s ease-in-out infinite;
}

.login-brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -.02em;
}

.login-tagline {
  font-size: .8125rem;
  color: var(--c-text-muted);
  margin-top: .25rem;
}

/* Alertas */
.login-alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  border-left: 3px solid;
}
.login-alert--error   { background: rgba(248,81,73,.1);  border-color: var(--c-error);   color: #ffa29e; }
.login-alert--warning { background: rgba(210,153,34,.1); border-color: var(--c-warning); color: #f0c674; }

/* Formulário */
.login-form { display: flex; flex-direction: column; gap: 1.125rem; }

.login-field { display: flex; flex-direction: column; gap: .375rem; }

.login-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--c-text-muted);
  letter-spacing: .03em;
  text-transform: uppercase;
}

.login-input-wrap { position: relative; }

.login-input-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
  opacity: .6;
}

.login-input {
  width: 100%;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: .9375rem;
  padding: .75rem .875rem .75rem 2.75rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.login-input::placeholder { color: var(--c-text-faint); }
.login-input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-dim);
}
.login-input--error { border-color: var(--c-error); }

.login-toggle-pass {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1rem;
  opacity: .5;
  transition: opacity var(--dur);
}
.login-toggle-pass:hover { opacity: 1; }

/* Botão de login */
.login-btn {
  width: 100%;
  background: var(--c-accent);
  color: #0d1117;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: .9375rem;
  font-weight: 500;
  padding: .875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-top: .5rem;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.login-btn:hover:not(:disabled) {
  background: var(--c-accent-dark);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}
.login-btn:active:not(:disabled) { transform: translateY(0); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }

.login-btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(13,17,23,.4);
  border-top-color: #0d1117;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.login-footer-text {
  text-align: center;
  font-size: .8rem;
  color: var(--c-text-faint);
  margin-top: 1.75rem;
  line-height: 1.5;
}

.login-copyright {
  font-size: .75rem;
  color: var(--c-text-faint);
  text-align: center;
}

/* ============================================================
   LAYOUT PRINCIPAL (Sidebar + Conteúdo)
   ============================================================ */

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 90;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100dvh;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--dur) var(--ease);
  overflow: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  font-size: 1.75rem;
  filter: drop-shadow(0 0 8px var(--c-accent-glow));
  flex-shrink: 0;
}
.sidebar-brand-text { overflow: hidden; }
.sidebar-brand-name {
  display: block;
  font-family: var(--font-display);
  font-size: .8125rem;
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-role {
  display: block;
  font-size: .7rem;
  color: var(--c-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.sidebar-menu { list-style: none; }

.sidebar-separator {
  height: 1px;
  background: var(--c-border);
  margin: .625rem .75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5625rem .875rem;
  margin: .125rem .5rem;
  border-radius: var(--radius-md);
  color: var(--c-text-muted);
  font-size: .875rem;
  font-weight: 400;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
  text-decoration: none;
}
.sidebar-link:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}
.sidebar-link.active {
  background: var(--c-accent-dim);
  color: var(--c-accent);
  font-weight: 500;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 3px;
  background: var(--c-accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-icon { font-size: 1rem; flex-shrink: 0; }
.sidebar-label { flex: 1; }

.sidebar-badge {
  background: var(--c-accent);
  color: #0d1117;
  font-size: .6875rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

/* Footer da sidebar */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .875rem 1rem;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--c-accent-dim);
  border: 1px solid var(--c-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  font-weight: 700;
  color: var(--c-accent);
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}
.sidebar-user-name {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  display: block;
  font-size: .7rem;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  color: var(--c-text-faint);
  font-size: 1.125rem;
  flex-shrink: 0;
  padding: .25rem;
  border-radius: var(--radius-sm);
  transition: color var(--dur), background var(--dur);
}
.sidebar-logout:hover { color: var(--c-error); background: rgba(248,81,73,.1); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  flex-direction: column;
  gap: 5px;
  padding: .25rem;
}
.topbar-toggle-bar {
  display: block;
  width: 20px; height: 2px;
  background: var(--c-text);
  border-radius: 1px;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.topbar-notif-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 1.125rem;
  color: var(--c-text-muted);
  padding: .375rem;
  border-radius: var(--radius-sm);
  transition: color var(--dur), background var(--dur);
}
.topbar-notif-btn:hover { color: var(--c-text); background: var(--c-surface-2); }
.topbar-notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--c-error);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Content area */
.content-area {
  flex: 1;
  padding: 1.75rem 1.5rem;
  max-width: 1400px;
  width: 100%;
}

/* ── Painel de notificações ───────────────────────────────── */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 1rem;
  width: 320px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  animation: fadeDown .2s var(--ease);
}
.notif-panel[hidden] { display: none; }

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--c-border);
  font-size: .875rem;
  font-weight: 500;
}
.notif-panel-mark-all {
  background: none;
  border: none;
  color: var(--c-accent);
  font-size: .75rem;
  font-family: inherit;
}
.notif-panel-mark-all:hover { text-decoration: underline; }

.notif-list { list-style: none; max-height: 360px; overflow-y: auto; }
.notif-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--c-text-muted);
  font-size: .875rem;
}
.notif-item {
  display: block;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--c-border);
  transition: background var(--dur);
  cursor: pointer;
}
.notif-item:hover { background: var(--c-surface-2); }
.notif-item--unread { background: var(--c-accent-dim); }
.notif-item__title {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--c-text);
  margin-bottom: .2rem;
}
.notif-item__msg {
  font-size: .75rem;
  color: var(--c-text-muted);
  line-height: 1.4;
}
.notif-item__time {
  font-size: .7rem;
  color: var(--c-text-faint);
  margin-top: .3rem;
}

/* ============================================================
   COMPONENTES REUTILIZÁVEIS
   ============================================================ */

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.card--flat { background: var(--c-surface-2); border: none; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.2;
}
.page-subtitle {
  font-size: .875rem;
  color: var(--c-text-muted);
  margin-top: .25rem;
}

/* ── Botões ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .5625rem 1.125rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--c-accent); color: #0d1117; border-color: var(--c-accent); }
.btn--primary:hover:not(:disabled) { background: var(--c-accent-dark); border-color: var(--c-accent-dark); box-shadow: var(--shadow-glow); }

.btn--secondary { background: var(--c-surface-2); color: var(--c-text); border-color: var(--c-border); }
.btn--secondary:hover:not(:disabled) { background: var(--c-surface-3); border-color: var(--c-border-light); }

.btn--danger { background: rgba(248,81,73,.12); color: var(--c-error); border-color: rgba(248,81,73,.3); }
.btn--danger:hover:not(:disabled) { background: rgba(248,81,73,.2); }

.btn--ghost { background: transparent; color: var(--c-text-muted); border-color: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--c-surface-2); color: var(--c-text); }

.btn--sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn--lg { padding: .75rem 1.5rem; font-size: 1rem; }

/* ── Formulários ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--c-text-muted);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.form-label--required::after { content: ' *'; color: var(--c-error); }

.form-control {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: .9375rem;
  padding: .625rem .875rem;
  width: 100%;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.form-control::placeholder { color: var(--c-text-faint); }
.form-control:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-dim);
}
.form-control:disabled { opacity: .5; cursor: not-allowed; }
.form-control--error { border-color: var(--c-error) !important; }

select.form-control { appearance: none; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: .75rem; color: var(--c-text-faint); }
.form-error { font-size: .75rem; color: var(--c-error); }
.form-actions { display: flex; gap: .75rem; align-items: center; margin-top: 1.5rem; flex-wrap: wrap; }

/* ── Alertas ────────────────────────────────────────────────── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  border-left: 3px solid;
  position: relative;
}
.alert--success { background: rgba(63,185,80,.1);  border-color: var(--c-success); color: #7ee787; }
.alert--error   { background: rgba(248,81,73,.1);  border-color: var(--c-error);   color: #ffa29e; }
.alert--warning { background: rgba(210,153,34,.1); border-color: var(--c-warning); color: #f0c674; }
.alert--info    { background: rgba(88,166,255,.1); border-color: var(--c-info);    color: #a5c8ff; }

.alert-close {
  position: absolute;
  top: .5rem;
  right: .625rem;
  background: none;
  border: none;
  color: inherit;
  opacity: .6;
  font-size: 1rem;
  line-height: 1;
}
.alert-close:hover { opacity: 1; }

/* ── Tabelas ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--c-border); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table thead { background: var(--c-surface-2); }
.table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 500;
  color: var(--c-text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.table td {
  padding: .875rem 1rem;
  color: var(--c-text);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--c-surface-2); }

/* ── Badges de etapa ─────────────────────────────────────── */
.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .625rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}
.stage-badge--new          { background: rgba(99,102,241,.15);  color: #a5b4fc; }
.stage-badge--identifying  { background: rgba(245,158,11,.15);  color: #fcd34d; }
.stage-badge--qualified    { background: rgba(16,185,129,.15);  color: #6ee7b7; }
.stage-badge--forwarded    { background: rgba(59,130,246,.15);  color: #93c5fd; }
.stage-badge--lost         { background: rgba(239,68,68,.15);   color: #fca5a5; }

/* ── Badges de role ───────────────────────────────────────── */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .625rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
}
.role-badge--admin    { background: var(--c-accent-dim); color: var(--c-accent); }
.role-badge--operator { background: rgba(88,166,255,.12); color: var(--c-info); }

/* ── Status badge (ativo/inativo) ────────────────────────── */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: .8125rem;
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  display: block;
}
.status-dot--active::before   { background: var(--c-success); box-shadow: 0 0 6px var(--c-success); }
.status-dot--inactive::before { background: var(--c-text-faint); }

/* ── Toasts ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  background: var(--c-surface-3);
  border: 1px solid var(--c-border-light);
  border-radius: var(--radius-lg);
  padding: .875rem 1.125rem;
  font-size: .875rem;
  color: var(--c-text);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: .625rem;
  pointer-events: all;
  max-width: 320px;
  animation: slideInRight .25s var(--ease) both;
}
.toast--success { border-left: 3px solid var(--c-success); }
.toast--error   { border-left: 3px solid var(--c-error); }
.toast--warning { border-left: 3px solid var(--c-warning); }
.toast--info    { border-left: 3px solid var(--c-info); }
.toast--hiding  { animation: slideOutRight .25s var(--ease) forwards; }

/* ── Modais ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s var(--ease);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .2s var(--ease) both;
}
.modal--wide { max-width: 800px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--c-text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--c-text-muted);
  font-size: 1.25rem;
  padding: .25rem;
  border-radius: var(--radius-sm);
  transition: color var(--dur), background var(--dur);
}
.modal-close:hover { color: var(--c-text); background: var(--c-surface-2); }

/* ── Paginação ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}
.page-link {
  padding: .375rem .625rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--c-text-muted);
  transition: background var(--dur), color var(--dur);
  min-width: 34px;
  text-align: center;
}
.page-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.page-link--active { background: var(--c-accent-dim); color: var(--c-accent); font-weight: 600; }
.page-link--disabled { opacity: .4; pointer-events: none; }

/* ── Filtros ─────────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}
.filters .form-group { margin-bottom: 0; }

/* ── Stats cards (dashboard) ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.stat-card:hover { border-color: var(--c-border-light); box-shadow: var(--shadow-sm); }
.stat-card__icon { font-size: 1.5rem; }
.stat-card__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1;
}
.stat-card__label { font-size: .8125rem; color: var(--c-text-muted); }
.stat-card__delta { font-size: .75rem; }
.stat-card__delta--up   { color: var(--c-success); }
.stat-card__delta--down { color: var(--c-error); }

/* ── Kanban Board ─────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
}
.kanban-col {
  flex-shrink: 0;
  width: 280px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  background: inherit;
}
.kanban-col-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.kanban-col-count {
  font-size: .75rem;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  padding: .125rem .5rem;
  border-radius: 99px;
}
.kanban-cards { padding: .75rem; display: flex; flex-direction: column; gap: .625rem; min-height: 80px; }

.kanban-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: .875rem;
  cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur);
  user-select: none;
}
.kanban-card:hover { border-color: var(--c-border-light); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kanban-card.sortable-ghost { opacity: .4; }
.kanban-card.sortable-chosen { box-shadow: var(--shadow-md); transform: scale(1.02); }

.kanban-card__name { font-size: .875rem; font-weight: 500; color: var(--c-text); margin-bottom: .375rem; }
.kanban-card__company { font-size: .75rem; color: var(--c-text-muted); margin-bottom: .5rem; }
.kanban-card__preview { font-size: .75rem; color: var(--c-text-faint); line-height: 1.4; margin-bottom: .5rem; }
.kanban-card__meta { display: flex; justify-content: space-between; align-items: center; }
.kanban-card__time { font-size: .7rem; color: var(--c-text-faint); }
.kanban-card__phone { font-size: .7rem; color: var(--c-text-faint); }

/* Drop zone visual */
.kanban-dropzone {
  border: 2px dashed var(--c-accent);
  border-radius: var(--radius-md);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-accent);
  font-size: .8rem;
  opacity: .5;
}

/* ── Conversa / Chat ─────────────────────────────────────── */
.chat-wrap {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  max-height: 520px;
  overflow-y: auto;
  padding: 1rem;
  background: var(--c-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
}
.chat-msg {
  display: flex;
  gap: .625rem;
  max-width: 80%;
}
.chat-msg--in  { align-self: flex-start; }
.chat-msg--out { align-self: flex-end; flex-direction: row-reverse; }

.chat-bubble {
  padding: .625rem .875rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg--in  .chat-bubble { background: var(--c-surface-2); color: var(--c-text); border-bottom-left-radius: 2px; }
.chat-msg--out .chat-bubble {
  background: var(--c-accent-dim);
  border: 1px solid rgba(0,201,167,.2);
  color: var(--c-text);
  border-bottom-right-radius: 2px;
}
.chat-msg--out.chat-bubble--ai { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.2); }

.chat-meta {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding-top: .25rem;
}
.chat-sender { font-size: .7rem; color: var(--c-text-muted); }
.chat-time   { font-size: .65rem; color: var(--c-text-faint); }

/* ── Utilitários ─────────────────────────────────────────── */
.d-none     { display: none !important; }
.d-flex     { display: flex; }
.gap-sm     { gap: .5rem; }
.gap-md     { gap: 1rem; }
.text-muted { color: var(--c-text-muted); }
.text-sm    { font-size: .875rem; }
.text-xs    { font-size: .75rem; }
.fw-500     { font-weight: 500; }
.fw-700     { font-weight: 700; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }
.mb-1       { margin-bottom: .5rem; }
.mb-2       { margin-bottom: 1rem; }
.w-100      { width: 100%; }
.text-right { text-align: right; }
.text-center{ text-align: center; }

/* ── Animações ────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }

  .topbar-toggle { display: flex; }

  .topbar-title { font-size: .9375rem; }

  .content-area { padding: 1.25rem 1rem; }

  .form-row { grid-template-columns: 1fr; }

  .kanban-board { padding-bottom: .75rem; }

  .modal { padding: 1.5rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .toast-container { left: 1rem; right: 1rem; }
  .toast { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 2rem 1.25rem; }
  .page-header { flex-direction: column; }
}