/* Visual: fundo claro, uma cor de marca (azul) e tons de cinza. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e8eaee;
  --brand: #1463ff;
  --brand-ink: #0b4fd9;
  --brand-soft: #eef3ff;
  --brand-mid: #b9cdfc;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 2px 10px rgba(17, 24, 39, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, select, input { font: inherit; color: inherit; }
h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; margin: 8px 0 12px; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.ic { display: block; flex: none; }
/* Valores: entrada em azul, saída no tom do texto (o sinal de menos já diz). */
.in { color: var(--brand); }
.out { color: var(--text); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(246, 247, 249, .9);
  backdrop-filter: blur(12px);
}
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.top-actions { display: flex; gap: 6px; }
.top-left { display: flex; align-items: center; gap: 8px; }
.back-btn { width: 32px; height: 32px; border-radius: 50%; }
.top-btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--brand); border-radius: 10px;
}
.top-btn .ic { width: 20px; height: 20px; }
.top-btn[hidden] { display: none; }
.brand img { border-radius: 8px; }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 0 0 12px; border: 1px solid var(--line);
}
.card.note { display: flex; gap: 12px; align-items: flex-start; }
.card.note .ic { color: var(--brand); margin-top: 2px; }
.card.note span { display: block; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.card.warn { font-size: .9rem; color: var(--muted); }

.month-select {
  appearance: none; border: 0; background: none; font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em;
  margin: 8px 0 12px; padding: 0 22px 0 0; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 8px center, right 3px center; background-size: 5px 5px; background-repeat: no-repeat;
}

.hero { border-radius: 20px; padding: 20px; margin-bottom: 12px; color: #fff; background: var(--brand); }
.hero.down { background: var(--text); }
.hero-label { font-size: .88rem; opacity: .85; }
.hero-value { display: block; font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.hero-note { font-size: .9rem; opacity: .9; }
.hero-sub {
  display: block; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .25);
  font-size: .88rem; opacity: .95;
}

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .82rem; }
.stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 6px; }
.bar-head span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar-head b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar i.pessoal { background: var(--brand-mid); }

.tag {
  font-style: normal; font-size: .7rem; font-weight: 500; padding: 1px 7px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}

.rows { list-style: none; margin: 0; padding: 0; }
.rows.card { padding: 4px 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-desc { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: .78rem; color: var(--muted); }
.row > b { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px 16px; border-radius: 12px; border: 0;
  font-weight: 600; cursor: pointer; text-align: center; margin-top: 10px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-ink); }
.btn.ghost { background: var(--surface); border: 1px solid var(--line); }
.btn.danger { color: var(--muted); }
.file-btn input { display: none; }

.empty { text-align: center; padding: 48px 8px; }
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 18px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.empty p { color: var(--muted); }

.segmented { display: flex; background: #eceef2; border-radius: 12px; padding: 3px; margin: 0 0 12px; }
.segmented button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.hint { color: var(--muted); font-size: .88rem; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 32px 16px; border: 1.5px dashed var(--brand-mid); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; margin-bottom: 12px;
}
.drop.over { background: var(--brand-soft); }
.drop input { display: none; }
.drop .empty-icon { margin-bottom: 4px; }
.drop span { color: var(--muted); font-size: .88rem; }
.tips { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: .9rem; color: var(--muted); }
.tips b { color: var(--text); }

.loading { text-align: center; padding: 60px 0; color: var(--muted); }
.spinner { width: 32px; height: 32px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.review { list-style: none; padding: 0; margin: 0 0 90px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.review li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.review-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.review-top span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-top b { font-weight: 600; white-space: nowrap; }
.flip {
  flex: none; border: 1px dashed var(--line); background: none; border-radius: 8px;
  padding: 1px 6px; font-weight: 600; white-space: nowrap; cursor: pointer; font-variant-numeric: tabular-nums;
}
.flip.in { color: var(--brand); }
.review-ctrl { display: flex; gap: 8px; margin-top: 8px; }
.review-ctrl select { flex: 1; min-width: 0; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: .85rem; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: .8rem; font-weight: 600; cursor: pointer; background: var(--surface); color: var(--muted); }
.chip.n { border-color: var(--brand-mid); background: var(--brand-soft); color: var(--brand); }
.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; gap: 10px; padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--line);
  max-width: 560px; margin: 0 auto;
}
.sticky-actions .btn { margin: 0; }

.banner {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin: 0 0 10px; font-size: .88rem; color: var(--muted);
}
.banner .ic { color: var(--brand); }
.banner b { color: var(--brand); font-weight: 600; }
.banner b.plain { color: var(--text); }
.demo-banner { border-color: var(--brand-mid); background: var(--brand-soft); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; max-width: 120px; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: .7rem; font-weight: 500; color: var(--faint); padding: 4px 0;
}
.tabbar button.active { color: var(--brand); font-weight: 600; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(17, 24, 39, .35); display: none; align-items: flex-end; }
.sheet.open { display: flex; }
.sheet-body {
  width: 100%; max-width: 560px; margin: 0 auto; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-body h3 { margin-bottom: 2px; }
.sheet-body label { display: block; font-size: .85rem; color: var(--muted); margin: 14px 0 12px; }
.sheet-body select { display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.sheet-body .check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.sheet-body .check input { accent-color: var(--brand); }
.sheet-actions { display: flex; gap: 10px; }

/* ---------- Estoque, vendas e cadastros ---------- */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.small-btn {
  width: auto; margin: 0; padding: 8px 12px; font-size: .85rem; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand);
}
.btn:disabled { opacity: .45; cursor: default; }
.alert-card { width: 100%; text-align: left; cursor: pointer; font-size: .95rem; }
.row.static { cursor: default; }
.pad { padding: 16px 0; }

.qty { font-weight: 600; min-width: 32px; text-align: right; }
.qty.low { color: var(--brand); }
.tag.strong { border-color: var(--brand-mid); color: var(--brand); background: var(--brand-soft); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  color: var(--brand); background: var(--brand-soft); flex: none;
}
.small-empty { padding: 28px 8px 8px; }
.small-empty h3 { margin: 6px 0 4px; font-size: 1rem; }
.small-empty p { margin: 0; font-size: .9rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.sheet-body { max-height: 88vh; overflow-y: auto; }
.sheet-body input:not([type="checkbox"]), .sheet-body textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 1rem;
}
.sheet-body input:focus, .sheet-body textarea:focus, .sheet-body select:focus, .search input:focus { outline: 2px solid var(--brand-mid); outline-offset: 0; border-color: var(--brand); }
.sheet-body .grid2 label { margin: 10px 0 0; }
.sheet-body .btn.ghost + .sheet-actions, .sheet-body .check + .sheet-actions { margin-top: 6px; }

.search {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--faint);
}
.search input { flex: 1; border: 0; background: none; padding: 11px 0; color: var(--text); outline: none; }
.sell-list { margin-bottom: 150px; }
.sell-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sell-row:last-child { border-bottom: 0; }
.stepper { display: flex; align-items: center; gap: 10px; flex: none; }
.stepper b { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper button {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.stepper button.solo, .stepper button[data-inc] { border-color: var(--brand-mid); background: var(--brand-soft); color: var(--brand); }
.checkout {
  position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6;
  padding: 10px 16px 12px; background: var(--surface); border-top: 1px solid var(--line);
  max-width: 560px; margin: 0 auto;
}
.checkout .segmented { margin-bottom: 0; }
.checkout .btn { margin-top: 8px; }

/* ---------- Lançamento rápido ---------- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 4px; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  color: var(--brand); font: inherit; font-size: .8rem; font-weight: 600;
}
.qa span { color: var(--text); }
.qa:active { background: var(--brand-soft); }
.stat .add-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--brand-mid); background: var(--brand-soft); color: var(--brand);
  border-radius: 99px; font-size: .78rem; font-weight: 600;
}
.io-add { margin-top: 8px; }
.io-btn { margin: 0; background: var(--surface); border: 1px solid var(--line); color: var(--brand); }
.segmented.io button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.mic {
  display: grid; place-items: center; width: 84px; height: 84px; margin: 14px auto 6px; cursor: pointer;
  border-radius: 50%; border: 0; background: var(--brand); color: #fff; box-shadow: 0 6px 20px rgba(20, 99, 255, .35);
}
.mic.on { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(20, 99, 255, .45); } 50% { box-shadow: 0 0 0 14px rgba(20, 99, 255, 0); } }

/* ---------- Período, contas fixas, instalar ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips .chip { font-weight: 500; }
.dates .field { margin-top: 0; }
h2 .ic { display: inline-block; vertical-align: -3px; color: var(--brand); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-head h3 { margin-bottom: 4px; }
.link { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: .85rem; cursor: pointer; padding: 0; }
.paid { color: var(--brand); }
.bill-banner { border-color: var(--brand-mid); }
.install-head { display: flex; gap: 12px; align-items: flex-start; color: var(--brand); }
.install-head h3 { color: var(--text); margin-bottom: 2px; }
.steps { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.steps .ic { display: inline-block; vertical-align: -4px; color: var(--brand); }
.step-n {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .8rem;
}
.small-code { font-size: 1rem; text-align: center; }
.sheet-body .code-box { margin: 8px 0; }

/* ---------- Confirmação ---------- */
.ask { position: fixed; inset: 0; z-index: 40; background: rgba(17, 24, 39, .4); display: none; align-items: center; justify-content: center; padding: 16px; }
.ask.open { display: flex; }
.ask-body { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 20px 16px 16px; box-shadow: 0 10px 40px rgba(17, 24, 39, .2); }
.ask-body p { margin: 0 0 8px; font-size: 1rem; }
.btn.danger-solid { background: #b42318; color: #fff; }

/* ---------- Compra e acesso ---------- */
body.gated .tabbar { display: none; }
body.gated { padding-bottom: 24px; }
.gate { text-align: center; padding: 16px 0 8px; }
.gate .spinner { margin-top: 40px; }
.gate h2 { font-size: 1.5rem; margin-top: 12px; }
.benefits { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; text-align: left; }
.benefits li { display: flex; align-items: center; gap: 12px; font-size: .95rem; }
.benefits .ic { color: var(--brand); }
.price-card { text-align: left; }
.plans { display: grid; gap: 8px; margin-bottom: 4px; }
.plan {
  position: relative; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name price" "sub price";
  align-items: center; gap: 0 12px; width: 100%; text-align: left; cursor: pointer;
  padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
}
.plan[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand) inset; }
.plan-name { grid-area: name; font-weight: 600; }
.plan-sub { grid-area: sub; font-size: .8rem; color: var(--muted); }
.plan-price { grid-area: price; font-size: 1.25rem; letter-spacing: -.01em; }
.plan-badge {
  position: absolute; top: -9px; right: 12px; font-style: normal; font-size: .68rem; font-weight: 700;
  background: var(--brand); color: #fff; padding: 2px 8px; border-radius: 99px;
}
.legal { line-height: 1.5; }
.legal a { color: var(--brand); }
.price { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.price b { font-size: 1.8rem; letter-spacing: -.02em; }
.price span { color: var(--muted); font-size: .9rem; }
.field { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; text-align: left; }
.field input {
  display: block; width: 100%; margin-top: 4px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 1rem;
}
.field input:focus { outline: 2px solid var(--brand-mid); border-color: var(--brand); }
.code-box { text-align: left; }
.code-box summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.error { color: #b42318; font-size: .9rem; min-height: 1.2em; }
.code-big {
  font: 700 1.6rem/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .06em;
  background: var(--brand-soft); color: var(--brand-ink); border-radius: 14px; padding: 18px 12px; margin: 16px 0 4px;
  user-select: all;
}
.mono { font-family: ui-monospace, Consolas, monospace; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: .88rem; transition: .25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
