/* =====================================================================
   Painel SL Desenvolvimentos
   Identidade: azul-marinho da parede + turquesa do logo + serifada do "SL"
   ===================================================================== */

:root {
  --navy: #1B2130;
  --navy-deep: #131826;
  --navy-line: #2A3246;
  --turquoise: #5CE1E6;
  --turquoise-soft: #D9F7F8;
  --turquoise-ink: #0B6B70;   /* turquesa legível sobre fundo claro */
  --paper: #F2F4F7;
  --surface: #FFFFFF;
  --ink: #1B2130;
  --ink-2: #4A5368;
  --ink-3: #7A8296;
  --line: #E1E5EC;
  --good: #1D8A5E;
  --warn: #B7790C;
  --bad: #C63E3E;

  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;

  --radius-panel: 14px;
  --radius-control: 8px;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
img { max-width: 100%; display: block; }
a { color: var(--turquoise-ink); }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--turquoise-ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); margin: 0; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--turquoise); color: var(--ink); padding: 8px 14px; border-radius: var(--radius-control); z-index: 100; }
.skip-link:focus { left: 8px; }

/* ---------- Botões e formulários ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-control);
  font: 600 14px/1 var(--font-ui); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn-primary { background: var(--turquoise); color: var(--navy-deep); }
.btn-primary:hover { background: #47D2D8; color: var(--navy-deep); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-block { width: 100%; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span:first-child { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  font: 400 15px/1.4 var(--font-ui); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--turquoise-ink); box-shadow: 0 0 0 3px var(--turquoise-soft); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 84px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--turquoise-ink); font: 600 13px var(--font-ui); cursor: pointer; padding: 6px 8px;
}

/* ---------- Avisos ---------- */
.flash-stack { display: grid; gap: 8px; margin-bottom: 20px; }
.flash {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-control); font-size: 14px;
  border-left: 3px solid;
}
.flash-success { background: #E6F5EE; border-color: var(--good); color: #145C3F; }
.flash-error   { background: #FBEAEA; border-color: var(--bad); color: #8A2424; }
.flash-info    { background: var(--turquoise-soft); border-color: var(--turquoise-ink); color: #0A4F53; }
.flash-close { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }

/* =====================================================================
   Telas de acesso (login, recuperação, instalador)
   ===================================================================== */
.auth-body { background: var(--navy); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 48px; background: var(--navy);
  background-image: radial-gradient(circle at 30% 40%, #232B3E 0, var(--navy) 60%);
}
.auth-logo { width: min(420px, 80%); }
.auth-tagline { color: #AEB6C8; max-width: 34ch; text-align: center; margin: 36px 0 0; font-size: 15px; }
.auth-panel {
  background: var(--surface); padding: 48px clamp(24px, 6vw, 88px);
  display: flex; flex-direction: column; justify-content: center;
}
.auth-panel > * { width: 100%; max-width: 380px; }
.auth-logo-mobile { display: none; }
.auth-title { font: 600 30px/1.2 var(--font-display); margin: 0 0 8px; }
.auth-text { color: var(--ink-2); margin: 0 0 24px; }
.auth-title + .form { margin-top: 20px; }
.auth-link { margin: 20px 0 0; font-size: 14px; }

.install { max-width: 460px; margin: 48px auto; background: var(--surface); border-radius: var(--radius-panel); padding: 36px clamp(20px, 5vw, 40px); }
.install-logo { width: 200px; margin: 0 auto 28px; background: var(--navy); padding: 16px 20px; border-radius: var(--radius-control); }
.install-errors { color: var(--bad); padding-left: 18px; display: grid; gap: 8px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { justify-content: flex-start; padding-top: 0; background: var(--surface); }
  .auth-logo-mobile { display: block; width: calc(100% + 48px); max-width: none; margin: 0 -24px 32px; padding: 28px 56px; background: var(--navy); }
}

/* =====================================================================
   Estrutura do painel
   ===================================================================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--navy); color: #C9CFDC;
}
.sidebar-brand { display: block; padding: 22px 28px 18px; border-bottom: 1px solid var(--navy-line); }
.sidebar-brand img { width: 172px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.nav-group { margin: 18px 12px 6px; font-size: 12px; font-weight: 600; color: #7F889C; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-control);
  color: #C9CFDC; text-decoration: none; font-weight: 500;
}
.nav-link svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover { background: #232A3C; color: #FFFFFF; }
.nav-link.is-active { background: #232A3C; color: var(--turquoise); }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--turquoise);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--navy-line); }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--turquoise); color: var(--navy-deep);
  font: 600 15px var(--font-display);
}
.sidebar-user-info { min-width: 0; flex: 1; display: grid; }
.sidebar-user-info strong { color: #FFFFFF; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info small { font-size: 12px; color: #7F889C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { border: 0; background: none; color: #AEB6C8; cursor: pointer; padding: 6px; border-radius: 6px; }
.btn-logout:hover { color: var(--turquoise); background: #232A3C; }
.btn-logout svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 18px clamp(16px, 3vw, 36px);
  background: rgba(242, 244, 247, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.page-title { margin: 0; font: 600 26px/1.2 var(--font-display); }
.topbar-date { margin-left: auto; color: var(--ink-3); font-size: 13px; }
.menu-toggle { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-control); padding: 8px; cursor: pointer; color: var(--ink); }
.menu-toggle svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.content { padding: 28px clamp(16px, 3vw, 36px) 48px; max-width: 1320px; width: 100%; }
.sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.is-open { transform: none; box-shadow: 12px 0 40px rgba(10, 14, 24, .35); }
  .sidebar-backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(10, 14, 24, .45); z-index: 30; }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .page-title { font-size: 22px; }
}
@media (max-width: 560px) {
  .topbar-date { display: none; }
}

/* =====================================================================
   Dashboard
   ===================================================================== */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.greeting { margin: 0 0 2px; font-size: 18px; font-weight: 600; }
.period-form select { width: auto; min-width: 210px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; color: var(--ink-2); }

.empty-hero {
  background: var(--surface); border: 1px dashed #C4CBD8; border-radius: var(--radius-panel);
  padding: 24px 28px; margin-bottom: 28px;
}
.empty-hero h2 { font: 600 21px/1.3 var(--font-display); margin: 0 0 6px; }
.empty-hero p { margin: 0; color: var(--ink-2); max-width: 70ch; }

.results { margin-bottom: 32px; }
.results-grid {
  display: grid; grid-template-columns: minmax(240px, 320px) 1fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden;
}
/* O elemento de destaque do painel: o ROAS, como o logo na parede */
.roas-block {
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  padding: 28px; background: var(--navy); color: #FFFFFF;
}
.roas-label { font-size: 13px; color: #AEB6C8; font-weight: 600; }
.roas-value { font: 600 clamp(48px, 6vw, 68px)/1 var(--font-display); color: var(--turquoise); font-variant-numeric: lining-nums; }
.roas-block.is-good .roas-value { color: var(--turquoise); }
.roas-block.is-warn .roas-value { color: #F2C35B; }
.roas-block.is-bad  .roas-value { color: #FF8A8A; }
.roas-hint { font-size: 12px; color: #7F889C; }

.stat-list { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.stat-list > div { padding: 20px 24px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-list > div:nth-last-child(-n+3) { border-bottom: 0; }
.stat-list dt { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.stat-list dd { margin: 0; white-space: nowrap; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.agency-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 20px; background: var(--surface); border-radius: var(--radius-control);
  border-top: 2px solid var(--line);
}
.tile-label { font-size: 13px; color: var(--ink-3); }
.tile-value { white-space: nowrap; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-foot { font-size: 12.5px; color: var(--ink-3); }
.tile-foot.is-bad { color: var(--bad); font-weight: 600; }
.footnote { margin: 28px 0 0; font-size: 13px; color: var(--ink-3); max-width: 72ch; }

@media (max-width: 1180px) {
  .agency-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .results-grid { grid-template-columns: 1fr; }
  .stat-list { grid-template-columns: repeat(2, 1fr); }
  .stat-list > div { border-left: 0; }
  .stat-list > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .stat-list > div:nth-last-child(-n+3) { border-bottom: 1px solid var(--line); }
  .stat-list > div:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 480px) {
  .agency-grid { grid-template-columns: 1fr; }
  .stat-list dd { font-size: 17px; }
  .stat-list > div { padding: 16px; }
  .period-form, .period-form select { width: 100%; }
}

/* ---------- Telas provisórias ---------- */
.soon { background: var(--surface); border-radius: var(--radius-panel); padding: 40px clamp(20px, 4vw, 48px); max-width: 640px; }
.soon-stage { margin: 0 0 8px; color: var(--turquoise-ink); font-weight: 700; font-size: 14px; }
.soon h2 { font: 600 24px/1.3 var(--font-display); margin: 0 0 10px; }
.soon p { color: var(--ink-2); margin: 0 0 24px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
