:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #5c6475;
    --border: #e1e4ea;
    --accent: #1f6feb;
    --accent-soft: #e8f0fe;
    --accent-text: #0b4dbf;
    --danger-soft: #fdecec;
    --danger-text: #a01b1b;
    --radius: 10px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418;
        --surface: #1a1e24;
        --text: #e7eaf0;
        --muted: #9aa3b2;
        --border: #2b313b;
        --accent: #4c8dff;
        --accent-soft: #1c2a44;
        --accent-text: #9cc0ff;
        --danger-soft: #3a1c1c;
        --danger-text: #ffb4b4;
    }
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.6; background: var(--bg); }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 .25rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

button {
    font: inherit;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    padding: .5rem 1rem;
    cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; margin-top: 1rem; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input {
    font: inherit;
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
label { display: block; font-size: .9rem; margin: .9rem 0 .3rem; }

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.brand-mark {
    width: 2rem; height: 2rem; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: #fff;
}

.alert { background: var(--danger-soft); color: var(--danger-text); padding: .6rem .8rem; border-radius: var(--radius); margin-top: 1rem; }

/* Entrada */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 2rem;
}
.auth-card h1 { margin-top: 1.5rem; }

/* Painel */
body.panel { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.25rem 1rem; }
.sidebar nav { margin-top: 1.75rem; display: flex; flex-direction: column; gap: .25rem; }
.nav-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem; border-radius: var(--radius);
    color: var(--text); text-decoration: none;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-step {
    width: 1.5rem; height: 1.5rem; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem; border: 1px solid var(--border);
}
.nav-item.active .nav-step { border-color: var(--accent); }

.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.account { font-weight: 600; }
/* Item do grid: sem min-width 0 ele cresce até a largura da maior tabela (as tabelas rolam dentro de .table-wrap). */
.main { min-width: 0; }
.content { padding: 1.5rem; max-width: 960px; }

.flow { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; font-size: .85rem; }
.flow li { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .2rem .8rem; color: var(--muted); }
.flow li + li::before { content: "→ "; }

.placeholder {
    margin-top: 1.5rem; padding: 2rem;
    border: 1px dashed var(--border); border-radius: 14px; background: var(--surface);
    color: var(--muted);
}

@media (max-width: 720px) {
    body.panel { grid-template-columns: minmax(0, 1fr); }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; margin-top: 1rem; }
    .content { padding: 1rem; }
}

/* Conexões (etapa 2) */
h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
:root { --ok-soft: #e6f4ea; --ok-text: #1e6b34; --wait-soft: #fff4d6; --wait-text: #7a5300; }
@media (prefers-color-scheme: dark) {
    :root { --ok-soft: #173424; --ok-text: #9be3b0; --wait-soft: #3a2e10; --wait-text: #ffd98a; }
}
.flow li.flow-current { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.cards { display: grid; gap: 1rem; margin-top: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem 1.5rem; }
.card > p { margin-top: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.pill { font-size: .8rem; padding: .15rem .7rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok-text); border-color: transparent; }
.pill.wait { background: var(--wait-soft); color: var(--wait-text); border-color: transparent; }
.pill.bad { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem 1.5rem; margin: 1rem 0 0; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.actions { margin-top: 1rem; }
button.primary-inline { background: var(--accent); border-color: var(--accent); color: #fff; }
.subcard { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.notice { background: var(--bg); padding: .6rem .8rem; border-radius: var(--radius); margin-top: 1rem; }
.notice.success { background: var(--ok-soft); color: var(--ok-text); }
.declared { margin-top: 1rem; }
label.check { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1rem; font-size: .95rem; }
label.check input { width: auto; margin-top: .3rem; }

/* Nichos (etapa 3) */
details.niche > summary { cursor: pointer; list-style: none; }
details.niche > summary::-webkit-details-marker { display: none; }
details.niche > summary::before { content: "▸"; color: var(--muted); margin-right: .5rem; }
details.niche[open] > summary::before { content: "▾"; }
.niche-title { display: flex; flex-direction: column; flex: 1; }
.niche-name { font-weight: 600; font-size: 1.05rem; }
fieldset.group { border: 0; padding: 0; margin: 1.25rem 0 0; }
fieldset.group legend { font-weight: 600; font-size: .95rem; padding: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 1rem; }
.checks label.check { margin-top: .6rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; }
.field.invalid input { border-color: var(--danger-text); }
.field-error { color: var(--danger-text); font-size: .85rem; margin-top: .25rem; }

/* WhatsApp (etapa 5) */
img.qr { display: block; margin: 1rem 0; background: #fff; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); }
.paircode { font-size: 1.8rem; font-weight: 700; letter-spacing: .2rem; margin: 1rem 0; font-family: ui-monospace, Menlo, Consolas, monospace; }
.inline-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.inline-form .row { display: flex; gap: .5rem; }
.inline-form .row input { flex: 1; }

/* Destinos (etapa 6) */
.table-wrap { overflow-x: auto; margin-top: 1rem; }
.dest-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.dest-table th, .dest-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dest-table th { font-weight: 600; color: var(--muted); font-size: .8rem; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.declaration { margin-top: .75rem; }
ul.available { list-style: none; padding: 0; margin: 1rem 0 0; }
ul.available li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
select { font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }

/* Fila — links de afiliado (etapa 7) */
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; }
textarea { font: inherit; width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
textarea.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
ol.batch-items { margin: .5rem 0 0; padding-left: 1.25rem; }
h4 { font-size: .95rem; margin: 1rem 0 .25rem; }

/* Primeiros passos (etapa 9) */
ol.steps { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .75rem; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.25rem; }
.step.current { border-color: var(--accent); }
.step-head { display: flex; align-items: center; gap: .75rem; }
.step-title { font-weight: 600; flex: 1; }
.step-mark { width: 1.8rem; height: 1.8rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); font-size: .85rem; }
.step.done .step-mark { background: var(--ok-soft); color: var(--ok-text); border-color: transparent; }
.step p { margin-top: .4rem; }
a.button { display: inline-block; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem; color: var(--text); background: var(--surface); }
a.button.primary-inline { background: var(--accent); border-color: var(--accent); color: #fff; }
.activation { margin-top: 1.5rem; }
.activation button { margin-top: .75rem; }
.next-step { margin-bottom: 1.25rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Fila — seleção em massa das associações de links (sem JavaScript: a CSP não permite scripts).
   O número de "N associações" acompanha as caixas marcadas por contador de CSS. */
.bulk-select { counter-reset: bulk-sel; }
.bulk-select .bulk-check:checked { counter-increment: bulk-sel; }
.bulk-select .bulk-count::after { content: counter(bulk-sel); }
.bulk-select .row-actions { margin: .75rem 0 .25rem; }
.bulk-summary { margin-top: .75rem; }
