/* ═══════════════════════════════════════════════════════
   MeuCNPJ — Design System
   ═══════════════════════════════════════════════════════ */

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

:root {
  --bg:        #0f1117;
  --surface:   #181c27;
  --surface2:  #1e2334;
  --border:    #2a2f42;
  --text:      #e8eaf0;
  --muted:     #8891aa;
  --accent:    #3b82f6;
  --accent-bg: #1e293b;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --tag-bg:    #1e2334;
  --radius:    10px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ─── HEADER ─────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
}
.logo span { color: var(--accent); }
.logo-badge {
  font-size: .65rem;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
  letter-spacing: .5px;
}

/* ─── HERO / SEARCH ──────────────────────────────── */
.hero {
  max-width: 680px;
  margin: 60px auto 0;
  padding: 0 20px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.5px;
  margin-bottom: 12px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 32px;
}

.search-box {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  transition: border-color .2s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box.invalid { border-color: var(--red); }
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 1.05rem;
  padding: 8px 12px;
  letter-spacing: 1px;
}
.search-box input::placeholder {
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0;
  font-size: .95rem;
}
.btn-search {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 24px;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-search:hover { opacity: .9; }
.btn-search:active { transform: scale(.97); }
.btn-search:disabled { opacity: .5; cursor: not-allowed; }

.search-hint {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.hint-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .78rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, color .2s;
  font-family: 'DM Mono', monospace;
  letter-spacing: .5px;
}
.hint-chip:hover { border-color: var(--accent); color: var(--text); }

/* ─── HISTÓRICO RECENTE ─────────────────────────── */
.history-section {
  max-width: 680px;
  margin: 24px auto 0;
  padding: 0 20px;
  text-align: center;
}
.history-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}
.history-chips {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.history-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .75rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  font-family: 'DM Mono', monospace;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.history-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-bg);
}
.history-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .7rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.history-chip:hover .history-remove {
  opacity: 1;
}
.history-remove:hover {
  color: var(--red);
}

/* ─── LOADING ────────────────────────────────────── */
#loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 60px auto;
  color: var(--muted);
  font-size: .9rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── ERROR ──────────────────────────────────────── */
#error-msg {
  display: none;
  max-width: 500px;
  margin: 40px auto;
  background: #1e1010;
  border: 1px solid #3d1515;
  border-radius: var(--radius);
  padding: 20px 24px;
  color: #f87171;
  text-align: center;
  font-size: .9rem;
}
#error-msg strong { display: block; font-size: 1rem; margin-bottom: 6px; }

/* ─── TOAST ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast-icon {
  color: var(--green);
  font-size: 1rem;
}

/* ─── RESULT ─────────────────────────────────────── */
#result {
  display: none;
  max-width: 860px;
  margin: 40px auto 80px;
  padding: 0 20px;
  animation: fadeInUp .4s ease-out;
}

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

/* Status banner */
.status-banner {
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.status-banner.ativa  { background: #0f1f12; border: 1px solid #166534; }
.status-banner.baixada { background: #1a1010; border: 1px solid #7f1d1d; }
.status-banner.suspensa { background: #1c1700; border: 1px solid #78350f; }
.status-banner.inapta { background: #1c1700; border: 1px solid #78350f; }
.status-banner.nula { background: #1a1010; border: 1px solid #7f1d1d; }

.company-name { font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.company-fantasy { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.banner-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.status-pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}
.pill-ativa    { background: #166534; color: #bbf7d0; }
.pill-baixada  { background: #7f1d1d; color: #fecaca; }
.pill-suspensa { background: #78350f; color: #fed7aa; }
.pill-inapta   { background: #78350f; color: #fed7aa; }
.pill-nula     { background: #7f1d1d; color: #fecaca; }

/* Cache badge */
.cache-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .68rem;
  font-weight: 600;
  color: var(--yellow);
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 12px;
  padding: 2px 10px;
  letter-spacing: .3px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 16px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  background: var(--surface2);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: .72rem;
  font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Section card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  animation: fadeIn .3s ease-out;
}

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

.card-title {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}

/* Grid fields */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 24px;
}
.field label {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  display: block;
  margin-bottom: 4px;
}
.field span {
  font-size: .92rem;
  color: var(--text);
  word-break: break-word;
}
.field span.mono { font-family: 'DM Mono', monospace; font-size: .88rem; }
.field-full { grid-column: 1 / -1; }

/* Copy button */
.copy-wrap { display: inline-flex; align-items: center; gap: 8px; }
.btn-copy {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: .7rem;
  padding: 2px 8px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-copy:hover { color: var(--text); border-color: var(--accent); }

/* CNAE badges */
.cnae-list { display: flex; flex-direction: column; gap: 8px; }
.cnae-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
}
.cnae-code {
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 2px;
}
.cnae-desc { font-size: .88rem; }
.cnae-badge {
  font-size: .65rem;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
  white-space: nowrap;
}

/* Phone list */
.phone-list { display: flex; flex-wrap: wrap; gap: 8px; }
.phone-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: 'DM Mono', monospace;
  font-size: .88rem;
}
.fax-badge {
  font-size: .65rem;
  background: #1c1700;
  color: #fcd34d;
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
}

/* QSA table */
.qsa-list { display: flex; flex-direction: column; gap: 10px; }
.qsa-item {
  background: var(--surface2);
  border-radius: 8px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
}
.qsa-name { font-weight: 500; font-size: .92rem; }
.qsa-qual {
  font-size: .78rem;
  color: var(--muted);
  grid-row: 2;
}
.qsa-date {
  font-size: .75rem;
  color: var(--muted);
  text-align: right;
  align-self: start;
}
.qsa-faixa {
  font-size: .73rem;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  color: var(--muted);
  justify-self: end;
  align-self: end;
}

/* CNO table */
.cno-list { display: flex; flex-direction: column; gap: 10px; }
.cno-item {
  background: var(--surface2);
  border-radius: 8px;
  padding: 14px 18px;
}
.cno-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.cno-nome { font-weight: 500; font-size: .9rem; }
.cno-code {
  font-family: 'DM Mono', monospace;
  font-size: .75rem;
  color: var(--accent);
  white-space: nowrap;
}
.cno-body { display: flex; flex-wrap: wrap; gap: 12px; }
.cno-field label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: block; }
.cno-field span { font-size: .82rem; }
.pill-cno-ativa    { background: #166534; color: #bbf7d0; font-size: .68rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.pill-cno-encerrada { background: #7f1d1d; color: #fecaca; font-size: .68rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.pill-cno-paralisada { background: #78350f; color: #fed7aa; font-size: .68rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-size: .88rem;
}

/* Print button */
.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}
.btn-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: .8rem;
  padding: 7px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-sm:hover { color: var(--text); border-color: var(--accent); }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
}
footer a {
  color: var(--muted);
  transition: color .15s;
}
footer a:hover {
  color: var(--accent);
}

/* ─── RESPONSIVE ────────────────────────────────── */
@media (max-width: 540px) {
  .fields-grid { grid-template-columns: 1fr 1fr; }
  .company-name { font-size: 1.1rem; }
  .qsa-item { grid-template-columns: 1fr; }
  .cno-header { flex-direction: column; }
}

/* ─── PRINT ─────────────────────────────────────── */
@media print {
  body { background: #fff; color: #111; }
  header, .search-box, .hint-chip, .toolbar, footer,
  .btn-copy, .history-section, .toast, .cache-badge { display: none !important; }
  .card { border: 1px solid #ddd; background: #fff; }
  .tabs { display: none; }
  .tab-panel { display: block !important; }
  .status-banner { background: #f0fdf4 !important; border-color: #86efac !important; }
  #result { animation: none; }
  .card { animation: none; }
}
