/* Jarvis DS B — Mesa diurna
   Papel de trabalho quente, carimbo verde, Geist + Geist Mono.
   Fonte de verdade visual: criativos.php. Páginas novas usam shell-b + estas classes.

   Receita de página:
     jarvis_shell_b_start('slug', 'Título · Jarvis' [, $extraHead])
     <header class="topbar">  h1 + p.sub  |  .btn.btn-primary
     <div class="filters-bar">  .campo (busca/select)  +  period-filter
     <div class="counts">  opcional
     .page-state  loading / error / empty
     .kpi-grid > .kpi-card
     .charts-grid > .chart-card
     .secao-tabela > .tabela
     dialog.modal
     jarvis_shell_b_end()

   Não usar: shell.php, style.css, Inter, #2563eb, sidebar escura, sombra em card.
*/
:root {
    --bg: #F7F7F4;
    --surface: #FFFFFF;
    --surface-sunken: #F0F0EC;
    --ink: #1D1D1A;
    --ink-2: #55554F;
    --ink-3: #8A8A82;
    --line: #E5E5DF;
    --line-soft: #EEEEE9;
    --accent: #0C5C44;
    --accent-hover: #0A4D39;
    --accent-tint: #E2EFE9;
    --radius-card: 12px;
    --radius-ctrl: 8px;
    --radius-tag: 6px;
    --page-x: 28px;
    --ctrl-h: 38px;
    --gap: 16px;

    --positivo: #0C5C44;
    --negativo: #8A3A13;
    --negativo-bg: #F6EBD7;
    --neutro: #5A574F;
    --neutro-bg: #EAE8E2;
    --info: #2E4A6B;
    --info-bg: #E3EBF4;
    --aviso: #8A6A13;
    --aviso-bg: #F3EBD0;

    /* aliases do shell A — inline styles e JS legado */
    --text-primary: var(--ink);
    --text-secondary: var(--ink-2);
    --text-muted: var(--ink-3);
    --card-bg: var(--surface);
    --card-border: var(--line);
    --accent-primary: var(--accent);
    --accent-success: var(--positivo);
    --accent-danger: var(--negativo);
    --accent-warning: var(--aviso);
    --border-color: var(--line);
}

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

html, body { height: 100%; }

body {
    font-family: "Geist", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.shell {
    display: grid;
    grid-template-columns: 208px 1fr;
    min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100dvh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 20px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 14px;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    color: #FFFFFF;
    font-weight: 700;
    font-size: 14px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.brand-name {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}

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

.nav a {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-ctrl);
    color: var(--ink-2);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover { background: var(--surface-sunken); color: var(--ink); }

.nav a.ativo {
    background: var(--accent-tint);
    color: var(--accent);
    font-weight: 600;
}

.nav a:focus-visible,
.sidebar-logout:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sidebar-foot {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid var(--line-soft);
    font-size: 12px;
    color: var(--ink-3);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-logout {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
    text-align: left;
}

.sidebar-logout:hover { color: var(--negativo); }

/* ---------- Main ---------- */
.main { min-width: 0; padding-bottom: 32px; }

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 28px var(--page-x) 20px;
}

.topbar h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.topbar .sub {
    margin-top: 5px;
    font-size: 13.5px;
    color: var(--ink-2);
}

/* ---------- Botões ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--ctrl-h);
    padding: 0 16px;
    border-radius: var(--radius-ctrl);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-ghost,
.btn-secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-2);
}
.btn-ghost:hover,
.btn-secondary:hover { border-color: #D5D5CD; color: var(--ink); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--ctrl-h);
    padding: 0 16px;
    border-radius: var(--radius-ctrl);
    border: 1px solid var(--line);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn-danger-text {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--negativo);
    cursor: pointer;
}
.btn-danger-text:hover { text-decoration: underline; }

.btn-text {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
}
.btn-text:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------- Controles ---------- */
.campo {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-ctrl);
    padding: 0 12px;
    height: var(--ctrl-h);
    transition: border-color 0.15s ease;
}

.campo:focus-within { border-color: var(--accent); }

.campo select,
.campo input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    height: 100%;
    outline: none;
    padding-right: 4px;
}

.campo select { cursor: pointer; }

.campo-busca { min-width: 220px; }
.campo-busca input { width: 100%; }

.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 var(--page-x) 16px;
}

.counts {
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    color: var(--ink-3);
    padding: 0 var(--page-x) 14px;
}

.counts strong { color: var(--ink-2); font-weight: 600; }

.select-filter,
.form-input,
.period-date {
    height: var(--ctrl-h);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-ctrl);
    color: var(--ink);
    padding: 0 12px;
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
}

.select-filter { cursor: pointer; width: auto; min-width: 11rem; }

.select-filter:focus,
.form-input:focus,
.period-date:focus { border-color: var(--accent); }

.period-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.period-custom-fields {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.period-apply-btn { width: auto; }

/* ---------- Tabela ---------- */
.secao-tabela,
.table-card {
    margin: 0 var(--page-x) var(--gap);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.secao-tabela-head,
.table-title {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.secao-tabela-head p {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--ink-3);
    font-weight: 400;
}

.tabela-scroll,
.table-scroll { overflow-x: auto; }

.tabela,
.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tabela th, .tabela td,
.custom-table th, .custom-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.tabela th,
.custom-table th {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.th-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
}

.th-sort:hover { color: var(--ink); }

.th-sort::after {
    content: "↕";
    font-size: 10px;
    font-weight: 500;
    opacity: 0.35;
}

th[aria-sort="ascending"] .th-sort::after,
th[aria-sort="descending"] .th-sort::after {
    opacity: 1;
    color: var(--accent);
}

th[aria-sort="ascending"] .th-sort::after { content: "↑"; }
th[aria-sort="descending"] .th-sort::after { content: "↓"; }

.tabela tbody tr:hover td,
.custom-table tbody tr:hover td { background: var(--surface-sunken); }

.tabela .num,
.num {
    font-family: "Geist Mono", monospace;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.thumb {
    width: 64px;
    height: 40px;
    border-radius: var(--radius-tag);
    object-fit: cover;
    display: block;
    background: var(--surface-sunken);
    border: 1px solid var(--line);
}

.thumb-vazio {
    width: 64px;
    height: 40px;
    border-radius: var(--radius-tag);
    background: var(--surface-sunken);
    border: 1px dashed var(--line);
    display: grid;
    place-items: center;
    font-size: 10px;
    color: var(--ink-3);
}

.criativo-titulo { font-weight: 600; font-size: 13.5px; }

.criativo-conceito {
    margin-top: 2px;
    font-size: 12px;
    color: var(--ink-3);
    max-width: 340px;
    white-space: normal;
}

/* ---------- Tags e pills ---------- */
.tag {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 500;
    border-radius: var(--radius-tag);
    padding: 3px 8px;
    background: var(--neutro-bg);
    color: var(--neutro);
    white-space: nowrap;
}

.tag-acento { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.tag-funil-tofu { background: var(--info-bg); color: var(--info); font-weight: 600; }
.tag-funil-mid { background: var(--aviso-bg); color: var(--aviso); font-weight: 600; }
.tag-funil-bofu { background: var(--accent-tint); color: var(--accent); font-weight: 600; }

.pill,
.status-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-tag);
    padding: 3px 8px;
    white-space: nowrap;
}

.pill-erro,
.status-pill--error { color: var(--negativo); background: var(--negativo-bg); }
.pill-breve,
.status-pill--pending { color: var(--neutro); background: var(--neutro-bg); }

/* Status como select com cara de pill */
.status-select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    border-radius: var(--radius-tag);
    padding: 4px 22px 4px 9px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    background-color: var(--neutro-bg);
    color: var(--neutro);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%235A574F' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.status-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.status-em_teste { background-color: var(--info-bg); color: var(--info); }
.status-em_observacao { background-color: var(--aviso-bg); color: var(--aviso); }
.status-validado { background-color: var(--accent-tint); color: var(--accent); }
.status-escalando { background-color: var(--accent); color: #FFFFFF; }
.status-pausado { background-color: var(--negativo-bg); color: var(--negativo); }
.status-arquivado { background-color: var(--neutro-bg); color: var(--ink-3); }

.acoes { white-space: nowrap; }
.acoes > * + * { margin-left: 12px; }

/* ---------- KPI ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 0 var(--page-x) var(--gap);
}

.kpi-grid-2 { grid-template-columns: repeat(2, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 14px 16px;
}

.kpi-card-header {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 6px;
}

.kpi-val {
    font-family: "Geist Mono", monospace;
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ink);
}

.kpi-val-money { font-size: 18px; }

.kpi-trend {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
}

.trend-up,
.kpi-trend.trend-up { color: var(--positivo); }

.trend-down,
.kpi-trend.trend-down { color: var(--negativo); }

.trend-neutral,
.kpi-trend .trend-label {
    color: var(--ink-3);
    font-weight: 500;
}

/* ---------- Charts ---------- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 var(--page-x) var(--gap);
}

.charts-grid-single { grid-template-columns: 1fr; }

.chart-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 240px;
}

.chart-card-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.chart-card-subtitle {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--ink-3);
}

.chart-container {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 200px;
}

/* ---------- Dashboard: painel de cliente ---------- */
.clients-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 var(--page-x);
}

.client-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.client-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-soft);
}

.client-panel-title { min-width: 0; }

.client-panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.client-panel-last-lead {
    margin-top: 2px;
    font-size: 12px;
    color: var(--ink-3);
}

.client-panel-kpis {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.client-panel-kpi {
    background: var(--surface-sunken);
    border-radius: var(--radius-ctrl);
    padding: 10px 12px;
}

.client-panel-kpi > span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 2px;
}

.client-panel-kpi strong {
    display: block;
    font-family: "Geist Mono", monospace;
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.client-panel-kpi small {
    display: block;
    font-size: 11.5px;
    margin-top: 2px;
}

.client-panel-block + .client-panel-block {
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.client-panel-block-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 8px;
}

.client-panel-block-title-start {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.client-panel-block-ver {
    flex-shrink: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    text-transform: none;
    letter-spacing: 0;
}

.client-panel-block-ver:hover { color: var(--accent-hover); text-decoration: underline; }

.client-panel-block-error {
    font-size: 12.5px;
    color: var(--negativo);
}

.client-panel-kpis-compact { grid-template-columns: repeat(2, 1fr); }
.client-panel.pending { opacity: 0.72; }
.client-panel.error { border-color: var(--negativo-bg); }

.clients-grid--skeleton {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 var(--page-x);
}

.client-panel-skeleton {
    min-height: 160px;
    border-radius: var(--radius-card);
    border: 1px solid var(--line);
    background: var(--surface-sunken);
}

.client-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin: 0 var(--page-x);
}

.client-select-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 16px;
    text-decoration: none;
    color: inherit;
}

.client-select-card:hover { border-color: var(--accent); }

/* ---------- Estados de página ---------- */
.page-state {
    margin: 0 var(--page-x);
    padding: 40px 0;
    text-align: center;
    color: var(--ink-3);
    font-size: 13.5px;
}

.page-state-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 4px;
}

.page-state-text { color: var(--ink-3); }

.page-state--error { color: var(--negativo); }

.page-state--empty {
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius-card);
    padding: 40px 16px;
}

.page-state--loading { padding-top: 20px; }

/* ---------- Modal ---------- */
dialog.modal {
    position: fixed;
    inset: 0;
    margin: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 0;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 64px);
    overflow: auto;
    background: var(--surface);
    color: var(--ink);
}

dialog.modal.icp-modal {
    width: min(760px, calc(100vw - 32px));
}

dialog.modal::backdrop { background: rgba(29, 29, 26, 0.4); }

dialog.modal-preview {
    width: min(920px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    background: var(--ink);
    color: #fff;
    border-color: transparent;
}

dialog.modal-preview .modal-head {
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

dialog.modal-preview .modal-close { color: rgba(255, 255, 255, 0.7); }
dialog.modal-preview .modal-close:hover { color: #fff; }

.preview-stage {
    display: grid;
    place-items: center;
    padding: 12px 16px 20px;
    min-height: 200px;
}

.preview-stage img,
.preview-stage video {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 140px);
    border-radius: var(--radius-tag);
}

.thumb-btn {
    display: block;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-tag);
}

.thumb-btn:hover .thumb { outline: 2px solid var(--accent); outline-offset: 1px; }

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

.modal-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.modal-close {
    border: none;
    background: none;
    font: inherit;
    font-size: 18px;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover { color: var(--ink); }

.modal-body { padding: 20px; }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-grid .cheio { grid-column: 1 / -1; }

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

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-ctrl);
    background: var(--surface);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.15s ease;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); }

.field .ajuda {
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--ink-3);
}

.preview-atual {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--ink-3);
}

.preview-atual img,
.preview-atual video {
    width: 96px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-tag);
    border: 1px solid var(--line);
}

/* ---------- Responsivo ---------- */
@media (max-width: 760px) {
    :root { --page-x: 16px; }

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

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        flex-wrap: wrap;
    }

    .brand { padding: 0; border-bottom: none; margin-bottom: 0; }

    .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .nav a { padding: 6px 9px; font-size: 12.5px; }

    .sidebar-foot { display: none; }

    .topbar { padding: 20px var(--page-x) 16px; }
    .campo-busca { min-width: 0; flex: 1; }

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

@media (min-width: 960px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .charts-grid { grid-template-columns: 2fr 1fr; }
    .clients-grid,
    .clients-grid--skeleton { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Toggle Tabela / Funil ---------- */
.view-toggle {
    display: flex;
    margin-left: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-ctrl);
    overflow: hidden;
}

.view-btn {
    height: 36px;
    padding: 0 14px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}

.view-btn.ativo {
    background: var(--accent-tint);
    color: var(--accent);
}

/* ---------- Funil: cone ToF → MoF → BoF ---------- */
.funil-wrap { padding: 8px var(--page-x) 56px; }

.funil {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.funil-tier { min-width: 0; width: 100%; }

.funil-tier-mofu,
.funil-tier-bofu {
    margin-top: 8px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.funil-tier-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.funil-tier-head h2 {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.funil-tier-count {
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    font-weight: 500;
}

.funil-tier-tofu .funil-tier-head h2,
.funil-tier-tofu .funil-tier-count { color: var(--info); }

.funil-tier-mofu .funil-tier-head h2,
.funil-tier-mofu .funil-tier-count { color: var(--aviso); }

.funil-tier-bofu .funil-tier-head h2,
.funil-tier-bofu .funil-tier-count { color: var(--accent); }

.funil-strip {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
}

.funil-piece {
    scroll-snap-align: start;
    flex: 0 0 168px;
    min-width: 0;
}

.funil-piece .thumb-btn {
    display: block;
    width: 168px;
    border-radius: 10px;
}

.funil-piece .thumb,
.funil-piece .thumb-vazio {
    width: 168px;
    height: 298px;
    object-fit: cover;
    object-position: center top;
    border-radius: 10px;
}

.funil-piece .thumb-vazio { font-size: 12px; }

.funil-piece-title {
    margin-top: 8px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
}

.funil-piece-conceito {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--ink-2);
}

.funil-piece-fmt {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-3);
}

.funil-piece-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    align-items: center;
}

.funil-piece .acoes { margin-top: 6px; }

.funil-vazio {
    width: 100%;
    padding: 8px 4px 4px;
    font-size: 12.5px;
    text-align: center;
    color: var(--ink-3);
}

.funil-sem {
    width: 100%;
    margin-top: 36px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.funil-sem h2 {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    margin-bottom: 14px;
}

@media (prefers-reduced-motion: no-preference) {
    .funil-piece .thumb { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
    .funil-piece:hover .thumb { transform: translateY(-3px); }
}

.pill.status-em_teste { background: var(--info-bg); color: var(--info); }
.pill.status-em_observacao { background: var(--aviso-bg); color: var(--aviso); }
.pill.status-validado { background: var(--accent-tint); color: var(--accent); }
.pill.status-escalando { background: var(--accent); color: #fff; }
.pill.status-pausado { background: var(--negativo-bg); color: var(--negativo); }
.pill.status-arquivado { background: var(--neutro-bg); color: var(--ink-3); }

.log-lista {
    margin-top: 20px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.log-item p {
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--ink);
    white-space: pre-wrap;
}

.log-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.log-item-head time {
    font-size: 12px;
    color: var(--ink-3);
}

@media (max-width: 760px) {
    .view-toggle { margin-left: 0; }
    .funil-piece,
    .funil-piece .thumb-btn,
    .funil-piece .thumb,
    .funil-piece .thumb-vazio { width: 140px; }
    .funil-piece { flex-basis: 140px; }
    .funil-piece .thumb,
    .funil-piece .thumb-vazio { height: 248px; }
}

.page-state .clients-grid,
.page-state .clients-grid--skeleton { margin-left: 0; margin-right: 0; }

.table-hint {
    font-size: 12.5px;
    color: var(--ink-3);
    padding: 0 16px 12px;
    line-height: 1.45;
}

.table-hint-scroll { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.client-select-card-name { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.client-select-card-action { font-size: 12.5px; color: var(--ink-3); }

.custom-table-vendas th:nth-child(3),
.custom-table-vendas td:nth-child(3),
.custom-table-vendas th:nth-child(4),
.custom-table-vendas td:nth-child(4) { text-align: right; white-space: nowrap; }

.custom-table.custom-table-ads-monthly,
.custom-table.custom-table-ads-campaigns { table-layout: auto; min-width: 100%; }
.custom-table.custom-table-ads-monthly th:nth-child(1),
.custom-table.custom-table-ads-monthly td:nth-child(1) { white-space: nowrap; }
.custom-table.custom-table-ads-campaigns th:nth-child(1),
.custom-table.custom-table-ads-campaigns td:nth-child(1) { white-space: normal; word-break: break-word; min-width: 8rem; }
.custom-table.custom-table-ads-monthly th:not(:first-child),
.custom-table.custom-table-ads-monthly td:not(:first-child),
.custom-table.custom-table-ads-campaigns th:not(:first-child),
.custom-table.custom-table-ads-campaigns td:not(:first-child) { text-align: right; white-space: nowrap; }
.custom-table.custom-table-ads-monthly .ads-monthly-total-row td,
.custom-table.custom-table-ads-campaigns .ads-monthly-total-row td {
    font-weight: 700;
    background: var(--surface-sunken);
    border-top: 2px solid var(--line);
}
.custom-table tr.campaign-row-clickable { cursor: pointer; }
.custom-table tr.campaign-row-clickable td:last-child { color: var(--accent); font-weight: 600; }

.custom-table.custom-table-comissoes {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
    font-size: 12.5px;
    border-collapse: separate;
    border-spacing: 0;
}
.custom-table.custom-table-comissoes th,
.custom-table.custom-table-comissoes td {
    width: auto !important;
    white-space: nowrap;
    text-align: right;
    padding: 8px 10px;
    font-size: inherit;
}
.custom-table.custom-table-comissoes th:not(:first-child),
.custom-table.custom-table-comissoes td:not(:first-child) {
    font-family: "Geist Mono", monospace;
    font-variant-numeric: tabular-nums;
}
.custom-table.custom-table-comissoes th:first-child,
.custom-table.custom-table-comissoes td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    width: 11rem !important;
    min-width: 11rem;
    max-width: 11rem;
    white-space: normal;
    box-shadow: 1px 0 0 var(--line-soft);
}
.custom-table.custom-table-comissoes th:not(:first-child):not(:last-child),
.custom-table.custom-table-comissoes td:not(:first-child):not(:last-child) { min-width: 5.25rem; }
.custom-table.custom-table-comissoes th:last-child,
.custom-table.custom-table-comissoes td:last-child { min-width: 7.25rem; white-space: normal; }
.custom-table.custom-table-comissoes thead th:first-child { z-index: 4; background: var(--surface-sunken); }
.custom-table.custom-table-comissoes .comissao-col-current { background: var(--accent-tint); }
.custom-table.custom-table-comissoes .comissao-col-future { background: var(--info-bg); }
.custom-table.custom-table-comissoes .comissao-total-row td { border-top: 2px solid var(--line); background: var(--surface-sunken); font-weight: 600; }
.custom-table.custom-table-comissoes .comissao-total-row td:first-child { background: var(--surface-sunken); }
.custom-table.custom-table-comissoes tbody tr:not(.comissao-total-row):hover td:first-child { background: var(--surface-sunken); }

.comissao-total-cell, .comissao-month-cell { display: block; line-height: 1.25; }
.comissao-total-cell-trend, .comissao-month-yoy { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; }
.comissao-month-yoy-up { color: var(--positivo); }
.comissao-month-yoy-down { color: var(--negativo); }
.comissao-badge { display: block; margin-top: 2px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--accent); }

.platform-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-tag);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.platform-tag svg { width: 12px; height: 12px; flex-shrink: 0; }
.platform-tag--meta { background: var(--info-bg); color: var(--info); }
.platform-tag--google { background: var(--negativo-bg); color: var(--negativo); }
.platform-tag--google-organic { background: var(--accent-tint); color: var(--accent); }
.platform-tag--chatgpt { background: var(--neutro-bg); color: var(--neutro); }
.platform-tag--sites,
.platform-tag--influenciadores,
.platform-tag--neutral { background: var(--neutro-bg); color: var(--neutro); }

.audit-link { color: var(--accent); font-weight: 600; font-size: 12.5px; text-decoration: none; }
.audit-link:hover { text-decoration: underline; }
.audit-empty { padding: 32px 16px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

.audit-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(29, 29, 26, 0.4);
}
.audit-modal-overlay.is-open { display: flex; }
.audit-modal {
    display: flex;
    flex-direction: column;
    width: min(920px, 100%);
    max-height: min(88vh, 900px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    overflow: hidden;
}
.audit-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.audit-modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.audit-modal-meta { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.audit-modal-close {
    border: none;
    background: none;
    font: inherit;
    font-size: 18px;
    color: var(--ink-3);
    cursor: pointer;
    padding: 4px;
}
.audit-modal-close:hover { color: var(--ink); }
.audit-modal-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 16px 16px; }
.custom-table.custom-table-audit { table-layout: auto; min-width: 640px; }
.custom-table.custom-table-audit th,
.custom-table.custom-table-audit td { width: auto !important; text-align: left !important; white-space: normal; }

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    background: var(--bg);
    font-family: "Geist", system-ui, sans-serif;
    color: var(--ink);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 28px;
}
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-card p { color: var(--ink-2); font-size: 13.5px; margin-bottom: 20px; }
.login-error {
    background: var(--negativo-bg);
    color: var(--negativo);
    padding: 10px 12px;
    border-radius: var(--radius-ctrl);
    margin-bottom: 14px;
    font-size: 13.5px;
}
.form-group { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.login-card .form-input { width: 100%; }
.login-card .btn { width: 100%; }

dialog.modal.modal-wide {
    width: min(860px, calc(100vw - 32px));
}
#cron-groups .tabela tbody tr { cursor: pointer; }
.cron-log {
    margin: 0;
    padding: 16px 20px;
    max-height: min(60vh, 480px);
    overflow: auto;
    background: var(--ink);
    color: #F7F7F4;
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.analise-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 0 16px 12px;
}
.analise-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
    color: var(--ink-2);
}
.analise-legend li { display: inline-flex; align-items: center; gap: 6px; }
.analise-legend-swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.analise-legend-swatch--global { background: var(--neutro); }
.analise-legend-swatch--google { background: var(--info); }
.analise-legend-swatch--meta { background: var(--accent); }
.analise-count { font-size: 12px; color: var(--ink-3); font-family: "Geist Mono", monospace; }
.analise-table-wrap { overflow: auto; max-height: min(70vh, 44rem); width: 100%; }
.analise-table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.analise-table {
    --analise-head-row1: 2.15rem;
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    font-family: "Geist Mono", monospace;
    font-variant-numeric: tabular-nums;
}
.analise-table th, .analise-table td {
    padding: 7px 6px;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
    text-align: center;
}
.analise-table thead th {
    position: sticky;
    z-index: 3;
    font-size: 10px;
    font-family: "Geist", system-ui, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: var(--ink-3);
    background: var(--surface-sunken);
}
.analise-table thead tr:first-child th { top: 0; z-index: 4; height: var(--analise-head-row1); }
.analise-table thead tr:nth-child(2) th { top: var(--analise-head-row1); }
.analise-table .col-date {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    min-width: 7.75rem;
    padding-left: 10px;
    font-weight: 600;
    font-family: "Geist", system-ui, sans-serif;
    box-shadow: 1px 0 0 var(--line);
}
.analise-table thead .col-date { top: 0; z-index: 6; background: var(--surface-sunken); }
.analise-table thead .group-global { background: var(--neutro-bg); color: var(--neutro); }
.analise-table thead .group-google { background: var(--info-bg); color: var(--info); }
.analise-table thead .group-meta { background: var(--accent-tint); color: var(--accent); }
.analise-table tbody tr:hover td, .analise-table tbody tr:hover td.col-date { background: var(--surface-sunken); }
.analise-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 3;
    font-weight: 700;
    background: var(--surface-sunken);
    border-top: 2px solid var(--line);
}
.analise-table tfoot .col-date { z-index: 5; background: var(--neutro-bg); }
.analise-table .group-global { background: var(--neutro-bg); }
.analise-table .group-google { background: var(--info-bg); }
.analise-table .group-meta { background: var(--accent-tint); }
.analise-table .sep { border-right: 2px solid var(--line); }
.analise-table .money { color: var(--positivo); font-weight: 600; }
.analise-table .leads-val { color: var(--info); font-weight: 600; }
.analise-table .roas-val { font-weight: 700; }
.analise-table .is-zero { color: var(--ink-3); font-weight: 400; }
.analise-table-skeleton {
    min-height: 14rem;
    border-radius: var(--radius-ctrl);
    border: 1px solid var(--line);
    background: var(--surface-sunken);
}

@media (max-width: 768px) {
    .table-hint-scroll { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* ---------- ICP ---------- */
.icp-lede,
.icp-leitura,
.icp-note-list--page,
.icp-section-title,
.icp-panel--wide {
    margin: 0 var(--page-x) var(--gap);
}

.icp-lede {
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--ink-2);
}

.icp-lede ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.icp-lede li + li { margin-top: 4px; }

.icp-leitura {
    padding: 14px 16px;
    background: var(--accent-tint);
    color: var(--accent);
    border-radius: var(--radius-card);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.45;
}

.icp-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 var(--page-x) var(--gap);
}

.icp-split > .table-card,
.icp-split > .icp-panel { margin: 0; }

.icp-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 14px 16px 16px;
}

.icp-panel h2,
.icp-section-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
    margin-bottom: 10px;
}

.icp-note-list,
.icp-anti {
    margin: 0;
    padding-left: 18px;
    font-size: 13.5px;
    line-height: 1.45;
}

.icp-note-list li + li,
.icp-anti li + li { margin-top: 8px; }

.icp-note-list--ol { padding-left: 20px; }

.icp-anti strong {
    display: block;
    margin-bottom: 2px;
    color: var(--ink);
}

.icp-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 var(--page-x) var(--gap);
}

.icp-card {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}

.icp-card:hover { border-color: var(--accent); }

.icp-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.icp-card-photo {
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 10;
    background: var(--surface-sunken);
    overflow: hidden;
}

.icp-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.icp-card-ph {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.icp-card-photo--0 { background: var(--accent-tint); color: var(--accent); }
.icp-card-photo--1 { background: var(--info-bg); color: var(--info); }
.icp-card-photo--2 { background: var(--negativo-bg); color: var(--negativo); }
.icp-card-photo--3 { background: var(--neutro-bg); color: var(--neutro); }
.icp-card-photo--4 { background: var(--aviso-bg); color: var(--aviso); }

.icp-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px 16px;
}

.icp-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.icp-card-meta .tag { white-space: normal; }

.icp-card-ticket {
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
    white-space: nowrap;
}

.icp-card-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.icp-card-role {
    margin-top: -2px;
    font-size: 13px;
    color: var(--ink-2);
}

.icp-card-line {
    font-size: 13px;
    line-height: 1.4;
    color: var(--ink);
}

.icp-card-k {
    display: inline;
    margin-right: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.icp-card-msg {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--accent);
}

.modal-head .sub {
    margin-top: 4px;
    font-size: 13px;
    color: var(--ink-2);
    word-break: break-all;
}

.icp-modal-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.icp-modal-body h3 {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 8px;
}

.icp-modal-body ul {
    margin: 0;
    padding-left: 18px;
}

.icp-modal-body li + li { margin-top: 4px; }

.icp-modal-body p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
}

.icp-modal-quote {
    margin: 0;
    padding: 12px 14px;
    background: var(--surface-sunken);
    border-radius: var(--radius-ctrl);
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--ink-2);
}

.icp-modal-msg { font-weight: 600; color: var(--accent); }

@media (min-width: 760px) {
    .icp-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
    .icp-split { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1200px) {
    .icp-grid { grid-template-columns: repeat(3, 1fr); }
}
