/* ==========================================================
   Base: tokens da marca, tipografia, estrutura da aplicação
   Paleta = evolução do azul-marinho luminoso (identidade/design-guide.md)
   ========================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: #060e24;
  --bg-elevado: #0a1730;
  --superficie: #0d1a33;
  --superficie-2: #12223f;
  --superficie-3: #1a2d51;
  --campo: #081329;

  --borda: rgba(255, 255, 255, 0.08);
  --borda-forte: rgba(255, 255, 255, 0.14);

  --texto: #f1f5fb;
  --texto-2: #a9b6ca;
  --texto-3: #8290a8;

  --azul: #2f7bff;
  --azul-texto: #82adff;
  --azul-suave: rgba(47, 123, 255, 0.13);
  --roxo: #8b5cf6;
  --verde: #22c55e;
  --verde-texto: #4ade80;
  --verde-suave: rgba(34, 197, 94, 0.12);
  --amarelo: #eab308;
  --amarelo-texto: #facc15;
  --amarelo-suave: rgba(234, 179, 8, 0.12);
  --vermelho: #ef4444;
  --vermelho-texto: #f87171;
  --vermelho-suave: rgba(239, 68, 68, 0.12);

  --cor-custo: #64748b;
  --cor-extras: #94a3b8;
  --cor-imposto: #d97706;
  --cor-pagamento: #eab308;
  --cor-comissao: #f59e0b;
  --cor-lucro: #22c55e;

  --gradiente: linear-gradient(135deg, #2f7bff 0%, #8b5cf6 100%);
  /* Mesmo azul→roxo, um tom mais fundo: texto branco com contraste ≥ 4,5:1 */
  --gradiente-botao: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --raio-sm: 10px;
  --raio: 14px;
  --raio-lg: 18px;
  --sombra-suave: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  --sombra-elevada: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --brilho: 0 8px 22px -10px rgba(47, 123, 255, 0.55);
  --foco: 0 0 0 3px rgba(47, 123, 255, 0.35);
  --grade: rgba(255, 255, 255, 0.022);

  --fonte: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --curva: cubic-bezier(0.2, 0.8, 0.2, 1);
  --lateral: 256px;
}

[data-theme="claro"] {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-elevado: #ffffff;
  --superficie: #ffffff;
  --superficie-2: #f2f5fa;
  --superficie-3: #e5eaf3;
  --campo: #ffffff;

  --borda: rgba(15, 23, 42, 0.09);
  --borda-forte: rgba(15, 23, 42, 0.16);

  --texto: #0b1528;
  --texto-2: #475569;
  --texto-3: #5f6e84;

  --azul-texto: #1d5fd6;
  --azul-suave: rgba(47, 123, 255, 0.09);
  --verde-texto: #15803d;
  --verde-suave: rgba(34, 197, 94, 0.1);
  --amarelo-texto: #a16207;
  --amarelo-suave: rgba(234, 179, 8, 0.12);
  --vermelho-texto: #b91c1c;
  --vermelho-suave: rgba(239, 68, 68, 0.09);

  --sombra-suave: 0 1px 2px rgba(15, 23, 42, 0.04);
  --sombra-elevada: 0 24px 48px -24px rgba(15, 23, 42, 0.28);
  --brilho: 0 8px 20px -10px rgba(47, 123, 255, 0.5);
  --grade: rgba(15, 23, 42, 0.035);
}

/* ---------- Reset ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--fonte);
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 0% -10%, rgba(47, 123, 255, 0.11), transparent 60%),
    radial-gradient(700px 460px at 100% 0%, rgba(139, 92, 246, 0.07), transparent 60%),
    linear-gradient(var(--grade) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--grade) 1px, transparent 1px) 0 0 / 44px 44px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 75%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 75%);
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--azul-texto); }
img, svg { display: block; }
[hidden] { display: none !important; }
::selection { background: rgba(47, 123, 255, 0.35); }

:focus-visible {
  outline: 2px solid var(--azul);
  outline-offset: 2px;
}

.num { font-variant-numeric: tabular-nums; }

.visualmente-oculto {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pular-conteudo {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--azul);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s var(--curva);
}

.pular-conteudo:focus-visible { transform: none; }

.icone {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Estrutura ---------- */

.app {
  display: grid;
  grid-template-columns: var(--lateral) minmax(0, 1fr);
  min-height: 100dvh;
}

.app:not(.is-pronto) { visibility: hidden; }

.topbar,
.bottom-nav,
.menu-overlay { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 20px 14px 16px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg-elevado) 86%, transparent);
  border-right: 1px solid var(--borda);
  scrollbar-width: thin;
}

.marca {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px 18px;
  color: inherit;
  text-decoration: none;
}

.marca img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 6px 16px -8px rgba(47, 123, 255, 0.7);
}

.marca__nome { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.marca__sub { font-size: 12px; color: var(--texto-3); font-weight: 500; }

.sidebar__cta { margin: 0 4px 10px; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav__grupo {
  margin: 18px 0 4px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--texto-3);
}

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--texto-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.nav__item .icone { color: var(--texto-3); transition: color 0.15s; }
button.nav__item { width: 100%; border: 0; background: transparent; text-align: left; }
.nav__item:hover { background: var(--superficie-2); color: var(--texto); }

.nav__item[aria-current="page"] {
  background: var(--superficie-2);
  color: var(--texto);
  font-weight: 600;
}

.nav__item[aria-current="page"] .icone { color: var(--azul-texto); }

.nav__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gradiente);
}

.nav__novo {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--azul-texto);
  background: var(--azul-suave);
}

.sidebar__rodape {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--borda);
}

.licenca {
  padding: 0 10px;
  font-size: 12px;
  color: var(--texto-3);
  line-height: 1.4;
}

.licenca strong {
  display: block;
  overflow: hidden;
  color: var(--texto-2);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  min-width: 0;
  padding: 36px clamp(20px, 4vw, 56px) 72px;
  container-type: inline-size;
  outline: none;
}

.view { display: none; max-width: 1160px; margin: 0 auto; }
.view.is-ativo { display: block; animation: entrar 0.32s var(--curva) both; }
.view--estreita { max-width: 780px; }

.cabecalho-view {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.cabecalho-view h1 {
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 800;
  letter-spacing: -0.028em;
  outline: none;
}

.cabecalho-view p {
  max-width: 62ch;
  margin-top: 6px;
  color: var(--texto-2);
  font-size: 15px;
}

.sobretitulo {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--azul-texto);
}

@keyframes entrar {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Celular e tablet ---------- */

@media (max-width: 900px) {
  body { font-size: 16px; }
  body.menu-aberto { overflow: hidden; }

  .app { display: block; }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--borda);
  }

  .topbar .marca { padding: 0; }
  .topbar .marca img { width: 30px; height: 30px; border-radius: 9px; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(300px, 86vw);
    height: 100dvh;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: var(--bg-elevado);
    box-shadow: var(--sombra-elevada);
    transform: translateX(-102%);
    transition: transform 0.28s var(--curva);
  }

  .sidebar.is-aberta { transform: none; }

  .menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(2, 6, 23, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s;
  }

  .menu-overlay.is-visivel { opacity: 1; pointer-events: auto; }

  .nav__item { min-height: 46px; font-size: 15px; }

  .main { padding: 20px 16px calc(100px + env(safe-area-inset-bottom)); }

  .cabecalho-view { margin-bottom: 20px; }
  .cabecalho-view p { font-size: 15px; }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg-elevado);
    border-top: 1px solid var(--borda);
  }

  .bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--texto-3);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
  }

  .bottom-nav__item .icone { width: 22px; height: 22px; }
  .bottom-nav__item[aria-current="page"] { color: var(--texto); }
  .bottom-nav__item[aria-current="page"] .icone { color: var(--azul-texto); }

  .bottom-nav__bolha {
    display: grid;
    place-items: center;
    width: 46px;
    height: 30px;
    border-radius: 11px;
    background: var(--gradiente-botao);
    box-shadow: var(--brilho);
  }

  .bottom-nav__bolha .icone,
  .bottom-nav__item[aria-current="page"] .bottom-nav__bolha .icone { color: #fff; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .main { padding-left: 32px; padding-right: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
