/* zstrack — tema claro e escuro, contraste AA, foco sempre visível. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #111827;
  --muted: #565f70;
  --primary: #2453d4;
  --primary-hover: #1c44b3;
  --primary-soft: #eaf0fd;
  --on-primary: #ffffff;
  --success: #08703f;
  --success-soft: #e7f6ee;
  --danger: #b4232a;
  --danger-soft: #fdecec;
  --warning: #8a5300;
  --warning-soft: #fff4e0;
  --bar: #2453d4;
  --bar-2: #8aa6ea;
  --on-bar: #ffffff;
  --focus: #2453d4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --radius: 12px;
  --fz-div: rgba(99, 102, 241, .35);
  --gap: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b2030; --surface: #262d3e; --surface-2: #2d3548; --border: #343d52; --border-strong: #4a5570;
    --text: #eef1f6; --muted: #a9b2c4; --primary: #6f9bff; --primary-hover: #8daeff; --primary-soft: #1c2740; --on-primary: #0b1020;
    --success: #4fd39a; --success-soft: #12271e; --danger: #ff8a8a; --danger-soft: #2c1517; --warning: #f2b75a; --warning-soft: #2b2112;
    --bar: #6f9bff; --bar-2: #3b5590; --on-bar: #0b1020; --focus: #8daeff; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b2030; --surface: #262d3e; --surface-2: #2d3548; --border: #343d52; --border-strong: #4a5570;
  --text: #eef1f6; --muted: #a9b2c4; --primary: #6f9bff; --primary-hover: #8daeff; --primary-soft: #1c2740; --on-primary: #0b1020;
  --success: #4fd39a; --success-soft: #12271e; --danger: #ff8a8a; --danger-soft: #2c1517; --warning: #f2b75a; --warning-soft: #2b2112;
  --bar: #6f9bff; --bar-2: #3b5590; --on-bar: #0b1020; --focus: #8daeff; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Inter, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num, .kpi-value, td.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg:not(.chart) { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.chart text { font-family: Inter, "Segoe UI", system-ui, sans-serif; }

.skip { position: absolute; left: 12px; top: -60px; background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: 8px; z-index: 100; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; color: var(--on-primary); }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
label, .label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
input, select, textarea { width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
input::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.form-error { color: var(--danger); font-size: 13px; min-height: 1.2em; margin-top: 8px; }
code, .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.code { display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); }
.login-logo { display: block; height: 36px; width: auto; margin-bottom: 24px; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card form { margin-top: 18px; display: grid; gap: 4px; }
.login-card .btn { margin-top: 12px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; padding: 0 8px; }
.brand img { display: block; height: 32px; width: auto; }
.side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-link, .side nav a { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 0 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left; }
.side-link:hover, .side nav a:hover { background: var(--surface-2); color: var(--text); }
.side nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--border); padding-top: 12px; }
.mobile-bar { display: none; }
.main { min-width: 0; padding: 28px 32px 48px; max-width: 1440px; }
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
main { outline: none; }
#view[aria-busy="true"] { opacity: .6; transition: opacity .15s; }

/* ---------- blocos ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel + .panel, .section + .section { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1 1 220px; min-width: 0; }
.mt { margin-top: 16px; }
.grid > .panel { margin-top: 0; }
#pageTitle:focus { outline: none; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 20px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filters .field { flex: 1 1 160px; max-width: 230px; }
.filters .field.wide { max-width: none; flex-basis: 240px; }
.filters .actions { flex: 0 0 auto; display: flex; gap: 8px; }

/* avisos */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 12px; }
.notice svg { margin-top: 2px; }
.notice.warn { background: var(--warning-soft); border-color: transparent; color: var(--text); }
.notice.warn svg { color: var(--warning); }
.notice.bad { background: var(--danger-soft); border-color: transparent; }
.notice.bad svg { color: var(--danger); }
.notice.good { background: var(--success-soft); border-color: transparent; }
.notice.good svg { color: var(--success); }
.notice .grow { flex: 1; }

/* indicadores */
.kpis { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; transition: border-color .15s; }
.kpi:hover { border-color: var(--border-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-ico { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); flex: none; }
.kpi-ico svg { width: 17px; height: 17px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi.main-kpi .kpi-value { font-size: 26px; }

/* tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
caption { text-align: left; padding: 0 0 10px; font-weight: 600; font-size: 15px; }
.table-wrap caption { padding: 14px 16px 6px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody th { font-weight: 600; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tfoot th, tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.cell-name { min-width: 220px; max-width: 360px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.link-btn:hover { color: var(--primary); text-decoration-color: currentColor; }
.plain-table th, .plain-table td { padding: 9px 12px 9px 0; }
.plain-table th:last-child, .plain-table td:last-child { padding-right: 0; }
.plain-table td.num + td { padding-left: 12px; }
.plain-table thead th { background: none; }
.plain-table tbody tr:hover { background: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* barras (decorativas; o texto ao lado diz o número) */
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; background: var(--bar); border-radius: 99px; }
.funnel-bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; min-width: 120px; }
.funnel-bar > span { display: block; height: 100%; background: var(--bar); border-radius: 6px; min-width: 3px; }

/* gráfico */
.chart { width: 100%; height: 240px; display: block; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
details > summary { cursor: pointer; color: var(--primary); font-weight: 500; margin-top: 12px; }
details > summary:hover { color: var(--primary-hover); }
details[open] > summary { margin-bottom: 10px; }

/* segmento (Campanhas / Conjuntos / Anúncios) */
.segmented { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; gap: 2px; margin-bottom: 16px; }
.segmented button { min-height: 34px; padding: 0 16px; border: 0; border-radius: 7px; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 14px; font-size: 13.5px; }
.crumbs li + li::before { content: "/"; color: var(--muted); margin-right: 6px; }
.crumbs button { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.crumbs [aria-current] { font-weight: 600; }

/* chave liga/desliga (checkbox com role=switch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 40px; height: 22px; margin: 0; cursor: pointer; }
.switch .track { width: 40px; height: 22px; border-radius: 22px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .45; }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.steps { margin: 8px 0 14px; padding-left: 20px; color: var(--muted); }
.steps li { margin: 4px 0; }
.steps strong { color: var(--text); font-weight: 600; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 700; flex: none; }
.sub-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.sub-panel + .sub-panel { margin-top: 12px; }
.empty { padding: 28px 0; text-align: center; color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 10px); background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; font-weight: 500; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  .side.open { transform: none; visibility: visible; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .main { padding: 20px 16px 40px; }
  .filters .field { max-width: none; }
  .kpi-value { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Resumo personalizável (grade de 12 colunas) ---------- */
.dash { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.dash > .w { min-width: 0; display: flex; }
.dash > .w > * { flex: 1; min-width: 0; }
.w-s { grid-column: span 3; } .w-m { grid-column: span 4; } .w-l { grid-column: span 6; } .w-xl { grid-column: span 12; }
.dash .panel h3 { font-size: 15px; }
.editor { margin-bottom: 16px; }
.ed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.ed-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ed-item.off { background: var(--surface-2); }
.ed-item.off .ed-show { color: var(--muted); }
.ed-item.dragging { opacity: .5; }
.ed-item.drop { border-color: var(--primary); }
.grip { color: var(--muted); cursor: grab; letter-spacing: -2px; user-select: none; }
.ed-show { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; cursor: pointer; }
.ed-show input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.ed-size { width: auto; min-width: 150px; min-height: 32px; padding: 4px 8px; }
@media (max-width: 1180px) { .w-s { grid-column: span 6; } .w-m, .w-l { grid-column: span 6; } }
@media (max-width: 800px) { .dash > .w { grid-column: span 12; } .ed-item { flex-wrap: wrap; } .ed-show { flex-basis: 100%; } }

/* ---------- visual geral ---------- */
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { background: var(--danger-soft); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 7px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.info { color: var(--muted); display: inline-flex; cursor: help; }
.filters { box-shadow: var(--shadow); }
.dash { gap: var(--gap); }
.no-kpi-icons .kpi-ico { display: none; }
.no-kpi-subs .kpi-sub { display: none; }
[data-density="compact"] { --gap: 10px; }
[data-density="compact"] .kpi { padding: 11px 14px; gap: 3px; }
[data-density="compact"] .kpi-value { font-size: 21px; }
[data-density="compact"] .kpi-ico { width: 26px; height: 26px; }
[data-density="compact"] .panel { padding: 14px 16px; }
[data-density="compact"] .main { padding-top: 20px; }
.editing .dash > .w { outline: 1px dashed var(--border-strong); outline-offset: 3px; border-radius: var(--radius); }

/* ---------- funil em faixa (degradê) ---------- */
.fz { position: relative; display: grid; grid-template-columns: repeat(var(--fz-n), minmax(0, 1fr)); height: var(--fz-h); margin: 4px 0 6px; }
.fz svg.fz-svg { stroke: none; position: absolute; left: 0; right: 0; top: 46px; bottom: 44px; width: 100%; height: calc(100% - 90px); display: block; }
.fz.no-val svg.fz-svg { bottom: 12px; height: calc(100% - 58px); }
.fz-col { position: relative; display: grid; grid-template-rows: 46px 1fr 44px; align-items: center; text-align: center; min-width: 0; padding: 0 4px; }
.fz.no-val .fz-col { grid-template-rows: 46px 1fr 12px; }
.fz-col + .fz-col { border-left: 1px solid var(--fz-div); }
.fz.no-div .fz-col { border-left: 0; }
.fz-label { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: start; padding-top: 6px; }
.fz-pct { font-size: 19px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .35); font-variant-numeric: tabular-nums; }
.fz-val { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 800px) { .fz-label { font-size: 11.5px; white-space: normal; line-height: 1.2; } .fz-pct { font-size: 14px; } .fz-val { font-size: 12.5px; } }

/* ---------- gaveta de personalização (à esquerda, no lugar do menu) ---------- */
.app.editing { grid-template-columns: 380px minmax(0, 1fr); }
.app.editing .side { overflow: hidden; gap: 12px; padding-bottom: 0; }
.app.editing .side-foot { display: none; }
.app.editing .side nav a { min-height: 34px; }

.drawer { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 -12px; border-top: 1px solid var(--border); background: var(--surface); }
.dr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 12px; }
.dr-head h2 { font-size: 17px; outline: none; }
.dr-tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.dr-tabs button { flex: 1; min-height: 40px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dr-tabs button:hover { color: var(--text); }
.dr-tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.dr-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }
.dr-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.dr-foot .ghost { margin-left: auto; }
.dr-sec { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 8px; }
.dr-body > .dr-sec:first-child, .dr-body > .notice + .dr-field { margin-top: 4px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; color: var(--muted); letter-spacing: 0; }
.dr-body .hint { margin: -2px 0 10px; }
.dr-field { margin-bottom: 12px; }
.dr-field label output { float: right; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.dr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="range"] { padding: 0; min-height: 28px; accent-color: var(--primary); border: 0; background: none; }
input[type="color"] { padding: 3px; height: 40px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { min-height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.swatches.round-set { display: flex; flex-wrap: wrap; }
.swatch { height: 34px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.swatch.round { width: 36px; height: 36px; border-radius: 50%; }
.swatch.auto { background: conic-gradient(#2453d4, #7c3aed, #db2777, #ea580c, #0f9f6e, #2453d4); }
.opts { border: 0; margin: 0; padding: 0; display: grid; gap: 2px; }
.opt { display: flex; align-items: center; gap: 10px; margin: 0; padding: 7px 10px; border-radius: 8px; font-weight: 500; cursor: pointer; }
.opt:hover { background: var(--surface-2); }
.opt input, .ed-item input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--primary); flex: none; }
#edFind { margin-bottom: 4px; }
.ed-list { max-height: none; }
.ed-item { gap: 8px; padding: 8px 8px 8px 10px; }
.ed-item:hover { border-color: var(--border-strong); }
.ed-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 500; line-height: 1.3; }
.ed-tag { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.ed-btns { display: inline-flex; gap: 4px; flex: none; }
.ed-size { min-width: 0; width: 118px; font-size: 12.5px; min-height: 32px; padding: 4px 6px; }
.grip { display: inline-flex; }
.grip svg { fill: currentColor; stroke-width: 2.4; }
.ed-item.step .grow { flex: 1; min-width: 0; }
.ed-item.step .hint { margin: 2px 0 0; font-size: 11.5px; }
.step-name { min-height: 32px; padding: 4px 8px; font-weight: 600; }
.ed-item.off .step-name { color: var(--muted); }
@media (max-width: 800px) {
  .app.editing { grid-template-columns: 1fr; }
  .app.editing .side { transform: none; visibility: visible; width: min(100%, 400px); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .ed-item { flex-wrap: nowrap; }
  .ed-size { width: 96px; }
}

/* ---------- lançamento manual ---------- */
.panel.manual { margin-bottom: 16px; }
.manual-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; align-items: start; }
.manual-grid .actions { display: flex; gap: 8px; align-self: end; padding-bottom: 2px; }
.manual-grid .hint { margin-top: 4px; }
/* na gaveta do menu: nome em cima, tamanho e botões embaixo */
#edOn .ed-item { flex-wrap: wrap; row-gap: 6px; }
#edOn .ed-name { flex: 1 1 calc(100% - 30px); }
#edOn .ed-size { flex: 1; width: auto; margin-left: 26px; }

/* =================== layout profissional (v3) =================== */
:root { --side-bg: #ffffff; --head-bg: rgba(245, 246, 248, .86); --ring-off: #e3e6eb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --side-bg: #1f2535; --head-bg: rgba(27, 32, 48, .86); --ring-off: #3a4358; --fz-div: rgba(139, 141, 255, .45); } }
:root[data-theme="dark"] { --side-bg: #1f2535; --head-bg: rgba(27, 32, 48, .86); --ring-off: #3a4358; --fz-div: rgba(139, 141, 255, .45); }

body { font-size: 14px; letter-spacing: -.005em; }
.app { grid-template-columns: 240px minmax(0, 1fr); }
.side { background: var(--side-bg); padding: 18px 12px; gap: 14px; }
.brand { padding: 2px 10px 8px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.side ul .nav-label:first-child { padding-top: 4px; }
.side-link, .side nav a { min-height: 38px; border-radius: 9px; font-size: 13.5px; }
.side nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--primary); }


.main { padding: 0 28px 48px; max-width: none; }
.page-head { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  margin: 0 -28px 20px; padding: 16px 28px; background: var(--head-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.ph-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-head h1 { font-size: 20px; }
.ph-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ph-actions:empty { display: none; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.seg button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.pill { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 700; }
.btn { min-height: 36px; border-radius: 9px; font-size: 13.5px; }

.filters { margin-bottom: 16px; }
.panel { padding: 18px 20px; }
.panel-head { margin-bottom: 12px; }
.kpi-label { font-size: 12.5px; }
.kpi-value { font-size: 25px; }
.kpi-sub { font-size: 12px; }
.chart { height: auto; }

/* tamanhos */
.w-t { grid-column: span 8; } .w-n { grid-column: span 9; }
@media (max-width: 1180px) { .w-t, .w-n { grid-column: span 12; } }
@media (max-width: 800px) { .dash > .w { grid-column: span 12; } }

/* anéis, rosca e legendas */
.ring { width: 20px; height: 20px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: var(--ring-off); stroke-width: 3; }
.ring circle.on { stroke: var(--primary); stroke-linecap: round; }
.ring-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.ring-table th[scope="row"] { font-weight: 500; }
.donut { display: grid; grid-template-columns: minmax(120px, 170px) 1fr; gap: 16px; align-items: center; }
.donut .chart { max-width: 170px; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.legend-list i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-list .num { margin-left: auto; color: var(--muted); }
@container (max-width: 300px) { .donut { grid-template-columns: 1fr; } }
.dash > .w { container-type: inline-size; }

/* funil: conversão entre etapas, custo e nota */
.fz-conv { position: absolute; left: 0; top: 46px; transform: translate(-50%, -50%); z-index: 2; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700;
  background: var(--surface); color: var(--muted); border: 1px solid var(--fz-div); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fz-val { display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.fz-val small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.fz.with-cost .fz-col { grid-template-rows: 46px 1fr 54px; }
.fz.with-cost svg.fz-svg { bottom: 54px; height: calc(100% - 100px); }
.fz-col { cursor: default; }
.fz-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* edição com o mouse */
.edit-hint { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius); background: var(--primary-soft); color: var(--text); font-size: 13px; border: 1px solid var(--primary); }
.edit-hint svg { color: var(--primary); }
.dash.is-editing > .w { position: relative; cursor: grab; user-select: none; outline: 1.5px dashed var(--border-strong); outline-offset: 3px; border-radius: var(--radius); }
.dash.is-editing > .w:hover { outline-color: var(--primary); }
.dash.is-editing > .w > :not(.w-chrome):not(.w-resize) { pointer-events: none; }
.dash.is-editing details { pointer-events: none; }
.w-chrome { position: absolute; top: -12px; left: 10px; right: 10px; z-index: 5; display: flex; align-items: center; gap: 4px; pointer-events: none; }
.w-chrome > * { pointer-events: auto; }
.w-grip { display: inline-flex; align-items: center; gap: 4px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 8px 2px 4px; border-radius: 7px;
  background: var(--primary); color: var(--on-primary); font-size: 11.5px; font-weight: 600; margin-right: auto; cursor: grab; }
.w-grip svg { width: 14px; height: 14px; fill: currentColor; }
.w-chrome button { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; }
.w-chrome button:hover { border-color: var(--primary); color: var(--primary); }
.w-chrome button svg { width: 14px; height: 14px; }
.w-chrome [data-whide]:hover { border-color: var(--danger); color: var(--danger); }
.w-size { font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border-strong); color: var(--muted); white-space: nowrap; }
.w-resize { position: absolute; top: 20%; bottom: 20%; right: -9px; width: 12px; z-index: 5; cursor: ew-resize; border-radius: 6px; background: var(--primary); opacity: .0; transition: opacity .15s; }
.dash.is-editing > .w:hover .w-resize, body.resizing-w .w-resize { opacity: .9; }
.w-ph { min-height: 110px; border: 2px dashed var(--primary); border-radius: var(--radius); background: var(--primary-soft); }
.w-src { display: none !important; }
.w-ghost { position: fixed !important; z-index: 200; pointer-events: none; opacity: .92; box-shadow: 0 18px 40px rgba(0, 0, 0, .35); transform: rotate(1.2deg); list-style: none; border-radius: var(--radius); overflow: hidden; }
.ghost-chip { padding: 10px 14px; background: var(--primary); color: var(--on-primary); font-weight: 600; border-radius: 10px; }
body.dragging-w, body.dragging-w * { cursor: grabbing !important; user-select: none; }
body.resizing-w, body.resizing-w * { cursor: ew-resize !important; user-select: none; }
.ed-item[data-drag] { cursor: grab; }
.ed-group + .ed-group { margin-top: 10px; }
.ed-gtitle { font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 6px; }

@media (max-width: 800px) {
  .app, .app.editing { grid-template-columns: minmax(0, 1fr); }
  .ph-actions { width: 100%; }
  .ph-actions .btn { flex: 1; }
  .main { padding: 0 16px 40px; }
  .page-head { margin: 0 -16px 16px; padding: 12px 16px; top: 57px; }
  .seg { overflow-x: auto; max-width: 100%; }
}

/* barra do dashboard: título + olho, aparência e editar */
.ph-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ph-tools { display: inline-flex; gap: 2px; }
.tool { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.tool:hover { background: var(--surface-2); color: var(--text); }
.tool[aria-pressed="true"], .tool[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary); }
.app.editing .drawer { margin-top: 4px; }

/* valores escondidos (olho) */
.hide-values .kpi-value, .hide-values .kpi-sub, .hide-values td.num, .hide-values .fz-val, .hide-values .fz-pct, .hide-values .fz-conv,
.hide-values .chart text, .hide-values .legend-list .num, .hide-values .table-wrap caption { filter: blur(7px); user-select: none; }

/* editando: a lateral mostra só a personalização (some logo, menu e rodapé) */
.app.editing .side { padding: 0; gap: 0; }
.app.editing .side > :not(.drawer) { display: none !important; }
.app.editing .drawer { margin: 0; border-top: 0; height: 100vh; }
.app.editing .dr-head { padding-top: 20px; }
@media (max-width: 800px) { .app.editing .drawer { height: 100%; } }

/* logo Trakfy: escura no tema claro, branca no tema escuro */
.logo-d { display: none !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-l { display: none !important; } :root:not([data-theme="light"]) .logo-d { display: block !important; } }
:root[data-theme="dark"] .logo-l { display: none !important; }
:root[data-theme="dark"] .logo-d { display: block !important; }
.brand-logo { height: 34px; width: auto; }
.login-logo { height: 44px; width: auto; }
.bar-logo { height: 26px; width: auto; }

/* =================== tema "preto premium" (Trakfy) =================== */
:root {
  --bg: #fafafa; --surface: #ffffff; --surface-2: #f4f4f5; --border: #e4e4e7; --border-strong: #d4d4d8;
  --text: #09090b; --muted: #5b5b66; --primary: #09090b; --primary-hover: #27272a; --primary-soft: #f1f1f3; --on-primary: #ffffff;
  --success: #3d7a0a; --success-soft: #eef7e2; --danger: #c02626; --danger-soft: #fdecec; --warning: #8a5300; --warning-soft: #fff6e5;
  --bar: #09090b; --bar-2: #a1a1aa; --on-bar: #ffffff; --focus: #2563eb; --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --side-bg: #ffffff; --head-bg: rgba(250, 250, 250, .85); --ring-off: #e4e4e7; --fz-div: rgba(9, 9, 11, .12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0b; --surface: #141416; --surface-2: #1c1c20; --border: #26262b; --border-strong: #3a3a41;
    --text: #fafafa; --muted: #a1a1aa; --primary: #fafafa; --primary-hover: #e4e4e7; --primary-soft: #222226; --on-primary: #0a0a0b;
    --success: #a3e635; --success-soft: #1a2410; --danger: #f87171; --danger-soft: #2a1414; --warning: #fbbf24; --warning-soft: #261f0d;
    --bar: #fafafa; --bar-2: #52525b; --on-bar: #0a0a0b; --focus: #fafafa; --shadow: none;
    --side-bg: #0e0e10; --head-bg: rgba(10, 10, 11, .85); --ring-off: #2a2a30; --fz-div: rgba(255, 255, 255, .12);
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0b; --surface: #141416; --surface-2: #1c1c20; --border: #26262b; --border-strong: #3a3a41;
  --text: #fafafa; --muted: #a1a1aa; --primary: #fafafa; --primary-hover: #e4e4e7; --primary-soft: #222226; --on-primary: #0a0a0b;
  --success: #a3e635; --success-soft: #1a2410; --danger: #f87171; --danger-soft: #2a1414; --warning: #fbbf24; --warning-soft: #261f0d;
  --bar: #fafafa; --bar-2: #52525b; --on-bar: #0a0a0b; --focus: #fafafa; --shadow: none;
  --side-bg: #0e0e10; --head-bg: rgba(10, 10, 11, .85); --ring-off: #2a2a30; --fz-div: rgba(255, 255, 255, .12);
}
.kpi, .panel, .filters, .table-wrap { box-shadow: var(--shadow); }
.kpi-ico { background: var(--surface-2); color: var(--muted); }
.side nav a[aria-current="page"] { background: var(--primary-soft); color: var(--text); }
.edit-hint { border-color: var(--border-strong); }
.fz-pct.dark-txt { color: #0a0a0b; text-shadow: none; }
/* funil padrão acompanha o tema: no escuro vai de branco a grafite, no claro de preto a cinza */
:root { --fz-a: #18181b; --fz-b: #a1a1aa; --fz-hi: #ffffff; --fz-lo: #0a0a0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fz-a: #fafafa; --fz-b: #3f3f46; --fz-hi: #0a0a0b; --fz-lo: #ffffff; } }
:root[data-theme="dark"] { --fz-a: #fafafa; --fz-b: #3f3f46; --fz-hi: #0a0a0b; --fz-lo: #ffffff; }
.fz-pct.fz-hi { color: var(--fz-hi); text-shadow: none; }
.fz-pct.fz-lo { color: var(--fz-lo); text-shadow: none; }
/* comparação com o período anterior */
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 1px 7px; border-radius: 99px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.kpi-delta.pos { color: var(--success); background: var(--success-soft); }
.kpi-delta.neg { color: var(--danger); background: var(--danger-soft); }
.kpi-delta .vs { font-weight: 500; color: var(--muted); }
.hide-values .kpi-delta { filter: blur(6px); }

/* ---------- menu lateral recolhível ---------- */
.side { overflow: visible; }
.side-toggle { position: absolute; top: 26px; right: -14px; z-index: 45; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); transition: transform .2s; }
.side-toggle:hover { background: var(--surface-2); }
.side-toggle svg { width: 16px; height: 16px; }
.brand .brand-mini { display: none; border-radius: 8px; }
.app.collapsed:not(.editing) { grid-template-columns: 72px minmax(0, 1fr); }
.app.collapsed:not(.editing) .side-toggle { transform: rotate(180deg); }
/* recolhido: só ícones */
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) { width: 72px; padding-left: 12px; padding-right: 12px; }
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) .side-link,
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) nav a { justify-content: center; padding: 0; }
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) .brand-logo { display: none !important; }
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) .brand-mini { display: block; margin: 0 auto; }
.app.collapsed:not(.editing) .side:not(:hover):not(:has(:focus-visible)) .brand { padding: 2px 0 8px; }
/* recolhido + mouse em cima (ou foco do teclado): abre por cima do conteúdo, sem empurrar a tela */
.app.collapsed:not(.editing) .side:hover, .app.collapsed:not(.editing) .side:has(:focus-visible) { width: 240px; z-index: 40; box-shadow: 8px 0 30px rgba(0, 0, 0, .35); }
.side .lbl { white-space: nowrap; }
@media (max-width: 800px) { .side-toggle { display: none; } .app.collapsed { grid-template-columns: minmax(0, 1fr); } }
