/* ======================================================================
   Veloso Barbearia — mobile-first. Tema claro/escuro automático.
   ====================================================================== */
:root {
  --bg: #f5f2ec;
  --surface: #ffffff;
  --surface-2: #efebe3;
  --ink: #1c1814;
  --muted: #6a6258;
  --line: #e3ddd2;
  --brand: #e0a13a;
  --brand-ink: #1c1814;
  --brand-soft: #fbf0d9;
  --pos: #1b7f45;
  --pos-soft: #e3f4ea;
  --neg: #c0392b;
  --neg-soft: #fbe9e6;
  --hero-bg: #16130f;
  --hero-ink: #f6efe0;
  --hero-pos: #5fd493;
  --focus: #1d6fd8;
  --c1: #1b7f45; --c2: #1d6fd8; --c3: #e0a13a; --c4: #8a4fc4; --c5: #8f877b;
  --navh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --raio: 14px;
  --sombra: 0 1px 2px rgba(28, 24, 20, .06), 0 4px 14px rgba(28, 24, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100e0b;
    --surface: #1b1814;
    --surface-2: #26221c;
    --ink: #f3ece0;
    --muted: #a39a8c;
    --line: #2e2922;
    --brand-soft: #34290f;
    --pos: #5fd493;
    --pos-soft: #12301f;
    --neg: #ff8a7a;
    --neg-soft: #3a1b17;
    --hero-bg: #1f1a12;
    --focus: #6aa9ff;
    --c1: #5fd493; --c2: #6aa9ff; --c3: #e0a13a; --c4: #b98ae8; --c5: #8f877b;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h3 { font-size: 1rem; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.ico { flex: none; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.splash, .carregando { display: grid; place-items: center; min-height: 40vh; color: var(--muted); }

/* ------------------------------------------------------------ controles */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 22px; height: 22px; accent-color: var(--brand); }
input:not([type=checkbox]), select {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 1rem; font-weight: 400;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
}
input:not([type=checkbox]):focus, select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }
.rotulo { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 700; text-decoration: none; transition: transform .06s, filter .15s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.perigo { background: var(--neg); color: #fff; }
.btn.perigo-txt { background: transparent; color: var(--neg); border-color: var(--neg); }
.btn.grande { min-height: 56px; font-size: 1.1rem; flex: 1; }
.btn.pequeno { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.link { background: none; border: 0; padding: 8px 4px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ink); }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .3; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.rolagem { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.card .chips.rolagem { margin: 0 -16px; }
.chips.rolagem::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: .95rem;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); display: inline-flex; align-items: center; justify-content: center;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; margin-bottom: 14px; }
.seg > * { flex: 1; min-height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; font-weight: 700; color: var(--muted); text-decoration: none; font-size: .95rem; text-align: center; }
.seg > .on { background: var(--surface); color: var(--ink); box-shadow: var(--sombra); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.card > h3 { margin-bottom: 12px; }
.card.stack > h3 { margin-bottom: 0; }
.erro { color: var(--neg); font-weight: 600; }
.ok { color: var(--pos); font-weight: 600; }
.aviso { background: var(--brand-soft); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: .92rem; }
.vazio { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; gap: 14px; align-items: center; color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.tag.ok { background: var(--pos-soft); color: var(--pos); }
.tag.off { background: var(--neg-soft); color: var(--neg); }
.tag.dest { background: var(--brand-soft); color: var(--ink); }

/* ------------------------------------------------------------ login */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.auth-card form, .auth-card .stack { text-align: left; margin-top: 12px; }
.auth-logo { align-self: center; border-radius: 16px; }
.auth-card h1 { font-size: 1.5rem; }

/* ------------------------------------------------------------ shell */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); background: var(--bg); border-bottom: 1px solid var(--line); }
.marca { display: flex; align-items: center; gap: 10px; }
.marca img { border-radius: 8px; }
.topbar-dir { display: flex; align-items: center; gap: 4px; }
.chip-sync { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--brand-soft); font-weight: 700; font-size: .85rem; }
main { flex: 1; padding: 14px 16px calc(var(--navh) + var(--safe-b) + 24px); width: 100%; max-width: 760px; margin: 0 auto; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: calc(var(--navh) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); }
.nav a { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 700; }
.nav a.ativo { color: var(--ink); box-shadow: inset 0 3px 0 var(--brand); }
.nav a.ativo .ico { color: var(--brand); }

/* ------------------------------------------------------------ lançar */
.resumo-dia { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; text-decoration: none; background: var(--hero-bg); color: var(--hero-ink); border-radius: var(--raio); padding: 12px 16px; margin-bottom: 14px; }
.resumo-dia strong { font-size: 1.45rem; color: var(--hero-pos); font-variant-numeric: tabular-nums; }
.resumo-dia .muted { color: color-mix(in srgb, var(--hero-ink) 65%, transparent); font-size: .9rem; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { position: relative; }
.tile-main { width: 100%; min-height: 96px; padding: 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--raio); box-shadow: var(--sombra); transition: transform .06s, border-color .15s; }
.tile-main:active { transform: scale(.97); }
.tile.on .tile-main { border-color: var(--brand); background: var(--brand-soft); }
.tile-nome { font-weight: 700; font-size: 1.02rem; line-height: 1.2; padding-right: 44px; }
.tile-preco { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.tile-qtd { position: absolute; top: 8px; right: 10px; min-width: 38px; text-align: center; padding: 2px 8px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 1.05rem; pointer-events: none; }
.tile-menos { position: absolute; right: 4px; bottom: 4px; width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: transparent; font-size: 1.8rem; font-weight: 700; color: var(--ink); border-radius: 12px; }
.tile-menos::before { content: ""; position: absolute; inset: 8px; border-radius: 10px; background: var(--surface); border: 1.5px solid var(--line); z-index: -1; }

.checkout { position: sticky; bottom: calc(var(--navh) + var(--safe-b) + 8px); margin-top: 16px; background: var(--surface); border: 1.5px solid var(--brand); border-radius: 18px; padding: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, .22); display: flex; flex-direction: column; gap: 10px; z-index: 10; }
.checkout-linhas { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.formas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.formas .chip { padding: 0 4px; font-size: .88rem; border-radius: 12px; }
.checkout-acoes { display: flex; gap: 8px; }
.quando { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quando input { max-width: 230px; }

/* ------------------------------------------------------------ período / painel */
.periodo { margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.datas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.hero { background: var(--hero-bg); color: var(--hero-ink); border-radius: 20px; padding: 18px 18px 16px; margin-bottom: 12px; }
.hero-topo { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: .95rem; color: color-mix(in srgb, var(--hero-ink) 75%, transparent); }
.hero-valor { font-size: clamp(2.4rem, 12vw, 3.6rem); font-weight: 800; line-height: 1.1; margin: 6px 0 10px; color: var(--hero-pos); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero-sub { display: flex; gap: 22px; flex-wrap: wrap; font-size: 1rem; color: color-mix(in srgb, var(--hero-ink) 75%, transparent); }
.hero-sub b { color: var(--hero-ink); font-variant-numeric: tabular-nums; }
.hero-sub b.neg, .dia-soma.neg { color: #ff8a7a; }
.delta { font-weight: 700; font-size: .85rem; }
.delta small { font-weight: 500; opacity: .85; }
.delta.bom { color: var(--pos); }
.delta.ruim { color: var(--neg); }
.delta.neutro { color: var(--muted); font-weight: 500; }
.hero .delta.bom { color: var(--hero-pos); }
.hero .delta.ruim { color: #ff9a8b; }
.hero .delta.neutro { color: color-mix(in srgb, var(--hero-ink) 60%, transparent); }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--sombra); min-width: 0; }
.kpi-rot { color: var(--muted); font-size: .82rem; font-weight: 600; }
.kpi b { font-size: 1.35rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi small { color: var(--muted); font-size: .8rem; }

.vbars { display: flex; align-items: flex-end; gap: 3px; height: 170px; }
.vcol { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 0; border: 0; background: transparent; }
.vtrilho { flex: 1; display: flex; align-items: flex-end; }
.vbarra { width: 100%; background: var(--pos); border-radius: 5px 5px 2px 2px; min-height: 0; transition: filter .15s; }
.vbarra.zero { background: var(--line); height: 2px !important; }
.vcol.sel .vbarra { background: var(--brand); }
.vcol:hover .vbarra { filter: brightness(1.12); }
.vrot { font-size: .72rem; color: var(--muted); text-align: center; height: 1.1em; white-space: nowrap; }
.vsel { margin-top: 10px; font-size: .92rem; color: var(--muted); min-height: 1.4em; }
.vsel strong { color: var(--ink); }

.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hlinha { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; margin-bottom: 4px; }
.hrot { font-weight: 600; overflow-wrap: anywhere; }
.hval { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.htrilho { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hbarra { height: 100%; background: var(--pos); border-radius: 999px; }
.hbars.neg .hbarra { background: var(--neg); }

.pilha { display: flex; height: 18px; border-radius: 999px; overflow: hidden; gap: 2px; margin-bottom: 14px; }
.pilha span { display: block; min-width: 4px; }
.legenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.legenda li { display: flex; align-items: center; gap: 10px; font-size: .95rem; }
.bolinha { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.lrot { flex: 1; font-weight: 600; }
.lval { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ histórico */
.barra-lista { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.dia { margin-bottom: 18px; }
.dia-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 4px 6px; }
.dia-topo h3 { font-size: .95rem; color: var(--muted); }
.dia-topo h3::first-letter { text-transform: uppercase; }
.dia-soma { font-weight: 800; font-variant-numeric: tabular-nums; }
.lancs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); overflow: hidden; }
.lanc { display: grid; grid-template-columns: 46px 1fr auto 44px; align-items: center; gap: 8px; padding: 8px 4px 8px 12px; border-bottom: 1px solid var(--line); }
.lanc:last-child { border-bottom: 0; }
.lanc-hora { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.lanc-desc { display: flex; flex-direction: column; min-width: 0; }
.lanc-desc strong { font-size: .95rem; overflow-wrap: anywhere; }
.lanc-desc small { color: var(--muted); }
.lanc-valor { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lanc.entrada .lanc-valor { color: var(--pos); }
.lanc.saida .lanc-valor { color: var(--neg); }

/* ------------------------------------------------------------ dinheiro */
.saldos { display: grid; gap: 10px; margin-bottom: 12px; }
.saldo-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--sombra); }
.saldo-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.saldo-card span { color: var(--muted); font-weight: 600; font-size: .9rem; }
.saldo-card .icon-btn { width: 32px; height: 32px; margin: -4px -8px -4px 0; flex: none; }
.saldo-card b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.saldo-card small { color: var(--muted); font-size: .8rem; }
.saldo-card.destaque { background: var(--hero-bg); color: var(--hero-ink); border-color: transparent; }
.saldo-card.destaque span, .saldo-card.destaque small { color: color-mix(in srgb, var(--hero-ink) 70%, transparent); }
.saldo-card.destaque .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.saldo-card.destaque b { font-size: clamp(2rem, 10vw, 2.8rem); color: var(--hero-pos); }
.saldo-card b.neg { color: var(--neg); }
.saldo-card.destaque b.neg { color: #ff8a7a; }
.prev-ajuste { font-size: .92rem; font-weight: 600; min-height: 1.3em; }
.prev-ajuste.bom { color: var(--pos); }
.prev-ajuste.ruim { color: var(--neg); }
.acoes-mov { display: flex; gap: 10px; margin-bottom: 10px; }
.nota { font-size: .88rem; margin-bottom: 14px; }
.nota .link { padding: 0 2px; min-height: 0; }
.kpis.dois { grid-template-columns: 1fr 1fr; }
.opcoes { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.opcoes legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 8px; }
.opcoes label.check { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.opcoes input[type=radio] { width: 22px; height: 22px; accent-color: var(--brand); }

/* ------------------------------------------------------------ ajustes */
.lista-cfg { list-style: none; margin: 0 0 14px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--raio); overflow: hidden; }
.lista-cfg li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px 8px 14px; border-bottom: 1px solid var(--line); }
.lista-cfg li:last-child { border-bottom: 0; }
.lista-cfg li.inativo .cfg-info { opacity: .55; }
.cfg-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfg-info > span { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.cfg-info strong { overflow-wrap: anywhere; }
.cfg-acoes { display: flex; flex: none; }
.btn.sair { width: 100%; }

/* ------------------------------------------------------------ modal / toast */
.modal { border: 0; border-radius: 20px; padding: 0; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.modal::backdrop { background: rgba(0, 0, 0, .5); }
.modal-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.modal-form h3 { font-size: 1.15rem; }
.modal-corpo { display: flex; flex-direction: column; gap: 14px; }
.modal-acoes { display: flex; gap: 8px; justify-content: flex-end; }
.modal-acoes .btn { flex: 1; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--navh) + var(--safe-b) + 12px); z-index: 100; max-width: 520px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast.erro { background: var(--neg); color: #fff; }
.toast button { flex: none; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-weight: 800; }

/* ------------------------------------------------------------ telas maiores */
@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 900px) {
  :root { --navh: 0px; }
  .app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .nav { position: sticky; top: 57px; align-self: start; grid-column: 1; grid-row: 2; display: flex; flex-direction: column; height: auto; padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line); background: transparent; min-height: calc(100dvh - 57px); }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; font-size: 1rem; }
  .nav a.ativo { background: var(--surface); box-shadow: var(--sombra); }
  main { grid-column: 2; grid-row: 2; max-width: 980px; padding: 24px 28px 40px; }
  .toast { bottom: 24px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  #corpo { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
  #corpo > .hero, #corpo > .kpis, #corpo > .aviso, #corpo > .vazio, #corpo > .carregando { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .nav, .topbar, .checkout { display: none; } main { padding: 0; } }
