:root {
  color-scheme: light;
  --bg: #f5f8f6; --surface: #ffffff; --surface-2: #f0f4f2; --border: #e3e9e6;
  --text: #0e1c17; --text-2: #50605a; --muted: #7a8983;
  --brand: #0f8a5f; --brand-ink: #0b6b4a; --brand-deep: #0c3b2d; --brand-soft: #e3f4ec;
  --good: #0b7a52; --bad: #c8372d; --warn: #a66300; --bad-soft: #fdecea; --warn-soft: #fdf3dd; --info-soft: #e8f1fc; --info: #1c5fb0;
  --s-rev: #059669; --s-cost: #eb6834; --s-profit: #2a78d6;
  --shadow: 0 1px 2px rgba(14, 28, 23, .05);
  --radius: 14px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1210; --surface: #121b18; --surface-2: #18231f; --border: #24322c;
  --text: #e9f0ed; --text-2: #b3c1bb; --muted: #84948d;
  --brand: #1fae7b; --brand-ink: #4fd0a1; --brand-deep: #0c3b2d; --brand-soft: #143328;
  --good: #4fd0a1; --bad: #f0857c; --warn: #e2b057; --bad-soft: #3a1d1a; --warn-soft: #35290f; --info-soft: #14283f; --info: #7fb4f0;
  --s-rev: #199e70; --s-cost: #d95926; --s-profit: #3987e5;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-2); } .small { font-size: 12.5px; } .num { font-variant-numeric: tabular-nums; }
.pos { color: var(--good); } .neg { color: var(--bad); }
code, .mono { font: 12.5px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* estrutura */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.app.collapsed { grid-template-columns: 64px 1fr; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; font-size: 16px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-deep); color: #d9f5e8; display: grid; place-items: center; font-weight: 800; flex: none; }
.nav-title { font-size: 11px; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav svg, .ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.collapsed .side { padding: 16px 8px; }
.collapsed .nav span, .collapsed .nav-title, .collapsed .brand b { display: none; }
.collapsed .nav a { justify-content: center; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.top .grow { flex: 1; }
.content { padding: 26px 28px 60px; max-width: 1500px; margin: 0 auto; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 20px; margin-bottom: 20px; }
.head > div:first-child { flex: 1 1 320px; }
.head p { color: var(--text-2); margin-top: 4px; }

/* controles */
.btn, select, input, textarea { font: inherit; color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
select, input, textarea { height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); min-width: 0; }
textarea { height: auto; padding: 8px 10px; width: 100%; resize: vertical; }
:is(.btn, select, input, textarea, a):focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
label { display: grid; gap: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { font: inherit; border: 0; background: none; color: var(--text-2); padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 550; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.form .wide { grid-column: 1 / -1; }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card > h2 { margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.g11 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stack { display: grid; gap: 16px; }
.kpi .lab { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-weight: 550; }
.kpi .val { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin: 8px 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .sub { font-size: 12.5px; color: var(--text-2); }
.kpi .chip-ic { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; }
.kpi.solid { background: linear-gradient(135deg, #0f7a55, #17a36f); border-color: transparent; color: #fff; }
.kpi.solid.loss { background: linear-gradient(135deg, #9f2b23, #c8473c); }
.kpi.solid .lab, .kpi.solid .sub, .kpi.solid .pos, .kpi.solid .neg { color: rgba(255, 255, 255, .88); }
.kpi.solid .chip-ic { background: rgba(255, 255, 255, .18); color: #fff; }
.mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 0; padding: 0; overflow: hidden; }
.mini > div { padding: 14px 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.mini b { display: block; font-size: 17px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.mini span { color: var(--text-2); font-size: 12.5px; }

/* tabelas */
.tbl-wrap { overflow-x: auto; margin: 0 -20px -20px; border-top: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
th:first-child { background: var(--surface-2); z-index: 2; }
td.l, th.l { text-align: left; }
tbody tr:hover td { background: var(--surface-2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; background: var(--surface-2) !important; }
tr.click { cursor: pointer; }
.tight th, .tight td { padding: 9px 8px; }
.tight td:first-child { max-width: 190px; }
.bar-cell { position: relative; }
.bar-cell i { position: absolute; top: 7px; bottom: 7px; border-radius: 3px; opacity: .16; }
.bar-cell span { position: relative; }
.empty { padding: 34px 20px; text-align: center; color: var(--text-2); }

/* etiquetas */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.tag.good { background: var(--brand-soft); color: var(--good); } .tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); } .tag.info { background: var(--info-soft); color: var(--info); }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 11px; background: var(--info-soft); color: var(--info); margin-bottom: 16px; align-items: flex-start; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note b { font-weight: 650; } .note .grow { flex: 1; color: var(--text); }
.copy { display: flex; gap: 6px; align-items: stretch; }
.copy code { flex: 1; min-width: 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; overflow-x: auto; white-space: nowrap; }
.copy code.wrap { white-space: pre-wrap; word-break: break-all; }
.field { display: grid; gap: 5px; margin-top: 12px; } .field > span { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row .grow { flex: 1; }

/* conta na ponta do lápis */
.dre { display: grid; gap: 0; }
.dre div { display: grid; grid-template-columns: 1fr auto 62px; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.dre div.sum { font-weight: 700; border-bottom: 1px solid var(--border); }
.dre div.final { font-size: 17px; font-weight: 750; border: 0; padding-top: 12px; }
.dre small { color: var(--muted); text-align: right; font-size: 12px; }
.dre .v { font-variant-numeric: tabular-nums; text-align: right; }

/* vendas recentes */
.sale { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.sale:last-child { border: 0; } .sale b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sale .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* gráfico */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-l { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2.5px solid; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.legend i.dash { border-top-style: dashed; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); font-size: 12.5px; min-width: 170px; z-index: 5; }
.tip b { display: block; margin-bottom: 5px; }
.tip div { display: flex; justify-content: space-between; gap: 14px; padding: 1.5px 0; font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 550; z-index: 99; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 90vw; }
.toast.err { background: var(--bad); color: #fff; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { width: min(380px, 92vw); display: grid; gap: 14px; } .login-box h1 { font-size: 20px; } .err { color: var(--bad); font-weight: 600; }

@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand, .nav-title { display: none; } .nav { display: flex; gap: 4px; } .nav span { display: none; }
  .content { padding: 18px 14px 50px; } .top { padding: 10px 14px; }
  .g21 { grid-template-columns: 1fr; } h1 { font-size: 22px; }
}

/* ---------- rastreamento: modal, fluxo rápido, tracks, visitas ---------- */
.g6 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g6 .kpi .val { font-size: 24px; }
.modal { position: fixed; inset: 0; background: rgba(5, 12, 10, .55); z-index: 60; display: grid; place-items: start center; padding: 4vh 16px; overflow-y: auto; }
.modal-box { background: var(--bg); border: 1px solid var(--border); border-radius: 16px; width: min(720px, 100%); box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal-box.wide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); border-radius: 16px 16px 0 0; z-index: 2; }
.modal-head h2 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 20px; }
.seg.tabs { display: flex; width: 100%; margin-bottom: 16px; }
.seg.tabs button { flex: 1; padding: 8px; }
.howto { background: var(--surface-2); border-radius: 11px; padding: 12px 16px; margin-top: 12px; }
.howto ol { margin: 6px 0 6px 18px; padding: 0; }
.collected h3 { font-size: 14px; margin-bottom: 8px; }
.collected ul, .tips { margin: 0; padding-left: 18px; color: var(--text-2); display: grid; gap: 5px; }
.collected > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.mini-stats > div { background: var(--surface-2); border-radius: 10px; padding: 12px 8px; text-align: center; }
.mini-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 12px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 7px 14px; margin: 0; }
.kv dt { color: var(--text-2); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 550; min-width: 0; }
.break { word-break: break-all; white-space: normal; }
.chip { display: inline-block; font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin: 1px 0; }
.pbadge { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--brand-deep); color: #d9f5e8; font-size: 11px; font-weight: 800; letter-spacing: .02em; vertical-align: middle; flex: none; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--text-2); }
.steps li b { display: block; color: var(--text); font-size: 13.5px; }
.steps li small { display: block; font-size: 12px; }
.steps .n { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-weight: 700; flex: none; }
.steps li.on .n { border-color: var(--brand); color: var(--brand-ink); }
.steps li.done .n { background: var(--brand); border-color: var(--brand); color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile { font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 10px; display: grid; justify-items: center; gap: 8px; cursor: pointer; text-align: center; }
.tile:hover { border-color: var(--brand); }
.tile.on { border-color: var(--brand); background: var(--brand-soft); }
.tile .pbadge { width: 38px; height: 38px; font-size: 13px; border-radius: 10px; }
.pick { display: grid; gap: 8px; }
.pick-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 11px; cursor: pointer; color: var(--text); font-weight: 400; }
.pick-row.on { border-color: var(--brand); background: var(--brand-soft); }
.pick-row b, .pick-row small { display: block; }
.pick-row input { width: auto; height: auto; }
.wiz-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.switch { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }
@media (max-width: 860px) { .steps { grid-template-columns: 1fr 1fr; } .mini-stats { grid-template-columns: 1fr 1fr; } }
