/* ============================================================
   ReachLoop Design System
   Dark-first, professional, clean animations
   Inspired by Emil Kowalski's polish principles
   ============================================================ */

/* ── Custom Properties ───────────────────────────────────── */
:root {
  --bg:          #0c0c0f;
  --surface:     #111115;
  --surface-2:   #18181d;
  --surface-3:   #1e1e25;
  --border:      #27272f;
  --border-subtle: #1c1c23;

  --text:        #f4f4f6;
  --text-2:      #a1a1aa;
  --text-3:      #71717a;

  --accent:      #818cf8;
  --accent-dark: #6366f1;
  --accent-muted:rgba(129, 140, 248, 0.10);

  --success:     #4ade80;
  --success-muted: rgba(74, 222, 128, 0.10);
  --warning:     #fbbf24;
  --warning-muted: rgba(251, 191, 36, 0.10);
  --danger:      #f87171;
  --danger-muted:  rgba(248, 113, 113, 0.10);
  --info:        #60a5fa;
  --info-muted:  rgba(96, 165, 250, 0.10);

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow:    0 4px 16px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);

  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:  cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position:  400px 0; }
}

@keyframes panelIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

[data-animate] {
  animation: fadeSlideUp 0.4s var(--ease-out) both;
}

/* ── Typography helpers ───────────────────────────────────── */
.mt-6 { margin-top: 24px; }

/* ── Brand ───────────────────────────────────────────────── */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.brand-icon-sm svg { width: 22px; height: 22px; }

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.btn-primary {
  background: var(--accent-dark);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}

.btn-primary:hover {
  background: #7178f5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

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

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-stop {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.btn-stop:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.4);
  transform: translateY(-1px);
}

/* Loading state */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn.loading svg:last-child {
  display: none;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn.loading .btn-spinner { display: block; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
  animation: fadeSlideUp 0.25s var(--ease-out);
}

.alert-error {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ── Forms ───────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.required {
  color: var(--danger);
  margin-left: 2px;
}

.field-hint {
  color: var(--text-3);
  font-weight: 400;
}

.field-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  width: 100%;
}

.field-input::placeholder { color: var(--text-3); }

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.field-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── Auth pages ──────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow-y: auto;
}

.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(99,102,241,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(129,140,248,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.auth-container {
  width: 100%;
  max-width: 380px;
  position: relative;
  z-index: 1;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

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

.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-switch {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 20px;
}

.auth-link {
  color: var(--accent);
  font-weight: 500;
  transition: opacity 0.1s;
}

.auth-link:hover { opacity: 0.8; }

/* ── Onboarding ──────────────────────────────────────────── */
.onboarding-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 24px 24px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-y: auto;
}

.onboarding-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% -5%, rgba(99,102,241,0.07) 0%, transparent 60%);
  pointer-events: none;
}

.onboarding-header {
  width: 100%;
  max-width: 680px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  position: relative;
  z-index: 1;
}

.onboarding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 680px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.onboarding-intro { margin-bottom: 28px; }

.onboarding-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 6px;
}

.onboarding-subtitle {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
  max-width: 480px;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 28px;
}

.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: all 0.15s var(--ease);
}

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

.tab.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Onboarding form ─────────────────────────────────────── */
.onboarding-form { display: flex; flex-direction: column; gap: 0; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

.field-full { grid-column: 1 / -1; }

/* ── Drop zone ───────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  position: relative;
  background: var(--surface-2);
  margin-bottom: 16px;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.drop-zone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  display: none;
}

.drop-icon {
  color: var(--text-3);
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
}

.drop-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
}

.drop-subtitle {
  font-size: 13px;
  color: var(--text-3);
}

.drop-browse {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.1s;
}

.drop-browse:hover { opacity: 0.8; }

.drop-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
}

.drop-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.drop-file-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--mono);
  animation: fadeIn 0.2s var(--ease);
}

.pdf-processing-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* ── App layout (dashboard) ──────────────────────────────── */
.app-page { overflow: hidden; }

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

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  gap: 4px;
  animation: fadeIn 0.3s var(--ease-out);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: all 0.15s var(--ease);
  text-decoration: none;
}

.sidebar-link:hover {
  color: var(--text-2);
  background: var(--surface-2);
}

.sidebar-link.active {
  color: var(--text);
  background: var(--surface-3);
}

.sidebar-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  font-family: var(--mono);
  transition: all 0.15s var(--ease);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 0;
  border-top: 1px solid var(--border-subtle);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-email {
  font-size: 11px;
  color: var(--text-3);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  color: var(--text-3);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  display: flex;
}

.logout-btn:hover {
  color: var(--danger);
  background: var(--danger-muted);
}

/* ── Main content ────────────────────────────────────────── */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
  animation: fadeIn 0.3s var(--ease-out);
}

.content-section { display: none; }
.content-section.active { display: block; }

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 2px;
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-3);
}

.section-subtitle strong { color: var(--text-2); }

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s var(--ease);
  animation: fadeSlideUp 0.4s var(--ease-out) both;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }

.stat-card:hover {
  border-color: var(--border);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  font-family: var(--mono);
  transition: all 0.3s var(--ease);
}

.stat-value.stat-success { color: var(--success); }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Pipeline log ────────────────────────────────────────── */
.pipeline-log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  animation: fadeSlideUp 0.3s var(--ease-out);
}

.pipeline-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.pipeline-log-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pipeline-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.pipeline-spinner.active { display: block; }

.pipeline-log-close {
  color: var(--text-3);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
  display: flex;
}

.pipeline-log-close:hover {
  color: var(--text-2);
  background: var(--surface-2);
}

.pipeline-entries {
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.pipeline-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
  animation: slideInUp 0.2s var(--ease-out) both;
  padding: 3px 0;
}

.pipeline-entry-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.pipeline-entry.info    .pipeline-entry-dot { background: var(--info); }
.pipeline-entry.success .pipeline-entry-dot { background: var(--success); }
.pipeline-entry.error   .pipeline-entry-dot { background: var(--danger); }

.pipeline-entry.info    { color: var(--text-2); }
.pipeline-entry.success { color: var(--success); }
.pipeline-entry.error   { color: var(--danger); }

/* ── Table card ──────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeSlideUp 0.4s 0.1s var(--ease-out) both;
}

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

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

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

thead th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 20px;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-subtle);
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.12s var(--ease);
  animation: fadeIn 0.25s var(--ease-out) both;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 13px 20px;
  font-size: 13px;
  color: var(--text-2);
  vertical-align: middle;
}

.td-name {
  font-weight: 500;
  color: var(--text);
  max-width: 160px;
}

.td-email {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-actions {
  width: 60px;
  text-align: right;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: all 0.12s var(--ease);
}

.action-btn:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

/* ── Status badges ───────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s var(--ease);
}

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

/* State colours */
.status-novo        { background: rgba(113,113,122,0.15); color: #a1a1aa; }
.status-novo        .status-dot { background: #71717a; }

.status-contactado  { background: rgba(96,165,250,0.12); color: var(--info); }
.status-contactado  .status-dot { background: var(--info); }

.status-respondeu   { background: var(--warning-muted); color: var(--warning); }
.status-respondeu   .status-dot { background: var(--warning); }

.status-em_conversa { background: var(--accent-muted); color: var(--accent); }
.status-em_conversa .status-dot { background: var(--accent); animation: pulse 1.5s ease infinite; }

.status-convertido  { background: var(--success-muted); color: var(--success); }
.status-convertido  .status-dot { background: var(--success); }

.status-descartado  { background: var(--danger-muted); color: var(--danger); }
.status-descartado  .status-dot { background: var(--danger); }

.status-sem_resposta { background: rgba(113,113,122,0.10); color: #71717a; }
.status-sem_resposta .status-dot { background: #52525b; }

.status-follow_up   { background: rgba(34,211,238,0.10); color: #22d3ee; }
.status-follow_up   .status-dot { background: #22d3ee; }

.status-invalido    { background: rgba(220,38,38,0.10); color: #f87171; }
.status-invalido    .status-dot { background: #dc2626; }

/* Conversion suggestion — classifier flags it, user must confirm/dismiss */
.suggestion-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  padding: 3px 6px 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--warning-muted);
  color: var(--warning);
  animation: pulse 1.8s ease infinite;
}

.suggestion-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.suggestion-confirm { background: var(--success-muted); color: var(--success); }
.suggestion-confirm:hover { background: var(--success); color: #052e16; }

.suggestion-dismiss { background: var(--danger-muted); color: var(--danger); }
.suggestion-dismiss:hover { background: var(--danger); color: #fff; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  gap: 12px;
}

.empty-icon { color: var(--text-3); margin-bottom: 4px; }

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

.empty-subtitle {
  font-size: 12px;
  color: var(--text-3);
  max-width: 260px;
  line-height: 1.6;
}

/* ── Skeleton loaders ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--radius-sm);
}

.table-loading {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-row {
  height: 38px;
  border-radius: var(--radius-sm);
}

/* ── Messages panel ──────────────────────────────────────── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 40;
  display: none;
  animation: fadeIn 0.2s var(--ease);
}

.panel-overlay.open { display: block; }

.messages-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease-out);
  box-shadow: var(--shadow-lg);
}

.messages-panel.open {
  transform: translateX(0);
}

.messages-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 2px;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}

.panel-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: all 0.12s var(--ease);
  flex-shrink: 0;
}

.panel-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.messages-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  font-size: 13px;
  color: var(--text-3);
}

.message-bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: slideInUp 0.2s var(--ease-out) both;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
}

.message-type-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-type-badge.enviado {
  background: var(--accent-muted);
  color: var(--accent);
}

.message-type-badge.recebido {
  background: var(--success-muted);
  color: var(--success);
}

.message-body {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.message-subject {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.message-text {
  font-size: 12px;
  color: var(--text-2);
  white-space: pre-wrap;
  line-height: 1.7;
}

.message-intent {
  font-size: 10px;
  font-weight: 500;
  color: var(--warning);
  background: var(--warning-muted);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}

/* ── Empresa card ────────────────────────────────────────── */
.empresa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeSlideUp 0.4s var(--ease-out) both;
}

.empresa-field {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  align-items: start;
}

.empresa-field:last-child { border-bottom: none; }

.empresa-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 2px;
}

.empresa-value {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Toast notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s var(--ease-out);
  max-width: 340px;
}

.toast-success {
  background: #052e16;
  color: var(--success);
  border: 1px solid rgba(74,222,128,0.2);
}

.toast-error {
  background: #1c0909;
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.2);
}

.toast-info {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform 0.15s var(--ease-spring);
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Delete action button ────────────────────────────────── */
.action-btn-danger {
  color: var(--text-3);
  transition: color 0.15s var(--ease);
}

.action-btn-danger:hover {
  color: var(--danger);
  background: var(--danger-muted);
}

/* ── 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(--text-3); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 64px; min-width: 64px; }
  .sidebar-brand .brand-name,
  .sidebar-link span:not(svg),
  .sidebar-badge,
  .user-info,
  .user-email { display: none; }
  .sidebar-link { justify-content: center; }
  .sidebar-brand { justify-content: center; }
  .app-main { padding: 20px 16px; }
  .messages-panel { width: 100%; }
}

@media (max-width: 600px) {
  .auth-card { padding: 24px; }
  .onboarding-card { padding: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
