/* Tema escuro por padrão (data-theme="light" troca para o claro) */
:root {
  --bg: #0b0c0e;
  --panel: #16171b;
  --panel-2: #1d1f24;
  --ink: #f2f3f0;
  --ink-2: #c9cbc6;
  --muted: #8b8e93;
  --line: #26282e;
  --line-2: #1f2126;
  --rail: #0b0c0e;
  --rail-ink: #9a9da2;
  --rail-hi: #1a1b1f;
  --accent: #c8f550;
  --accent-ink: #0b0c0e;
  --accent-soft: rgba(200, 245, 80, .12);
  --bar: rgba(200, 245, 80, .14);
  --bad: #ff6b5e;
  --bad-soft: rgba(255, 107, 94, .14);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, .14);
  --good: #5ee0a0;
  --good-soft: rgba(94, 224, 160, .13);
  --pill: #f2f3f0;
  --pill-ink: #0b0c0e;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
  --thermal: linear-gradient(90deg, #2b4bd8, #21c3d6 30%, #3fd36b 52%, #ffd23f 74%, #ff3b2f);
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 22px;
  --font-ui: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Geist", "Inter", system-ui, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eeefeb; --panel: #ffffff; --panel-2: #f5f6f2; --ink: #111214; --ink-2: #3a3c40; --muted: #6c6f74;
  --line: #e1e2dd; --line-2: #ecede8; --rail: #111214; --rail-ink: #9a9da2; --rail-hi: #1d1f24;
  --accent: #b4e63a; --accent-ink: #111214; --accent-soft: rgba(140, 190, 20, .14); --bar: rgba(150, 200, 30, .2);
  --bad: #d93f36; --bad-soft: #fde8e6; --warn: #b7791f; --warn-soft: #fdf3e1; --good: #1a8a5f; --good-soft: #e3f4ec;
  --pill: #111214; --pill-ink: #ffffff; --shadow: 0 1px 2px rgba(0,0,0,.04); color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:root[data-theme="light"] a { color: #4d6b00; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.n, .kpi-v { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; margin: 0; }
h1 { font-size: 34px; line-height: 1.1; font-weight: 500; letter-spacing: -.035em; }
h2 { font-size: 16px; line-height: 1.3; }
h3 { font-size: 14px; font-weight: 600; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; border-right: 1px solid #1a1b1f; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #f2f3f0; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.03em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; background: #c8f550; position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: radial-gradient(circle, #ff3b2f 0, #ffd23f 35%, #0b0c0e 36%); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .lbl-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5d6066; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 999px; color: var(--rail-ink); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--rail-hi); color: #f2f3f0; text-decoration: none; }
.nav a.on { background: #f2f3f0; color: #0b0c0e; }
.nav a.on svg { color: #0b0c0e; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .95; }
.nav .sep { height: 0; margin: 4px 6px; }
.rail-foot { margin-top: auto; padding: 12px; font-size: 12.5px; display: flex; gap: 6px; background: #131417; border: 1px solid #1d1f24; border-radius: 16px; }
.rail-foot button { flex: 1; background: #1d1f24; border: 0; color: var(--rail-ink); padding: 7px 8px; cursor: pointer; border-radius: 999px; }
.rail-foot button:hover { color: #f2f3f0; background: #26282e; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); padding: 14px 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-2); }
.topbar .grow { flex: 1; }
.content { padding: 28px 32px 72px; max-width: 1520px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 70ch; }

/* ---------------------------------------------------------------- controles */
.sel, .inp { height: 38px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 0 14px; min-width: 0; }
.sel { padding-right: 34px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8e93' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; cursor: pointer; font-weight: 500; }
.sel option { background: var(--panel); color: var(--ink); }
.inp { border-radius: var(--r-s); }
.inp:focus, .sel:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { height: auto; padding: 10px 12px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--pill); color: var(--pill-ink); }
.btn { height: 38px; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel); }
.btn.sm { height: 32px; padding: 0 13px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--ink-2); }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--ink-2); font-weight: 500; transition: background .15s; }
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--pill); border-color: var(--pill); color: var(--pill-ink); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; color: var(--ink-2); }
.field .hint { color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- painéis */
.panel { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-l); padding: 22px 24px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { position: relative; padding: 20px 22px 22px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-l); min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: 14px; top: 14px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 9l6-6M4 3h5v5' stroke='%238b8e93' fill='none' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") center no-repeat; }
.kpi:first-child { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kpi:first-child .kpi-l { color: rgba(11,12,14,.7); }
.kpi:first-child::after { border-color: rgba(11,12,14,.2); background-color: rgba(11,12,14,.06); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 9l6-6M4 3h5v5' stroke='%230b0c0e' fill='none' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E"); }
.kpi:first-child .delta.up, .kpi:first-child .delta.down, .kpi:first-child .delta.flat { color: #0b0c0e; background: rgba(11,12,14,.1); }
.kpi-l { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; padding-right: 36px; }
.kpi-v { font-family: var(--font-display); font-size: 40px; font-weight: 500; letter-spacing: -.045em; line-height: 1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.delta { font-size: 12px; font-weight: 600; letter-spacing: 0; padding: 3px 8px; border-radius: 999px; }
.delta.up { color: var(--good); background: var(--good-soft); } .delta.down { color: var(--bad); background: var(--bad-soft); } .delta.flat { color: var(--muted); background: var(--line-2); }
.kpi.bad .kpi-v { color: var(--bad); }

/* ---------------------------------------------------------------- tabelas */
.tbl-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.n, .tbl td.n { text-align: right; }
.tbl th.sort { cursor: pointer; }
.tbl th.sort:hover { color: var(--ink); }
.tbl th.on { color: var(--accent); }
:root[data-theme="light"] .tbl th.on { color: var(--ink); }
.tbl td { padding: 12px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.tbl tr.click:hover td:first-child { border-radius: 12px 0 0 12px; }
.tbl tr.click:hover td:last-child { border-radius: 0 12px 12px 0; }
.tbl .lbl { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-cell { position: relative; }
.bar-cell .b { position: absolute; left: 0; top: 8px; bottom: 8px; background: var(--bar); border-radius: 6px; z-index: 0; }
.bar-cell span { position: relative; z-index: 1; }
.heatcell { display: inline-block; min-width: 50px; text-align: right; padding: 2px 8px; border-radius: 999px; font-weight: 500; }

.list { display: flex; flex-direction: column; gap: 4px; }
.li { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; position: relative; border-radius: 10px; }
.li .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; z-index: 1; }
.li .v { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; position: relative; z-index: 1; display: flex; gap: 8px; align-items: center; }
.li .b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar); border-radius: 10px; z-index: 0; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.neutral { background: var(--line-2); color: var(--muted); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; font-size: 20px; }
.loading { padding: 48px; text-align: center; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.err { background: var(--bad-soft); color: var(--bad); padding: 11px 16px; border-radius: var(--r-m); }
.note { background: var(--warn-soft); color: var(--warn); padding: 11px 16px; border-radius: var(--r-m); }

/* ---------------------------------------------------------------- gráfico */
.chart { width: 100%; height: 240px; display: block; }
.chart .grid-l { stroke: var(--line-2); stroke-dasharray: 2 4; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .ln3 { fill: none; stroke: var(--good); stroke-width: 2; stroke-linejoin: round; }
.chart .ln2 { fill: none; stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 3 4; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .hov { stroke: var(--muted); stroke-dasharray: 2 3; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 7px; background: var(--accent); }
.legend i.l2 { background: var(--bad); }
.legend i.l3 { background: var(--good); }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(520px 380px at 80% 12%, rgba(200, 245, 80, .10), transparent 70%),
  radial-gradient(640px 460px at 8% 92%, rgba(255, 59, 47, .08), transparent 70%), var(--bg); }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 28px; padding: 32px; }
.login .btn.primary { height: 44px; justify-content: center; }
.login .brand { color: var(--ink); padding: 0 0 8px; font-size: 28px; }
.login p { margin: 0 0 6px; color: var(--muted); }

/* ---------------------------------------------------------------- heatmap */
.hm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.hm-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.stage-wrap { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-l); padding: 16px; position: relative; }
.stage-info { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.stage { position: relative; margin: 0 auto; overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.stage-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.stage-frame { position: absolute; inset: 0; }
.stage-frame .replayer-wrapper { position: absolute !important; left: 0 !important; top: 0 !important; transform: none !important; margin: 0 !important; float: none !important; }
.stage-frame iframe { border: 0; display: block; pointer-events: none; background: #fff; }
.stage-frame .replayer-mouse, .stage-frame .replayer-mouse-tail { display: none !important; }
.stage-blank { position: absolute; left: 0; top: 0; right: 0; background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px); background-size: 40px 40px; background-color: #fbfbfc; }
.stage-dim { position: absolute; inset: 0; background: rgba(20, 22, 31, .32); pointer-events: none; transition: opacity .2s; }
.stage-layer { position: absolute; left: 0; top: 0; will-change: transform; }
.stage-layer canvas { position: absolute; left: 0; top: 0; }
.stage-hit { position: absolute; inset: 0; cursor: default; }
.zone { position: absolute; border-radius: 3px; outline: 1px solid rgba(255,255,255,.65); transition: outline-color .15s; }
.zone:hover, .zone.hl { outline: 2px solid #fff; z-index: 5; box-shadow: 0 0 0 4px rgba(0,0,0,.35); }
.zone b { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(20, 22, 31, .86); color: #fff; font: 600 calc(12px * var(--inv, 1))/1 var(--font-ui); padding: calc(4px * var(--inv, 1)) calc(7px * var(--inv, 1)); border-radius: 999px; white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }
.scroll-mark { position: absolute; left: 0; right: 0; border-top: 2px dashed rgba(20, 22, 31, .75); pointer-events: none; }
.scroll-mark { border-top-width: calc(2px * var(--inv, 1)); }
.scroll-mark span { position: absolute; right: 10px; top: calc(-13px * var(--inv, 1)); background: rgba(20, 22, 31, .88); color: #fff; font: 600 calc(12px * var(--inv, 1))/1 var(--font-ui); padding: calc(6px * var(--inv, 1)) calc(9px * var(--inv, 1)); border-radius: 999px; }
.scroll-mark.fold { border-top-color: #fff; border-top-style: solid; }
.scroll-mark.fold span { left: 10px; right: auto; background: #fff; color: #1c2030; }
.minimap { position: absolute; right: -10px; top: 0; width: 6px; border-radius: 3px; background: var(--line); }
.minimap i { position: absolute; left: 0; right: 0; background: var(--ink); border-radius: 3px; opacity: .55; }
.scale { height: 8px; border-radius: 4px; background: var(--thermal); }
.scale-l { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }
.hm-side .panel + .panel { margin-top: 12px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.stat-row .v { font-family: var(--font-display); font-weight: 700; font-size: 21px; }
.stat-row .l { color: var(--muted); font-size: 12.5px; }
.zone-list .li { cursor: pointer; }
.zone-list .li:hover .k { color: var(--accent); }

.tip { position: fixed; z-index: 100; pointer-events: none; background: #f2f3f0; color: #0b0c0e; padding: 10px 13px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; max-width: 300px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.tip b { font-weight: 600; }
.tip .tr { display: flex; justify-content: space-between; gap: 18px; }
.tip .tr span:last-child { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- sessões / replay */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.sess-row td { vertical-align: top; }
.path-crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; color: var(--ink-2); max-width: 520px; }
.path-crumbs span { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 9px; border-radius: 999px; font-size: 12.5px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-crumbs em { color: var(--muted); font-style: normal; font-size: 11px; }
.dev-ico { width: 16px; height: 16px; vertical-align: -3px; color: var(--muted); }

.replay-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.player-box { background: #08090a; border: 1px solid var(--line-2); border-radius: var(--r-l); padding: 12px; min-height: 420px; display: flex; align-items: center; justify-content: center; color: #aab0c2; }
.player-box .rr-player { box-shadow: none; background: transparent; border-radius: 8px; }
.player-box .rr-controller { background: #16171b !important; border-radius: 0 0 8px 8px; }
.player-box .rr-timeline__time, .player-box .rr-controller__btns button { color: #e8eaf0 !important; }
.player-box .rr-controller__btns button svg { fill: #e8eaf0; }
.player-box .rr-controller__btns button.active { background: #c8f550 !important; color: #0b0c0e !important; }
.player-box .rr-progress { background: #2a2c31 !important; }
.player-box .rr-progress__step { background: #c8f550 !important; }
.player-box .rr-progress__handler { background: #f2f3f0 !important; }
.timeline { max-height: 70vh; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.tl-item { display: grid; grid-template-columns: 46px 18px 1fr; gap: 8px; align-items: start; padding: 8px 8px; border-radius: 12px; cursor: pointer; }
.tl-item:hover { background: var(--panel-2); }
.tl-item.now { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.tl-item .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.tl-item .d { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.tl-item .d.pv { background: var(--accent); width: 12px; height: 12px; margin-top: 4px; border-radius: 3px; }
.tl-item .d.rage { background: var(--bad); }
.tl-item .d.dead { background: var(--warn); }
.tl-item .d.goal { background: var(--good); width: 12px; height: 12px; margin-top: 4px; }
.tl-item .d.error { background: var(--bad); border-radius: 2px; transform: rotate(45deg); }
.tl-item .x { min-width: 0; }
.tl-item .x div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item.pv-item { margin-top: 6px; }
.tl-item.pv-item .x div:first-child { font-weight: 600; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- jornada / funil */
.sankey { width: 100%; display: block; }
.sankey .node rect { rx: 3; }
.sankey .node text { font-size: 12px; font-weight: 500; fill: var(--ink); paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.sankey .node .cnt { fill: var(--muted); font-size: 11px; }
.sankey .link { fill: none; stroke-opacity: .28; transition: stroke-opacity .15s; }
.sankey .link:hover { stroke-opacity: .5; }
.sankey .step-h { fill: var(--muted); font-size: 12px; }
.funnel { display: flex; flex-direction: column; gap: 6px; }
.f-step { display: grid; grid-template-columns: 220px 1fr 150px; gap: 16px; align-items: center; }
.f-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-name small { display: block; font-weight: 400; color: var(--muted); }
.f-bar { height: 44px; background: var(--panel-2); border-radius: 12px; position: relative; overflow: hidden; }
.f-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 12px; }
.f-bar span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 600; color: #0b0c0e; }
.f-drop { display: grid; grid-template-columns: 220px 1fr 150px; gap: 16px; color: var(--muted); font-size: 12.5px; padding: 2px 0 6px; }
.f-drop div:nth-child(2) { padding-left: 12px; border-left: 2px dotted var(--line); }
.step-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.step-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--pill); color: var(--pill-ink); border-radius: 999px; padding: 4px 6px 4px 12px; font-weight: 500; max-width: 280px; }
.step-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; }
.arrow { color: var(--muted); }

/* ---------------------------------------------------------------- configurações */
.snippet { position: relative; background: #08090a; border: 1px solid var(--line); color: #e6e8e3; border-radius: var(--r-m); padding: 14px 16px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.snippet .btn { position: absolute; right: 10px; top: 10px; background: #c8f550; border-color: #c8f550; color: #0b0c0e; }
.site-pick { display: flex; flex-direction: column; gap: 4px; }
.site-pick button { text-align: left; border: 1px solid transparent; background: none; padding: 11px 14px; border-radius: 14px; cursor: pointer; }
.site-pick button.on { background: var(--panel-2); border-color: var(--accent); }
.site-pick button small { display: block; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--accent-ink); padding: 10px 18px; border-radius: 999px; z-index: 200; font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,.2); }

/* ---------------------------------------------------------------- responsivo */
@media (max-width: 1180px) {
  .hm-layout, .replay-layout { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* ---------------------------------------------------------------- celular (app) */
.appbar, .tabbar, .sheet-bg, .kpi-ico, .only-m { display: none; }
@media (max-width: 860px) {
  body { font-size: 14px; }
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .only-d { display: none; }
  .only-m { display: block; }

  /* barra do topo */
  .appbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 31; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); }
  .appbar .brand { padding: 0; font-size: 18px; color: var(--ink); }
  .appbar .brand span:last-child { display: none; }
  .appbar-t { flex: 1; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
  .ico-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
  .ico-btn svg { width: 18px; height: 18px; }

  /* filtros: uma linha que rola na horizontal */
  .topbar { top: calc(60px + env(safe-area-inset-top)); padding: 4px 16px 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-bottom: 0; background: var(--bg); backdrop-filter: none; gap: 8px; }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar > * { flex: none; }
  .topbar .grow, #sync { display: none; }
  .topbar .sel { height: 36px; max-width: 170px; }
  .topbar .seg button { padding: 5px 12px; }
  .topbar .toggle { font-size: 13px; }
  #sync-b { width: 36px; height: 36px; padding: 0; justify-content: center; border: 1px solid var(--line); background: var(--panel); order: -1; }
  #sync-b span { display: none; }

  .content { padding: 4px 16px calc(112px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 16px; align-items: stretch; flex-direction: column; }
  .page-head h1 { display: none; }
  .page-head p { margin: 0; font-size: 13.5px; }
  .page-head > .btn, .page-head > div:last-child > .btn { width: 100%; justify-content: center; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .grid { gap: 12px; }
  .panel { padding: 18px 16px; border-radius: 22px; }
  .tbl-wrap { margin: 0 -16px; padding: 0 16px; }

  /* indicadores: cards 2x2 com ícone e variação no topo */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .kpi { min-height: 0; padding: 14px 14px 16px; gap: 6px; border-radius: 20px; justify-content: flex-start; }
  .kpi::after { display: none; }
  .kpi-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--panel-2); color: var(--accent); margin-bottom: 10px; }
  :root[data-theme="light"] .kpi-ico { color: #4d6b00; }
  .kpi-ico svg { width: 17px; height: 17px; }
  .kpi:first-child .kpi-ico { background: rgba(11,12,14,.1); color: #0b0c0e; }
  .kpi-l { font-size: 12.5px; padding-right: 0; line-height: 1.3; }
  .kpi-v { font-size: 28px; letter-spacing: -.04em; }
  .kpi-v .delta { position: absolute; top: 14px; right: 12px; font-size: 11px; padding: 3px 7px; }

  /* gráfico em colunas */
  .mbars { display: flex; align-items: stretch; gap: 8px; height: 220px; padding-top: 8px; }
  .mbar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); }
  .mbar-v { font-size: 11px; font-weight: 600; visibility: hidden; white-space: nowrap; color: var(--ink); }
  .mbar-t { flex: 1; width: 100%; max-width: 34px; border-radius: 999px; background: var(--panel-2); position: relative; overflow: hidden; }
  .mbar-t i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 999px; background: #3a3d44; transition: background .15s; }
  :root[data-theme="light"] .mbar-t i { background: #c9cbc4; }
  .mbar-t b { position: absolute; left: 30%; right: 30%; bottom: 6px; border-radius: 999px; background: var(--good); min-height: 4px; }
  .mbar-l { font-size: 11px; white-space: nowrap; }
  .mbar.on .mbar-t i { background: var(--accent); }
  .mbar.on .mbar-v { visibility: visible; }
  .mbar.on .mbar-l { color: var(--ink); font-weight: 600; }
  .panel-head { flex-wrap: wrap; }
  .legend { gap: 10px; font-size: 12px; }

  /* sessões viram cards */
  .sess-tbl, .sess-tbl tbody { display: block; }
  .sess-tbl thead { display: none; }
  .sess-tbl tr.sess-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px; margin-bottom: 10px; background: var(--panel-2); border-radius: 18px; }
  .sess-tbl tr.sess-row td { display: block; padding: 0; border: 0; background: none !important; border-radius: 0 !important; }
  .sess-tbl td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .sess-tbl td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; font-size: 15px; }
  .sess-tbl td:nth-child(3) { grid-column: 1 / -1; }
  .sess-tbl td:nth-child(4) { grid-column: 1; align-self: center; color: var(--muted); }
  .sess-tbl td:nth-child(4)::before { content: "Origem: "; }
  .sess-tbl td:nth-child(5) { grid-column: 1 / -1; grid-row: 4; }
  .sess-tbl td:nth-child(5):empty { display: none; }
  .sess-tbl td:nth-child(6) { grid-column: 2; grid-row: 3; text-align: right; }
  .sess-tbl .path-crumbs span { max-width: 140px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters > * { flex: none; }

  /* mapa de calor / replay / jornada */
  .hm-tools { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
  .hm-tools::-webkit-scrollbar { display: none; }
  .hm-tools > * { flex: none; }
  .stage-wrap { padding: 10px; border-radius: 20px; }
  .player-box { min-height: 260px; padding: 8px; }
  .f-step, .f-drop { grid-template-columns: 1fr; gap: 4px; }
  .f-drop div:first-child, .f-drop div:last-child { display: none; }

  /* barra de navegação flutuante */
  .tabbar { display: flex; position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 6px; gap: 4px; background: #16171b; border: 1px solid #26282e; border-radius: 999px; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
  :root[data-theme="light"] .tabbar { background: #111214; border-color: #111214; box-shadow: 0 12px 32px rgba(0,0,0,.2); }
  .tabbar a, .tabbar button { flex: 1; min-width: 0; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 999px; color: #9a9da2; font-size: 10.5px; font-weight: 500; background: none; border: 0; cursor: pointer; text-decoration: none; transition: flex .2s, background .2s, color .2s; }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar a.on, .tabbar button.on { flex: 1.7; flex-direction: row; gap: 7px; background: #c8f550; color: #0b0c0e; font-size: 13px; font-weight: 600; }
  .tabbar a:hover { text-decoration: none; }

  /* folha "Mais" */
  .sheet-bg { display: flex; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); align-items: flex-end; }
  .sheet-bg[hidden] { display: none !important; }
  .sheet { width: 100%; background: var(--panel); border-radius: 28px 28px 0 0; padding: 10px 12px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; animation: up .22s ease-out; }
  .sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
  .sheet a, .sheet button { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; color: var(--ink); background: none; border: 0; font-size: 15px; font-weight: 500; text-align: left; cursor: pointer; text-decoration: none; }
  .sheet a:hover, .sheet button:hover { background: var(--panel-2); text-decoration: none; }
  .sheet a.on { background: var(--accent-soft); }
  .sheet svg { width: 20px; height: 20px; color: var(--muted); }
  #s-out { color: var(--bad); } #s-out svg { color: var(--bad); }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }

  .tip { display: none; }
  .panel:has(> .tbl-wrap > .sess-tbl) { background: none; border: 0; padding: 0; box-shadow: none; }
  .panel:has(> .tbl-wrap > .sess-tbl) .tbl-wrap { margin: 0; padding: 0; }
  .sess-tbl tr.sess-row { background: var(--panel); border: 1px solid var(--line-2); }
  #jr-start, #fn-add { width: 100% !important; flex: 1 1 100%; }
  #sk-box > div { margin: 0 -16px; padding: 0 16px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ajustes finos */
.tbl .btn.primary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tbl tr.click:hover .btn.primary { background: var(--accent); color: var(--accent-ink); }
:root[data-theme="light"] .tbl .btn.primary { color: #3f5a00; }
.player-box .switch input[type="checkbox"]:checked + label:before { background: #c8f550 !important; }
.player-box .switch label:after { background: #f2f3f0 !important; }
.snippet { padding-right: 120px; }
