/* Dashboard Tainá Psiquiatra — rosa claro sobre quase-preto.
   O acento é cor de marca e marca de dado ao mesmo tempo. Os gráficos mostram
   uma métrica por vez, então nunca há duas séries disputando matiz: um acento
   só resolve, sem precisar de paleta categórica. #f2a9c4 dá 9,9:1 sobre a
   superfície dos cartões, bem acima do mínimo. */
:root {
  --bg: #0b0a0a;
  --surface: #151214;
  --surface-2: #1c181a;
  --line: #272225;
  --ink: #f0e9ec;
  --ink-2: #a89ba1;
  --ink-3: #726770;
  --accent: #f2a9c4;
  --accent-deep: #d98aa8;
  --accent-soft: #2b1a20;
  --ok: #7fb069;
  --bad: #d98b7a;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--surface);
  border-right: 1px solid var(--line); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand img {
  width: 46px; height: 46px; border-radius: 50%; object-fit: cover;
  /* o retrato tem fundo azul: o enquadramento corta a maior parte dele */
  object-position: 50% 28%;
  border: 2px solid var(--accent); flex: 0 0 auto;
}
.brand .name { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; }
.brand .sub { font-size: 12px; color: var(--ink-3); }

.nav-label {
  font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; margin-bottom: -10px;
}

/* ---------- navegação ---------- */
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 10px; cursor: pointer; color: var(--ink-2);
  font-size: 13.5px; font-weight: 500; user-select: none;
  border: 1px solid transparent;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); border-color: #40262f; }
.nav a .ic { width: 18px; display: grid; place-items: center; color: var(--accent); flex: 0 0 auto; }
.nav a.active .ic { color: var(--accent); }
.nav a:not(.active) .ic { color: var(--accent-deep); opacity: .75; }

/* ---------- filtro de datas ---------- */
/* Um por seção, no canto superior. O estado é compartilhado: trocar a janela
   em uma seção vale para todas, senão os números de páginas diferentes
   falariam de períodos diferentes sem avisar. */
.datefilter { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.datefilter .fld { display: flex; flex-direction: column; gap: 4px; }
.datefilter label { font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.datefilter input[type="date"] {
  color-scheme: dark; /* sem isto o seletor nativo vem claro sobre o fundo escuro */
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 9px; font: inherit; font-size: 12.5px;
}
.datefilter input[type="date"]:focus { outline: 2px solid var(--accent-deep); outline-offset: 1px; }
.datefilter button {
  padding: 8px 13px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600;
  background: var(--accent); color: #171013; border: 1px solid var(--accent);
}
.datefilter button.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); font-weight: 500; }
.datefilter button.ghost:hover { border-color: var(--accent-deep); color: var(--ink); }

.foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.foot .mini {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft);
  color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.foot .t { font-size: 12px; font-weight: 600; }
.foot .s { font-size: 10.5px; color: var(--ink-3); }

/* ---------- cabeçalho da página ---------- */
.page-head { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.page-head .ttl { min-width: 0; }
.page-head h1 { margin: 0 0 4px; font-size: 21px; font-weight: 650; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--ink-2); font-size: 13px; }

/* ---------- cartões ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 15px; min-width: 0; }
.kpi .lbl { font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; margin-top: 7px; line-height: 1.15; }
.kpi .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.kpi .delta { font-size: 11.5px; margin-top: 5px; font-weight: 600; }
.kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--bad); } .kpi .delta.flat { color: var(--ink-3); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 20px; overflow: hidden; }
.card-head { padding: 15px 17px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .hint { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-3); }
.card-body { padding: 14px 17px 17px; }

/* ---------- alternador de métrica ---------- */
.metrics { display: flex; gap: 6px; flex-wrap: wrap; }
.metrics button {
  padding: 5px 11px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 11.5px;
  background: transparent; color: var(--ink-2); border: 1px solid var(--line);
}
.metrics button:hover { border-color: var(--accent-deep); color: var(--ink); }
.metrics button.on { background: var(--accent); color: #171013; border-color: var(--accent); font-weight: 600; }

/* ---------- gráfico ---------- */
.plot { position: relative; width: 100%; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.grid line { stroke: var(--line); stroke-width: 1; }
.axis text { fill: var(--ink-3); font-size: 10.5px; }
.serie { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { fill: url(#fade); }
.dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.tip {
  position: absolute; pointer-events: none; background: #0a0908; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 12px;
  white-space: nowrap; transform: translate(-50%, -115%); opacity: 0; transition: opacity .09s;
  box-shadow: 0 8px 22px rgba(0,0,0,.55);
}
.tip.on { opacity: 1; }
.tip .d { color: var(--ink-3); font-size: 10.5px; }
.tip .v { font-weight: 650; }

/* ---------- tabela ---------- */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 210px; }
th { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; border: 1px solid var(--line); color: var(--ink-2); }
.badge.on { color: var(--ok); border-color: #2f4328; }

/* ---------- criativos ---------- */
.grid-ads { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 14px; }
.ad { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.ad .thumb { aspect-ratio: 4/5; background: #0a0908; position: relative; }
.ad .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad .rank { position: absolute; left: 8px; top: 8px; width: 23px; height: 23px; border-radius: 50%; background: var(--accent); color: #171013; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.ad .body { padding: 10px 11px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.ad .t { font-size: 12.5px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.ad .m { font-size: 11px; color: var(--ink-3); word-break: break-word; }
.ad .eng { font-size: 11.5px; color: var(--ink-2); }
.ad .eng b { color: var(--accent); }
.ad a.link {
  margin-top: auto; display: block; text-align: center; padding: 6px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none; font-size: 11.5px; font-weight: 600;
  border: 1px solid #40262f;
}
.ad a.link:hover { background: var(--accent); color: #171013; }
.ad .nolink { margin-top: auto; text-align: center; padding: 6px; font-size: 11px; color: var(--ink-3); }

.empty { padding: 30px; text-align: center; color: var(--ink-3); font-size: 13px; }
.note { font-size: 11.5px; color: var(--ink-3); margin-top: 10px; line-height: 1.5; }
.hidden { display: none !important; }

/* ---------- telas estreitas ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .datefilter { width: 100%; }
  .datefilter .fld { flex: 1 1 130px; }
  .datefilter input[type="date"] { width: 100%; }
  .main { padding: 20px 16px 50px; }
  .foot { display: none; }
}
