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

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --bg:        #0d0f12;
    --surface:   #13161b;
    --border:    rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.14);
    --text:      #e8eaed;
    --muted:     #6b7280;
    --accent:    #22d3a5;
    --accent-dim:#0d3d2e;
    --danger:    #f87171;
    --warning:   #fbbf24;
    --radius:    10px;
    --font-display: 'Syne', sans-serif;
    --font-body:    'DM Sans', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

.container--wide { max-width: 1200px; }

/* ── Page wrap ──────────────────────────────────────────────── */
.page-wrap {
    padding-top: 36px;
    padding-bottom: 60px;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
    border-bottom: 1px solid var(--border);
    background: rgba(13,15,18,0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 24px;
}

.logo {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--text);
    flex-shrink: 0;
}

.logo span { color: var(--accent); }

/* ── Header search ──────────────────────────────────────────── */
.header-search {
    display: flex;
    flex: 1;
    max-width: 480px;
}

.header-search form {
    display: flex;
    width: 100%;
    gap: 0;
}

.header-search input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 8px 14px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
}

.header-search input:focus { border-color: var(--accent); }

.header-search button {
    background: var(--accent);
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 8px 16px;
    color: #000;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: opacity .2s;
    white-space: nowrap;
}

.header-search button:hover { opacity: .85; }

nav a {
    font-size: 13px;
    color: var(--muted);
    transition: color .2s;
    white-space: nowrap;
}

nav a:hover { color: var(--text); }

/* ── Main ───────────────────────────────────────────────────── */
main { flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.card--hover {
    transition: border-color .2s, transform .2s;
    cursor: pointer;
}

.card--hover:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.card--flush { padding: 0; }
.card--mb    { margin-bottom: 20px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge--ativa {
    background: rgba(34,211,165,0.1);
    color: var(--accent);
    border: 1px solid rgba(34,211,165,0.25);
}

.badge--ativa::before { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.badge--inativa {
    background: rgba(248,113,113,0.1);
    color: var(--danger);
    border: 1px solid rgba(248,113,113,0.25);
}

.badge--inativa::before { background: var(--danger); }

.badge--suspensa {
    background: rgba(251,191,36,0.1);
    color: var(--warning);
    border: 1px solid rgba(251,191,36,0.25);
}

.badge--suspensa::before { background: var(--warning); }

/* ── Field label/value ──────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 3px; }

.field__label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
}

.field__value {
    font-size: 14px;
    color: var(--text);
}

.field__value--cnpj {
    font-family: var(--font-mono);
    font-size: 15px;
    letter-spacing: .04em;
}

/* ── Fields grid ────────────────────────────────────────────── */
.fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px 28px;
}

.fields-grid--tight {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.fields-grid--mb { margin-bottom: 24px; }

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

/* ── Divider ────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── Section title ──────────────────────────────────────────── */
.section-title {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 14px;
}

/* ── Big search ─────────────────────────────────────────────── */
.search-big {
    display: flex;
    gap: 0;
    max-width: 600px;
    margin: 0 auto;
}

.search-big input {
    flex: 1;
    background: var(--surface);
    border: 2px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 16px 20px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 16px;
    letter-spacing: .04em;
    outline: none;
    transition: border-color .2s;
}

.search-big input:focus { border-color: var(--accent); }
.search-big input::placeholder { color: var(--muted); font-size: 14px; }

.search-big button {
    background: var(--accent);
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0 28px;
    color: #000;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: opacity .2s;
}

.search-big button:hover { opacity: .85; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td a:hover { color: var(--accent); }

/* ── Footer ─────────────────────────────────────────────────── */
footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    margin-top: 60px;
    color: var(--muted);
    font-size: 13px;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

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

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

.fade-up { animation: fadeUp .35s ease forwards; }

/* ── Autocomplete ───────────────────────────────────────────── */
.ac-wrap { position: relative; flex: 1; display: flex; flex-direction: column; }

.ac-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #1a1d24;
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    z-index: 200;
    overflow: hidden;
}

.ac-dropdown.ac-open { display: block; }

.ac-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active { background: rgba(34,211,165,0.07); }

.ac-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.ac-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ac-cnpj  { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.ac-dot   { width: 6px; height: 6px; border-radius: 50%; }
.ac-dot--ativa   { background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.ac-dot--inativa { background: var(--danger); }

/* ── Utilities ──────────────────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-muted   { color: var(--muted); }
.text-danger  { color: var(--danger); }
.text-sm      { font-size: 14px; }
.text-xs      { font-size: 13px; }
.font-mono    { font-family: var(--font-mono); }

/* ── Hero (home) ────────────────────────────────────────────── */
.hero {
    padding: 80px 0 60px;
    text-align: center;
}

.hero__eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 20px;
}

.hero__title {
    font-family: var(--font-display);
    font-size: clamp(32px, 5vw, 52px);
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.1;
    margin-bottom: 16px;
}

.hero__subtitle {
    color: var(--muted);
    font-size: 16px;
    margin-bottom: 40px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.hero__hint  { color: var(--muted); font-size: 12px; margin-top: 16px; }
.hero__error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ── Stats (home) ───────────────────────────────────────────── */
.stats { padding: 0 0 60px; }

.stats__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.stat-card {
    text-align: center;
    padding: 20px;
}

.stat-card__value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
}

.stat-card__value--neutral { color: var(--text); }

.stat-card__label {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* ── States section (home) ──────────────────────────────────── */
.states-section { padding: 0 0 80px; }

.section-heading {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.state-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.state-link {
    display: inline-block;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    transition: border-color .2s, color .2s;
}

.state-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Page header ────────────────────────────────────────────── */
.page-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-title--lg { font-size: 24px; }

.page-meta {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 28px;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px;
}

.empty-state__icon  { font-size: 32px; margin-bottom: 16px; }
.empty-state__title { font-size: 16px; margin-bottom: 8px; }
.empty-state__hint  { color: var(--muted); font-size: 13px; }

/* ── Table helpers ──────────────────────────────────────────── */
.link-table {
    font-weight: 500;
    transition: color .2s;
}

.link-table:hover { color: var(--accent); }

.text-fantasia {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.td-cnpj     { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.td-location { font-size: 13px; color: var(--muted); }
.td-date     { font-size: 12px; color: var(--muted); }
.td-rank     { color: var(--muted); font-size: 12px; width: 40px; }
.td-name     { font-weight: 500; }
.td-number   { font-family: var(--font-mono); font-size: 13px; }
.td-empty    { text-align: center; color: var(--muted); padding: 40px; }

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 24px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.breadcrumb a {
    color: var(--muted);
    transition: color .2s;
}

.breadcrumb a:hover { color: var(--text); }

.breadcrumb__current { color: var(--text); }

/* ── Company header ─────────────────────────────────────────── */
.company-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
}

.company-title {
    font-family: var(--font-display);
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.2;
    margin-bottom: 6px;
}

.company-subtitle {
    font-size: 14px;
    color: var(--muted);
}

/* ── CNPJ copy row ──────────────────────────────────────────── */
.cnpj-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-copy {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 2px 8px;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
    transition: all .2s;
    font-family: var(--font-body);
}

.btn-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Section block ──────────────────────────────────────────── */
.section-block { margin-bottom: 24px; }

.cnae-code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    margin-right: 8px;
}

.contact-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.simples-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ── QSA ────────────────────────────────────────────────────── */
.list-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.qsa-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.qsa-name  { font-size: 14px; font-weight: 500; }
.qsa-since { font-size: 11px; color: var(--muted); margin-left: 8px; }
.qsa-role  { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ── Related companies ──────────────────────────────────────── */
.related-section { margin-top: 40px; }

.related-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

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

.related-card {
    display: block;
    padding: 16px;
}

.related-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.related-cnpj {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.pagination__btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    background: var(--surface);
    color: inherit;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid var(--border);
    transition: border-color .2s;
}

.pagination__btn:hover              { border-color: var(--accent); }
.pagination__btn--current           { background: var(--accent); color: #000; font-weight: 700; border-color: var(--accent); }
.pagination__btn--current:hover     { border-color: var(--accent); }
.pagination__btn--disabled          { color: var(--muted); cursor: default; }
.pagination__btn--disabled:hover    { border-color: var(--border); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    .header-search { display: none; }

    .search-big { flex-direction: column; }
    .search-big input {
        border-right: 2px solid var(--border);
        border-bottom: none;
        border-radius: var(--radius) var(--radius) 0 0;
    }
    .search-big button {
        border-radius: 0 0 var(--radius) var(--radius);
        padding: 14px;
    }

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

    .stats__grid { grid-template-columns: 1fr; max-width: 280px; }
}