/* ═══════════════════════════════════════════════════════════════
   ELTRO CRM — Design System
   Estilo: clean, neutro (Tailwind zinc / Radix UI), verde do logo
   Eltro como cor primária. Todas as cores vêm dos tokens abaixo; o tema
   escuro só redefine os tokens (não há overrides por componente).
   ═══════════════════════════════════════════════════════════════ */

/* ─── Tokens: tema claro (padrão) ─── */
:root {
  color-scheme: light;

  /* Superfícies */
  --bg-body: #fafafa;          /* zinc-50  — fundo da página */
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --bg-surface: #f4f4f5;       /* zinc-100 — cabeçalhos, áreas secundárias */
  --bg-input: #ffffff;
  --bg-muted: #f4f4f5;
  --bg-dark: #ffffff;          /* legado: texto sobre fundo primário */

  /* Bordas */
  --border: #e4e4e7;           /* zinc-200 */
  --border-light: #d4d4d8;     /* zinc-300 */
  --border-subtle: #f0f0f2;

  /* Marca — verde do logo Eltro (#2adfa2), escurecido p/ contraste no claro */
  --brand: #2adfa2;
  --primary: #058a63;
  --primary-dim: #04704f;
  --primary-fg: #ffffff;
  --primary-glow: color-mix(in srgb, var(--primary) 14%, transparent);
  --primary-ghost: color-mix(in srgb, var(--primary) 7%, transparent);
  --ring: color-mix(in srgb, var(--primary) 28%, transparent);

  --accent-green: #059669;
  --accent-green-glow: color-mix(in srgb, var(--accent-green) 14%, transparent);

  /* Semânticas */
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --purple: #7c3aed;

  /* Texto */
  --text: #18181b;             /* zinc-900 */
  --text-secondary: #52525b;   /* zinc-600 */
  --text-muted: #71717a;       /* zinc-500 */

  /* Tipografia */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* Números (telefones, datas, valores): Inter com algarismos tabulares,
     mantém o alinhamento de colunas sem a aparência de fonte de código */
  --font-mono: var(--font-sans);

  /* Elevação */
  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-sm: 0 1px 3px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-md: 0 4px 12px rgba(24, 24, 27, 0.08), 0 1px 3px rgba(24, 24, 27, 0.05);
  --shadow-lg: 0 12px 32px rgba(24, 24, 27, 0.12), 0 2px 6px rgba(24, 24, 27, 0.06);

  /* Layout */
  --sidebar-width: 248px;
  --sidebar-collapsed: 72px;
  --topbar-height: 56px;

  /* Raios */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
}

/* ─── Tokens: tema escuro ─── */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-body: #09090b;          /* zinc-950 */
  --bg-sidebar: #0c0c0e;
  --bg-card: #111113;
  --bg-card-hover: #18181b;
  --bg-surface: #18181b;       /* zinc-900 */
  --bg-input: #0c0c0e;
  --bg-muted: #18181b;
  --bg-dark: #04261b;

  --border: #27272a;           /* zinc-800 */
  --border-light: #3f3f46;     /* zinc-700 */
  --border-subtle: #1c1c1f;

  --primary: #2adfa2;          /* verde do logo */
  --primary-dim: #5ee8b9;
  --primary-fg: #04261b;
  --primary-glow: color-mix(in srgb, var(--primary) 16%, transparent);
  --primary-ghost: color-mix(in srgb, var(--primary) 8%, transparent);
  --ring: color-mix(in srgb, var(--primary) 32%, transparent);

  --accent-green: #34d399;

  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --purple: #a78bfa;

  --text: #fafafa;
  --text-secondary: #a1a1aa;   /* zinc-400 */
  --text-muted: #71717a;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg-body);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

a { color: var(--primary); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection { background: var(--primary-glow); }

/* Números alinhados em qualquer lugar que use a fonte mono */
.tabular, [style*="--font-mono"] { font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* Scrollbars discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-light) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-brand {
  padding: 0 16px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.brand-logo img { height: 18px; width: auto; display: block; }
.brand-logo .logo-on-dark { display: none; }
[data-theme="dark"] .brand-logo .logo-on-light { display: none; }
[data-theme="dark"] .brand-logo .logo-on-dark { display: block; }

.brand-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  height: 20px;
  line-height: 18px;
}

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

.nav-section { margin-bottom: 16px; }
.nav-section:last-child { margin-bottom: 0; }

.nav-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color .12s, color .12s;
  position: relative;
}

.nav-item:hover { color: var(--text); background: var(--bg-surface); }

.nav-item.active {
  color: var(--text);
  background: var(--bg-surface);
  font-weight: 600;
}

.nav-item.active .nav-icon { color: var(--primary); opacity: 1; }

.nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }

.nav-badge {
  margin-left: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
  height: 20px;
  line-height: 18px;
  border-radius: 999px;
}

.nav-badge.primary { background: var(--primary-ghost); border-color: transparent; color: var(--primary); }

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background-color .12s;
}

.user-card:hover { background: var(--bg-surface); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  object-fit: cover;
}

.user-info { overflow: hidden; min-width: 0; }

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

.user-role { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══════════════════════════════════════════
   MAIN + TOPBAR
   ═══════════════════════════════════════════ */
.main { margin-left: var(--sidebar-width); min-height: 100vh; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  background: color-mix(in srgb, var(--bg-body) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
}

.topbar-toggle:hover { color: var(--text); background: var(--bg-surface); }

.search-box { flex: 1; max-width: 380px; position: relative; }

.search-box input {
  width: 100%;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px 0 34px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}

.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.topbar-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background-color .12s, color .12s;
  position: relative;
  flex-shrink: 0;
}

.topbar-btn:hover { color: var(--text); background: var(--bg-surface); }

/* Botões de ação em linhas de tabela (reutilizam .topbar-btn) */
.data-table .topbar-btn { width: 30px; height: 30px; padding: 0 !important; }

.topbar-btn .dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg-body);
  box-sizing: content-box;
}

.topbar-separator { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

.topbar-form { margin: 0; display: flex; }

.logout-btn:hover { color: var(--danger) !important; background: color-mix(in srgb, var(--danger) 8%, transparent) !important; }

.breadcrumb { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .current { color: var(--text); font-weight: 500; }
.breadcrumb-sep { color: var(--border-light); }

/* ═══════════════════════════════════════════
   PAGE
   ═══════════════════════════════════════════ */
.page { padding: 24px 24px 48px; max-width: 1600px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}

.page-header-form { margin-bottom: 12px; }
.page-title-crumb { font-size: 20px; }
.page-title-crumb a { color: var(--text-muted); font-weight: 500; text-decoration: none; }
.page-title-crumb a:hover { color: var(--text); }
.crumb-sep { color: var(--border-light); margin: 0 8px; font-weight: 400; }

.page-subtitle { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }

.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn-primary,
.btn-outline,
.btn-cancel,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
  -webkit-user-select: none;
  user-select: none;
}

.btn-primary:focus-visible,
.btn-outline:focus-visible,
.btn-cancel:focus-visible,
.btn-danger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.btn-primary:disabled, .btn-outline:disabled, .btn-danger:disabled { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border: 1px solid var(--primary);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover { background: var(--primary-dim); border-color: var(--primary-dim); color: var(--primary-fg); }

.btn-outline,
.btn-cancel {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover,
.btn-cancel:hover { background: var(--bg-surface); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
  box-shadow: var(--shadow-xs);
}

.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }

/* Botões compactos em cabeçalhos de card e barras de filtro */
.chart-header .btn-outline, .chart-header .btn-primary,
.table-card-header .btn-outline, .table-card-header .btn-primary,
.activity-header .btn-outline, .stats-header .btn-outline,
.donut-header .btn-outline, .detail-section .btn-outline,
.vehicle-card-footer .btn-outline, .vehicle-card-footer .btn-primary {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  gap: 5px;
}

/* ═══════════════════════════════════════════
   CARDS (base comum)
   ═══════════════════════════════════════════ */
.kpi-card, .chart-card, .table-card, .activity-card, .stats-card, .donut-card,
.form-card, .detail-card, .email-sidebar, .email-items, .email-detail-card,
.cal-week, .vehicle-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card { padding: 16px 18px; position: relative; overflow: hidden; }

.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon svg { width: 16px; height: 16px; }
.kpi-icon.cyan   { background: var(--primary-ghost); color: var(--primary); }
.kpi-icon.green  { background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }
.kpi-icon.purple { background: color-mix(in srgb, var(--purple) 10%, transparent); color: var(--purple); }
.kpi-icon.orange { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.kpi-value.glow-cyan { color: var(--text); }

.kpi-delta, .kpi-change { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.delta-up, .delta-down {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11.5px;
}
.delta-up   { color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); }
.delta-down { color: var(--danger);  background: color-mix(in srgb, var(--danger) 10%, transparent); }

.kpi-spark { position: absolute; bottom: 0; right: 0; width: 100px; height: 40px; opacity: .25; }

/* ═══════════════════════════════════════════
   CHARTS
   ═══════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.chart-card { padding: 18px; overflow: hidden; min-width: 0; }

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

.chart-title, .table-card-title, .activity-title, .stats-title, .donut-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

/* Segmented control (Radix Tabs) */
.chart-filters {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 3px;
}

.chart-filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color .12s, color .12s;
}

.chart-filter-btn.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-xs); }
.chart-filter-btn:hover:not(.active) { color: var(--text); }

.chart-area { height: 260px; position: relative; display: flex; align-items: center; justify-content: center; }
.chart-area canvas { max-width: 100%; max-height: 100%; }

/* ═══════════════════════════════════════════
   PIPELINE FUNNEL
   ═══════════════════════════════════════════ */
.funnel-container { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }

.funnel-step { display: flex; align-items: center; gap: 12px; }

.funnel-bar-wrap {
  flex: 1;
  height: 34px;
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.funnel-bar {
  --bar: var(--primary);
  height: 100%;
  min-width: max-content;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bar) 20%, transparent) !important;
  border-left: 3px solid var(--bar);
  transition: width .4s ease;
}

.funnel-bar-label { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; }

.funnel-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.funnel-pct {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════
   DASHBOARD BOTTOM ROW
   ═══════════════════════════════════════════ */
.bottom-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr);
  gap: 12px;
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════ */
.table-card { overflow: hidden; min-width: 0; }

.table-card-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.data-table th {
  text-align: left;
  height: 40px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background-color .1s; }
.data-table tbody tr:hover td { background: var(--bg-card-hover); }
[data-theme="dark"] .data-table tbody tr:hover td { background: var(--bg-surface); }

.data-table a { text-decoration: none; }
.data-table .lead-name { color: var(--text); font-weight: 500; }
.data-table a:hover .lead-name { color: var(--primary); }
.data-table .lead-email { font-size: 12px; color: var(--text-muted); }

/* ─── Badges (Radix Badge "soft") ─── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.status-badge.novo        { background: color-mix(in srgb, var(--info) 10%, transparent);    color: var(--info); }
.status-badge.qualificado { background: var(--primary-ghost);                                color: var(--primary); }
.status-badge.proposta    { background: color-mix(in srgb, var(--purple) 10%, transparent);  color: var(--purple); }
.status-badge.negociacao  { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); }
.status-badge.ganho       { background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }
.status-badge.perdido     { background: color-mix(in srgb, var(--danger) 10%, transparent);  color: var(--danger); }

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.score-bar-bg { width: 64px; height: 6px; border-radius: 999px; background: var(--bg-surface); overflow: hidden; }
[data-theme="dark"] .score-bar-bg { background: var(--border); }
.score-bar-fill { height: 100%; border-radius: 999px; transition: width .4s; }

/* ═══════════════════════════════════════════
   ACTIVITY FEED
   ═══════════════════════════════════════════ */
.activity-card, .stats-card { display: flex; flex-direction: column; min-width: 0; }

.activity-header, .stats-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-list { flex: 1; overflow-y: auto; padding: 6px 8px; max-height: 340px; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius);
  transition: background-color .12s;
}

.activity-item:hover { background: var(--bg-surface); }

.activity-dot-line { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 6px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 3px var(--bg-card); }
.activity-line { width: 1px; flex: 1; min-height: 14px; background: var(--border); }
.activity-item:last-child .activity-line { display: none; }

.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }
.activity-text strong { color: var(--text); font-weight: 600; }
.activity-text .highlight { color: var(--primary); font-weight: 500; }
.activity-time { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════════════════════════════════
   QUICK STATS
   ═══════════════════════════════════════════ */
.stats-list { padding: 6px 8px; display: flex; flex-direction: column; }

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  transition: background-color .12s;
}

.stat-row + .stat-row { border-top: 1px solid var(--border-subtle); border-radius: 0; }
.stat-row:hover { background: var(--bg-surface); }

.stat-row-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.stat-icon-wrap {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

.stat-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   DONUTS
   ═══════════════════════════════════════════ */
.donut-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.donut-card { padding: 18px; }
.donut-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.donut-area { height: 220px; position: relative; }

/* ═══════════════════════════════════════════
   ANIMAÇÕES (mantidas para templates que as referenciam)
   ═══════════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ═══════════════════════════════════════════
   FORMS — layout
   ═══════════════════════════════════════════ */
.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.form-layout-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.form-layout-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--topbar-height) + 16px);
}

.side-field-group { display: flex; flex-direction: column; gap: 6px; }

.form-card { overflow: hidden; }

.form-section { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }

.form-section-header {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 16px;
  display: block;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }

.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group.full-width { grid-column: 1 / -1; }

.form-label { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.3; }
.form-label .required { color: var(--danger); margin-left: 2px; }

/* ─── Inputs (Radix TextField) ─── */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}

.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--border-light); }

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); opacity: .8; }

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-input:disabled, .form-select:disabled, .form-textarea:disabled,
.form-input[readonly] { background: var(--bg-surface); color: var(--text-muted); cursor: not-allowed; }

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 15l5 5 5-5M7 9l5-5 5 5' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-select[multiple] { background-image: none; padding-right: 12px; }
.form-select option { background: var(--bg-card); color: var(--text); }

.form-textarea { min-height: 88px; resize: vertical; }

input[type="file"].form-input { padding: 5px 8px; }
input[type="file"]::file-selector-button {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  margin-right: 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ─── Checkbox (Radix Checkbox) ─── */
.form-check { display: flex; align-items: center; gap: 8px; padding-top: 6px; }

.form-check input[type="checkbox"],
.opcional-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-input);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  transition: background-color .12s, border-color .12s;
}

.form-check input[type="checkbox"]:checked,
.opcional-check input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }

.form-check input[type="checkbox"]:checked::after,
.opcional-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid var(--primary-fg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-check input[type="checkbox"]:focus-visible,
.opcional-check input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.form-check-label { font-size: 14px; color: var(--text); cursor: pointer; }

.form-help { font-size: 12px; color: var(--text-muted); }
.form-error, .form-errors { font-size: 12.5px; color: var(--danger); }
.form-errors ul, .errorlist { list-style: none; color: var(--danger); font-size: 12.5px; }

/* ─── Barra de ações do formulário ─── */
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.form-action-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.form-action-more { margin-left: auto; position: relative; }

/* Dropdown (Radix DropdownMenu) */
.form-action-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 220px;
  padding: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.form-action-dropdown.open { display: block; animation: fadeInUp .12s ease-out; }

.form-action-dropdown button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.form-action-dropdown button:hover { background: var(--bg-surface); }

/* ─── Campos compostos ─── */
.datetime-composite, .name-composite, .phone-field { display: flex; gap: 8px; }
.datetime-composite .form-input, .name-composite .form-input, .phone-field .form-input { flex: 1; min-width: 0; }

.address-dual { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.address-block { min-width: 0; }

.address-block-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy-addr {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 24px;
  padding: 0 6px;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.btn-copy-addr:hover { background: var(--bg-surface); color: var(--text); }

.address-fields { display: flex; flex-direction: column; gap: 10px; }
.address-row, .form-grid-addr { display: grid; grid-template-columns: minmax(0, 1fr) 80px 120px; gap: 8px; }
.form-grid-addr { gap: 16px; margin-top: 14px; }

.input-with-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-input);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}

.input-with-prefix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.input-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.input-with-prefix .form-input { border: none; background: transparent; box-shadow: none !important; }
.input-with-actions { position: relative; }

.input-error { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent) !important; }

/* ─── Scheduler (agenda visual nos formulários) ─── */
.scheduler-timeline { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-card); }
.scheduler-date { padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.scheduler-hours { position: relative; overflow-x: auto; }

.scheduler-hour-labels {
  display: grid;
  grid-template-columns: 100px repeat(12, 1fr);
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  font-variant-numeric: tabular-nums;
}

.scheduler-hour-labels span { padding: 6px 4px; text-align: center; border-right: 1px solid var(--border); }
.scheduler-row { display: grid; grid-template-columns: 100px 1fr; min-height: 36px; }
.scheduler-row + .scheduler-row { border-top: 1px solid var(--border-subtle); }

.scheduler-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-right: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 0;
}

.scheduler-user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--purple) 14%, transparent);
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.scheduler-cells { display: grid; grid-template-columns: repeat(12, 1fr); position: relative; }
.scheduler-cell { border-right: 1px solid var(--border-subtle); min-height: 36px; }
.scheduler-cell:last-child { border-right: none; }
.scheduler-block { position: absolute; top: 5px; bottom: 5px; background: color-mix(in srgb, var(--danger) 55%, transparent); border-radius: 4px; z-index: 2; }
.scheduler-now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 5; pointer-events: none; display: none; }

/* ═══════════════════════════════════════════
   ALERTS (Radix Callout)
   ═══════════════════════════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
}

.alert svg { flex-shrink: 0; }

.alert-success { background: color-mix(in srgb, var(--success) 8%, var(--bg-card)); border-color: color-mix(in srgb, var(--success) 25%, transparent); color: var(--success); }
.alert-error, .alert-danger { background: color-mix(in srgb, var(--danger) 8%, var(--bg-card)); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.alert-warning { background: color-mix(in srgb, var(--warning) 8%, var(--bg-card)); border-color: color-mix(in srgb, var(--warning) 28%, transparent); color: var(--warning); }
.alert-info { background: color-mix(in srgb, var(--info) 8%, var(--bg-card)); border-color: color-mix(in srgb, var(--info) 25%, transparent); color: var(--info); }

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */
.empty-state { text-align: center; padding: 48px 20px; }

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-desc { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; }

/* ═══════════════════════════════════════════
   DETAIL VIEW
   ═══════════════════════════════════════════ */
.detail-card { overflow: hidden; }

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

.detail-header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.detail-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.detail-name { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; color: var(--text); }
.detail-email { font-size: 13.5px; color: var(--text-muted); margin-top: 1px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-section { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }

.detail-section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 14px; }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
.detail-field { min-width: 0; }
.detail-field-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 2px; }
.detail-field-value { font-size: 14px; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }

/* ═══════════════════════════════════════════
   DELETE CONFIRM (Radix AlertDialog)
   ═══════════════════════════════════════════ */
.delete-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 28px;
  text-align: center;
  max-width: 440px;
  margin: 48px auto;
}

.delete-icon {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.delete-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.delete-desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 22px; line-height: 1.55; }

/* ═══════════════════════════════════════════
   EMAIL
   ═══════════════════════════════════════════ */
.email-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; min-height: 600px; }

.email-sidebar { padding: 10px; position: sticky; top: calc(var(--topbar-height) + 16px); align-self: start; }

.email-folders { display: flex; flex-direction: column; gap: 2px; }

.email-folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color .12s, color .12s;
}

.email-folder-item:hover { background: var(--bg-surface); color: var(--text); }
.email-folder-item.active { background: var(--bg-surface); color: var(--text); font-weight: 600; }
.email-folder-item.active .ef-icon { color: var(--primary); }

.ef-icon { width: 16px; height: 16px; flex-shrink: 0; }

.email-badge {
  margin-left: auto;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.email-content { min-width: 0; }
.email-items { overflow: hidden; }

.email-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background-color .1s;
}

.email-item:last-child { border-bottom: none; }
.email-item:hover { background: var(--bg-card-hover); }
[data-theme="dark"] .email-item:hover { background: var(--bg-surface); }
.email-item.unread { background: var(--primary-ghost); }

.email-item-star { cursor: pointer; flex-shrink: 0; opacity: .4; transition: opacity .15s; }
.email-item-star:hover, .email-item-star.starred { opacity: 1; }

.email-item-avatar, .email-detail-avatar {
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.email-item-avatar { width: 34px; height: 34px; font-size: 12px; }
.email-detail-avatar { width: 42px; height: 42px; font-size: 14px; }

.email-item-body { flex: 1; min-width: 0; }
.email-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 1px; }
.email-item-from { font-size: 13.5px; color: var(--text); }
.email-item-date { font-size: 12px; color: var(--text-muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.email-item-subject { font-size: 13.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-item-preview { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

.fw700 { font-weight: 600; color: var(--text); }

.email-detail-actions { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.email-detail-card { padding: 24px; }
.email-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.email-detail-meta { flex: 1; min-width: 0; }
.email-detail-from { font-size: 14.5px; font-weight: 600; color: var(--text); }
.email-detail-to { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.email-detail-date { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.email-detail-subject {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.email-detail-body { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }

.email-detail-lead {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Compose: toolbar de formatação */
.compose-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}

.compose-toolbar-sep { width: 1px; height: 18px; background: var(--border-light); margin: 0 4px; }

.tb-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tb-btn:hover { background: var(--bg-card); color: var(--text); }
.tb-btn.active { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-xs); }

.tb-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  height: 28px;
  padding: 0 6px;
  cursor: pointer;
}

.compose-body-wrap { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.compose-body-wrap .form-textarea { border: none; border-radius: 0; min-height: 250px; box-shadow: none; }
.compose-body-wrap .form-textarea:focus { box-shadow: none; }

.compose-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.compose-attach-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 32px;
  padding: 0 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  box-shadow: var(--shadow-xs);
}

.compose-attach-btn:hover { background: var(--bg-surface); color: var(--text); }

/* ═══════════════════════════════════════════
   CALENDÁRIO — visão semanal
   ═══════════════════════════════════════════ */
.cal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-title { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; color: var(--text); }
.cal-views { display: flex; gap: 4px; }

.cal-week { overflow: hidden; }

.cal-day-headers {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.cal-time-gutter { border-right: 1px solid var(--border); }

.cal-day-header {
  padding: 8px;
  text-align: center;
  border-right: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.cal-day-header:last-child { border-right: none; }
.cal-day-header.today { background: var(--primary-ghost); }

.cal-day-name { display: block; font-weight: 500; margin-bottom: 1px; }

.cal-day-num { font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

.cal-day-num.today-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-fg);
}

.cal-grid-scroll { max-height: 640px; overflow-y: auto; }
.cal-grid { position: relative; }

.cal-row {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  min-height: 48px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.cal-time-label {
  padding: 2px 8px 0;
  font-size: 11px;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cal-cell { border-right: 1px solid var(--border-subtle); min-height: 48px; }
.cal-cell:last-child { border-right: none; }
.cal-cell.today-col { background: var(--primary-ghost); }

.cal-events { position: absolute; inset: 0 0 auto 0; pointer-events: none; }

.cal-event-block {
  position: absolute;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  padding: 2px 6px;
  font-size: 11px;
  overflow: hidden;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
  transition: filter .12s;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cal-event-block:hover { filter: brightness(.97); }
.cal-event-time { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-event-name { font-size: 11.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cal-now-line { position: absolute; height: 2px; background: var(--danger); z-index: 10; pointer-events: none; }
.cal-now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ═══════════════════════════════════════════
   VEÍCULOS — grid de cards + galeria
   ═══════════════════════════════════════════ */
.view-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 3px;
}

.view-toggle-btn {
  width: 30px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-toggle-btn.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-xs); }
.view-toggle-btn:hover:not(.active) { color: var(--text); }

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

.vehicle-card {
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: box-shadow .15s, border-color .15s;
}

.vehicle-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-md); }

.vehicle-card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  height: auto;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  position: relative;
  overflow: hidden;
}

.vehicle-card-img img { width: 100%; height: 100%; object-fit: cover; }
.vehicle-card-status { position: absolute; top: 10px; right: 10px; }
.vehicle-card-status .status-badge { background: var(--bg-card); box-shadow: var(--shadow-sm); }

.vehicle-card-body { padding: 12px 14px; }
.vehicle-card-title { font-size: 14.5px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.vehicle-card-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.vehicle-card-specs { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.vehicle-card-spec { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.vehicle-card-price { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); font-variant-numeric: tabular-nums; }
.vehicle-card-fipe { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.vehicle-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.vehicle-no-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.opcionais-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 12px; }
.opcional-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }

.margin-display {
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  text-align: center;
}

.margin-item-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.margin-item-value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.margin-positive { color: var(--success); }
.margin-negative { color: var(--danger); }

/* ═══════════════════════════════════════════
   DROP ZONE — upload
   ═══════════════════════════════════════════ */
.drop-zone {
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-surface);
  transition: border-color .15s, background-color .15s;
}

.drop-zone:hover { border-color: var(--primary); background: var(--primary-ghost); }
.drop-zone.drag-over { border-color: var(--primary); border-style: solid; background: var(--primary-glow); }

.drop-zone-content { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.drop-zone-text { font-size: 14px; color: var(--text-secondary); }
.drop-zone-link { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.drop-zone-hint { font-size: 12px; color: var(--text-muted); }

/* ═══════════════════════════════════════════
   FILTROS (barra de busca das listagens)
   ═══════════════════════════════════════════ */
.filter-card { margin-bottom: 16px; padding: 14px 16px !important; }
.filter-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter-form .form-label { margin-bottom: 6px; }

/* ═══════════════════════════════════════════
   RESPONSIVO
   ═══════════════════════════════════════════ */
@media (max-width: 1280px) {
  .bottom-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bottom-row > .table-card { grid-column: 1 / -1; }
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-row { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .form-layout { grid-template-columns: minmax(0, 1fr); }
  .form-layout-side { position: static; }
  .form-grid-addr { grid-template-columns: 1fr 1fr; }
  .bottom-row, .donut-row { grid-template-columns: minmax(0, 1fr); }
  .breadcrumb { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(9, 9, 11, .45);
    z-index: 45;
  }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar-toggle { display: inline-flex; }
  .page { padding: 16px 16px 40px; }
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .address-dual { grid-template-columns: minmax(0, 1fr); }
  .email-layout { grid-template-columns: minmax(0, 1fr); }
  .email-sidebar { position: static; }
  .vehicle-grid { grid-template-columns: minmax(0, 1fr); }
  .margin-display { grid-template-columns: minmax(0, 1fr); }
  .form-section, .detail-section, .detail-header { padding: 16px; }
  .form-actions { padding: 12px 16px; }
  .cal-day-headers, .cal-row { grid-template-columns: 40px repeat(7, 1fr); }
  .cal-time-label { font-size: 10px; padding: 2px 4px 0; }
}

@media (max-width: 520px) {
  .search-box { display: none; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
