:root {
  --bg: #14090c;
  --bg-2: #1c0d12;
  --surface: #241218;
  --surface-2: #2e1720;
  --line: #3d2029;
  --line-2: #4f2a36;
  --wine: #8e2440;
  --wine-2: #b23a55;
  --wine-3: #d9607c;
  --rose: #f3d9c9;
  --text: #f6ebee;
  --text-2: #c9b1b8;
  --text-3: #8f737b;
  --ok: #5fc59a;
  --ok-bg: rgba(95, 197, 154, .12);
  --warn: #f0b65e;
  --warn-bg: rgba(240, 182, 94, .12);
  --bad: #f07a7a;
  --bad-bg: rgba(240, 122, 122, .12);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #3a1120 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: Fraunces, Georgia, serif; letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(100px + var(--safe-b)); }

.topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 14px; }
.marca { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text-2); font-size: 14px; }
.marca img { width: 28px; height: 28px; }

.mes-nav { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.mes-nav button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; }
.mes-nav button:hover { background: var(--surface-2); color: var(--text); }
.mes-nav span { min-width: 120px; text-align: center; font-weight: 600; font-size: 14px; text-transform: capitalize; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #6d1a32 0%, #3d0e1c 70%, #2a0a14 100%);
  border: 1px solid #7a2a40;
  border-radius: 24px; padding: 20px; margin-bottom: 18px; position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(243, 217, 201, .14), transparent 70%); }
.hero .rot { color: #e9c3cc; font-size: 13px; font-weight: 500; }
.hero .grande { font-size: 36px; font-weight: 600; margin: 2px 0 12px; color: #fff4f0; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hero-grid div { background: rgba(0, 0, 0, .2); border-radius: 12px; padding: 8px 10px; }
.hero-grid small { display: block; color: #d9b3bd; font-size: 11px; }
.hero-grid b { font-size: 14px; font-weight: 600; }
.barra { height: 6px; background: rgba(0, 0, 0, .3); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.barra i { display: block; height: 100%; background: linear-gradient(90deg, var(--rose), #ffb3c2); border-radius: 99px; transition: width .4s; }

/* ---------- Seções ---------- */
.sec-tit { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.sec-tit h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sec-tit span { color: var(--text-3); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.atual { border-color: var(--wine-2); box-shadow: 0 0 0 1px var(--wine-2), var(--shadow); background: linear-gradient(180deg, #2f1520, var(--surface)); }

/* Semana */
.sem-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sem-cab h3 { margin: 0; font-size: 16px; font-weight: 600; }
.sem-cab .datas { color: var(--text-3); font-size: 13px; }
.sem-meta { text-align: right; }
.sem-meta small { display: block; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.sem-meta b { font-size: 22px; font-weight: 600; }

.itens { list-style: none; padding: 0; margin: 12px 0 0; border-top: 1px dashed var(--line-2); }
.itens li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.itens li:last-child { border-bottom: 0; }
.itens li .d { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.itens li .d small { color: var(--text-3); margin-left: 4px; }
.itens li.repasse { color: var(--warn); }
.itens li.repasse .d { color: var(--warn); }
.itens .vazio { color: var(--text-3); justify-content: center; }

.sep { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.sep label { font-size: 12px; color: var(--text-3); display: block; margin-bottom: 4px; }
.sep-acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutro { background: var(--surface-2); color: var(--text-2); }
.pill.vinho { background: rgba(178, 58, 85, .2); color: var(--wine-3); }

/* Lista de contas */
.filtros { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line-2); background: transparent; color: var(--text-2); padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--wine); border-color: var(--wine-2); color: #fff; }

.lista { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.linha { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.linha:last-child { border-bottom: 0; }
.linha .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 16px; background: var(--surface-2); }
.linha .meio { flex: 1; min-width: 0; cursor: pointer; }
.linha .meio b { display: block; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha .meio small { color: var(--text-3); font-size: 12.5px; }
.linha .val { text-align: right; font-weight: 600; white-space: nowrap; }
.linha .val small { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-3); }
.linha.paga .meio b { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.vazio-box { text-align: center; color: var(--text-3); padding: 34px 16px; }
.vazio-box .e { font-size: 30px; margin-bottom: 6px; }

.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-2); background: transparent; display: grid; place-items: center; flex: none; padding: 0; }
.check.on { background: var(--ok); border-color: var(--ok); color: #0d2a1d; }
.check svg { width: 14px; height: 14px; }

/* Cartões */
.cc { border-radius: 20px; padding: 18px; margin-bottom: 12px; color: #fff; position: relative; overflow: hidden; border: 1px solid rgba(255, 255, 255, .08); }
.cc::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255, 255, 255, .14), transparent 55%); pointer-events: none; }
.cc .cc-top { display: flex; justify-content: space-between; align-items: center; position: relative; }
.cc .cc-top b { font-size: 17px; }
.cc .cc-top small { opacity: .8; font-size: 12px; }
.cc .cc-val { font-size: 28px; font-weight: 600; margin: 16px 0 4px; position: relative; }
.cc .cc-sub { font-size: 12.5px; opacity: .85; position: relative; }
.cc .cc-acoes { display: flex; gap: 8px; margin-top: 14px; position: relative; flex-wrap: wrap; }
.cc .cc-acoes button { background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .15); color: #fff; border-radius: 99px; padding: 7px 12px; font-size: 13px; font-weight: 500; }

/* Pessoas */
.pessoas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pessoa { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.pessoa .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--wine); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.pessoa b { display: block; font-size: 14px; }
.pessoa span { color: var(--warn); font-weight: 600; font-size: 15px; }

/* ---------- Botões / forms ---------- */
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.pri { background: linear-gradient(180deg, var(--wine-2), var(--wine)); color: #fff; box-shadow: 0 6px 18px rgba(142, 36, 64, .35); }
.btn.sec { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); }
.btn.fant { background: transparent; color: var(--text-2); }
.btn.perigo { background: var(--bad-bg); color: var(--bad); }
.btn.peq { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; }

.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.inp, select.inp, textarea.inp {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; outline: none; font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--wine-2); box-shadow: 0 0 0 3px rgba(178, 58, 85, .25); }
.inp.dinheiro { font-variant-numeric: tabular-nums; font-weight: 600; }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .sw { width: 40px; height: 24px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.toggle .sw::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; }
.toggle input:checked + .sw { background: var(--wine-2); }
.toggle input:checked + .sw::after { transform: translateX(16px); }

.semanas-sel { display: flex; flex-wrap: wrap; gap: 8px; }
.semanas-sel label { margin: 0; }
.semanas-sel input { display: none; }
.semanas-sel span { display: inline-block; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-2); font-size: 13px; color: var(--text-2); }
.semanas-sel input:checked + span { background: var(--wine); border-color: var(--wine-2); color: #fff; }
.semanas-sel input:disabled + span { opacity: .4; }
.dica { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

.cores { display: flex; gap: 10px; flex-wrap: wrap; }
.cores label input { display: none; }
.cores label span { width: 34px; height: 34px; border-radius: 50%; display: block; border: 3px solid transparent; }
.cores label input:checked + span { border-color: #fff; }

/* ---------- Navegação inferior ---------- */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b));
  width: min(calc(100% - 24px), 520px);
  background: rgba(36, 18, 24, .88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-2); border-radius: 22px; display: flex; padding: 6px; z-index: 20; box-shadow: var(--shadow);
}
.nav button { flex: 1; border: 0; background: transparent; color: var(--text-3); padding: 8px 2px 6px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: #fff; background: linear-gradient(180deg, rgba(178, 58, 85, .45), rgba(142, 36, 64, .25)); }

.fab {
  position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(96px + var(--safe-b)); z-index: 21;
  width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: linear-gradient(180deg, var(--wine-3), var(--wine)); color: #fff; box-shadow: 0 10px 26px rgba(142, 36, 64, .55);
  display: grid; place-items: center;
}
.fab svg { width: 26px; height: 26px; }

/* ---------- Modal (bottom sheet) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 2, 3, .65); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet {
  background: var(--bg-2); border: 1px solid var(--line-2); border-bottom: 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + var(--safe-b)); animation: sobe .22s ease-out;
}
.sheet .alca { width: 42px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 16px; font-size: 20px; font-weight: 600; }
.sheet .acoes { display: flex; gap: 10px; margin-top: 18px; }
.sheet .acoes .btn { flex: 1; }
@media (min-width: 640px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 24px; border-bottom: 1px solid var(--line-2); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes sobe { from { transform: translateY(40px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--surface-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .box { width: 100%; max-width: 380px; text-align: center; }
.login img { width: 64px; height: 64px; margin-bottom: 14px; }
.login h1 { margin: 0 0 6px; font-size: 28px; font-weight: 600; }
.login p { color: var(--text-2); margin: 0 0 22px; }
.login form { text-align: left; }
.erro { color: var(--bad); font-size: 13.5px; margin: -4px 0 12px; min-height: 1em; }

.ajuste-linha { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ajuste-linha + .ajuste-linha { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.ajuste-linha small { display: block; color: var(--text-3); font-size: 12.5px; }
.carregando { display: grid; place-items: center; min-height: 60vh; color: var(--text-3); }
.campo label.toggle { display: inline-flex; margin: 0; }
