/* ============================================================
   0KM × Assinatura — "terminal de meia-noite encontra showroom"
   Âmbar/ouro = Compra (patrimônio) · Teal = Assinatura (fluxo)
   ============================================================ */

:root {
  --bg: #0a0b0e;
  --bg-2: #0f1116;
  --ink: #f3efe4;
  --muted: #8b909c;
  --faint: #565b66;
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);
  --panel: rgba(255, 255, 255, 0.025);

  --amber: #f0b429;
  --amber-soft: #f6cd6b;
  --amber-deep: #b9831a;
  --teal: #2fd6b6;
  --teal-soft: #6ee7cf;
  --teal-deep: #1a9c84;

  --pos: #61d8a2;
  --neg: #f0816b;

  --r: 16px;
  --r-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Schibsted Grotesk", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Atmosfera: auras + grão ---- */
.aura {
  position: fixed;
  z-index: 0;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  pointer-events: none;
}
.aura--amber { top: -22vmax; right: -16vmax; background: radial-gradient(circle, var(--amber), transparent 65%); animation: drift1 24s var(--ease) infinite alternate; }
.aura--teal { bottom: -26vmax; left: -18vmax; background: radial-gradient(circle, var(--teal), transparent 65%); opacity: 0.13; animation: drift2 30s var(--ease) infinite alternate; }
@keyframes drift1 { to { transform: translate(-5vmax, 6vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(6vmax, -4vmax) scale(1.15); } }

.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Masthead ---- */
.masthead {
  position: relative; z-index: 2;
  max-width: 1180px; margin: 0 auto;
  padding: clamp(2.4rem, 6vw, 5rem) clamp(1.2rem, 4vw, 2.4rem) 1rem;
  animation: rise 0.9s var(--ease) both;
}
.masthead__kicker {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.74rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1.4rem;
}
.masthead__kicker .vs { color: var(--faint); font-family: var(--font-display); font-style: italic; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot--amber { background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.dot--teal { background: var(--teal); box-shadow: 0 0 12px var(--teal); }

.masthead__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 4.3rem);
  line-height: 1.02; letter-spacing: -0.02em; margin: 0 0 1rem;
  font-optical-sizing: auto;
  /* Quebra balanceada pelo container (linhas parelhas), sem <br> no texto. */
  text-wrap: balance;
}
.masthead__title em {
  font-style: italic; font-weight: 400;
  background: linear-gradient(100deg, var(--amber-soft), var(--amber-deep));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.masthead__title em:last-of-type {
  background: linear-gradient(100deg, var(--teal-soft), var(--teal-deep));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.masthead__sub { color: var(--muted); max-width: 48ch; font-size: 1.02rem; margin: 0; text-wrap: pretty; }
/* Segunda frase: cabe numa linha no desktop e quebra sozinha quando a tela apertar. */
.masthead__sub--2 { margin-top: 0.4rem; max-width: none; }

/* Botão Recomeçar — canto sup. direito no desktop, abaixo do texto no mobile */
.restart {
  position: absolute; top: clamp(2.4rem, 6vw, 5rem); right: clamp(1.2rem, 4vw, 2.4rem);
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--muted);
  font-family: var(--font-ui); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.6rem 1rem; border-radius: 999px; cursor: pointer;
  backdrop-filter: blur(8px); transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.restart:hover { color: var(--ink); border-color: var(--amber-deep); background: rgba(240,180,41,0.08); }
.restart__icon { font-size: 1rem; transition: transform 0.5s var(--ease); display: inline-block; }
.restart:hover .restart__icon { transform: rotate(-180deg); }
@media (max-width: 620px) {
  .restart { position: static; margin-top: 1.4rem; }
}

/* ---- Layout ---- */
.layout {
  position: relative; z-index: 2;
  max-width: 1180px; margin: 0 auto;
  padding: 2rem clamp(1.2rem, 4vw, 2.4rem) 3rem;
  display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 1.4rem;
  align-items: start;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

.console { display: flex; flex-direction: column; gap: 1.4rem; position: sticky; top: 1.4rem; animation: rise 0.9s 0.1s var(--ease) both; }
@media (max-width: 880px) { .console { position: static; } }

/* ---- Panels ---- */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.4rem 1.4rem 1.5rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 40px -28px rgba(0,0,0,0.8);
}
/* Painel com um combo aberto sobe acima dos painéis irmãos (cada painel é um stacking context
   por causa do backdrop-filter, então o z-index da lista não basta). Usamos :has() em vez de uma
   classe via JS pra evitar corrida: o blur atrasado de um combo irmão removia a classe que o
   recém-aberto tinha colocado (ambos no mesmo painel). O CSS recalcula sozinho, sem corrida. */
.console .panel:has(.combo.is-open) { z-index: 40; }
.panel__title {
  display: flex; align-items: baseline; gap: 0.6rem;
  font-family: var(--font-ui); font-weight: 600; font-size: 0.82rem;
  letter-spacing: 0.16em; text-transform: uppercase; margin: 0 0 0.3rem;
}
.panel__title .num { font-family: var(--font-mono); color: var(--amber); font-size: 0.74rem; opacity: 0.85; }
.panel__hint { color: var(--faint); font-size: 0.84rem; margin: 0 0 1.1rem; }

/* ---- Fields ---- */
.field { margin-top: 1rem; }
.field > label {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.45rem;
}
.field__tag { font-family: var(--font-mono); text-transform: none; letter-spacing: 0; color: var(--amber); font-size: 0.72rem; }

input { font-family: inherit; color: var(--ink); }
input:focus-visible { outline: none; }

/* Combobox */
.combo { position: relative; }
.combo__input {
  width: 100%; background: rgba(0,0,0,0.25); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 0.7rem 0.85rem; font-size: 0.96rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.combo__input::placeholder { color: var(--faint); }
.combo__input:focus { border-color: var(--amber-deep); box-shadow: 0 0 0 3px rgba(240,180,41,0.12); background: rgba(0,0,0,0.35); }
.combo__input:disabled { opacity: 0.5; cursor: not-allowed; }
.combo.is-chosen .combo__input { border-color: var(--line); color: var(--ink); }

.combo__list {
  list-style: none; margin: 0.4rem 0 0; padding: 0.3rem;
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  max-height: 260px; overflow-y: auto;
  background: #14161c; border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: 0 24px 48px -16px rgba(0,0,0,0.9);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity 0.16s, transform 0.16s;
}
.combo.is-open .combo__list { opacity: 1; transform: translateY(0); pointer-events: auto; }
.combo__list li {
  padding: 0.55rem 0.7rem; border-radius: 7px; cursor: pointer; font-size: 0.92rem;
  display: flex; justify-content: space-between; gap: 1rem; transition: background 0.12s;
}
.combo__list li:hover, .combo__list li.is-active { background: rgba(240,180,41,0.1); }
.combo__list li .muted { color: var(--faint); font-family: var(--font-mono); font-size: 0.78rem; }
.combo__list li.empty { color: var(--faint); cursor: default; justify-content: center; }
.combo__list::-webkit-scrollbar { width: 8px; }
.combo__list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }

/* Money + percent inputs */
.money, .pct {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(0,0,0,0.25); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 0.6rem 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.money:focus-within, .pct:focus-within { border-color: var(--amber-deep); box-shadow: 0 0 0 3px rgba(240,180,41,0.12); }
.money > span, .pct > span { color: var(--faint); font-family: var(--font-mono); font-size: 0.9rem; }
.money__input, .pct__input {
  flex: 1; min-width: 0; background: none; border: none;
  font-family: var(--font-mono); font-size: 1.05rem; font-weight: 500; letter-spacing: 0.01em;
}
.pct__input { font-size: 0.98rem; text-align: right; }
.money__input { font-size: 1.15rem; }

.rates { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 1rem; }
.field--rate { margin-top: 0; min-width: 0; }
.money, .pct { min-width: 0; }
.pct__input, .money__input { width: 100%; }
.field--rate label { justify-content: flex-start; }
.src { font-family: var(--font-mono); color: var(--teal); font-size: 0.66rem; letter-spacing: 0; text-transform: none; }
.src.is-edited { color: var(--amber); }
.reset {
  background: none; border: none; color: var(--faint); cursor: pointer;
  font-size: 0.95rem; padding: 0 0.1rem; transition: color 0.2s, transform 0.3s;
}
.reset:hover { color: var(--teal); transform: rotate(-90deg); }

/* Market chips */
.market { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }
.chip {
  display: flex; flex-direction: column; gap: 0.15rem;
  background: rgba(47,214,182,0.06); border: 1px solid rgba(47,214,182,0.2);
  border-radius: var(--r-sm); padding: 0.5rem 0.75rem; flex: 1; min-width: 120px;
  animation: pop 0.5s var(--ease) both;
}
.chip__k { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.chip__v { font-family: var(--font-mono); font-size: 0.98rem; font-weight: 500; color: var(--teal-soft); }
.chip__note { font-size: 0.66rem; letter-spacing: 0.01em; margin-top: 0.05rem; }
.chip__note.is-good { color: var(--pos); }
.chip__note.is-mid { color: var(--muted); }
.chip__note.is-bad { color: var(--amber-soft); }

.status { font-size: 0.8rem; color: var(--faint); margin: 0.9rem 0 0; min-height: 1em; }
.status.is-error { color: var(--neg); }
.status .spin { display: inline-block; animation: spin 0.9s linear infinite; }

/* Advanced */
.advanced { margin-top: 1.3rem; border-top: 1px solid var(--line-soft); padding-top: 0.4rem; }
.advanced summary {
  cursor: pointer; list-style: none; font-size: 0.78rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); padding: 0.6rem 0; user-select: none;
  display: flex; align-items: center; gap: 0.5rem;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "＋"; color: var(--amber); font-family: var(--font-mono); }
.advanced[open] summary::before { content: "－"; }
.advanced__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; padding: 0.5rem 0 0.3rem; }

/* Curva de depreciação ano a ano */
.depcurve { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line-soft); }
.depcurve__head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem;
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.7rem;
}
.depcurve__legend { font-size: 0.66rem; letter-spacing: 0.04em; text-transform: none; color: var(--faint); display: inline-flex; align-items: center; gap: 0.35rem; }
.depcurve__row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }
.depcell { min-width: 0; }
.depcell > label {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem;
  font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 0.35rem; white-space: nowrap;
}
.depcell .pct { padding: 0.45rem 0.5rem; gap: 0.2rem; }
.depcell .pct__input { font-size: 0.86rem; }
.depcell .pct > span { font-size: 0.78rem; }
.badge {
  font-family: var(--font-mono); font-style: normal; font-size: 0.56rem; letter-spacing: 0.04em;
  padding: 0.08rem 0.32rem; border-radius: 5px; line-height: 1.4; white-space: nowrap;
}
.badge--fipe, #badge-dep1.is-fipe, .badge.is-fipe { background: rgba(47,214,182,0.14); color: var(--teal-soft); }
.badge--est, .badge.is-est { background: rgba(240,180,41,0.14); color: var(--amber-soft); }
.badge:empty { display: none; }
@media (max-width: 460px) { .depcurve__row { grid-template-columns: repeat(3, 1fr); } }

/* ---- Result column ---- */
.result { min-height: 420px; animation: rise 0.9s 0.2s var(--ease) both; }
.empty {
  height: 100%; min-height: 420px; display: flex; flex-direction: column; gap: 1.2rem;
  align-items: center; justify-content: center; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r); color: var(--faint);
  padding: 2rem;
}
.empty__lottie {
  width: clamp(200px, 60%, 300px); aspect-ratio: 1; margin: -1.5rem 0 -1rem;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,0.45));
  animation: floaty 4.5s var(--ease) infinite;
}
.empty__lottie svg { display: block; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.empty p { max-width: 28ch; margin: 0; }

.output { display: flex; flex-direction: column; gap: 1.4rem; }

/* Verdict */
.verdict {
  position: relative; overflow: hidden;
  border-radius: var(--r); padding: 1.8rem;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(240,180,41,0.12), transparent 55%),
    radial-gradient(120% 140% at 0% 100%, rgba(47,214,182,0.1), transparent 55%),
    var(--panel);
  box-shadow: 0 20px 60px -34px rgba(0,0,0,0.9);
}
.verdict.is-buy { --vc: var(--amber); }
.verdict.is-sub { --vc: var(--teal); }
.verdict::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--vc, var(--amber)); box-shadow: 0 0 24px var(--vc, var(--amber));
}
.verdict__lead { font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; }
.verdict__headline {
  font-family: var(--font-display); font-weight: 500; font-optical-sizing: auto;
  font-size: clamp(1.5rem, 3.4vw, 2.3rem); line-height: 1.08; letter-spacing: -0.015em; margin: 0 0 0.7rem;
}
.verdict__headline b { color: var(--vc, var(--amber)); font-weight: 600; font-style: italic; }
.verdict__detail { color: var(--muted); margin: 0; font-size: 0.98rem; }
.verdict__detail strong { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }

/* Chart */
.panel--chart { padding-top: 1.2rem; }
.legend { display: flex; gap: 1.4rem; margin-bottom: 0.6rem; font-size: 0.8rem; color: var(--muted); }
.legend__item { display: flex; align-items: center; gap: 0.5rem; }
.swatch { width: 14px; height: 3px; border-radius: 2px; }
.swatch--amber { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.swatch--teal { background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.chartbox { position: relative; height: 300px; }

/* Ledger table */
.tablewrap { overflow-x: auto; margin-top: 0.4rem; }
.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 0.7rem 0.5rem; text-align: right; white-space: nowrap; }
.ledger th {
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.ledger th:first-child, .ledger td:first-child { text-align: left; }
.ledger td { font-family: var(--font-mono); font-size: 0.9rem; border-bottom: 1px solid var(--line-soft); }
.ledger tbody tr { transition: background 0.15s; }
.ledger tbody tr:hover { background: rgba(255,255,255,0.02); }
.ledger tbody tr.is-breakeven td { background: rgba(240,180,41,0.07); }
.ledger tbody tr.is-breakeven td:first-child { color: var(--amber); font-weight: 600; }
.ledger .col-buy { color: var(--amber-soft); }
.ledger .col-sub { color: var(--teal-soft); }
.ledger .pos { color: var(--pos); }
.ledger .neg { color: var(--neg); }

.footnote { font-size: 0.78rem; color: var(--faint); margin: 0.9rem 0 0; }
.footnote .pos { color: var(--pos); } .footnote .neg { color: var(--neg); }

/* Colophon */
.colophon {
  position: relative; z-index: 2; max-width: 1180px; margin: 0 auto;
  padding: 1.5rem clamp(1.2rem, 4vw, 2.4rem) 3rem;
  font-size: 0.78rem; color: var(--faint); border-top: 1px solid var(--line-soft);
}
.colophon a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.colophon a:hover { color: var(--teal); }

/* Animations */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash { 0% { background: rgba(240,180,41,0.18); } 100% { background: transparent; } }
.flash { animation: flash 0.6s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
