/* Tema escuro é o padrão. O botão do topo grava data-theme="light" ou "dark" (localStorage). */
:root {
  --bg: #0d0e12;
  --panel: #15171d;
  --panel-2: #1d2028;
  --text: #eceef3;
  --muted: #9aa1ae;
  --line: #272b35;
  --accent: #ff7a2f;
  --accent-ink: #1b0d03;
  --ok: #5fd39a;
  --ok-bg: #12301f;
  --warn: #f3c164;
  --warn-bg: #362a0f;
  --bad: #ff8a7a;
  --bad-bg: #3a1813;
  --mute-bg: #262933;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
  --tip-bg: #f3f4f7;
  --tip-text: #15171d;
  --radius: 14px;
  /* gráficos: paleta categórica (validada para daltonismo) e degradê do funil */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #9085e9;
  --s-other: #5d6472;
  --fg-a: #7c5cff;
  --fg-b: #ff7a2f;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --panel-2: #f0f1f5;
  --text: #15171d;
  --muted: #5b6270;
  --line: #e2e4ea;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e3f3ea;
  --warn: #8a5a00;
  --warn-bg: #fbefd5;
  --bad: #b42318;
  --bad-bg: #fde7e4;
  --mute-bg: #eceef2;
  --shadow: 0 1px 2px rgba(20, 22, 30, 0.05);
  --tip-bg: #15171d;
  --tip-text: #f3f4f7;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #6250d6;
  --s-other: #a3a9b5;
  --fg-a: #6d4aff;
  --fg-b: #f26a1b;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 3px; }
h1 { font-size: 22px; margin: 8px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* topo */
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
.brand.big { font-size: 22px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { text-decoration: none; padding: 7px 11px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-size: 14px; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.top-actions form { margin: 0; }
.icon-btn { display: inline-flex; align-items: center; }
.icon-btn, .link-btn { background: none; border: 1px solid transparent; color: var(--muted); font: inherit; cursor: pointer; padding: 6px 9px; border-radius: 8px; }
.icon-btn:hover, .link-btn:hover { background: var(--panel-2); color: var(--text); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 16px 16px 48px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: wait; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
input, select { font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%; }
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* filtros */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { flex: 1 1 150px; min-width: 0; }
.filters label.grow { flex: 2 1 220px; }
.filters .btn { flex: 0 0 auto; min-height: 38px; }
.range { margin: -4px 0 10px; font-size: 13px; }

/* barra de sincronização */
.syncbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; border: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.syncbar form { margin: 0; }
.syncbar.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.syncbar.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 8px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi-l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.kpi-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.pos .kpi-v { color: var(--ok); }
.kpi.neg .kpi-v { color: var(--bad); }
.fx { font-size: 12px; margin: 4px 0 14px; }

/* tabelas */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
table.data td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.name, table.data th.name { text-align: left; white-space: normal; min-width: 180px; max-width: 360px; }
table.sales td { text-align: left; }
table.sales th { text-align: left; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
table.data td .sub { font-size: 12px; margin-top: 2px; }
table.data td.empty { text-align: center; color: var(--muted); padding: 28px; }
tr.unattr td { background: var(--panel-2); }
.tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { text-decoration: none; padding: 8px 12px; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.crumb { padding: 10px 12px 0; font-size: 13px; }
.wrap > .crumb { padding: 0 0 6px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 12px; }

/* badges */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--mute-bg); color: var(--muted); white-space: nowrap; }
.badge.sm { font-size: 11px; padding: 1px 6px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* avisos */
.flash { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; background: var(--panel-2); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }

/* login */
.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.login-card p { margin: -6px 0 4px; }

/* configurações / código */
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
pre.code { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; margin: 0; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; max-height: 70vh; overflow: auto; }
.status-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; font-size: 14px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.head-row form { margin: 0; }
.head-row select { width: auto; }

@media (max-width: 640px) {
  .top-in { gap: 8px; padding: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-v { font-size: 19px; }
  .filters label { flex: 1 1 calc(50% - 10px); }
  .filters .btn { flex: 1 1 100%; }
  h1 { font-size: 19px; }
  .hide-sm { display: none; }
  .nav a { padding: 7px 9px; }
  table.data td.name, table.data th.name { min-width: 150px; }
}

/* ================================================================ Painel (resumo) */
body { font-feature-settings: 'tnum' 1, 'cv11' 1; }
.top { background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px); }
.card { border-radius: var(--radius); }
.link-btn.small { font-size: 13px; padding: 4px 6px; }
.link-btn.danger { color: var(--bad); }
.link-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.page-head h1 { margin: 0 0 2px; }
.page-head .range { margin: 0; }
.refresh { display: flex; align-items: center; gap: 10px; margin: 0; }
.refresh .upd { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* campos extra dos filtros */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; flex: 1 1 150px; min-width: 0; position: relative; }
.ms summary { list-style: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 400; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 30px 8px 10px; min-height: 38px; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms summary::-webkit-details-marker { display: none; }
.ms summary::after { content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); }
.ms[open] summary { outline: 2px solid var(--accent); outline-offset: 1px; }
.ms-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; max-width: min(320px, calc(100vw - 32px)); max-height: 320px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.ms-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--line); position: sticky; bottom: -8px; background: var(--panel); padding-bottom: 2px; }
label.chk { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; color: var(--text); padding: 6px 6px; border-radius: 6px; cursor: pointer; }
label.chk:hover { background: var(--panel-2); }
label.chk input { width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
label.chk span { overflow-wrap: anywhere; }
.filters label.inline-chk { flex: 0 1 auto; align-self: center; padding-bottom: 4px; }

/* KPIs */
.kpi-h { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.kpi-l { flex: 1 1 auto; min-width: 0; }
.kpi, .chart-h { position: relative; }
.info { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; margin: -3px -4px -3px 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: help; }
.info:hover, .info:focus-visible { color: var(--text); background: var(--panel-2); outline: none; }
.tip { display: none; position: absolute; z-index: 30; left: 8px; right: 8px; top: calc(100% - 4px); background: var(--tip-bg); color: var(--tip-text); font-size: 12.5px; line-height: 1.45; font-weight: 400; text-transform: none; letter-spacing: 0; padding: 9px 11px; border-radius: 9px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.info:hover + .tip, .info:focus + .tip { display: block; }
.kpis-hero { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi.big { padding: 16px 18px; }
.kpi.big .kpi-v { font-size: 30px; margin-top: 8px; }
.kpi.big .kpi-h .tip { top: calc(100% + 6px); left: -10px; right: -10px; }
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { border-radius: 12px; }
.kpi .tip { top: 100%; }
.kpis .kpi-h { min-height: 32px; align-items: flex-start; }
.kpis .info { margin-top: -2px; }
.lab-short { display: none; }
.kpi-s a { color: var(--accent); }
.kpi.big:first-child { background: linear-gradient(160deg, color-mix(in srgb, var(--fg-a) 16%, var(--panel)) 0%, var(--panel) 70%); }

/* cartões de gráfico */
.chart { padding: 16px 18px 18px; margin-bottom: 0; min-width: 0; }
.chart-h { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.chart-h h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.005em; }
.chart-h h2 .muted { font-weight: 500; }
.chart-h .tip { top: calc(100% + 4px); left: 0; right: auto; width: min(380px, 100%); }
.chart-sub { flex-basis: 100%; font-size: 12px; color: var(--muted); margin-top: -2px; }
.chart-empty { display: grid; place-items: center; min-height: 140px; color: var(--muted); font-size: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; padding: 16px; }
.charts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

/* cores por classe (indireção: --c) */
.c1 { --c: var(--s1); } .c2 { --c: var(--s2); } .c3 { --c: var(--s3); }
.c4 { --c: var(--s4); } .c5 { --c: var(--s5); } .c6 { --c: var(--s6); }
.c-other { --c: var(--s-other); }

/* funil */
.funnel-card { margin-bottom: 14px; }
.funnel { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); min-height: 264px; }
.funnel-shape { position: absolute; left: 0; top: 58px; width: 100%; height: calc(100% - 58px - 46px); display: block; overflow: visible; }
.fg-a { stop-color: var(--fg-a); }
.fg-b { stop-color: var(--fg-b); }
.fstage { position: relative; z-index: 1; display: grid; grid-template-rows: 22px 20px 1fr 34px; text-align: center; padding: 6px 6px 0; border-left: 1px solid var(--line); min-width: 0; }
.fstage:first-of-type { border-left: 0; }
.ft { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fprev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmid { display: grid; place-items: center; }
.fpill { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; padding: 3px 12px; border-radius: 999px; background: color-mix(in srgb, var(--panel) 84%, transparent); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); white-space: nowrap; }
.fc { font-size: 19px; font-weight: 700; align-self: end; padding-bottom: 6px; }

/* rosca */
.donut { display: flex; align-items: center; gap: 18px; }
.donut-svg { width: 128px; height: 128px; flex: none; }
.donut-svg circle:not(.track) { stroke: var(--c); }
.donut-svg circle:not(.track):hover { stroke-width: 19; }
circle.track { stroke: var(--panel-2); }
.donut-n { font-size: 21px; font-weight: 750; fill: var(--text); }
.donut-t { font-size: 10px; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1 1 auto; min-width: 0; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; column-gap: 8px; align-items: center; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.lg-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-v { font-weight: 650; }
.lg-p { color: var(--muted); min-width: 44px; text-align: right; }
.lg-s { grid-column: 2 / -1; font-size: 12px; color: var(--muted); margin-top: -1px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 12px; }
.legend-row li { grid-template-columns: 10px auto auto; }

/* anéis de aprovação */
.rings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
.ring { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ring-svg { width: 78px; height: 78px; }
.ring-svg circle:not(.track) { stroke: var(--c); }
.ring-n { font-size: 12px; font-weight: 750; fill: var(--text); }
.ring-l { font-size: 13px; font-weight: 650; margin-top: 4px; }
.ring-s { font-size: 12px; color: var(--muted); }

/* barras / linhas com eixos em HTML */
.plot { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 190px auto; column-gap: 8px; }
.yax { grid-row: 1; grid-column: 1; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); }
.yax span { height: 0; display: flex; align-items: center; justify-content: flex-end; white-space: nowrap; }
.plot-area { grid-row: 1; grid-column: 2; position: relative; min-width: 0; }
.plot-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot-svg .grid { stroke: var(--line); stroke-width: 1; }
.plot-svg .zero { stroke: var(--muted); stroke-width: 1; opacity: 0.55; }
.plot-svg .bar { fill: var(--s1); }
.plot-svg .hit { fill: transparent; }
.plot-svg .hit:hover { fill: color-mix(in srgb, var(--text) 7%, transparent); }
.plot-svg .ln { stroke: var(--c); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.xax { grid-row: 2; grid-column: 2; display: grid; font-size: 11px; color: var(--muted); padding-top: 6px; }
.xax span { text-align: center; white-space: nowrap; }
.xax-24 { grid-template-columns: repeat(24, minmax(0, 1fr)); }
.xax-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.xax .xhide { visibility: hidden; }
.plot-unit { grid-row: 2; grid-column: 1; font-size: 10px; color: var(--muted); padding-top: 7px; text-align: right; }
.xhair { position: absolute; top: 0; bottom: 0; width: 1px; background: color-mix(in srgb, var(--text) 35%, transparent); pointer-events: none; }
.ltip { position: absolute; top: 4px; z-index: 5; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); white-space: nowrap; min-width: 170px; }
.ltip b { display: block; margin-bottom: 4px; }
.ltip div { display: flex; align-items: center; gap: 8px; }
.ltip div span:last-child { margin-left: auto; font-weight: 650; }
.plot-line { cursor: crosshair; }

/* barras horizontais */
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: 13px; }
.hbars li { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-svg { width: 100%; height: 12px; display: block; border-radius: 4px; background: var(--panel-2); }
.hb-svg .bar { fill: var(--s1); }
.hb-svg .bar-na { fill: var(--s-other); }
.hb-v { font-weight: 650; white-space: nowrap; }
.hb-v .muted { font-weight: 400; }

/* vendas */
tr.is-test td { background: color-mix(in srgb, var(--warn-bg) 45%, transparent); }
td.actions { white-space: nowrap; }
td.actions form { display: inline; margin: 0; }

/* despesas */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; margin-bottom: 14px; }
.two-col .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.stack .btn { align-self: flex-start; }
.row3 { display: flex; flex-wrap: wrap; gap: 10px; }
.row3 label { flex: 1 1 140px; min-width: 0; }
.row3 label.grow { flex: 3 1 220px; }
.costs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.cost-row { flex-direction: row; align-items: center; gap: 10px; font-size: 14px; font-weight: 400; color: var(--text); min-width: 0; }
.cost-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-row input[name='custo'] { width: 120px; flex: none; text-align: right; }
.inline-filters { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; box-shadow: none; padding: 12px 14px; }
.inline-filters label { flex: 0 1 170px; }
.push { margin-left: auto; align-self: center; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .charts .span-2 { grid-column: span 3; }
  .charts .span-4 { grid-column: span 6; }
}
@media (max-width: 820px) {
  .kpis-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts .span-2, .charts .span-3, .charts .span-4 { grid-column: span 6; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .kpis-hero, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi.big { padding: 12px 12px; }
  .kpi.big .kpi-v { font-size: 21px; margin-top: 4px; }
  .kpi-l { font-size: 11px; letter-spacing: 0.02em; }
  .kpi.big .kpi-h .tip { left: 0; right: 0; }
  .page-head { align-items: flex-start; }
  .refresh { width: 100%; justify-content: space-between; }
  .chart { padding: 14px 14px 16px; }
  .funnel { min-height: 236px; }
  .funnel-shape { top: 52px; height: calc(100% - 52px - 40px); }
  .fstage { grid-template-rows: 20px 26px 1fr 30px; padding: 4px 2px 0; }
  .ft { font-size: 11px; letter-spacing: -0.01em; }
  .fstage { padding-left: 0; padding-right: 0; }
  .lab-full { display: none; }
  .lab-short { display: inline; }
  .fprev { font-size: 10px; white-space: normal; line-height: 1.15; }
  .fpill { font-size: 13.5px; padding: 2px 6px; }
  .fc { font-size: 14px; }
  .donut { gap: 14px; }
  .donut-svg { width: 104px; height: 104px; }
  .plot { grid-template-rows: 160px auto; }
  .xax .xhide-sm { visibility: hidden; }
  .hbars li { grid-template-columns: minmax(0, 38%) minmax(0, 1fr) auto; gap: 8px; }
  .filters .field { flex: 1 1 calc(50% - 10px); }
  .inline-filters label { flex: 1 1 calc(50% - 10px); }
  .push { margin-left: 0; flex-basis: 100%; }
  .cost-name { white-space: normal; overflow-wrap: anywhere; }
  .cost-row input[name='custo'] { width: 96px; }
}
