:root {
  --bg: #0b1220;
  --bg2: #0f172a;
  --card: #131c30;
  --card2: #1a2540;
  --line: #243149;
  --txt: #e8eefc;
  --muted: #8fa0bf;
  --brand: #3b82f6;
  --brand2: #2563eb;
  --green: #22c55e;
  --green-bg: #0f2a1c;
  --red: #ef4444;
  --red-bg: #2a1416;
  --amber: #f59e0b;
  --amber-bg: #2a2110;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #16233f 0%, var(--bg) 55%);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px;
  box-shadow: var(--shadow);
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.brand-logo {
  width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center;
  font-size: 26px; background: linear-gradient(135deg, var(--brand), #1e40af);
  box-shadow: 0 6px 20px rgba(59,130,246,.4);
}
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.brand p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
form label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line);
  color: var(--txt); padding: 15px 15px; border-radius: 13px; font-size: 16.5px;
  font-family: inherit; outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
input::placeholder, textarea::placeholder { color: #5f7093; }
.btn-primary {
  width: 100%; margin-top: 22px; background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff; border: none; padding: 14px; border-radius: 12px; font-size: 15.5px;
  font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(37,99,235,.4);
}
.btn-primary:active { transform: translateY(1px); }
.erro { color: #fca5a5; font-size: 13px; margin-top: 12px; text-align: center; min-height: 16px; }
.login-foot { color: var(--muted); font-size: 12px; margin-top: 20px; }

/* ---------- APP SHELL ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }               /* escondida no mobile */
.app-main { min-height: 100dvh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; padding: 16px 18px 14px; padding-top: calc(16px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--bg) 60%, rgba(11,18,32,.6));
  backdrop-filter: blur(8px);
}
.topbar-title { font-size: 25px; font-weight: 800; letter-spacing: -.4px; }
.topbar-sub { font-size: 13px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.topbar-user {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  padding: 10px 16px; border-radius: 11px; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
main { padding: 4px 16px 20px; }
#banners { padding: 0 16px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex;
  background: rgba(15,23,42,.94); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; padding: 5px 1px; border-radius: 10px; min-width: 0;
  letter-spacing: -.2px;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--brand); }
@media (min-width: 400px) { .tab { font-size: 11px; } .tab span { font-size: 22px; } }

/* ---------- SIDEBAR (desktop) ---------- */
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; font-weight: 800; font-size: 16px; }
.side-brand img { border-radius: 9px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 14px 15px; border-radius: 12px; font-size: 16px; font-weight: 600;
  font-family: inherit; transition: background .15s, color .15s;
}
.nav-item .ic { font-size: 21px; }
.nav-item:hover { background: var(--card); color: var(--txt); }
.nav-item.active { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  box-shadow: 0 6px 18px rgba(37,99,235,.35); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }
.side-notif { background: var(--card); border: 1px solid var(--line); color: #93c5fd;
  padding: 11px; border-radius: 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.side-logout { background: var(--card); border: 1px solid var(--line); color: var(--muted);
  padding: 11px; border-radius: 12px; font-size: 13px; font-weight: 600; cursor: pointer; }

/* ---------- BANNERS (instalar / notificações) ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; margin: 10px 0 4px;
  background: linear-gradient(135deg, #10233f, #0d1a30); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.banner .b-ico { font-size: 22px; }
.banner .b-txt { flex: 1; }
.banner .b-txt b { font-size: 13.5px; }
.banner .b-txt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.banner .b-act { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  border: none; padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.banner .b-x { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 4px; }

/* ---------- CARDS / GENERIC ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card-hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-hd h3 { font-size: 15px; font-weight: 700; }
.section-title { font-size: 13.5px; color: var(--muted); font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; margin: 20px 4px 11px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px;
}
.stat .lbl { font-size: 13px; color: var(--muted); font-weight: 600; line-height: 1.35; }
.stat .val { font-size: clamp(17px, 5.2vw, 24px); font-weight: 800; margin-top: 7px; letter-spacing: -.6px;
  white-space: nowrap; }
.stat.big { grid-column: 1 / -1; background: linear-gradient(135deg, #10233f, #0d1a30); }
.stat.big .val { font-size: clamp(26px, 9vw, 34px); }
/* Quanto maior o valor, menor a fonte — cabe sempre numa linha só */
.stat .val.sz2 { font-size: clamp(15px, 4.6vw, 21px); letter-spacing: -.8px; }
.stat .val.sz3 { font-size: clamp(13px, 4vw, 18px); letter-spacing: -.8px; }
.stat .val.sz4 { font-size: clamp(11px, 3.4vw, 16px); letter-spacing: -.8px; }
.stat.big .val.sz2 { font-size: clamp(23px, 8vw, 30px); }
.stat.big .val.sz3 { font-size: clamp(20px, 7vw, 26px); }
.stat.big .val.sz4 { font-size: clamp(17px, 6vw, 22px); }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  padding: 5px 11px; border-radius: 99px; }
.pill.green { background: var(--green-bg); color: #4ade80; }
.pill.red { background: var(--red-bg); color: #fca5a5; }
.pill.amber { background: var(--amber-bg); color: #fcd34d; }
.pill.blue { background: #10233f; color: #93c5fd; }
.pill.gray { background: #1c2536; color: var(--muted); }

.list-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 15px;
  padding: 16px; margin-bottom: 11px; cursor: pointer; transition: border .15s, transform .1s;
}
.list-item:active { border-color: var(--brand); transform: scale(.99); }
.li-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.li-title { font-size: 16.5px; font-weight: 700; }
.li-sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.li-row { display: flex; justify-content: space-between; margin-top: 11px; font-size: 14.5px; }
.li-row .k { color: var(--muted); }

.money { font-variant-numeric: tabular-nums; font-weight: 700; }

/* dica/ajuda abaixo de um campo */
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.field .hint { margin-bottom: 2px; }

/* Botão flutuante "estendido" com rótulo — mais fácil de entender */
.fab {
  position: fixed; right: 18px; bottom: 92px; z-index: 25;
  height: 58px; padding: 0 22px 0 20px; border-radius: 30px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  font-size: 16.5px; font-weight: 700; font-family: inherit;
  box-shadow: 0 10px 26px rgba(37,99,235,.55);
  display: inline-flex; align-items: center; gap: 9px;
}
.fab .fab-plus { font-size: 26px; line-height: 1; margin-top: -2px; }
.fab:active { transform: translateY(1px); }

.filters { display: flex; gap: 9px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; background: var(--card); border: 1px solid var(--line); color: var(--muted);
  padding: 10px 17px; border-radius: 99px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 44px 20px; font-size: 15px; line-height: 1.5; }
.empty .ico { font-size: 46px; display: block; margin-bottom: 12px; opacity: .6; }
.empty .btn-primary { display: inline-block; width: auto; padding: 13px 24px; margin-top: 16px; font-size: 15.5px; }

/* atalhos rápidos (dashboard) */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 11px; margin: 14px 0 4px; }
.quick button {
  display: flex; align-items: center; gap: 11px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  padding: 15px 16px; border-radius: 15px; font-size: 15px; font-weight: 700; font-family: inherit;
  transition: border-color .15s, transform .1s;
}
.quick button:active { transform: scale(.98); border-color: var(--brand); }
.quick button .qi { font-size: 24px; }
.quick button small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }

/* progress bar */
.bar { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #60a5fa); }

/* ---------- MODAL ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-width: 560px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; max-height: 92dvh; overflow-y: auto;
  animation: up .22s ease; padding-bottom: env(safe-area-inset-bottom);
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head {
  position: sticky; top: 0; background: var(--bg2); display: flex; justify-content: space-between;
  align-items: center; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); z-index: 2;
}
.modal-head h3 { font-size: 19px; font-weight: 800; }
.modal-x { background: var(--card); border: 1px solid var(--line); color: var(--muted);
  width: 34px; height: 34px; border-radius: 10px; font-size: 15px; cursor: pointer; }
.modal-body { padding: 16px 18px 24px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; color: var(--muted); font-weight: 600; margin-bottom: 7px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.switch { position: relative; width: 48px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.slider::before { content: ''; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn { flex: 1; padding: 15px; border-radius: 13px; font-size: 16.5px; font-weight: 700; cursor: pointer; border: none; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); color: var(--txt); }
.btn.danger { background: var(--red-bg); border: 1px solid #4a2226; color: #fca5a5; flex: 0 0 auto; padding: 13px 16px; }
.btn.save { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }

.sub-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 0;
  border-bottom: 1px solid var(--line); }
.sub-line:last-child { border-bottom: none; }
.sub-line .l { font-size: 15px; }
.sub-line .l small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 99;
  background: #1e293b; border: 1px solid var(--line); color: var(--txt);
  padding: 12px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); animation: up .2s;
}
.mini-add { background: none; border: 1px dashed var(--line); color: var(--brand);
  width: 100%; padding: 11px; border-radius: 12px; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.cat-tag { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: #1c2536; color: var(--muted); font-weight: 600; }

/* ---------- AGENDA ---------- */
.agenda-item { display: flex; gap: 12px; align-items: stretch; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.agenda-item.done { opacity: .55; }
.agenda-when { flex: 0 0 56px; text-align: center; border-right: 1px solid var(--line); padding-right: 10px;
  display: flex; flex-direction: column; justify-content: center; }
.agenda-when .d { font-size: 20px; font-weight: 800; line-height: 1; }
.agenda-when .m { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-top: 2px; }
.agenda-when .h { font-size: 12px; color: var(--brand); font-weight: 700; margin-top: 4px; }
.agenda-body { flex: 1; min-width: 0; }
.agenda-body .t { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.agenda-body .s { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.day-head { font-size: 12.5px; color: var(--muted); font-weight: 700; margin: 16px 4px 8px; text-transform: capitalize; }
.vencer-item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.vencer-item.atras { border-color: #4a2226; background: var(--red-bg); }

/* ---------- GASTOS ---------- */
.gasto-item { display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 9px; cursor: pointer;
  transition: border-color .15s, transform .1s; }
.gasto-item:active { border-color: var(--brand); transform: scale(.99); }
.gasto-item .g-ico { flex: 0 0 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-size: 21px; background: var(--bg2); }
.gasto-item .g-body { flex: 1; min-width: 0; }
.gasto-item .g-top { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gasto-item .g-sub { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap; }
.gasto-item .money { white-space: nowrap; }

/* ---------- CARD DE NOTIFICAÇÕES (Início) ---------- */
.notif-card { display: flex; align-items: center; gap: 12px; margin: 12px 0 2px;
  background: linear-gradient(135deg, #10233f, #0d1a30); border: 1px solid var(--line);
  border-radius: 15px; padding: 14px 15px; }
.notif-card.ok { border-color: #1c4a33; background: linear-gradient(135deg, #0f2a1c, #0d1f18); }
.notif-card.warn { border-color: #4a3a1a; background: var(--amber-bg); }
.notif-card.ios { border-color: #23406b; }
.notif-card .nc-ico { font-size: 24px; }
.notif-card .nc-txt { flex: 1; min-width: 0; }
.notif-card .nc-txt b { font-size: 14.5px; }
.notif-card .nc-txt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.4; }
.notif-card .nc-btn { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  border: none; padding: 11px 18px; border-radius: 11px; font-size: 14px; font-weight: 700; cursor: pointer;
  white-space: nowrap; }
.notif-card.ok .nc-btn { background: var(--green); }

/* ---------- DESKTOP ---------- */
@media (min-width: 900px) {
  body { background: radial-gradient(1400px 700px at 20% -10%, #16233f 0%, var(--bg) 55%); }
  .app { display: grid; grid-template-columns: 252px 1fr; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
    padding: 22px 16px; border-right: 1px solid var(--line); background: rgba(15,23,42,.6); backdrop-filter: blur(8px); }
  .tabbar { display: none; }
  .app-main { padding-bottom: 28px; }
  .topbar { padding: 22px 32px 16px; background: none; backdrop-filter: none; }
  .topbar-user { display: none; }
  .topbar-title { font-size: 26px; }
  main { padding: 6px 32px 28px; }
  #banners { padding: 0 32px; }
  .grid2 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .stat.big { grid-column: auto; }
  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
  .cards .list-item, .cards .agenda-item { margin-bottom: 0; }
  .section-title { margin-left: 4px; }
  .fab { right: 32px; bottom: 32px; }
  /* modal centralizado como diálogo no desktop */
  .modal-wrap { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; max-width: 640px; max-height: 88vh; animation: pop .18s ease; }
  @keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
  .card, .stat { transition: border-color .15s; }
}

@media (min-width: 1500px) {
  .app { grid-template-columns: 280px 1fr; }
  main, .topbar, #banners { padding-left: 48px; padding-right: 48px; }
}
