/*
VOICE   painel noturno de mesa de análise: preciso, calmo, números em destaque
IDEA    cockpit financeiro, cada número tem seu instrumento (anel, barras, linha do tempo)
PICTURE anel de saídas x renda no topo; barras de faturas futuras; cartões como objetos
COLOUR  quase preto azulado, teal = folga, índigo/violeta = compromissos, rosa = alerta
TYPE    Inter para texto, JetBrains Mono para valores
*/
:root {
  --bg: #04060c; --shell: #070b15;
  --line: rgba(255,255,255,.07); --line-soft: rgba(255,255,255,.045);
  --panel: rgba(255,255,255,.028); --panel-2: rgba(255,255,255,.045);
  --ink: #e9eef9; --ink-2: #aab6cd; --muted: #6f7b93; --dim: #4d586d;
  --teal: #2fe3c8; --cyan: #38bdf8; --blue: #4f7dff; --indigo: #6366f1; --violet: #8b5cf6;
  --rose: #f43f5e; --rose-2: #fb7185; --amber: #f59e0b;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink);
  font: 15px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(900px 520px at 50% -12%, #0e1834 0%, transparent 62%), var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  overflow-x: clip;
}
.mono { font-family: var(--mono); letter-spacing: -.02em; }

/* ---------- topo ---------- */
header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(4,6,12,.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand svg { width: 22px; height: 22px; }
.brand b { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
#titulo { font-size: 13px; color: var(--muted); font-weight: 500; margin: 0 0 0 4px; }
#titulo::before { content: '/'; color: var(--dim); margin-right: 8px; }
.synced { margin-left: auto; display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-2); background: rgba(47,227,200,.07); border: 1px solid rgba(47,227,200,.18); border-radius: 20px; padding: 4px 10px; }
.synced::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 6px var(--teal); }
.synced.off { background: rgba(244,63,94,.08); border-color: rgba(244,63,94,.22); }
.synced.off::before { background: var(--rose); box-shadow: 0 0 6px var(--rose); }

main { padding: 16px 14px 8px; max-width: 760px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; animation: entra .28s ease-out; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tab.active { animation: none; } }

/* ---------- navegação inferior ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(7,11,21,.88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; justify-content: center;
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 500; border-radius: 12px; position: relative; }
nav.tabs button svg { width: 21px; height: 21px; }
nav.tabs button.active { color: #fff; background: linear-gradient(180deg, rgba(47,227,200,.10), rgba(99,102,241,.06)); }
nav.tabs button.active::before { content: ''; position: absolute; top: 0; width: 22px; height: 2.5px; border-radius: 0 0 3px 3px; background: var(--teal); box-shadow: 0 0 10px var(--teal); }
nav.tabs button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- blocos ---------- */
.card {
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(165deg, rgba(255,255,255,.04), rgba(255,255,255,.012));
  padding: 14px 15px; margin-bottom: 12px; position: relative; overflow: hidden;
}
.card h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card h3 .pill { margin-left: auto; }
.card .sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
h2 { font-size: 11px; margin: 22px 2px 9px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.neg { color: var(--rose-2); } .pos { color: var(--teal); }
.pill { font-family: var(--mono); font-size: 10.5px; padding: 2px 8px; border-radius: 20px; white-space: nowrap;
  background: rgba(47,227,200,.10); color: var(--teal); border: 1px solid rgba(47,227,200,.2); font-weight: 500; }
.pill.warn { background: rgba(245,158,11,.10); color: var(--amber); border-color: rgba(245,158,11,.25); }
.pill.bad { background: rgba(244,63,94,.12); color: var(--rose-2); border-color: rgba(244,63,94,.25); }
.pill.neu { background: rgba(255,255,255,.05); color: var(--ink-2); border-color: var(--line); }
.alert { display: flex; gap: 10px; align-items: flex-start; border: 1px solid rgba(245,158,11,.25); background: rgba(245,158,11,.07);
  color: #fcd38a; border-radius: 12px; padding: 11px 13px; margin-bottom: 12px; font-size: 13px; }
.alert a { color: #fff; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row b { font-family: var(--mono); font-weight: 500; white-space: nowrap; }

/* ---------- herói ---------- */
.hero {
  background: radial-gradient(120% 110% at 85% 120%, rgba(99,102,241,.38) 0%, rgba(59,130,246,.12) 45%, transparent 72%),
    linear-gradient(170deg, rgba(130,120,255,.13), rgba(255,255,255,.012));
  border-color: rgba(139,130,255,.22);
  display: grid; grid-template-columns: minmax(0,1fr) 128px; gap: 6px 14px; align-items: center; padding: 16px 16px 14px;
}
.hero .lbl { font-size: 12px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.hero .big { font-family: var(--mono); font-size: clamp(28px, 9vw, 40px); font-weight: 500; letter-spacing: -.045em; margin: 6px 0 4px; white-space: nowrap; }
.hero .meta { font-size: 12px; color: var(--ink-2); display: grid; gap: 3px; }
.hero .meta b { font-family: var(--mono); color: #fff; font-weight: 500; }
.hero svg.anel { width: 128px; height: 128px; }
.hero .legend { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2);
  background: rgba(8,12,28,.55); border: 1px solid rgba(255,255,255,.08); border-radius: 20px; padding: 4px 9px; white-space: nowrap; }
.legend i { width: 7px; height: 7px; border-radius: 50%; }
.legend b { font-family: var(--mono); color: #fff; font-weight: 500; font-size: 11px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { margin: 0; padding: 12px 13px; }
.kpi .r1 { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .r1 svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.kpi .v { font-family: var(--mono); font-size: clamp(17px, 5.2vw, 22px); font-weight: 500; letter-spacing: -.03em; margin-top: 6px; white-space: nowrap; }
.kpi small { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.meter { height: 5px; border-radius: 5px; background: rgba(255,255,255,.07); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--indigo), var(--cyan), var(--teal)); }
.meter i.quente { background: linear-gradient(90deg, var(--amber), var(--rose)); }

/* ---------- gráficos ---------- */
.fig { position: relative; height: 190px; margin-top: 10px; }
.fig > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fig text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.fig .vlab { fill: var(--ink-2); font-size: 10px; }

/* linha do tempo de vencimentos */
.tl { display: grid; gap: 2px; margin-top: 8px; }
.tl .it { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.tl .it:last-child { border-bottom: 0; }
.tl .dia { text-align: center; border-radius: 11px; padding: 5px 0; background: var(--panel-2); border: 1px solid var(--line); }
.tl .dia b { display: block; font-family: var(--mono); font-size: 16px; font-weight: 500; line-height: 1.1; }
.tl .dia span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tl .dia.hoje { border-color: rgba(244,63,94,.4); background: rgba(244,63,94,.10); }
.tl .dia.hoje span { color: var(--rose-2); }
.tl .nm { font-size: 14px; } .tl .nm small { display: block; color: var(--muted); font-size: 11.5px; }
.tl .vl { font-family: var(--mono); font-weight: 500; white-space: nowrap; }

.ideia { border-color: rgba(47,227,200,.22); background: radial-gradient(120% 140% at 0% 0%, rgba(47,227,200,.12), transparent 60%), linear-gradient(165deg, rgba(255,255,255,.04), rgba(255,255,255,.012)); }
.ideia p { margin: 8px 0 0; font-size: 14px; color: var(--ink); }

/* ---------- cartões ---------- */
.cc { border-radius: 18px; padding: 15px 16px; margin-bottom: 12px; position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,.1);
  background: var(--g, linear-gradient(140deg, #1d2b64, #0d1430)); box-shadow: 0 18px 40px -22px rgba(0,0,0,.9); }
.cc::after { content: ''; position: absolute; right: -40px; top: -60px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.07); pointer-events: none; }
.cc .h { display: flex; align-items: center; gap: 8px; }
.cc .h b { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.cc .h .pill { margin-left: auto; background: rgba(0,0,0,.25); }
.cc .disp { font-family: var(--mono); font-size: 24px; font-weight: 500; letter-spacing: -.03em; margin-top: 12px; }
.cc .disp small { font-family: Inter, sans-serif; font-size: 11.5px; color: rgba(255,255,255,.6); font-weight: 400; letter-spacing: 0; margin-left: 6px; }
.cc .meter { background: rgba(0,0,0,.3); height: 6px; }
.cc .meter i { background: rgba(255,255,255,.85); }
.cc .meter i.quente { background: linear-gradient(90deg, #fbbf24, #fb7185); }
.cc .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cc .chips span { font-size: 11.5px; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.1); border-radius: 20px; padding: 3px 9px; color: rgba(255,255,255,.85); white-space: nowrap; }
.cc .chips b { font-family: var(--mono); font-weight: 500; color: #fff; }
.cc.inativo { filter: grayscale(.8); opacity: .6; }

/* ---------- formulários e botões ---------- */
button.primary, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 10px 16px;
  border-radius: 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
button.primary { color: #03231f; background: linear-gradient(135deg, var(--teal), var(--cyan)); box-shadow: 0 8px 22px -10px rgba(47,227,200,.7); }
.btn.ghost { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.btn.danger { background: rgba(244,63,94,.08); color: var(--rose-2); border-color: rgba(244,63,94,.25); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
label { display: block; font-size: 12px; color: var(--muted); margin-top: 10px; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; margin-top: 4px; border: 1px solid var(--line); border-radius: 11px;
  background: rgba(0,0,0,.3); color: var(--ink); font: inherit; font-size: 16px; }
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; margin: 0 8px 0 0; vertical-align: middle; accent-color: var(--teal); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 10px; }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 28px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .muted { font-family: var(--mono); font-size: 12px; }
details.card[open] > summary { margin-bottom: 4px; }
a { color: var(--teal); }

/* ---------- chat ---------- */
#chat-log { display: flex; flex-direction: column; gap: 10px; padding-bottom: 84px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; font-size: 14.5px; line-height: 1.45; }
.msg.eu { align-self: flex-end; color: #03231f; background: linear-gradient(135deg, var(--teal), var(--cyan)); border-bottom-right-radius: 5px; }
.msg.app { align-self: flex-start; background: linear-gradient(165deg, rgba(255,255,255,.06), rgba(255,255,255,.025)); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.pensando { color: var(--muted); }
.msg.pensando::after { content: '…'; animation: pisca 1.2s infinite; }
@keyframes pisca { 50% { opacity: .2; } }
#chat-form { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 5; display: flex; gap: 8px;
  padding: 10px 12px; background: rgba(4,6,12,.85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line-soft); }
#chat-form input { flex: 1; margin: 0; border-radius: 22px; padding-left: 16px; }
#chat-form button { width: 46px; min-height: 44px; border: 0; border-radius: 50%; color: #03231f; background: linear-gradient(135deg, var(--teal), var(--cyan)); display: grid; place-items: center; }
#chat-form button svg { width: 19px; height: 19px; }
.chips-s { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); border-radius: 20px; padding: 8px 12px; font: inherit; font-size: 13px; min-height: 36px; }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(700px 420px at 50% 0%, #10204a 0%, transparent 65%), var(--bg); }
#login[hidden] { display: none; }
#login form { width: 100%; max-width: 380px; padding: 24px 20px; }
#login h1 { margin: 10px 0 2px; font-size: 26px; letter-spacing: -.03em; }
#login .brand svg { width: 34px; height: 34px; }
#login button { width: 100%; margin-top: 16px; }
body.deslogado header, body.deslogado nav, body.deslogado main { display: none; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: #111a2e; color: var(--ink); border: 1px solid var(--line); padding: 9px 16px; border-radius: 22px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.6); }

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .hero { grid-template-columns: minmax(0,1fr) 150px; } .hero svg.anel { width: 150px; height: 150px; }
  .cards-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 12px; }
}
@media (max-width: 360px) { .hero { grid-template-columns: 1fr; } .hero svg.anel { justify-self: center; } }

/* Cadastro, convite e casa */
.login-troca { text-align: center; margin-top: 14px; }
.login-troca a, a.link { color: var(--teal); }
.convite-link { display: flex; gap: 8px; margin-top: 10px; }
.convite-link input { flex: 1; font-family: var(--mono); font-size: 12px; }
.membro { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.membro:last-child { border-bottom: 0; }
.pill.pes { background: rgba(139,92,246,.12); color: #c4b5fd; border-color: rgba(139,92,246,.3); }
[hidden] { display: none !important; }
