:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #667085;
  --line: #e4e7ec;
  --side: #12141a;
  --side-ink: #c9ced8;
  --accent: #0f7a5a;
  --accent-soft: #e3f4ee;
  --warn: #b54708;
  --warn-soft: #fef0c7;
  --bad: #b42318;
  --bad-soft: #fee4e2;
  --info: #175cd3;
  --info-soft: #e0edff;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; }
button:hover { border-color: #c4c9d2; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--info); }
button:disabled { opacity: 0.55; cursor: default; }
input, select { border: 1px solid var(--line); background: var(--surface); padding: 8px 10px; border-radius: 8px; width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* estrutura */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.side .brand { color: #fff; font-weight: 700; padding: 0 8px 12px; }
.side select { background: #1d2029; border-color: #2c303b; color: #fff; margin-bottom: 12px; }
.side a { display: block; padding: 8px 10px; border-radius: 8px; color: inherit; text-decoration: none; }
.side a:hover { background: #1d2029; }
.side a.on { background: #232733; color: #fff; font-weight: 600; }
.side .foot { margin-top: auto; padding: 8px; font-size: 12px; }
.side .foot button { background: none; border-color: #2c303b; color: var(--side-ink); margin-top: 8px; width: 100%; }
.main { padding: 28px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.center .card { width: 100%; max-width: 380px; }
.error { background: var(--bad-soft); color: var(--bad); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* números */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 24px; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: #3d4350; white-space: nowrap; }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: #eef0f3; border-radius: 6px; padding: 3px 4px 3px 9px; font-size: 13px; display: inline-flex; gap: 4px; align-items: center; }
.chip button { border: 0; background: none; padding: 0 4px; color: var(--muted); }

/* painel lateral da conversa */
.overlay { position: fixed; inset: 0; background: rgba(16, 18, 24, 0.45); display: flex; justify-content: flex-end; z-index: 10; }
.drawer { background: var(--surface); width: min(520px, 100%); height: 100%; overflow-y: auto; padding: 20px; }
.modal { background: var(--surface); margin: auto; border-radius: var(--radius); padding: 22px; width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; }
.overlay.mid { justify-content: center; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
pre { background: #12141a; color: #d6dae2; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; margin: 6px 0 12px; }
.bubble { max-width: 82%; padding: 8px 11px; border-radius: 12px; margin-bottom: 6px; background: #eef0f3; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.me { margin-left: auto; background: var(--accent-soft); }
.bubble time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.qr { display: block; margin: 12px auto; width: 260px; height: 260px; image-rendering: pixelated; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side .brand { padding: 0 8px; }
  .side select { width: auto; margin: 0; }
  .side .foot { margin: 0 0 0 auto; padding: 0; }
  .side .foot span { display: none; }
  .side .foot button { margin: 0; }
  .main { padding: 16px; }
}

/* ---------- visão geral / Meta Ads ---------- */
:root {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --seq-1: #e3eefb; --seq-2: #b9d4f4; --seq-3: #86b4eb; --seq-4: #4f8fdf; --seq-5: #2a6cc0;
  --grid: #eceef2;
}
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(15, 122, 90, 0.5); animation: live 2s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(15, 122, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(15, 122, 90, 0); } }
@media (prefers-reduced-motion: reduce) { .live { animation: none; } }
.kpi-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.kpi-value { display: block; font-size: 26px; letter-spacing: -0.02em; margin: 4px 0 2px; }
.up { color: var(--accent); } .down { color: var(--bad); }
.compare { padding: 0; overflow: hidden; }
.compare-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.compare-grid > div { padding: 16px 18px; border-right: 1px solid var(--line); }
.compare-grid > div:last-child { border-right: 0; }
.insight { background: #f4f7fb; border-top: 1px solid var(--line); padding: 12px 18px; font-size: 14px; }
.warn-box { background: var(--warn-soft); color: #7a2e0e; border: 1px solid #f7d58b; border-radius: var(--radius); margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile b { display: block; font-size: 20px; margin-top: 4px; letter-spacing: -0.01em; }
.tile-sub { color: var(--muted); }
.tile.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile.accent .kpi-label, .tile.accent .tile-sub { color: rgba(255, 255, 255, 0.82); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }
.badge-dark { background: var(--side); color: #fff; border-radius: 10px; padding: 8px 12px; text-align: center; }
.badge-dark span { display: block; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.badge-dark b { font-size: 20px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key.s1 { background: var(--series-1); } .key.s2 { background: var(--series-2); }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--series-1); } .chart .line.s2 { stroke: var(--series-2); }
.chart .area.s1 { fill: var(--series-1); opacity: 0.08; }
.chart .guide { stroke: #9aa3b2; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); } .chart .dot.s2 { fill: var(--series-2); }
.tip { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; background: var(--side); color: #fff; font-size: 12px; line-height: 1.6; padding: 8px 10px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); }
.funnel { display: grid; gap: 14px; }
.bar-track { height: 10px; background: #eef0f3; border-radius: 6px; margin: 6px 0 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 6px; }
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(10px, 1fr)); gap: 3px; align-items: center; overflow-x: auto; }
.heat-hour { font-size: 10px; color: var(--muted); }
.heat-day { font-size: 12px; color: var(--muted); }
.heat-cell { display: inline-block; height: 20px; border-radius: 4px; background: #f1f3f6; }
.heat-cell.l1 { background: var(--seq-1); } .heat-cell.l2 { background: var(--seq-2); } .heat-cell.l3 { background: var(--seq-3); }
.heat-cell.l4 { background: var(--seq-4); } .heat-cell.l5 { background: var(--seq-5); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface); padding: 6px 12px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }
.ad-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.ad-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ad-card.bad { border-color: #f4b5ad; } .ad-card.warn { border-color: #f7d58b; } .ad-card.good { border-color: #9ad8c1; }
.ad-thumb { position: relative; aspect-ratio: 16 / 9; background: #eef0f3; }
.ad-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-thumb .tag { position: absolute; left: 10px; top: 10px; }
.ad-body { padding: 14px; }
.ad-stats { grid-template-columns: auto 1fr auto 1fr; margin: 12px 0 8px; font-size: 13px; }
.num-table .num { text-align: right; white-space: nowrap; }
.num-table tfoot td { font-weight: 700; background: #f7f8fa; }
.sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.sort.on { color: var(--ink); }
