:root {
  --bg: #07131f;
  --card: #0d1f2f;
  --card-2: #102332;
  --line: rgba(245, 242, 233, 0.09);
  --text: #f5f2e9;
  --muted: #9eabb6;
  --gold: #d6ae45;
  --gold-soft: rgba(214, 174, 69, 0.14);
  --cyan: #28d9e8;
  --red: #ff6b6b;
  --green: #4ade80;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(214, 174, 69, 0.08), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--gold-soft); border: 1px solid rgba(214, 174, 69, 0.35); color: var(--gold); font-weight: 700; letter-spacing: 0.04em; font-size: 13px; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.chip { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; transition: background 0.2s, color 0.2s; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--gold); color: #07131f; font-weight: 650; }
.btn { border: 1px solid var(--line); background: var(--card); padding: 9px 14px; border-radius: 11px; cursor: pointer; transition: border-color 0.2s, transform 0.15s; }
.btn:hover { border-color: rgba(214, 174, 69, 0.5); }
.btn:active { transform: scale(0.97); }
.btn.gold { background: var(--gold); color: #07131f; border-color: var(--gold); font-weight: 650; }
.dates { display: flex; align-items: center; gap: 6px; }
.dates input { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; color-scheme: dark; }
.stamp { color: var(--muted); font-size: 12px; }

/* cards */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.two { grid-template-columns: 1.2fr 1fr; margin-bottom: 14px; }
.two.even { grid-template-columns: 1fr 1fr; }
.card { background: linear-gradient(180deg, var(--card), var(--card-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi.gold .value { color: var(--gold); }
.delta { font-weight: 600; padding: 1px 7px; border-radius: 99px; font-size: 11px; }
.delta.up { color: var(--green); background: rgba(74, 222, 128, 0.12); }
.delta.down { color: var(--red); background: rgba(255, 107, 107, 0.12); }
.delta.flat { color: var(--muted); background: rgba(255, 255, 255, 0.06); }

/* funnel */
.funnel { display: grid; gap: 10px; }
.step .row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.step .row b { font-weight: 650; }
.step .row span { color: var(--muted); }
.bar { height: 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), #f0d488); transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.mini div { background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 10px 12px; }
.mini small { color: var(--muted); display: block; font-size: 11px; }
.mini strong { font-size: 18px; font-weight: 650; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; padding: 0 8px 9px 0; white-space: nowrap; }
.tbl td { padding: 9px 8px 9px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl th.r, .tbl td.r { text-align: right; padding-right: 0; padding-left: 8px; }
.tbl td + td, .tbl th + th { padding-left: 14px; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, 0.07); white-space: nowrap; }
.pill.paid { background: rgba(74, 222, 128, 0.14); color: var(--green); }
.pill.pending { background: var(--gold-soft); color: var(--gold); }
.pill.bad { background: rgba(255, 107, 107, 0.13); color: var(--red); }
.pill.ok { background: rgba(74, 222, 128, 0.14); color: var(--green); }
.pill.off { color: var(--muted); }
.muted { color: var(--muted); }
.trunc { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hbar { display: grid; gap: 9px; }
.hbar .item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.hbar .item .bar { grid-column: 1 / -1; height: 8px; }
.hbar .item .bar i { background: linear-gradient(90deg, var(--cyan), #7ff0f8); }

.chart { position: relative; height: 280px; }
.chart.sm { height: 200px; }

/* creatives */
.creatives { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.cr { background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cr .th { aspect-ratio: 1.2; background: linear-gradient(135deg, #13304a, #0b1c2b); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.cr .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr .bd { padding: 10px 12px 12px; display: grid; gap: 4px; font-size: 12px; }
.cr .bd b { font-size: 13px; line-height: 1.3; }
.cr dl { margin: 4px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; color: var(--muted); }
.cr dd { margin: 0; color: var(--text); text-align: right; }
.rank { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* setup / notices */
.notice { border: 1px dashed rgba(214, 174, 69, 0.4); background: var(--gold-soft); border-radius: 14px; padding: 14px 16px; font-size: 13px; }
.notice.err { border-color: rgba(255, 107, 107, 0.45); background: rgba(255, 107, 107, 0.08); }
.notice h3 { margin: 0 0 6px; font-size: 14px; }
.notice ol { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.notice li { margin: 3px 0; }
pre { margin: 8px 0; padding: 10px 12px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: #dfe7ee; }
code { font: 12px ui-monospace, Menlo, Consolas, monospace; background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; }
.status { display: flex; flex-wrap: wrap; gap: 10px; }
.status .s { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(255, 255, 255, 0.04); border-radius: 12px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.15); }
.dot.warn { background: var(--gold); }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 560px); justify-content: center; align-content: center; padding: 20px; }
.login > .card { width: 100%; min-width: 0; }
.login form { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.login input:focus { outline: 2px solid rgba(214, 174, 69, 0.6); border-color: transparent; }
.login .error { color: var(--red); font-size: 13px; min-height: 18px; }

.skeleton { color: transparent !important; background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.1), rgba(255,255,255,0.05)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.fade { animation: fade 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two, .two.even { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .creatives { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cr .th { aspect-ratio: 1.6; }
  .kpi .value { font-size: 23px; }
  .top { align-items: flex-start; }
  .mini { grid-template-columns: 1fr; }
}

/* abas */
.tabs { display: flex; gap: 4px; margin: -6px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 10px 14px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--gold); border-bottom-color: var(--gold); }
.pane > section:last-child { margin-bottom: 0; }

/* clientes */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.search { flex: 1 1 220px; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.search:focus { outline: 2px solid rgba(214, 174, 69, 0.5); border-color: transparent; }
.toolbar .btn { text-decoration: none; }
.btn.wa { background: rgba(37, 211, 102, 0.14); border-color: rgba(37, 211, 102, 0.4); color: #6ee7a0; padding: 6px 11px; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.tbl.people td { vertical-align: top; }
.tbl.people a { color: inherit; }
.small { font-size: 12px; }

/* heatmap */
.heats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.heat-title { font-size: 12px; margin-bottom: 8px; }
.heat { display: grid; grid-template-columns: 32px repeat(24, minmax(0, 1fr)); gap: 2px; }
.hlabel { font-size: 11px; color: var(--muted); align-self: center; }
.hcell { aspect-ratio: 1; border-radius: 3px; background: rgba(245, 242, 233, 0.05); position: relative; }
.hcell::after { content: ""; position: absolute; inset: 0; border-radius: 3px; background: var(--gold); opacity: var(--a); }
.hhour { font-size: 9px; color: var(--muted); text-align: center; }

@media (max-width: 980px) { .heats { grid-template-columns: 1fr; } }
.toolbar .btn { color: var(--text); }

/* No celular, cada pessoa vira um cartão com o botão de WhatsApp no topo. */
@media (max-width: 640px) {
  .tbl.people thead { display: none; }
  .tbl.people, .tbl.people tbody { display: block; width: 100%; }
  .tbl.people tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
  .tbl.people tr[hidden] { display: none; }
  .tbl.people td { display: block; border: 0; padding: 0 !important; grid-column: 1; min-width: 0; text-align: left; }
  .tbl.people td:last-child { grid-column: 2; grid-row: 1 / span 3; align-self: start; }
  .tbl.people .trunc { max-width: 100%; }
}
