/* Dashboard Consulta Históricos de Clientes - Novavet Distribuidora */

:root {
  --bg: #F5F5F5;
  --surface: #FFFFFF;
  --surface-2: #FAFAFB;
  --ink: #2C2C2C;
  --ink-2: #565E6B;
  --ink-3: #667085;
  --line: #E6E8EB;
  --line-2: #D3D8DE;
  --zebra: #F5F5F5;
  --primary: #C94B5E;
  --primary-ink: #FFFFFF;
  --primary-hover: #B23F51;
  --primary-wash: rgba(201, 75, 94, .10);
  --sec: #4BA3D4;
  --sec-ink: #0E2A3A;
  --sec-hover: #3E96C8;
  --sec-text: #1B72A0;
  --sec-wash: rgba(75, 163, 212, .14);
  --s1: #C94B5E;
  --s2: #4BA3D4;
  --danger: #FF6B6B;
  --good: #1F7A3E;
  --good-wash: rgba(31, 122, 62, .10);
  --bad: #B4232F;
  --bad-wash: rgba(180, 35, 47, .09);
  --warn-wash: #FFF6DB;
  --warn-ink: #6B4E00;
  --focus: #1B72A0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 14px;
  --font-h: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-b: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --grid: #E9ECEF;
  --gold: #B7791F; --silver: #6B7280; --bronze: #A0522D;
}

:root[data-theme="dark"] {
  --bg: #121215; --surface: #1C1C21; --surface-2: #212127; --ink: #ECECEF; --ink-2: #B0B2BB; --ink-3: #9497A1;
  --line: #2C2C33; --line-2: #3A3A43; --zebra: #202026;
  --primary: #D2566A; --primary-hover: #DD6C7E; --primary-wash: rgba(210, 86, 106, .16);
  --sec: #5DB2E0; --sec-hover: #74BFE8; --sec-text: #7CC3EA; --sec-wash: rgba(93, 178, 224, .16);
  --s1: #D9606F; --s2: #4799CB; --danger: #FF7B7B;
  --good: #63D08A; --good-wash: rgba(99, 208, 138, .13); --bad: #FF8A8A; --bad-wash: rgba(255, 138, 138, .13);
  --warn-wash: #3A3018; --warn-ink: #F3D98A; --focus: #7CC3EA;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6); --grid: #2A2A31;
  --gold: #E0B24A; --silver: #B8BCC6; --bronze: #D08A5D;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121215; --surface: #1C1C21; --surface-2: #212127; --ink: #ECECEF; --ink-2: #B0B2BB; --ink-3: #9497A1;
    --line: #2C2C33; --line-2: #3A3A43; --zebra: #202026;
    --primary: #D2566A; --primary-hover: #DD6C7E; --primary-wash: rgba(210, 86, 106, .16);
    --sec: #5DB2E0; --sec-hover: #74BFE8; --sec-text: #7CC3EA; --sec-wash: rgba(93, 178, 224, .16);
    --s1: #D9606F; --s2: #4799CB; --danger: #FF7B7B;
    --good: #63D08A; --good-wash: rgba(99, 208, 138, .13); --bad: #FF8A8A; --bad-wash: rgba(255, 138, 138, .13);
    --warn-wash: #3A3018; --warn-ink: #F3D98A; --focus: #7CC3EA;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6); --grid: #2A2A31;
    --gold: #E0B24A; --silver: #B8BCC6; --bronze: #D08A5D;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.5 var(--font-b); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-h); margin: 0; color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 0 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--sec); color: var(--sec-ink); }
.btn-secondary:hover:not(:disabled) { background: var(--sec-hover); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 0;
  background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--primary-wash), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg); padding: 28px 24px 22px; display: grid; gap: 14px; }
.logo-chip { display: inline-block; background: #fff; border-radius: 12px; padding: 4px; line-height: 0; }
.login-card .logo-chip { justify-self: center; }
.login-card .logo-chip img { width: 200px; height: auto; }
.login-card h1 { font-size: 20px; text-align: center; color: var(--primary); }
.login-sub { margin: -6px 0 4px; text-align: center; color: var(--ink-2); font-size: 13px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--sec-text); }
.field input, .f select, .f .ms-field, .modal input[type=email], .modal input[type=text] {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 15px;
}
.field input:focus, .f select:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
.pw { position: relative; }
.pw input { padding-right: 46px; letter-spacing: .3em; }
.pw button { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; border-radius: 8px; }
.pw button svg { width: 20px; height: 20px; }
.form-error { color: var(--bad); font-size: 13px; font-weight: 500; }
.login-help { text-align: center; font-size: 12px; color: var(--ink-3); margin: 0; }
.notice { padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.notice-error { background: var(--bad-wash); color: var(--bad); }
.notice-warn { background: var(--warn-wash); color: var(--warn-ink); }
.notice-info { background: var(--sec-wash); color: var(--ink); }

/* ---------- topo ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .logo-chip img { height: 44px; width: auto; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 18px; line-height: 1.2; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border: 1px solid var(--line-2);
  border-radius: 999px; background: transparent; cursor: pointer; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  font: 700 12px var(--font-h); flex: none; }
.user-chip .who { text-align: left; line-height: 1.15; }
.user-chip .who b { display: block; font-size: 13px; }
.user-chip .who small { color: var(--ink-3); font-size: 11px; }
.only-mobile { display: none; }

/* ---------- layout ---------- */
.content { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.content > *, #results > * { min-width: 0; }
#results { grid-template-columns: minmax(0, 1fr); }
select { min-width: 0; max-width: 100%; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 16px 18px 6px; }
.card-head h2 { font-size: 16px; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
.card-body { padding: 8px 18px 18px; }
#results { transition: opacity .15s; display: grid; gap: 16px; }
#results.is-updating { opacity: .55; }

/* ---------- filtros ---------- */
.filters { padding: 16px 18px 18px; }
.filters-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.filters-head h2 { font-size: 16px; flex: 1; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip-btn { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent;
  cursor: pointer; font-size: 13px; font-weight: 500; }
.chip-btn:hover { background: var(--surface-2); }
.chip-btn[aria-pressed="true"] { background: var(--primary-wash); border-color: var(--primary); color: var(--ink); font-weight: 600; }
.filters-grid { display: grid; gap: 12px 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.f { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start; min-width: 0; }
.f > label, .f > .lbl { font-size: 12px; font-weight: 600; color: var(--sec-text); }
.f-period { grid-column: span 2; }
.period { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.pgrp { display: flex; align-items: center; gap: 6px; flex: 1 1 250px; min-width: 0; }
.pgrp span { font-size: 13px; color: var(--ink-2); min-width: 26px; }
.pgrp select { flex: 1 1 0; min-width: 0; }
.pgrp select.yr { flex: 0 0 92px; }
.f select { padding-right: 8px; }
.hint { font-size: 11px; color: var(--ink-3); }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch .txt { font-size: 13px; line-height: 1.25; }
.switch .txt small { display: block; color: var(--ink-3); font-size: 11px; }

/* multi-select */
.ms-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.ms-field .ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.ms-field .ms-text.is-empty { color: var(--ink-3); }
.ms-field svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.ms-pop { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; min-width: 260px; }
.ms-pop .ms-search { display: block; width: 100%; margin-bottom: 6px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-2);
  border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 15px; }
.ms-pop .ms-search:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
.ms-list { max-height: 260px; overflow: auto; margin: 0; padding: 0; list-style: none; }
.ms-opt { display: flex; align-items: flex-start; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }
.ms-opt .o-main { display: block; font-size: 13px; line-height: 1.3; }
.ms-opt .o-sub { display: block; font-size: 11px; color: var(--ink-3); line-height: 1.3; }
.ms-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 4px 0; font-size: 12px; color: var(--ink-3); }
.ms-foot button { border: 0; background: transparent; color: var(--sec-text); font-weight: 600; cursor: pointer; padding: 6px; }
.ms-empty { padding: 14px 8px; color: var(--ink-3); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 12px; border-radius: 999px;
  background: var(--sec-wash); font-size: 12px; }
.chip b { font-weight: 600; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.chip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.chip button:hover { background: var(--line-2); }
.chip button svg { width: 12px; height: 12px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: 1.5fr repeat(4, 1fr); }
.kpi { position: relative; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.kpi::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--kpi-accent, var(--line-2)); }
.kpi .k-label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .k-label i { width: 8px; height: 8px; border-radius: 50%; background: var(--kpi-accent, var(--line-2)); display: inline-block; }
.kpi .k-value { margin-top: 6px; font: 700 24px/1.15 var(--font-b); letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi.hero { --kpi-accent: var(--primary); }
.kpi.hero .k-value { font-size: clamp(30px, 4.2vw, 48px); line-height: 1.05; }
.kpi.k-dev { --kpi-accent: var(--danger); }
.kpi.k-sec { --kpi-accent: var(--sec); }
.k-delta { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.delta { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.delta svg { width: 10px; height: 10px; }
.delta.up { background: var(--good-wash); color: var(--good); }
.delta.down { background: var(--bad-wash); color: var(--bad); }
.delta.flat { background: var(--line); color: var(--ink-2); }
.note { font-size: 12px; color: var(--ink-3); margin: -4px 2px 0; }

/* ---------- gráfico ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--zebra); border: 1px solid var(--line); }
.seg button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.head-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0 18px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-box { position: relative; height: 320px; padding: 8px 12px 14px; }
.empty { display: grid; place-items: center; text-align: center; min-height: 140px; padding: 24px; color: var(--ink-3); }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2);
  padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
.tbl th.num { text-align: right; }
.tbl th .sort { display: inline-block; width: 10px; margin-left: 4px; color: var(--ink-3); opacity: .45; }
.tbl th[aria-sort="ascending"] .sort, .tbl th[aria-sort="descending"] .sort { opacity: 1; color: var(--primary); }
.tbl th:hover { color: var(--ink); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:nth-child(odd) td { background: var(--surface); }
.tbl tbody tr:nth-child(even) td { background: var(--zebra); }
.tbl tbody tr.row { cursor: pointer; }
.tbl tbody tr.row:hover td { background: var(--primary-wash); }
.tbl td.wrap { white-space: normal; min-width: 180px; }
.tbl td.nowrap { white-space: nowrap; }
.tbl tr.detail td { background: var(--surface-2) !important; padding: 12px 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 20px; font-size: 12px; }
.detail-grid dt { color: var(--ink-3); font-size: 11px; }
.detail-grid dd { margin: 0; font-weight: 500; }
.detail-grid div { min-width: 0; overflow-wrap: anywhere; }
.neg { color: var(--bad); }
.linklike { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.linklike:hover { color: var(--primary); text-decoration-color: var(--primary); }
.pos { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.pos svg { width: 16px; height: 16px; }
.pos.p1 svg { color: var(--gold); } .pos.p2 svg { color: var(--silver); } .pos.p3 svg { color: var(--bronze); }
.pct-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; min-width: 130px; }
.pct-bar { flex: 1; max-width: 70px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.pct-bar i { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.pager .pg-ctrl { display: flex; align-items: center; gap: 8px; }
.pager select { min-height: 36px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.tabs { display: inline-flex; gap: 4px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; font-size: 12px; color: var(--ink-3); padding: 4px 2px; }

/* ---------- drawer / menu ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: min(340px, 90vw); background: var(--surface); box-shadow: var(--shadow-lg);
  transform: translateX(-102%); transition: transform .22s ease; display: flex; flex-direction: column; visibility: hidden; }
.drawer.on { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.drawer-head .logo-chip img { height: 40px; width: auto; }
.drawer-body { overflow: auto; padding: 14px; display: grid; gap: 16px; align-content: start; flex: 1; }
.drawer .me { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.drawer .me b { display: block; font-size: 14px; } .drawer .me small { color: var(--ink-3); word-break: break-all; }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.menu-list button { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: left; font-size: 14px; font-weight: 500; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.menu-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 6px; font-family: var(--font-b); }
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.hist-list button { width: 100%; text-align: left; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.hist-list button:hover { background: var(--surface-2); }
.hist-list small { display: block; color: var(--ink-3); }

.bottombar { display: none; }

/* ---------- modal ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); }
dialog.modal.wide { width: min(920px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .5); }
.modal-in { display: grid; gap: 14px; padding: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.modal-in h2 { font-size: 18px; color: var(--primary); }
.modal-in p { margin: 0; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-wash); }
.opt input { margin-top: 3px; accent-color: var(--primary); width: 18px; height: 18px; }
.opt b { display: block; font-size: 14px; } .opt small { color: var(--ink-3); word-break: break-all; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kv div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.kv small { display: block; color: var(--ink-3); font-size: 11px; } .kv b { font-size: 15px; }
code, .code { font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--zebra); padding: 2px 6px; border-radius: 6px; }
.copyrow { display: flex; gap: 8px; align-items: center; }
.copyrow code { flex: 1; overflow-x: auto; white-space: nowrap; padding: 8px 10px; }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status.ativo { background: var(--good-wash); color: var(--good); }
.status.pendente { background: var(--warn-wash); color: var(--warn-ink); }
.status.inativo { background: var(--bad-wash); color: var(--bad); }

/* ---------- toast ---------- */
#toast-root { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; }
.toast.ok { background: var(--good); color: #fff; } .toast.err { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast.ok, :root[data-theme="dark"] .toast.err { color: #111; }

/* ---------- responsivo ---------- */
@media (max-width: 1199px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.hero { grid-column: 1 / -1; }
  .user-chip .who { display: none; }
  .user-chip { padding: 4px; }
}
@media (max-width: 1199px) {
  .tbl th, .tbl td { padding: 8px 8px; }
  .pct-cell { min-width: 0; }
  .pct-bar { max-width: 44px; }
  .tbl td.wrap { min-width: 150px; }
}
@media (max-width: 899px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f-period { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
  body { padding-bottom: 76px; }
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none !important; }
  .topbar { padding: 8px 10px; gap: 4px; }
  .topbar .logo-chip { display: none; }
  .topbar-title h1 { font-size: 15px; }
  .topbar-actions { display: none; }
  .content { padding: 12px 12px 24px; gap: 12px; }
  .card-head { padding: 14px 14px 4px; } .card-body { padding: 6px 14px 14px; }
  .kpi { padding: 14px; } .kpi .k-value { font-size: 18px; letter-spacing: -.02em; }
  .kpi.hero .k-value { font-size: 32px; }
  /* filtros viram gaveta */
  #filters { position: fixed; z-index: 70; inset: 0 0 0 auto; width: min(400px, 100vw); border-radius: 0; overflow: auto; transform: translateX(102%);
    transition: transform .22s ease; visibility: hidden; padding-bottom: 96px; box-shadow: var(--shadow-lg); }
  #filters.on { transform: none; visibility: visible; }
  .filters-grid { grid-template-columns: 1fr; }
  .f-period { grid-column: auto; }
  .filters-apply { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .btn, .chip-btn, .seg button { min-height: 48px; }
  .chip-btn { min-height: 40px; }
  .seg button { min-height: 40px; }
  .chart-box { height: 260px; padding: 4px 4px 10px; }
  .tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--line); }
  .tbl th:first-child { z-index: 3; }
  .pager { padding: 12px 14px; }
  .bottombar { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottombar button { display: grid; place-items: center; gap: 2px; min-height: 56px; border: 0; background: transparent; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--ink-2); position: relative; }
  .bottombar button svg { width: 22px; height: 22px; }
  .bottombar .b-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; }
  dialog.modal { width: calc(100vw - 16px); }
  .modal-in { padding: 16px; }
  #toast-root { bottom: 84px; }
}
@media (min-width: 768px) {
  .filters-apply { display: none; }
}
@media print {
  .topbar, .bottombar, #filters, .foot, .topbar-actions { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
