/* ════════════════════════════════════════════════════════════
   CNPJ Insights — Painel /app/
   Paleta Casa dos Dados (azul) alinhada com styles.css principal.
   ════════════════════════════════════════════════════════════ */

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

:root {
  /* Brand (azul Casa dos Dados — mesma do styles.css) */
  --brand-900: #0c2a52;
  --brand-800: #133b73;
  --brand-700: #1e40af;
  --brand-600: #2563eb;
  --brand-500: #3b82f6;
  --brand-100: #dbeafe;
  --brand-50:  #eff6ff;

  /* Semantic */
  --accent:  #06b6d4;
  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --danger:  #ef4444;
  --danger-50: #fef2f2;

  /* Ink (slate) */
  --ink-950: #020617;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --sidebar-w: 248px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--ink-50);
  color: var(--ink-900);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.022em; line-height: 1.2; color: var(--ink-900); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-800); }

/* ────────── LAYOUT ────────── */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--brand-900);
  color: #e0e7f1;
  padding: 22px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar .logo {
  font-size: 16px; font-weight: 700; letter-spacing: -0.02em;
  padding: 4px 12px 22px; display: flex; align-items: center; gap: 10px;
  color: white;
}
.sidebar .logo .mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: white; font-size: 13px;
  box-shadow: 0 4px 12px -2px rgba(59, 130, 246, .35);
}
.sidebar nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 7px;
  color: #94a3b8; font-weight: 500; font-size: 13.5px;
  transition: background .12s ease, color .12s ease;
  text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,.04); color: white; }
.sidebar nav a.active {
  background: linear-gradient(135deg, rgba(59,130,246,.16), rgba(30,64,175,.10));
  color: white;
  position: relative;
}
.sidebar nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--brand-500);
}
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar nav .section {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: #475569; padding: 14px 12px 6px; margin-top: 8px;
  font-weight: 600;
}
.sidebar .footer {
  padding-top: 14px; margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 13px;
  flex-shrink: 0;
}
.sidebar .footer .who { flex: 1; min-width: 0; overflow: hidden; }
.sidebar .footer .who .name {
  color: white; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Main */
.main { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }

/* ────────── COMPONENTS ────────── */
.card {
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px; border: 0;
  background: var(--ink-900); color: white; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  transition: all .14s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--ink-700); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--brand-700);
  box-shadow: 0 4px 14px -3px rgba(30, 64, 175, .35);
}
.btn-primary:hover { background: var(--brand-800); box-shadow: 0 6px 18px -4px rgba(30, 64, 175, .45); }

.btn-outline {
  background: white; color: var(--ink-900);
  border: 1px solid var(--ink-200); box-shadow: none;
}
.btn-outline:hover { background: var(--ink-50); border-color: var(--ink-300); }

.btn-ghost { background: transparent; color: var(--ink-700); box-shadow: none; }
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; border-radius: 10px; }
.btn-block { width: 100%; }

.input, .select {
  width: 100%;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: 8px;
  font-family: inherit; font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease;
  color: var(--ink-900);
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .18);
}
.input::placeholder { color: var(--ink-400); }

.label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-700);
  margin-bottom: 6px;
}

/* Hero — gradiente azul Casa dos Dados */
.hero {
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
  color: white;
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: 0 16px 40px -16px rgba(30, 64, 175, .45);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.15) 0%, transparent 70%);
  pointer-events: none;
}
.hero h2 { color: white; font-size: 24px; margin-bottom: 6px; font-weight: 700; letter-spacing: -0.02em; }
.hero p { color: rgba(255,255,255,.85); font-size: 14.5px; max-width: 540px; }
.hero .btn-primary {
  background: white; color: var(--brand-700);
  box-shadow: 0 6px 18px -4px rgba(0,0,0,.18);
}
.hero .btn-primary:hover { background: var(--ink-50); color: var(--brand-800); }

/* KPI cards */
.kpi {
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color .15s, box-shadow .15s;
}
.kpi:hover { border-color: var(--ink-300); box-shadow: var(--shadow); }
.kpi .icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-50); color: var(--brand-700);
  margin-bottom: 12px;
}
.kpi .icon svg { width: 18px; height: 18px; }
.kpi .label { font-size: 13px; color: var(--ink-500); margin-bottom: 4px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; color: var(--ink-900); line-height: 1.1; }
.kpi .value small { font-size: 14px; color: var(--ink-500); font-weight: 500; }
.kpi .progress {
  margin-top: 12px; height: 5px; background: var(--ink-100); border-radius: 4px; overflow: hidden;
}
.kpi .progress > div {
  height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
  border-radius: 4px;
  transition: width .4s ease;
}
.kpi .extra { font-size: 11.5px; color: var(--ink-500); margin-top: 8px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-free { background: var(--ink-100); color: var(--ink-700); }
.badge-pro { background: var(--brand-100); color: var(--brand-800); }
.badge-enterprise { background: linear-gradient(135deg, var(--brand-700), var(--brand-500)); color: white; }
.badge-success { background: var(--success-50); color: #065f46; }
.badge-warn { background: var(--warning-50); color: #92400e; }
.badge-danger { background: var(--danger-50); color: #991b1b; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; font-size: 13.5px; }
.table th {
  color: var(--ink-500); text-transform: uppercase;
  font-size: 11px; letter-spacing: .04em; font-weight: 600;
  border-bottom: 1px solid var(--ink-200);
  background: var(--ink-50);
}
.table tbody tr { border-bottom: 1px solid var(--ink-100); transition: background .1s; }
.table tbody tr:hover { background: var(--ink-50); }
.table tbody tr:last-child { border-bottom: 0; }
.table code {
  background: var(--ink-100); padding: 2px 7px; border-radius: 4px;
  font-size: 12px; font-family: var(--font-mono); color: var(--ink-700);
}

/* Alerts */
.alert {
  padding: 12px 14px; border-radius: 8px; font-size: 13.5px;
  margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-error { background: var(--danger-50); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-50); color: #065f46; border-color: #a7f3d0; }
.alert-info { background: var(--brand-50); color: var(--brand-800); border-color: #bfdbfe; }
.alert-warn { background: var(--warning-50); color: #92400e; border-color: #fde68a; }

/* Empty state */
.empty {
  text-align: center; padding: 48px 24px;
  color: var(--ink-500);
}
.empty .ico {
  width: 44px; height: 44px; margin: 0 auto 12px;
  color: var(--ink-300);
}
.empty .ico svg { width: 100%; height: 100%; }
.empty .title { font-size: 15px; font-weight: 600; color: var(--ink-700); margin-bottom: 4px; }
.empty .desc { font-size: 13.5px; }

/* Helpers */
.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.muted { color: var(--ink-500); font-size: 13.5px; }
.tiny { font-size: 12px; color: var(--ink-500); }
.hide { display: none !important; }
.code-block {
  background: var(--ink-900); color: var(--ink-100);
  padding: 14px 16px; border-radius: 8px;
  font-family: var(--font-mono); font-size: 12.5px;
  overflow-x: auto; line-height: 1.6;
}

/* Auth — split screen */
.auth-shell { display: grid; grid-template-columns: 1.2fr 1fr; min-height: 100vh; }
.auth-side {
  background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-700) 100%);
  color: white;
  padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-side::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 25% 80%, rgba(59,130,246,.25) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(6,182,212,.15) 0%, transparent 50%);
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side .brand-mark { display: flex; align-items: center; gap: 11px; }
.auth-side .brand-mark .mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--brand-700); font-size: 15px;
}
.auth-side .brand-name { font-size: 17px; font-weight: 700; }
.auth-side .pitch h1 {
  font-size: 38px; font-weight: 700; letter-spacing: -0.035em;
  line-height: 1.1; margin-bottom: 16px; color: white;
}
.auth-side .pitch p { font-size: 15px; color: rgba(255,255,255,.8); max-width: 360px; }
.auth-side .features { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; max-width: 380px; }
.auth-side .features div {
  display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255,255,255,.92);
}
.auth-side .features div svg { width: 16px; height: 16px; color: var(--brand-500); flex-shrink: 0; }
.auth-side .copyright { font-size: 12px; color: rgba(255,255,255,.55); }

.auth-form {
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px;
  background: white;
}
.auth-form-inner { width: 100%; max-width: 380px; margin: 0 auto; }
.auth-form h2 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.025em;
  margin-bottom: 6px;
}
.auth-form .subtitle { color: var(--ink-500); font-size: 14px; margin-bottom: 24px; }

.tab-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--ink-100); padding: 4px; border-radius: 9px;
  margin-bottom: 16px;
}
.tab-switch button {
  border: 0; background: transparent; padding: 8px;
  border-radius: 6px; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-500); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .12s ease;
}
.tab-switch button svg { width: 14px; height: 14px; }
.tab-switch button.active { background: white; color: var(--ink-900); box-shadow: var(--shadow-sm); }

/* Score circle */
.score-circle {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0;
  background: conic-gradient(var(--brand-700) 0deg, var(--brand-500) var(--deg, 0deg), var(--ink-100) var(--deg, 0deg) 360deg);
}
.score-circle::before {
  content: ""; position: absolute; inset: 6px;
  background: white; border-radius: 50%;
}
.score-circle .val {
  position: relative; font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
}
.score-circle.good { background: conic-gradient(var(--success) 0deg, #34d399 var(--deg), var(--ink-100) var(--deg) 360deg); }
.score-circle.warn { background: conic-gradient(var(--warning) 0deg, #fbbf24 var(--deg), var(--ink-100) var(--deg) 360deg); }
.score-circle.bad  { background: conic-gradient(var(--danger) 0deg, #f87171 var(--deg), var(--ink-100) var(--deg) 360deg); }

/* Pricing */
.pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 28px; }
.price-card {
  background: white; border: 1px solid var(--ink-200);
  border-radius: var(--radius-xl); padding: 30px 26px;
  position: relative;
  transition: transform .18s, box-shadow .18s;
}
.price-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.price-card.featured {
  border: 0; background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
  color: white; box-shadow: 0 16px 40px -12px rgba(30, 64, 175, .45);
  transform: scale(1.03);
}
.price-card.featured:hover { transform: scale(1.03) translateY(-2px); }
.price-card .plan-name {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  opacity: .85; margin-bottom: 8px;
}
.price-card .price {
  font-size: 40px; font-weight: 700; letter-spacing: -0.035em; line-height: 1;
}
.price-card .price small { font-size: 13px; font-weight: 500; opacity: .65; }
.price-card .features-list { list-style: none; padding: 0; margin: 22px 0; font-size: 13.5px; }
.price-card .features-list li {
  padding: 6px 0; display: flex; align-items: center; gap: 8px;
}
.price-card .features-list li svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--success); }
.price-card.featured .features-list li svg { color: white; }
.price-card .featured-tag {
  position: absolute; top: -11px; right: 22px;
  background: white; color: var(--brand-700);
  padding: 4px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  box-shadow: var(--shadow);
}

/* Markdown content */
.markdown { font-size: 14.5px; line-height: 1.65; color: var(--ink-900); }
.markdown h1 { font-size: 20px; font-weight: 700; margin: 22px 0 10px; }
.markdown h2, .markdown h3 { font-size: 16px; font-weight: 700; margin: 20px 0 8px; }
.markdown ul { padding-left: 22px; margin: 10px 0; }
.markdown li { margin: 4px 0; }
.markdown p { margin: 8px 0; }
.markdown hr { border: 0; border-top: 1px solid var(--ink-200); margin: 18px 0; }
.markdown strong { font-weight: 700; }

/* Mobile responsive */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; bottom: auto; height: auto;
    flex-direction: row; padding: 10px 14px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid rgba(255,255,255,.06);
  }
  .sidebar nav { flex-direction: row; gap: 4px; overflow-x: auto; flex: 1; }
  .sidebar .logo { padding: 0 8px 0 0; flex-shrink: 0; }
  .sidebar nav a.active::before { display: none; }
  .sidebar nav .section { display: none; }
  .sidebar .footer { display: none; }
  .main { padding: 24px 18px 48px; }
  .grid-3, .pricing { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { padding: 30px 24px; min-height: 240px; }
  .auth-side .pitch h1 { font-size: 28px; }
  .auth-form { padding: 30px 24px; }
  .price-card.featured { transform: none; }
  .price-card.featured:hover { transform: translateY(-2px); }
}

/* ────────── PRINT / PDF ────────── */
@media print {
  .sidebar, .card-header a, .btn, #empty-ico, details { display: none !important; }
  body { background: white; font-size: 12px; }
  .app-shell { display: block; }
  .main { padding: 0; max-width: 100%; }
  .card { border: 0; box-shadow: none; padding: 0; }
  #layout { display: block !important; }
  #lista, .empty { display: none !important; }
  .print-header { display: flex !important; }
  .markdown { font-size: 12px; }
  .score-circle { width: 70px; height: 70px; }
  @page { margin: 1.6cm; }
}
.print-header { display: none; align-items: center; justify-content: space-between;
  border-bottom: 2px solid var(--brand-700); padding-bottom: 12px; margin-bottom: 18px; }
.print-header .ph-brand { font-size: 16px; font-weight: 800; color: var(--brand-700); }
.print-header .ph-meta { font-size: 11px; color: var(--ink-500); text-align: right; }
