/* ============================================================
   Organização Financeira — estilos
   Números em mono (extrato/terminal). Cor = dado, não enfeite.
   ============================================================ */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --ink: #1b1f27;
  --ink-soft: #545c6b;
  --muted: #8a909c;
  --line: #e6e8ee;
  --navy: #22314f;

  --danger: #c6413c;   --danger-bg: #fbeceb;
  --amber: #a85908;    --amber-bg: #f9efe0;
  --green: #2c7a51;    --green-bg: #e6f2ea;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(27, 31, 39, .04), 0 6px 20px rgba(27, 31, 39, .05);

  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* [hidden] precisa vencer os display: das classes (.gate, .userbar, .devbanner) */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 32px) 64px;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.masthead__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(22px, 3.4vw, 30px);
  letter-spacing: -.02em;
  margin: 0;
}
.masthead__sub { color: var(--ink-soft); font-size: 14px; margin: 3px 0 0; }
.masthead__meta { text-align: right; font-size: 12.5px; color: var(--muted); }
.masthead__meta b { color: var(--ink-soft); font-family: var(--mono); font-weight: 500; }

/* ---------- Status do mês (hero) ---------- */
.status {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.status[data-nivel="ok"] { border-left-color: var(--green); }
.status[data-nivel="atencao"] { border-left-color: var(--amber); }
.status[data-nivel="risco"] { border-left-color: var(--danger); }
.status__chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; margin-bottom: 10px;
}
.status__chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status[data-nivel="ok"] .status__chip { color: var(--green); background: var(--green-bg); }
.status[data-nivel="atencao"] .status__chip { color: var(--amber); background: var(--amber-bg); }
.status[data-nivel="risco"] .status__chip { color: var(--danger); background: var(--danger-bg); }
.status__title {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(17px, 2.4vw, 21px); letter-spacing: -.01em; margin: 0 0 6px;
}
.status__text { color: var(--ink-soft); font-size: 14.5px; margin: 0; max-width: 68ch; }

/* ---------- KPIs ---------- */
.kpis {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px 15px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--muted);
}
.kpi[data-tom="ok"]::after { background: var(--green); }
.kpi[data-tom="atencao"]::after { background: var(--amber); }
.kpi[data-tom="risco"]::after { background: var(--danger); }
.kpi[data-tom="neutro"]::after { background: var(--navy); }
.kpi__label { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; margin: 0 0 8px; }
.kpi__value { font-family: var(--mono); font-weight: 600; font-size: clamp(21px, 3vw, 26px); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi[data-tom="risco"] .kpi__value { color: var(--danger); }
.kpi[data-tom="ok"] .kpi__value { color: var(--green); }
.kpi__note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ---------- Grid de painéis ---------- */
.grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel--wide { grid-column: 1 / -1; }
.panel__head { margin-bottom: 14px; }
.panel__title { font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: -.01em; margin: 0; }
.panel__hint { font-size: 12.5px; color: var(--muted); margin: 3px 0 0; }
.panel__foot { font-size: 12.5px; color: var(--ink-soft); margin: 12px 0 0; }

.chart-wrap { position: relative; width: 100%; height: 300px; }

/* ---------- Ações ---------- */
.actions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.action { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.action:first-child { border-top: 0; }
.action__mark {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
}
.action[data-status="feito"] .action__mark { background: var(--green); }
.action[data-status="andamento"] .action__mark { background: var(--amber); }
.action[data-status="pendente"] .action__mark { background: transparent; border: 1.5px dashed var(--muted); color: var(--muted); }
.action__body { min-width: 0; }
.action__title { font-size: 14px; font-weight: 500; margin: 0; }
.action[data-status="feito"] .action__title { color: var(--ink-soft); }
.action__detail { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }

/* ---------- Empréstimos ---------- */
.loans { display: grid; gap: 10px; margin-bottom: 18px; }
.loan {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 15px; background: var(--surface-2);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: baseline;
}
.loan__name { font-weight: 600; font-size: 14px; }
.loan__parcela { font-family: var(--mono); font-size: 14px; font-weight: 500; text-align: right; white-space: nowrap; }
.loan__parcela small { color: var(--muted); font-weight: 400; }
.loan__note { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 0; }
.tag {
  display: inline-block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: 1px;
}
.tag--resolvido { color: var(--green); background: var(--green-bg); }
.tag--ok { color: var(--green); background: var(--green-bg); }
.tag--atencao { color: var(--amber); background: var(--amber-bg); }
.tag--risco { color: var(--danger); background: var(--danger-bg); }

/* ---------- Cartões ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; background: var(--surface-2);
}
.card__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card__name { font-weight: 600; font-size: 13.5px; }
.card__fatura { font-family: var(--mono); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--line); margin: 10px 0 7px; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 3px; background: var(--navy); }
.bar__fill[data-hot="1"] { background: var(--danger); }
.card__meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.card--idle { opacity: .62; }
.card--idle .card__fatura { color: var(--green); }

/* ---------- Contas fixas ---------- */
.fixed { list-style: none; margin: 0; padding: 0; }
.fixed li { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.fixed li:first-child { border-top: 0; }
.fixed li b { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.fixed .fixed__total { border-top: 2px solid var(--ink); margin-top: 2px; font-weight: 600; }
.fixed .fixed__total b { font-weight: 600; }

/* ---------- Colophon ---------- */
.colophon {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
}
.colophon b { color: var(--ink-soft); font-weight: 600; }
.colophon code {
  font-family: var(--mono); font-size: 12px; background: #eceef3;
  padding: 1px 6px; border-radius: 5px; color: var(--ink-soft);
}

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .panel--wide { grid-column: auto; }
  .masthead__meta { text-align: left; }
  .chart-wrap { height: 260px; }
}

/* ---------- Banner modo local ---------- */
.devbanner {
  background: var(--amber-bg);
  color: var(--amber);
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}
.devbanner code { background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; }

/* ---------- Barra do usuário ---------- */
.userbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px clamp(16px, 4vw, 32px) 0;
}
.userbar__who { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.userbar__out {
  font-family: var(--body);
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}
.userbar__out:hover { background: var(--surface-2); }

/* ---------- Gates (login / loading / sem acesso) ---------- */
.gate {
  min-height: 82vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.gate__box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 44px);
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.gate__title { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 0 0 8px; }
.gate__sub { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 22px; }
.gate__btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--body);
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
}
.gate__btn:hover { filter: brightness(1.08); }
.gate__btn--ghost { color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); }
.gate__g {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  background: #fff; color: var(--navy);
  border-radius: 50%;
  font-family: var(--display); font-weight: 700; font-size: 13px;
}
.gate__err { color: var(--danger); font-family: var(--mono); font-size: 12.5px; margin: 14px 0 0; min-height: 1em; }
.gate__spinner {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: gate-spin .8s linear infinite;
}
@keyframes gate-spin { to { transform: rotate(360deg); } }

/* ---------- Acessibilidade ---------- */
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
