/* ============================================================
   Estilos compartilhados entre resumo.html, lancamentos.html e
   fechamento.html — tokens de cor, sidebar de navegação, topbar,
   painéis e componentes comuns (forms, chips, empty states).
   ============================================================ */

:root {
  --bg: #0a0613;
  --panel: #150c26;
  --panel-2: #1c1234;
  --border: #2c1c48;
  --green: #39ff9d;
  --green-dim: #0f3d29;
  --purple: #b26bff;
  --purple-dim: #2e1257;
  --text: #f1ecff;
  --muted: #8b7fab;
  --saida: #ff5577;
  --entrada: #39ff9d;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}
a { color: inherit; }

body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(600px 400px at 8% 0%, color-mix(in srgb, var(--green) 12%, transparent), transparent 60%),
    radial-gradient(700px 500px at 100% 20%, color-mix(in srgb, var(--purple) 16%, transparent), transparent 60%);
}

.app-shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

/* ---------------- sidebar de navegação (comum às 3 telas) ---------------- */
.sidebar {
  width: 210px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar .brand {
  font-weight: 800; font-size: 17px; letter-spacing: .03em; padding: 0 8px 22px;
  background: linear-gradient(90deg, var(--green), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.sidebar nav a .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .6; }
.sidebar nav a:hover { color: var(--text); background: var(--panel-2); }
.sidebar nav a.active {
  color: var(--bg); font-weight: 700;
  background: linear-gradient(90deg, var(--green), var(--purple));
}
.sidebar nav a.active .dot { background: var(--bg); opacity: 1; }
.nav-section {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  padding: 14px 12px 4px; opacity: .7;
}
.sidebar nav a.nav-sub { padding-left: 22px; font-size: 13px; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar-footer a {
  display: block; font-size: 12.5px; color: var(--muted); text-decoration: none; padding: 8px 12px;
}
.sidebar-footer a:hover { color: var(--green); }

/* ---------------- main / topbar ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 26px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 60%, transparent);
  position: sticky; top: 0; backdrop-filter: blur(6px); z-index: 3;
}
.search-box {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px;
}
.search-box svg { flex-shrink: 0; opacity: .6; }
.search-box input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 13.5px; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2); cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--green); border-color: var(--green); }
.mes-picker {
  display: flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 4px 4px 12px;
}
.mes-picker button {
  width: 26px; height: 26px; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 14px;
  border-radius: 6px;
}
.mes-picker button:hover { color: var(--green); background: var(--panel); }
.mes-picker input[type="month"] {
  background: none; border: none; color: var(--text); font-size: 13px; outline: none; cursor: pointer;
  font-family: inherit; padding: 4px 2px; color-scheme: dark;
}
.pill-link {
  font-size: 12.5px; font-weight: 700; padding: 9px 16px; border-radius: 999px; text-decoration: none;
  background: linear-gradient(90deg, var(--green), var(--purple)); color: #08050f;
}

.content { padding: 24px 26px 60px; }
.crumb { font-size: 11.5px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-bottom: 18px; }
.crumb b { color: var(--text); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.panel h2 {
  margin: 0 0 14px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
}

.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 24px 0; }
.sync-note { font-size: 11.5px; color: var(--muted); margin-bottom: 18px; }
.sync-note.erro { color: var(--saida); }

/* saldo real (usado no Resumo) */
.saldo-real {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-bottom: 20px;
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border); border-radius: 16px; padding: 18px 22px;
}
.saldo-real .principal { display: flex; flex-direction: column; gap: 2px; }
.saldo-real .principal .label {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.saldo-real .principal .valor { font-size: 30px; font-weight: 800; }
.saldo-real .contas { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.saldo-conta { display: flex; flex-direction: column; gap: 1px; padding: 6px 14px; border-left: 1px solid var(--border); }
.saldo-conta .nome { font-size: 11px; color: var(--muted); }
.saldo-conta .valor { font-size: 15px; font-weight: 700; }
.saldo-conta .valor.credito { color: var(--saida); }
.saldo-real .atualizado { font-size: 10.5px; color: var(--muted); margin-left: auto; align-self: flex-end; }
.saldo-real.erro { color: var(--saida); font-size: 13px; }

/* previstos (usado no Resumo) */
.previstos-panel { margin-bottom: 20px; }
.previstos-panel h2 button {
  font-size: 11px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--muted); cursor: pointer;
}
.previstos-panel h2 button:hover { color: var(--green); border-color: var(--green); }
.previstos-row { display: flex; gap: 12px; flex-wrap: wrap; }
.previsto-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--border); min-width: 220px;
}
.previsto-chip .status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.previsto-chip.recebido .status-dot { background: var(--green); }
.previsto-chip.aguardando .status-dot { background: var(--muted); }
.previsto-chip .info { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.previsto-chip .desc { font-size: 12.5px; font-weight: 600; }
.previsto-chip .meta { font-size: 10.5px; color: var(--muted); }
.previsto-chip .valor { font-size: 13px; font-weight: 700; color: var(--entrada); }
.previsto-chip .valor.saida { color: var(--saida); }
.previsto-chip button.excluir { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.previsto-chip button.excluir:hover { color: var(--saida); }

.previsto-form {
  display: none; gap: 8px; margin-top: 12px; padding: 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border); flex-wrap: wrap;
}
.previsto-form.aberto { display: flex; }
.previsto-form input, .previsto-form select {
  padding: 7px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 12.5px; outline: none;
}
.previsto-form input:focus, .previsto-form select:focus { border-color: var(--purple); }
.previsto-form input[name="descricao"] { flex: 1; min-width: 140px; }
.previsto-form input[name="valor"] { width: 100px; }
.previsto-form input[name="dia_mes"] { width: 70px; }
.previsto-form button[type="submit"] {
  padding: 7px 16px; border: none; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 12.5px;
  background: linear-gradient(90deg, var(--green), var(--purple)); color: #08050f;
}

/* stat cards com anel (usado no Resumo) */
.stats-row { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(240px, 1.6fr); gap: 16px; margin-bottom: 20px; }
.ring-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.ring {
  width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--ring-color, var(--green)) calc(var(--pct, 60) * 1%), var(--panel-2) 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--panel); }
.ring span { position: relative; font-size: 15px; font-weight: 800; }
.ring-card .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.ring-card .sub { font-size: 12.5px; color: var(--text); font-weight: 600; }

.balance-card { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.balance-card .top { display: flex; align-items: baseline; justify-content: space-between; }
.balance-card .value { font-size: 26px; font-weight: 800; }
.balance-card .value.pos { color: var(--green); }
.balance-card .value.neg { color: var(--saida); }
.balance-card .pct { font-size: 13px; color: var(--muted); }
.gauge { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.gauge > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--purple)); border-radius: 999px; }
.balance-card .hint { font-size: 11.5px; color: var(--muted); }

/* linhas de lançamento (usado em Lançamentos) */
.activity-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-desc { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.activity-valor { font-size: 13px; font-weight: 700; }
.activity-valor.entrada { color: var(--entrada); }
.activity-valor.saida { color: var(--saida); }
.activity-actions { display: flex; gap: 6px; align-items: center; }
.activity-actions select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 6px; font-size: 11px; max-width: 130px;
}

/* categorias (usado em Lançamentos) */
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; font-size: 13px; }
.cat-item:hover { background: var(--panel-2); }
.cat-item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cat-item .nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .tipo-tag { font-size: 9.5px; color: var(--muted); text-transform: uppercase; }

.cat-form { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.cat-form input[type="text"], .cat-form select {
  width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 12.5px; outline: none;
}
.cat-form input[type="text"]:focus, .cat-form select:focus { border-color: var(--purple); }
.cat-form-row { display: flex; gap: 6px; }
.cat-form input[type="color"] {
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 7px;
  background: var(--panel-2); cursor: pointer;
}
.cat-form button {
  padding: 8px; border: none; border-radius: 7px; cursor: pointer; font-weight: 700; font-size: 12.5px;
  background: linear-gradient(90deg, var(--green), var(--purple)); color: #08050f;
}
.cat-form .msg { font-size: 11px; min-height: 14px; }
.cat-form .msg.erro { color: var(--saida); }
.cat-form .msg.ok { color: var(--green); }

/* calendário (usado em Fechamento) */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.cal-nav button:hover { color: var(--green); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 11px; }
.cal-grid .dow { color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--text); position: relative; }
.cal-day.muted { color: var(--muted); opacity: .35; }
.cal-day.today { border: 1px solid var(--purple); }
.cal-day.has-tx::after { content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--green); }

/* anéis de categorias (usado em Fechamento) */
.rings-row { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 14px; }
.mini-ring-card { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 70px; }
.mini-ring {
  width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--ring-color, var(--purple)) calc(var(--pct, 0) * 1%), var(--panel-2) 0);
}
.mini-ring span { font-size: 11px; font-weight: 800; background: var(--panel); width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.mini-ring-card .label { font-size: 9.5px; color: var(--muted); text-align: center; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70px; }

/* ---------------- menu no mobile: vira gaveta deslizante ---------------- */
.hamburger-btn { display: none; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 39;
}

@media (max-width: 980px) {
  .hamburger-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 16px;
  }
  .sidebar {
    display: none; position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; z-index: 40;
    box-shadow: 10px 0 30px rgba(0,0,0,.5);
  }
  .sidebar.aberta { display: flex; }
  .sidebar-backdrop.aberta { display: block; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
