/* ═══════════════════════════════════════════════════════════════════════════
   Statter — design system
   Cores de status vindas da paleta validada (dataviz): cada condition sempre
   aparece como COR + FORMA + RÓTULO, nunca cor sozinha.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Marca — herdada do documento "Métricas da nossa rotina" */
  --teal:        #0D9488;
  --teal-dark:   #0F766E;
  --teal-deep:   #115E56;
  --teal-light:  #CCFBF1;
  --teal-pale:   #F0FDFA;
  --purp:        #8B5FC9;
  --purp-dark:   #5E3A9A;
  --purp-light:  #EDE9FE;
  --gold:        #F59E0B;
  --gold-pale:   #FFFBEB;

  /* Superfícies e tinta */
  --bg:          #F7F6F3;
  --surface:     #FFFFFF;
  --surface-2:   #FBFAF8;
  --ink:         #1A1A19;
  --ink-2:       #52514E;
  --muted:       #8A8984;
  --line:        #E6E4DD;
  --line-soft:   #F0EEE8;

  /* Conditions — paleta de status validada */
  --c-nonexistence: #898781;
  --c-danger:       #d03b3b;
  --c-emergency:    #ec835a;
  --c-normal:       #0ca30c;
  --c-affluence:    #184f95;

  /* Séries categóricas (slots 1 e 2 da ordem fixa) */
  --series-1:    #2a78d6;
  --series-2:    #eb6834;

  /* Chrome de gráfico */
  --grid:        #ECEAE3;
  --axis:        #D6D3CA;

  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 1px 2px rgba(26,26,25,.05), 0 4px 16px rgba(26,26,25,.04);
  --shadow-lg:   0 2px 6px rgba(26,26,25,.06), 0 12px 32px rgba(26,26,25,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-dark); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-in {
  max-width: 1000px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 22px;
}
.brand {
  font-weight: 800; font-size: 1.05rem; letter-spacing: -.02em;
  color: var(--teal-dark); text-decoration: none; display: flex;
  align-items: center; gap: 8px; flex-shrink: 0;
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); display: inline-block;
}
/* Altura fixa e width auto: o PNG tem margem transparente própria e esticar
   por largura deformaria o quadrado do ícone. */
.brand-logo { height: 30px; width: auto; display: block; flex-shrink: 0; }
.brand-logo-lg { height: 56px; width: auto; display: block; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  font-size: .875rem; font-weight: 600; color: var(--ink-2);
  text-decoration: none; padding: 8px 12px; border-radius: 8px;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--teal-pale); color: var(--teal-dark); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal-pale); border: 1px solid var(--teal-light);
  display: grid; place-items: center; font-size: 1rem;
  text-decoration: none; flex-shrink: 0;
}

.page { padding: 30px 0 70px; }

.page-head { margin-bottom: 24px; }
.page-title {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -.025em;
  line-height: 1.25;
}
.page-sub { color: var(--muted); font-size: .925rem; margin-top: 4px; }

.section-title {
  font-size: .78rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  margin: 32px 0 12px;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card + .card { margin-top: 14px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ─── Conditions ─────────────────────────────────────────────────────────── */
/* Sempre glifo + rótulo. A cor é reforço, nunca o único canal. */

.cond-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 10px; border-radius: 99px;
  font-size: .8rem; font-weight: 700; line-height: 1;
  border: 1.5px solid currentColor; white-space: nowrap;
}
.cond-badge .glyph { font-size: .85em; }

.cond-badge.sm { padding: 3px 9px 3px 8px; font-size: .72rem; }
.cond-badge.lg { padding: 8px 18px 8px 15px; font-size: .95rem; }

.c-non_existence { color: #4a4945; background: #f4f4f2; }
.c-danger        { color: #8f2020; background: #fdf1f1; }
.c-emergency     { color: #9a4a22; background: #fff5f0; }
.c-normal        { color: #046004; background: #f0fbf0; }
.c-affluence     { color: #123b70; background: #eef4fc; }

/* Celebração — só para Normal e Affluence */
.cond-badge.celebrate {
  animation: pop .45s cubic-bezier(.34,1.56,.64,1);
}
.c-affluence.celebrate {
  box-shadow: 0 0 0 4px rgba(24,79,149,.10), 0 4px 14px rgba(24,79,149,.18);
}
.c-normal.celebrate {
  box-shadow: 0 0 0 4px rgba(12,163,12,.10);
}
@keyframes pop {
  0%   { transform: scale(.82); opacity: 0; }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

/* ─── Métrica ────────────────────────────────────────────────────────────── */

.metric-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
  text-decoration: none; color: inherit;
}
.metric-row:last-child { border-bottom: 0; }
.metric-row:hover { background: var(--surface-2); }

.metric-ico {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 1.25rem;
}
.metric-main { flex: 1; min-width: 0; }
.metric-name { font-weight: 700; font-size: .975rem; }
.metric-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.metric-val {
  font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.metric-val small { font-size: .68em; font-weight: 600; color: var(--muted); }

.owner-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; background: var(--teal-pale);
  color: var(--teal-dark); border: 1px solid var(--teal-light);
}
.owner-chip.shared { background: var(--purp-light); color: var(--purp-dark); border-color: #DDD6FE; }

/* ─── Gamificação ────────────────────────────────────────────────────────── */

.xp-card {
  background: linear-gradient(135deg, var(--teal-dark) 0%, #134E48 100%);
  border-radius: var(--radius); padding: 22px 24px; color: #fff;
  position: relative; overflow: hidden;
}
.xp-card::after {
  content: ''; position: absolute; top: -70px; right: -50px;
  width: 190px; height: 190px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.xp-level { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.xp-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #99F6E4;
}
.xp-bar {
  height: 8px; border-radius: 99px; background: rgba(255,255,255,.18);
  margin-top: 14px; overflow: hidden; position: relative; z-index: 1;
}
.xp-bar i {
  display: block; height: 100%; border-radius: 99px;
  background: var(--gold); transition: width .8s cubic-bezier(.16,1,.3,1);
}
.xp-foot {
  font-size: .8rem; color: rgba(255,255,255,.72); margin-top: 8px;
  position: relative; z-index: 1;
}

.streak {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .8rem; font-weight: 700; padding: 4px 10px;
  border-radius: 99px; background: var(--gold-pale);
  color: #92400E; border: 1px solid #FDE68A;
}

.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge {
  text-align: center; padding: 14px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
}
.badge.earned {
  background: var(--gold-pale); border-color: #FDE68A;
}
.badge.locked { opacity: .42; filter: grayscale(1); }
.badge-ico { font-size: 1.5rem; line-height: 1; }
.badge-name { font-size: .74rem; font-weight: 700; margin-top: 6px; }
.badge-detail { font-size: .68rem; color: var(--muted); margin-top: 2px; }

/* ─── Botões ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: 11px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--teal-dark); border-color: var(--teal-dark); color: #fff;
}
.btn-primary:hover { background: var(--teal-deep); border-color: var(--teal-deep); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }

.btn-ai {
  background: var(--purp-light); border-color: #DDD6FE; color: var(--purp-dark);
}
.btn-ai:hover { background: #E4DDFB; }

/* ─── Formulários ────────────────────────────────────────────────────────── */

.field { margin-bottom: 18px; }
.label {
  display: block; font-size: .84rem; font-weight: 700;
  margin-bottom: 6px; color: var(--ink);
}
.hint { font-size: .8rem; color: var(--muted); margin-top: 5px; line-height: 1.55; }

.input, .select, .textarea {
  width: 100%; font: inherit; font-size: .925rem;
  padding: 11px 13px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.6; }

.input-warn { border-color: var(--c-emergency); }
.input-warn:focus { box-shadow: 0 0 0 3px rgba(236,131,90,.15); }
.input-bad { border-color: var(--c-danger); }
.input-bad:focus { box-shadow: 0 0 0 3px rgba(208,59,59,.15); }

/* Stepper de valor */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: 1.3rem; font-weight: 600; color: var(--ink-2);
  cursor: pointer; line-height: 1; flex-shrink: 0;
}
.stepper button:hover { background: var(--surface-2); border-color: var(--axis); }
.stepper input {
  width: 78px; text-align: center; font-size: 1.35rem; font-weight: 800;
  font-variant-numeric: tabular-nums; padding: 8px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
}
.stepper input:focus { outline: none; border-color: var(--teal); }
.stepper-unit { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* ─── Alertas ────────────────────────────────────────────────────────────── */

.alert {
  padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; line-height: 1.6; margin-bottom: 16px;
  border-left: 3px solid;
}
.alert-ok   { background: #F0FBF0; border-color: var(--c-normal); color: #046004; }
.alert-warn { background: #FFF5F0; border-color: var(--c-emergency); color: #9A4A22; }
.alert-bad  { background: #FDF1F1; border-color: var(--c-danger); color: #8F2020; }
.alert-info { background: var(--teal-pale); border-color: var(--teal); color: var(--teal-deep); }

/* ─── Login ──────────────────────────────────────────────────────────────── */

.auth-body {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 32px; box-shadow: var(--shadow-lg);
}
.auth-title {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -.025em;
  margin-bottom: 6px;
}
.auth-sub { color: var(--muted); font-size: .9rem; margin-bottom: 26px; }
.auth-foot {
  margin-top: 18px; text-align: center;
  font-size: .78rem; color: var(--muted);
}

.install-list { list-style: none; margin-bottom: 20px; }
.install-list li {
  padding: 8px 0 8px 26px; position: relative;
  border-bottom: 1px solid var(--line-soft); font-size: .875rem;
}
.install-list li::before {
  content: '✓'; position: absolute; left: 4px;
  color: var(--c-normal); font-weight: 700;
}

/* ─── Utilitários ────────────────────────────────────────────────────────── */

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap-gap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.tnum { font-variant-numeric: tabular-nums; }

.empty {
  text-align: center; padding: 50px 20px; color: var(--muted);
}
.empty-ico { font-size: 2.4rem; opacity: .45; }

/* ─── Fórmula: passos ────────────────────────────────────────────────────── */

.fstep {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px;
}
.fstep-head { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 12px; }
.fstep-num {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--teal-dark); color: #fff; font-size: .82rem;
  font-weight: 700; display: grid; place-items: center;
}
.fstep-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.fstep-q { font-size: 1rem; font-weight: 700; line-height: 1.4; margin-top: 2px; }
.fstep-help {
  font-size: .855rem; color: var(--ink-2); line-height: 1.65;
  background: var(--surface-2); border-left: 3px solid var(--teal-light);
  padding: 12px 15px; border-radius: 0 9px 9px 0; margin-bottom: 14px;
}

.ex-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ex {
  font-size: .8rem; line-height: 1.55; padding: 10px 13px;
  border-radius: 9px; border: 1px solid;
}
.ex-bad  { background: #FDF1F1; border-color: #F6D5D5; color: #8F2020; }
.ex-good { background: #F0FBF0; border-color: #CFEACF; color: #046004; }
.ex-tag {
  display: block; font-size: .66rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  opacity: .8; margin-bottom: 3px;
}

/* Accurate Estimation — passo 0, visualmente distinto dos passos da fórmula */
.fstep-estimation { border-left: 4px solid var(--gold); background: #FFFDF7; }

/* O passo de declaração (Danger nº 3) não pede Actionable Item */
.fstep-declaration { border-left: 4px solid var(--c-danger); }
.declaration-note {
  font-size: .8rem; line-height: 1.55; color: #8F2020;
  background: #FDF1F1; border-radius: 8px;
  padding: 9px 13px; margin-bottom: 12px;
}

/* ─── Os 4 critérios ─────────────────────────────────────────────────────── */

.criteria-card {
  background: var(--surface); border: 1.5px solid var(--teal-light);
  border-radius: var(--radius); padding: 18px 20px;
}
.criteria-head {
  font-size: .95rem; font-weight: 700; color: var(--teal-dark);
  margin-bottom: 6px;
}
.criteria-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.criteria-item {
  background: var(--teal-pale); border-radius: 9px; padding: 10px 13px;
}
.criteria-q {
  font-size: .82rem; font-weight: 700; color: var(--teal-deep);
}
.criteria-d {
  font-size: .76rem; color: var(--ink-2); line-height: 1.5; margin-top: 2px;
}

/* Fichas por passo: acendem conforme a resposta satisfaz cada critério */
.crit-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.crit {
  font-size: .7rem; font-weight: 700; padding: 3px 9px;
  border-radius: 99px; border: 1.5px solid var(--line);
  color: var(--muted); background: var(--surface-2);
  transition: all .15s; white-space: nowrap;
}
.crit::before { content: '○ '; }
.crit.on {
  color: #046004; background: #F0FBF0; border-color: #CFEACF;
}
.crit.on::before { content: '✓ '; }

.check { font-size: .78rem; margin-top: 6px; font-weight: 600; min-height: 18px; }
.check-idle { color: transparent; }
.check-ok   { color: #046004; }
.check-warn { color: #9A4A22; }
.check-bad  { color: #8F2020; }

/* ─── Sugestões de IA ────────────────────────────────────────────────────── */

.sug-panel {
  margin-top: 12px; background: #FAF8FF; border: 1px solid #E9E2FB;
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.sug-head {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--purp-dark); margin-bottom: 10px;
}
.sug-item {
  display: block; width: 100%; text-align: left; font: inherit;
  font-size: .855rem; line-height: 1.55; padding: 11px 13px;
  margin-bottom: 7px; border-radius: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid #E9E2FB; color: var(--ink);
  transition: border-color .12s, background .12s;
}
.sug-item:hover { border-color: var(--purp); background: #fff; }
.sug-item:last-of-type { margin-bottom: 0; }
.sug-foot { font-size: .74rem; color: var(--muted); margin-top: 10px; }
.sug-loading { font-size: .85rem; color: var(--purp-dark); }
.sug-error { font-size: .85rem; color: #8F2020; }

/* ─── Confete ────────────────────────────────────────────────────────────── */

.confetti-box {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  overflow: hidden;
}
.confetti-box i {
  position: absolute; top: -14px; width: 9px; height: 14px;
  border-radius: 2px; animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(104vh) rotate(560deg); opacity: .15; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-box { display: none; }
  .cond-badge.celebrate { animation: none; }
  .xp-bar i { transition: none; }
}

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .badges { grid-template-columns: repeat(2, 1fr); }
  .page-title { font-size: 1.35rem; }
  .nav a { padding: 8px 9px; font-size: .82rem; }
  .topbar-in { gap: 10px; }
  .ex-pair { grid-template-columns: 1fr; }
  .fstep { padding: 16px 15px; }
  .criteria-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Instalado no celular (PWA)
   ═══════════════════════════════════════════════════════════════════════════ */

/* O viewport usa `viewport-fit=cover`, então o conteúdo passa por baixo do
   notch e da barra de gestos. Estes recuos devolvem o espaço — valem zero em
   telas sem recorte, o que deixa o desktop intacto.

   O bloco também repõe os 20px laterais de `.wrap`: como `.page` declara
   `padding` na forma curta, ele zerava as laterais e o conteúdo encostava na
   borda da tela no celular. */
.topbar { padding-top: env(safe-area-inset-top); }
.topbar-in,
.wrap, .wrap-narrow {
  padding-left:  max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
body { padding-bottom: env(safe-area-inset-bottom); }
.auth-body {
  min-height: 100dvh;   /* 100vh mente no celular: conta a barra de endereço */
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

/* ─── Convite de instalação ──────────────────────────────────────────────── */

.install-bar {
  position: fixed; z-index: 200;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transform: translateY(140%);
  transition: transform .28s cubic-bezier(.2, .8, .3, 1);
}
.install-bar.on { transform: translateY(0); }
.install-bar img { border-radius: 9px; flex-shrink: 0; }

/* Abre espaço no fim da página para o convite não cobrir o último botão. */
body:has(.install-bar) { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

.install-txt { flex: 1; min-width: 0; line-height: 1.35; }
.install-txt strong { display: block; font-size: .9rem; }
.install-txt span { display: block; font-size: .78rem; color: var(--ink-2); }

.install-acts { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.install-x {
  font: inherit; font-size: .9rem; line-height: 1;
  padding: 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.install-x:hover { background: var(--surface-2); color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  .install-bar { transition: none; transform: translateY(0); }
}
