/* Painel HR Marketing Digital — v2 (menu lateral). Fundo preto, texto branco, azul royal. */
:root {
  --bg: #000000;
  --surface: #111318;
  --surface-2: #171a21;
  --border: #23262f;
  --text: #ffffff;
  --text-dim: #9aa0ac;
  --text-muted: #6b7280;
  --royal: #2563eb;
  --royal-light: #60a5fa;
  --royal-soft: rgba(37, 99, 235, 0.14);
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  /* Paleta categórica validada (dataviz) pro fundo escuro: azul, laranja, verde-água */
  --c1: #3987e5;
  --c2: #d95926;
  --c3: #199e70;
  --sidebar-w: 248px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--royal-light); }

/* ---------- login / telas cheias ---------- */
.full-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
}
.auth-card img.auth-logo { width: 112px; height: auto; display: block; margin: 0 0 22px; }
.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--text-dim); margin: 0 0 20px; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-field label { font-size: 12px; color: var(--text-dim); }
.input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}
.input:focus { outline: 2px solid var(--royal); outline-offset: 0; border-color: transparent; }
.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--royal); }
.btn.primary { background: var(--royal); border-color: var(--royal); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.block { width: 100%; padding: 11px 14px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.link-btn { background: none; border: 0; color: var(--royal-light); cursor: pointer; padding: 0; text-decoration: underline; }
.msg { font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.msg.error { color: #fca5a5; }
.msg.ok { color: #86efac; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 4px 8px 22px; }
.sidebar .brand img { width: 108px; height: auto; display: block; }
.sidebar .brand span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.client-pick { padding: 0 4px 16px; }
.client-pick label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.client-pick select { width: 100%; }
.client-name { font-size: 16px; font-weight: 600; padding: 0 6px 16px; }
.nav-group { margin-bottom: 14px; }
.nav-group .group-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-dim);
  cursor: pointer;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--royal-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--royal); }
.sidebar .foot { margin-top: auto; padding: 14px 6px 0; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }
.sidebar .foot .link-btn { font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 22px 28px 80px; }
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 20px;
}
.topbar h2 { font-size: 20px; margin: 0; flex: 1 1 auto; min-width: 0; }
.menu-btn { display: none; }
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
}
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 7px 11px; cursor: pointer; color: var(--text-dim); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--royal); color: #fff; }
.filters .dates { display: inline-flex; align-items: center; gap: 6px; }
.filters .dates .input { padding: 6px 8px; }
.filters label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); cursor: pointer; }
.filters .spacer { flex: 1; }
.sync-info { font-size: 12px; color: var(--text-muted); }
.sync-info.err { color: #fca5a5; }

/* ---------- conteúdo ---------- */
.section-title { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }
.note { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.state { color: var(--text-dim); padding: 30px 0; }
.banner {
  background: var(--royal-soft);
  border: 1px solid rgba(37, 99, 235, 0.4);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.banner.warn { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.4); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}
.card.hero { border-color: rgba(37, 99, 235, 0.55); }
.card .label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.delta { display: inline-block; font-size: 12px; font-weight: 600; margin-top: 4px; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.neutral { color: var(--text-dim); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}
.panel h3 { font-size: 14px; margin: 0 0 2px; }
.panel .desc { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; background: var(--surface); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.status-dot.active { background: var(--good); }
.status-dot.paused { background: var(--warn); }
.status-dot.ended { background: var(--text-muted); }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.bar-cell .bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--royal); min-width: 2px; }

/* funil */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: minmax(0, 220px) 1fr auto; gap: 12px; align-items: center; }
.funnel-row .f-label { font-size: 13px; }
.funnel-row .f-label small { display: block; color: var(--text-muted); font-size: 11px; }
.funnel-row .f-track { background: var(--surface-2); border-radius: 0 6px 6px 0; height: 26px; overflow: hidden; }
.funnel-row .f-bar { height: 100%; background: var(--royal); border-radius: 0 6px 6px 0; min-width: 3px; }
.funnel-row.marked .f-bar { background: var(--c3); }
.funnel-row .f-val { font-variant-numeric: tabular-nums; text-align: right; min-width: 90px; }
.funnel-row .f-val small { color: var(--text-muted); display: block; font-size: 11px; }

/* criativos */
details.creatives { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
details.creatives > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.creatives > summary::after { content: "▾"; color: var(--text-dim); }
details.creatives[open] > summary::after { content: "▴"; }
.creative-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.creative-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.creative-card img { width: 100%; max-height: 320px; object-fit: contain; background: #000; display: block; }
.creative-card .c-body { padding: 12px; }
.creative-card .c-name { font-weight: 600; margin-bottom: 4px; }
.creative-card .c-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; white-space: pre-line; }
.creative-card details summary { cursor: pointer; color: var(--royal-light); font-size: 13px; }
.creative-card .analysis { font-size: 13px; color: var(--text-dim); margin-top: 8px; white-space: pre-line; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-dim); }

/* orçamento */
.budget-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.budget-head .month { font-weight: 600; min-width: 140px; text-align: center; }
.pace { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.pace .dot { width: 9px; height: 9px; border-radius: 50%; }
.phase-list { display: flex; flex-direction: column; gap: 6px; }
.phase-item { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.phase-item .p-label { font-weight: 600; flex: 1 1 160px; }
.phase-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; margin-top: 12px; }

/* ---------- responsivo ---------- */
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px 16px 70px; }
  .topbar h2 { font-size: 17px; }
  .filters .spacer { display: none; }
  .phase-form { grid-template-columns: 1fr 1fr; }
  .funnel-row { grid-template-columns: 1fr auto; }
  .funnel-row .f-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 420px) {
  .card .value { font-size: 19px; }
  .seg button { padding: 7px 8px; }
}

/* plataformas (Meta / Google) */
.pf-icon { width: 16px; height: 16px; vertical-align: -3px; flex-shrink: 0; }
.panel h3 .pf-icon { width: 18px; height: 18px; margin-right: 4px; vertical-align: -4px; }
.pf-stats, .pf-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.pf-results { padding-top: 12px; border-top: 1px solid var(--border); }
.pf-stats div, .pf-results div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-stats span, .pf-results span { font-size: 12px; color: var(--text-dim); }
.pf-stats strong, .pf-results strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.pf-stats small, .pf-results small { font-size: 11px; color: var(--text-muted); }
.pf-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; font-size: 17px; margin: 30px 0 12px; padding-top: 18px; border-top: 1px solid var(--border); }
.pf-head .pf-icon { width: 22px; height: 22px; }
.pf-head span { font-size: 13px; font-weight: 400; color: var(--text-dim); }
.cards.cards-6 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.cards.cards-6 .value { font-size: 20px; }
/* criativos no ar */
.ad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ad-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; min-width: 0; }
.ad-card.idle { opacity: 0.55; }
.ad-thumb { position: relative; aspect-ratio: 1 / 1; background: #0b0d11; }
.ad-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-tag { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, 0.7); color: #fff; border-color: transparent; }
.idle-tag { left: auto; right: 8px; background: rgba(245, 158, 11, 0.85); color: #000; }
.ad-body { padding: 10px; }
.ad-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-camp { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 8px; }
.ad-nums { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ad-nums span:first-child { color: var(--text); font-weight: 600; }
@media (max-width: 420px) { .ad-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* alertas (só admin) */
.alerts-bar { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.alerts-bar:empty { display: none; }
.alerts-head { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.alerts-ok { font-size: 12px; color: var(--text-muted); }
.alert-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid; }
.alert-item.critical { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.55); }
.alert-item.warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.5); }
.a-icon { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; color: #000; }
.alert-item.critical .a-icon { background: #ef4444; color: #fff; }
.alert-item.warning .a-icon { background: #f59e0b; }
.a-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.a-text strong { font-size: 14px; }
.a-text span { font-size: 12px; color: var(--text-dim); }
.a-open { flex-shrink: 0; }
@media (max-width: 600px) { .alert-item { flex-wrap: wrap; } .a-open { width: 100%; } }
