/* Tema escuro igual ao Sistema de Férias Nemak */
:root {
  color-scheme: dark;
  --navy: #0b111a;
  --navy-2: #1c2c45;
  --bg: #0f141b;
  --surface: #171e28;
  --surface-2: #1d2632;
  --input-bg: #11171f;
  --fg: #e3e8ef;
  --muted: #8b97a8;
  --border: #2a3544;
  --primary: #4a8fe7;
  --primary-hover: #3576cc;
  --primary-2: #6aa8f5;
  --good: #3fbf7a;
  --good-bg: rgba(63, 191, 122, .15);
  --bad: #f2626d;
  --bad-bg: rgba(242, 98, 109, .15);
  --warn: #f0a93b;
  --warn-bg: rgba(240, 169, 59, .15);
  --accent: #f0a93b;
  --radius: 12px;
  --shadow: none;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
body.app { padding-bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
a { color: var(--primary-2); text-decoration: none; }
h1 { font-size: 1.45rem; margin: .2em 0 .5em; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .3em; }
h3 { font-size: 1rem; margin: 0 0 .7em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.ico { width: 20px; height: 20px; flex: none; vertical-align: -4px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 14px; padding-top: calc(14px + env(safe-area-inset-top)); }

/* ---------- Navegação inferior (celular e computador) ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--navy); border-top: 1px solid var(--border);
}
.bottomnav > a, .bottomnav summary {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; color: var(--muted); cursor: pointer; list-style: none;
}
.bottomnav summary::-webkit-details-marker { display: none; }
.bottomnav .on, .bottomnav .on summary { color: var(--primary-2); }
.bottomnav .ico { width: 24px; height: 24px; }
.bottomnav .fab {
  justify-self: center; width: 54px; height: 54px; border-radius: 50%;
  background: var(--primary); color: #fff; justify-content: center;
  box-shadow: 0 4px 14px rgba(74, 143, 231, .35); transform: translateY(-10px);
}
.bottomnav .fab .ico { width: 28px; height: 28px; }
.more { position: relative; }
.more .sheet {
  position: absolute; right: 8px; bottom: calc(100% + 10px);
  min-width: 200px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); padding: 6px;
}
.more .sheet a, .more .sheet button {
  display: flex; gap: 10px; align-items: center; width: 100%;
  padding: 12px; border-radius: 8px; color: var(--fg); font: inherit;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.more .sheet a:hover, .more .sheet button:hover { background: rgba(255, 255, 255, .05); }
.more .sheet form { margin: 0; }

@media (min-width: 900px) {
  /* No computador a barra fica centralizada, com a mesma largura de um celular grande. */
  .bottomnav { padding-left: calc(50% - 300px); padding-right: calc(50% - 300px); }
}
@media (max-width: 899px) { .hide-m { display: none !important; } }

/* ---------- Cartões / blocos ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px;
}
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between h1, .row-between h2, .row-between h3 { margin-bottom: .3em; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; }
.flash-ok { background: var(--good-bg); color: var(--good); }
.flash-erro { background: var(--bad-bg); color: var(--bad); }

/* Hero: fatura aberta */
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.hero h1 { margin: 0; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.hero-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 8px; }
.lbl { display: block; font-size: .78rem; color: var(--muted); }
.big { font-size: 1.45rem; }
.hero-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: .9rem; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpis-2 { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 12px; }
.kpi strong { display: block; font-size: 1.15rem; margin-top: 2px; }
.kpi small { color: var(--muted); font-size: .78rem; }
.kpi-bad { border-left-color: var(--bad); }
.kpi-bad strong { color: var(--bad); }
.kpi-good { border-left-color: var(--good); }
.kpi-good strong { color: var(--good); }

/* Barras */
.bar { position: relative; height: 8px; background: var(--border); border-radius: 99px; overflow: visible; margin: 6px 0; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--primary-2); }
.bar.good > span { background: var(--good); }
.bar.bad > span { background: var(--bad); }
.bar.warn > span { background: var(--warn); }
.bar.accent > span { background: var(--accent); }
.bar > i { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--fg); opacity: .55; border-radius: 2px; }
.hero .bar { height: 12px; }

/* Segmentado (período) */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg a { padding: 6px 10px; border-radius: 7px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.seg a.on { background: var(--primary); color: #fff; }

/* Listas do painel */
.insights { margin: 0; padding-left: 18px; }
.insights li { margin-bottom: 8px; }
.fat-list, .cat-list { display: grid; gap: 14px; }
.fat, .cat { color: inherit; display: block; }
.fat-top, .cat-top { display: flex; justify-content: space-between; gap: 10px; }
.fat-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--muted); }
.cat-sub { font-size: .8rem; }
@media (min-width: 900px) { .cat-list { grid-template-columns: 1fr 1fr; column-gap: 28px; } }

.rank { margin: 0; padding: 0; list-style: none; counter-reset: r; }
.rank li { counter-increment: r; border-top: 1px solid var(--border); }
.rank li:first-child { border-top: 0; }
.rank a { display: flex; gap: 10px; align-items: center; padding: 10px 0; color: inherit; }
.rank a::before { content: counter(r); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .78rem; color: var(--muted); flex: none; }
.rank-name { flex: 1; min-width: 0; }
.rank-name small { display: block; }

/* Lançamentos */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.filters .grow { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: 160px 1fr 140px 2fr auto; } .filters .grow { grid-column: auto; } }
.summary { display: flex; justify-content: space-between; padding: 0 4px 8px; font-size: .9rem; }
.tx-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tx-day { padding: 8px 14px; font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--border); text-transform: uppercase; letter-spacing: .3px; }
.tx-day:first-child { border-top: 0; }
.tx { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; color: inherit; border-top: 1px solid var(--border); }
.tx-day + .tx { border-top: 0; }
.tx:hover { background: var(--surface-2); }
.tx-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tx-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-val { white-space: nowrap; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: rgba(74, 143, 231, .16); font-size: .75rem; color: var(--primary-2); }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip-ok { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* Formulários */
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
label small { font-weight: 400; }
input, select, button { font: inherit; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=month], input[type=tel], select {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--input-bg); color: var(--fg); font-size: 16px; font-weight: 400;
}
input:focus, select:focus { outline: 2px solid var(--primary-2); outline-offset: 0; border-color: transparent; }
.input-money { text-align: right; font-variant-numeric: tabular-nums; }
.input-sm { min-height: 38px !important; padding: 6px 10px !important; }
.form { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .form { grid-template-columns: 1fr 1fr; } .form .span2 { grid-column: 1 / -1; } }
.form-compact { margin-top: 12px; }
.form .input-money[name=valor] { font-size: 1.6rem; min-height: 56px; font-weight: 600; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
.check input { width: 20px; height: 20px; }
.parc-box { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--border); border-radius: 10px; }
.form-actions { margin-top: 4px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.inline-form input[type=text] { flex: 1; min-width: 0; }
.add-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.danger-zone { margin: 0 0 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; min-height: 48px; }
.sticky-save { position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); margin: 12px 0; z-index: 5; }
@media (min-width: 900px) { .sticky-save { max-width: 320px; margin-left: auto; } }

details > summary { cursor: pointer; }
.manage-list details { border-top: 1px solid var(--border); padding: 10px 0; }
.manage-list details:first-child { border-top: 0; }

/* Tabela que vira cartões no celular */
.table-wrap { margin-bottom: 0; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
.tbl th, .tbl td { padding: 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th { font-size: .78rem; color: var(--muted); font-weight: 600; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .bar { min-width: 120px; }
.tbl input.input-money { width: 110px; }
@media (min-width: 900px) {
  .table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
}
@media (max-width: 899px) {
  .tbl-cards, .tbl-cards tbody, .tbl-cards tfoot, .tbl-cards tr, .tbl-cards td { display: block; width: 100%; }
  .tbl-cards { background: none; }
  .tbl-cards thead { display: none; }
  .tbl-cards tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; padding: 8px 14px; box-shadow: var(--shadow); }
  .tbl-cards td { border: 0; padding: 5px 0; }
  .tbl-cards td.num { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .tbl-cards td.num::before { content: attr(data-l); color: var(--muted); font-size: .85rem; }
  .tbl-cards td:empty { display: none; }
}

/* Lojas */
.store-list { display: grid; gap: 10px; }
.store { display: block; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.store-top { display: flex; justify-content: space-between; gap: 10px; }
.store-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
@media (min-width: 900px) { .store-list { grid-template-columns: 1fr 1fr; } }

/* Parcelas */
.cal { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; text-align: center; }
.cal-col { display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: .8rem; }
.cal-bar { height: 110px; width: 100%; max-width: 46px; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.cal-bar span { display: block; width: 100%; background: var(--accent); border-radius: 8px 8px 0 0; }
.parc-list { display: grid; gap: 4px; }
.parc { border-top: 1px solid var(--border); padding: 10px 0; }
.parc:first-child { border-top: 0; }
.parc > summary { list-style: none; }
.parc > summary::-webkit-details-marker { display: none; }
.parc-top { display: flex; justify-content: space-between; gap: 10px; }
.parc-sub { display: flex; flex-wrap: wrap; gap: 2px 14px; }

/* Plano */
.fixas { display: grid; gap: 2px; }
.fixa { display: flex; align-items: center; gap: 6px; }
.fixa .inline-form { flex: 1; margin: 4px 0; }
.fixa form { margin: 0; }
.fixa .input-sm { width: 110px; flex: none; }
.months { display: grid; gap: 10px; }
@media (min-width: 900px) { .months { grid-template-columns: 1fr 1fr; } }
.month { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.month.is-current { border-color: var(--primary-2); box-shadow: 0 0 0 1px var(--primary-2) inset; }
.month.st-ok { background: var(--good-bg); }
.month.st-bad { background: var(--bad-bg); }
.month-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.month-grid label { font-size: .75rem; }
.month-info { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 8px; }

/* Login */
body.guest { display: grid; min-height: 100vh; place-items: center; }
.auth { width: 100%; max-width: 380px; padding: 16px; }
.auth h1 { text-align: center; color: var(--primary); }
.auth .card { display: grid; gap: 14px; }

/* Gastos do mês (página inicial) */
.gm h2 { margin: 0; }
.gm-head { margin-bottom: 10px; }
.gm-total { text-align: right; }
.gm-total strong { display: block; font-size: 1.35rem; color: var(--primary-2); }
.quick {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "valor valor" "desc desc" "cat cat" "cartao data" "btn btn";
  padding: 12px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.q-valor { grid-area: valor; }
.q-desc { grid-area: desc; }
.q-cat { grid-area: cat; }
.q-cartao { grid-area: cartao; }
.q-data { grid-area: data; }
.q-btn { grid-area: btn; min-height: 48px; }
.q-valor input { font-size: 1.4rem !important; font-weight: 600; }
@media (min-width: 900px) {
  .quick { grid-template-columns: 140px 1fr 220px 120px 160px auto; grid-template-areas: "valor desc cat cartao data btn"; }
  .q-valor input { font-size: 1.1rem !important; }
  .q-btn { min-height: 44px; }
}
.gm-list { display: grid; }
.gm-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); color: inherit; }
.gm-item:first-child { border-top: 0; }
.gm-item:hover { background: var(--surface-2); }
.gm-dia { font-size: .8rem; color: var(--muted); width: 40px; flex: none; font-variant-numeric: tabular-nums; }
.gm-desc { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gm-desc b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-val { white-space: nowrap; }
.gm-mais { display: block; margin-top: 8px; }
.gm-vazio { margin: 4px 0 0; }
#gm-msg .flash { margin: 0 0 10px; }

/* Aviso de instalação do app (igual ao HPDC), acima da barra de navegação */
.aviso-instalar {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 70; width: min(520px, calc(100% - 24px));
  transform: translate(-50%, 160%); opacity: 0; transition: transform .3s ease, opacity .3s ease;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
body.guest .aviso-instalar { bottom: calc(14px + env(safe-area-inset-bottom)); }
.aviso-instalar.visivel { transform: translate(-50%, 0); opacity: 1; }
.aviso-instalar img { border-radius: 10px; flex-shrink: 0; }
.aviso-instalar-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.aviso-instalar-texto strong { font-size: 14px; }
.aviso-instalar-texto span { color: var(--muted); line-height: 1.4; }
.aviso-instalar-texto b { color: var(--fg); }
.aviso-instalar-acoes { display: flex; align-items: center; gap: 4px; }
.aviso-instalar-btn {
  padding: 8px 16px; border-radius: 999px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--primary); border: 1px solid var(--primary); color: #fff;
}
.aviso-instalar-btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.aviso-fechar { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 4px 6px; cursor: pointer; }
.ico-share { width: 16px; height: 16px; vertical-align: -3px; color: var(--primary-2); }

/* Avisos no WhatsApp */
.wa-item { padding: 8px 0; border-top: 1px solid var(--border); }
.wa-item:first-child { border-top: 0; }
.wa-nome { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-add { margin-top: 12px; }
.wa-passos { padding-left: 20px; margin: 10px 0; line-height: 1.6; }
.alerta-wa {
  display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; padding: 14px 16px;
  background: var(--bad-bg); border: 1px solid var(--bad); border-radius: var(--radius); color: var(--fg);
}
.alerta-wa strong { color: var(--bad); }
.alerta-wa span { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.alerta-wa .alerta-acao { color: var(--bad); font-weight: 600; }
