:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #16191f;
  --muted: #5f6774;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --ok: #1a7f37;
  --ok-soft: #e7f6ec;
  --info: #1f5fbf;
  --info-soft: #e8f0fc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e8eaee;
    --muted: #9aa2af;
    --accent: #2bb3a3;
    --accent-soft: #12302d;
    --accent-text: #06201d;
    --danger: #f97066;
    --danger-soft: #3a1a18;
    --warn: #f5c451;
    --warn-soft: #362b10;
    --ok: #4ac26b;
    --ok-soft: #12301b;
    --info: #79a7f2;
    --info-soft: #172a47;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0 0; }
.boot { padding: 48px; text-align: center; color: var(--muted); }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 14px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.side-foot strong { display: block; color: var(--text); font-weight: 600; }
.main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.mobile-bar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 30% 0 0; z-index: 20; height: auto; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .side.open { display: flex; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
  .main { padding: 16px; }
}

/* Cards & surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-detail { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.danger .value { color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-transform: uppercase; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .primary { font-weight: 600; color: var(--text); }
td .secondary { color: var(--muted); font-size: 12.5px; }
.wrap { white-space: normal; }

/* Forms */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 84px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { position: relative; min-width: 260px; flex: 1; max-width: 420px; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.error-box { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.note-box { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.ok-box { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border); padding: 10px 12px; border-radius: 8px; word-break: break-all; }

/* Detail */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; }
.tab { padding: 12px 12px 10px; border: none; background: none; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 5px; }
.timeline .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.timeline .desc { margin-top: 6px; white-space: pre-wrap; }
.timeline .actions-inline { display: flex; gap: 4px; margin-top: 6px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { margin: 14px 0 4px; }
.auth p { margin: 0 0 18px; color: var(--muted); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; }
.modal .card-head { position: sticky; top: 0; background: var(--surface); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }

.toast { position: fixed; bottom: 18px; right: 18px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-weight: 500; z-index: 60; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* Coluna de nome com largura fixa: nomes longos não empurram as outras colunas */
th.col-name, td.col-name { width: 260px; min-width: 260px; max-width: 260px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status do cliente (cores da legenda do time de CS) */
.status, .status-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.status-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.status-chip { cursor: pointer; padding: 5px 12px; font-size: 12.5px; opacity: .8; }
.status-chip b { font-weight: 700; margin-left: 4px; }
.status-chip:hover { opacity: 1; }
.status-chip.on { opacity: 1; box-shadow: 0 0 0 2px var(--text) inset; }
.st-lead { background: var(--surface); border-color: var(--border); color: var(--text); }
.st-lead_pendente { background: #fdf3cf; color: #9a6700; }
.st-lead_vencido { background: #ffe4d1; color: #c2410c; }
.st-lead_cancelado { background: #e5e7eb; color: #4b5563; }
.st-cliente { background: #dcf5e3; color: #15803d; }
.st-cliente_vencido { background: #fde2e2; color: #c62828; }
.st-cliente_cancelado { background: #efe3fd; color: #7e3fc2; }
.st-excluido { background: #cfd2d6; color: #1f2937; }
@media (prefers-color-scheme: dark) {
  .st-lead_pendente { background: #3a2f0c; color: #f5c451; }
  .st-lead_vencido { background: #3d2212; color: #fb923c; }
  .st-lead_cancelado { background: #2a2e36; color: #aab1bd; }
  .st-cliente { background: #12301b; color: #4ac26b; }
  .st-cliente_vencido { background: #3a1a18; color: #f97066; }
  .st-cliente_cancelado { background: #2c1d40; color: #c4a2f5; }
  .st-excluido { background: #3a3f48; color: #e5e7eb; }
}

/* Barra da tabela: busca (~80%) · filtros (~10%) · ordenação (~10%) */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.toolbar-search { flex: 8 1 0; max-width: none; min-width: 0; }
.toolbar-filter { flex: 1 0 auto; position: relative; }
.toolbar-sort { flex: 1 0 auto; width: auto; min-width: 150px; }
.filters-btn { width: 100%; }
.filters-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filters-btn .count { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 7px; font-size: 11.5px; line-height: 18px; }
.filters-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(760px, calc(100vw - 32px)); box-shadow: 0 12px 32px rgba(16, 24, 40, .18); }
.filters-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 20px; padding: 20px; }
.filters-grid .field { color: var(--text); font-weight: 600; font-size: 13px; gap: 8px; }
.filters-grid .span-3 { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
.action-filter { display: flex; gap: 8px; }
.action-filter select { width: 150px; flex: none; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; }
.tag button { border: none; background: var(--surface-2); border-radius: 50%; width: 18px; height: 18px; line-height: 16px; cursor: pointer; color: var(--muted); padding: 0; }
@media (max-width: 760px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar-search { flex-basis: 100%; }
  .filters-grid { grid-template-columns: 1fr; }
  .filters-panel { position: fixed; left: 16px; right: 16px; top: 80px; width: auto; }
}

/* Dashboard: distribuições */
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist-row { display: grid; grid-template-columns: 140px 1fr 70px 52px; align-items: center; gap: 10px; padding: 6px 8px; border: none; background: none; border-radius: 8px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.dist-row:hover { background: var(--surface-2); }
.dist-row.static { cursor: default; }
.dist-row.static:hover { background: none; }
.dist-row .status { justify-self: start; }
.dist-label { font-weight: 500; }
.dist-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.dist-bar > span { display: block; height: 100%; border-radius: 999px; border: none; }
.bar-accent { background: var(--accent); }
.dist-n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dist-pct { text-align: right; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dist-row.mrr-cols { grid-template-columns: 100px 1fr 64px 48px 110px; }
.dist-mrr { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dist-head span { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.dist-total { border-top: 1px solid var(--border); border-radius: 0; margin-top: 4px; padding-top: 10px; }
.dist-total .dist-label { font-weight: 700; }

/* Seleção de clientes */
th.col-check, td.col-check { width: 40px; padding-right: 0; }
td.col-check input, th.col-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
tr.row-selected td { background: var(--accent-soft); }
.selection-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 9px 18px; background: var(--accent-soft); border-bottom: 1px solid var(--border); font-size: 13px; }
.btn.link { color: var(--accent); text-decoration: underline; }
.bulk-select { width: auto; min-width: 220px; font-weight: 600; }
.bulk-select:disabled { opacity: .6; }

/* ---------- Dashboard: quadros e gráficos ---------- */
:root { --viz-1: #0f766e; --viz-a: #2a78d6; --viz-a-soft: #9cc2ee; --viz-b: #eb6834; --viz-grid: #e9ebef; }
@media (prefers-color-scheme: dark) { :root { --viz-1: #26a596; --viz-a: #3987e5; --viz-a-soft: #24476f; --viz-b: #d95926; --viz-grid: #2a2f39; } }

.dash-section { margin: 26px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-grid .wide { grid-column: 1 / -1; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.panel .card-head { align-items: flex-start; }
.panel .card-head .muted { margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.skeleton { height: 160px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
.skeleton.sm { height: 52px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.hero { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero.ok { color: var(--ok); }
.note { margin: 10px 0 0; }
.breakdown { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.breakdown li { display: grid; grid-template-columns: 1fr auto 44px; gap: 10px; align-items: baseline; }
.breakdown li span { color: var(--muted); }
.breakdown li b { font-variant-numeric: tabular-nums; }
.breakdown li em { font-style: normal; color: var(--muted); text-align: right; font-size: 12px; }
.mini-table th, .mini-table td { padding: 7px 10px; }
.mini-table th { background: none; border-bottom: 1px solid var(--border); }
.dist-row.aging-cols { grid-template-columns: 120px 1fr 110px 52px; }
.bar-danger { background: var(--danger); }
.rate { display: inline-flex; align-items: center; gap: 8px; }
.rate-bar { width: 60px; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: inline-block; }
.rate-bar span { display: block; height: 100%; background: var(--danger); border-radius: 999px; }

/* Colunas */
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; align-items: end; padding-top: 18px; border-bottom: 1px solid var(--viz-grid); }
.col { position: relative; display: flex; flex-direction: column; align-items: stretch; outline: none; }
.col-plot { height: 170px; display: flex; align-items: flex-end; justify-content: center; position: relative; gap: 2px; }
.col-bar { width: 70%; max-width: 34px; min-height: 1px; background: var(--viz-1); opacity: .55; border-radius: 4px 4px 0 0; transition: opacity .15s; }
.col-bar.current { opacity: 1; }
.col-plot.group .col-bar { width: 28%; max-width: 16px; opacity: 1; }
.col-plot.group.g2 .col-bar { width: 42%; max-width: 18px; }
.col-bar.s-a { background: var(--viz-a); }
.col-bar.s-a-soft { background: var(--viz-a-soft); }
.col-bar.s-b { background: var(--viz-b); }
.col:hover .col-bar, .col:focus .col-bar { opacity: 1; }
.col-label { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-x { text-align: center; font-size: 11px; color: var(--muted); padding-top: 6px; white-space: nowrap; }
.col-foot { text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tip { display: none; position: absolute; bottom: calc(100% - 24px); left: 50%; transform: translateX(-50%); z-index: 5; background: var(--text); color: var(--bg); padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); }
.tip span { opacity: .75; }
.col:hover .tip, .col:focus .tip, .tip.show { display: block; }
.table-toggle { margin-top: 8px; }
/* Gráfico com rolagem horizontal: cada mês tem largura mínima; com poucos meses ocupa a largura toda */
.h-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding-bottom: 4px; }
.cols-scroll { grid-auto-columns: minmax(72px, 1fr); min-width: 100%; width: max-content; }
.cols-scroll .tip { top: 0; bottom: auto; }
.cols-scroll .tip-start .tip { left: 0; transform: none; }
.cols-scroll .tip-end .tip { left: auto; right: 0; transform: none; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.sw-a { background: var(--viz-a); }
.sw-a-soft { background: var(--viz-a-soft); }
.sw-b { background: var(--viz-b); }

/* Linha */
.line-wrap { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; }
.line-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; padding: 2px 0; font-variant-numeric: tabular-nums; }
.line-plot { position: relative; height: 200px; }
.line-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.line-svg .grid { stroke: var(--viz-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.line-svg .line { fill: none; stroke: var(--viz-1); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.line-svg .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.line-plot .dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--viz-1); box-shadow: 0 0 0 2px var(--surface); opacity: 0; }
.line-plot .dot.on, .line-plot .dot:only-of-type { opacity: 1; }
.line-plot .tip { bottom: auto; top: 4px; transform: translate(-50%, 0); }
.line-x { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding-top: 4px; }
@media (min-width: 1100px) { .dash-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rate-bar { width: 36px; }
.mini-table td.num, .mini-table th.num { white-space: nowrap; }

/* Números do dashboard que levam à lista de clientes */
.drill { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit;
  text-decoration: underline dotted color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; border-radius: 4px; }
.drill:hover, .drill:focus-visible { color: var(--accent); text-decoration-color: currentColor; text-decoration-style: solid; outline: none; }
.stat .value .drill { text-decoration-thickness: 1px; }
.col.clickable, .col-bar.clickable { cursor: pointer; }
.col-plot.group .col-bar.clickable:hover { filter: brightness(1.12); }
.tag-drill { background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent)); color: var(--accent); font-weight: 600; }

/* Evolução: trecho reconstruído do Asaas tracejado */
.line-svg .line.est { stroke-dasharray: 5 4; opacity: .85; }
.legend-dash { display: inline-block; width: 18px; border-top: 2px dashed var(--viz-1); vertical-align: middle; margin-right: 4px; }
.line-plot .tip.tip-l { transform: translate(8px, 0); }
.line-plot .tip.tip-r { transform: translate(calc(-100% - 8px), 0); }

/* Automações */
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.auto-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.auto-card.paused { opacity: .7; }
.auto-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.auto-name { font-weight: 650; font-size: 15px; }
.auto-flow { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; min-width: 0; }
.auto-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.auto-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.danger-text { color: var(--danger); }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal.modal-wide { max-width: 760px; }
.sub-h { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
pre.json { max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.auto-flow .badge { white-space: nowrap; flex: none; }
.log-head { flex-wrap: wrap; }
.log-head > div:first-child { flex: 1 1 280px; }
