@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }

:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-2: #f2eee6;
  --text: #1b1a18;
  --muted: #8a8378;
  --line: #ebe5da;
  --ink: #161514;
  --accent: #f26a2e;
  --accent-2: #dd5518;
  --accent-soft: #fde6da;
  --danger: #d23c2c;
  --danger-soft: #fbe3df;
  --shadow-sm: 0 1px 2px rgb(40 30 20 / .05);
  --shadow: 0 2px 6px rgb(40 30 20 / .05), 0 14px 30px -14px rgb(40 30 20 / .22);
  --shadow-lg: 0 24px 50px -18px rgb(40 30 20 / .4);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1d1b18;
    --surface-2: #27241f;
    --text: #f3efe8;
    --muted: #a19a8e;
    --line: #2f2b25;
    --ink: #0b0a09;
    --accent: #ff7a3d;
    --accent-2: #f26a2e;
    --accent-soft: #3a2116;
    --danger: #f0786a;
    --danger-soft: #3a1915;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
    --shadow: 0 14px 30px -14px rgb(0 0 0 / .8);
    --shadow-lg: 0 24px 50px -18px rgb(0 0 0 / .9);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.4 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2 { letter-spacing: -.02em; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* tons pastel por categoria: o elemento recebe --c e o resto deriva dele */
.tile, .ptile, .grupo, .dd-op, .dd-btn .ic, .cat-op {
  --c-soft: color-mix(in srgb, var(--c, #857a6e) 10%, var(--surface));
  --c-tile: color-mix(in srgb, var(--c, #857a6e) 20%, var(--surface));
  --c-fg: color-mix(in srgb, var(--c, #857a6e) 82%, var(--text));
}
.tile {
  width: 40px; height: 40px; flex: none; border-radius: 13px; display: grid; place-items: center; font-size: 16px;
  background: var(--c-tile); color: var(--c-fg);
}

/* ---------- Topo ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 0 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center;
  font-size: 18px; color: var(--accent); background: var(--ink);
}
h1 { margin: 0; font-size: 19px; font-weight: 800; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.sync i { font-size: 11px; color: #6f8f5f; }
.sync.salvando i { color: var(--muted); animation: pulsa 1s ease infinite; }
.sync.off i { color: var(--accent); }

.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); display: grid; place-items: center; font-size: 17px;
  transition: transform .15s var(--ease), background .15s;
}
.icon-btn:active { transform: scale(.92); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); } }
.icon-btn.sm { width: 38px; height: 38px; border-radius: 12px; font-size: 15px; }

/* ---------- Resumo ---------- */
.painel {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 20px; border-radius: 26px; color: #fff;
  background: radial-gradient(70% 90% at 100% 0%, rgb(242 106 46 / .35), transparent 60%), #1f1d1a;
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .painel { background: radial-gradient(70% 90% at 100% 0%, rgb(255 122 61 / .25), transparent 60%), #24211d; } }
.painel-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.rotulo { font-size: 13px; font-weight: 600; color: rgb(255 255 255 / .65); }
.valor { display: block; margin-top: 2px; font-size: 36px; line-height: 1.1; font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.dica { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: rgb(255 255 255 / .55); }
.dica i { color: #f7b267; }
.anel {
  position: relative; width: 72px; height: 72px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  transition: --p .7s var(--ease);
}
.anel::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgb(255 255 255 / .12) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
}
.painel-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.stat { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 16px; background: rgb(255 255 255 / .07); }
.stat > i { width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 13px; background: rgb(255 255 255 / .1); color: #f7b267; }
.stat small { display: block; font-size: 11px; color: rgb(255 255 255 / .6); font-weight: 500; }
.stat b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Busca (fixa ao rolar) ---------- */
.filtros {
  position: sticky; top: 0; z-index: 25; margin-top: 8px; padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(16px); backdrop-filter: saturate(1.5) blur(16px);
  transition: box-shadow .2s;
}
.filtros.colado { box-shadow: 0 1px 0 var(--line); }
.busca { display: flex; align-items: center; gap: 12px; }
.campo { position: relative; flex: 1; }
.campo > i { position: absolute; left: 16px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: 14px; pointer-events: none; }
.campo input {
  width: 100%; height: 48px; padding: 0 44px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.campo input::-webkit-search-cancel-button { display: none; }
.campo input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.limpar { position: absolute; right: 6px; top: 50%; translate: 0 -50%; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.mini { display: flex; flex-direction: column; align-items: flex-end; overflow: hidden; max-width: 0; opacity: 0; transition: max-width .3s var(--ease), opacity .2s; }
.filtros.colado .mini { max-width: 130px; opacity: 1; }
.mini small { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.mini b { font-size: 15px; color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Status ---------- */
.seg { display: flex; gap: 4px; margin-top: 4px; padding: 4px; border-radius: 16px; background: var(--surface-2); }
.seg button {
  flex: 1; min-width: 0; height: 40px; padding: 0 2px; border: 0; border-radius: 12px; background: transparent;
  display: flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap;
  font-size: 13.5px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s, box-shadow .2s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg button[data-v="naotem"].on .n { background: var(--danger-soft); color: var(--danger); }
.seg .n { min-width: 20px; padding: 1px 6px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.seg button.on .n { background: var(--accent-soft); color: var(--accent-2); }
@media (prefers-color-scheme: dark) { .seg button.on .n { color: var(--accent); } }

/* ---------- Dropdowns ---------- */
.selects { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; margin-top: 10px; }
.dd { position: relative; min-width: 0; }
.dd-btn {
  width: 100%; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 8px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .15s var(--ease);
}
.dd-btn:active { transform: scale(.98); }
.dd.open .dd-btn, .dd-btn:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); outline: none; }
.dd-btn .ic { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 14px; background: var(--c-tile); color: var(--c-fg); }
.dd-txt { flex: 1; min-width: 0; }
.dd-txt small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.dd-txt b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-btn .seta {
  width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  transition: rotate .25s var(--ease), background .15s;
}
.dd.open .dd-btn .seta { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }
.dd.open .seta { rotate: 180deg; }
.dd.ativo .dd-btn { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.dd-menu {
  position: absolute; z-index: 30; top: calc(100% + 8px); left: 0;
  width: max(100%, 320px); max-width: calc(100vw - 32px); max-height: min(60vh, 440px); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 4px 6px 6px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-lg);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; scrollbar-gutter: stable;
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top;
  transition: opacity .18s, transform .22s var(--ease), visibility .18s;
}
#ddLocal .dd-menu { left: auto; right: 0; }
.dd.open .dd-menu { opacity: 1; visibility: visible; transform: none; }
.dd-menu::-webkit-scrollbar { width: 6px; }
.dd-menu::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.dd-menu::-webkit-scrollbar-track { background: transparent; margin: 14px 0; }
.dd-op {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border: 0; border-radius: 14px;
  background: transparent; text-align: left; transition: background .12s;
}
.dd-op:hover { background: var(--surface-2); }
.dd-op.on { background: var(--c-soft); }
.dd-op .tile { width: 36px; height: 36px; border-radius: 11px; font-size: 14px; }
.dd-op span.nm { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.dd-op small { color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dd-op small { min-width: 34px; text-align: right; }
.dd-op .marca { width: 16px; flex: none; color: var(--accent); font-size: 13px; visibility: hidden; }
.dd-op.on .marca { visibility: visible; }
.dd-vazio { padding: 14px; color: var(--muted); font-size: 13px; }

/* ---------- Seções de categoria ---------- */
#lista { margin-top: 4px; }
.grupo {
  margin-top: 14px; border-radius: 22px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.grupo-h {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 14px; cursor: pointer; user-select: none;
  position: relative; border-radius: 21px 21px 0 0; background: var(--c-soft);
}
.grupo.fechado .grupo-h { border-radius: 21px; }
.gt { min-width: 0; flex: 1; }
.gt h2 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; }
.gt small { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.grupo-h .sub { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.grupo-h .sub small { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.grupo-h .seta {
  width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; color: var(--c-fg); border: 1.5px solid color-mix(in srgb, var(--c-fg) 35%, transparent);
  transition: rotate .25s var(--ease);
}
.grupo.fechado .grupo-h .seta { rotate: -90deg; }
.gloc {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--c-fg); background: color-mix(in srgb, var(--c) 16%, transparent);
  transition: transform .15s var(--ease), background .15s;
}
.gloc:hover { background: color-mix(in srgb, var(--c) 28%, transparent); transform: scale(1.1); }
.gloc:active { transform: scale(.9); }
.gloc.tem { color: #fff; background: var(--c); }
.gprog { position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--c) 18%, transparent); overflow: hidden; }
.grupo.fechado .gloc {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--c-fg); background: color-mix(in srgb, var(--c) 16%, transparent);
  transition: transform .15s var(--ease), background .15s;
}
.gloc:hover { background: color-mix(in srgb, var(--c) 28%, transparent); transform: scale(1.1); }
.gloc:active { transform: scale(.9); }
.gloc.tem { color: #fff; background: var(--c); }
.gprog { bottom: 6px; }
.gprog span { display: block; height: 100%; background: var(--c); border-radius: 3px; transition: width .5s var(--ease); }
.itens { padding: 4px 6px 6px; }

/* ---------- Item ---------- */
.item {
  position: relative;
  display: grid; grid-template-columns: 1fr auto auto auto; grid-template-areas: "main edit nt chk" "ctl ctl ctl ctl";
  align-items: center; gap: 10px 8px; padding: 12px 10px; border-radius: 16px;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), background .2s;
}
.item + .item::before { content: ""; position: absolute; top: 0; left: 62px; right: 10px; height: 1px; background: var(--line); }
@media (hover: hover) {
  .item:hover { transform: scale(1.025); z-index: 2; background: var(--surface); box-shadow: var(--shadow); }
  .item:hover::before, .item:hover + .item::before { opacity: 0; }
}
.item:active { transform: scale(.985); }
.item.pop { animation: entra .35s var(--ease); }

.principal { grid-area: main; display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; grid-column: 1 / 2; }
.ptile {
  width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 17px;
  background: var(--c-tile); color: var(--c-fg); transition: filter .2s, opacity .2s, transform .2s var(--ease);
}
@media (hover: hover) { .item:hover .ptile { transform: rotate(-6deg) scale(1.08); } }
.info { min-width: 0; }
.nome { display: block; font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; transition: color .2s; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); }
.tag i { font-size: 10px; }

.edit { grid-area: edit; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; transition: background .15s, color .15s; }
.edit:hover, .edit:active { background: var(--surface-2); color: var(--text); }
.nt-btn { grid-area: nt; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; transition: background .15s, color .15s; }
.nt-btn:hover { background: var(--danger-soft); color: var(--danger); }
.item.falta .nt-btn { background: var(--danger-soft); color: var(--danger); }
.item.falta .nome { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 1.5px; }
.item.falta .ptile { filter: grayscale(1); opacity: .45; }
.item.falta .ctl { opacity: .5; }
.tag.nt { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.check {
  grid-area: chk; position: relative; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 50%, transparent); background: transparent;
  display: grid; place-items: center; color: transparent; font-size: 12px;
  transition: background .2s, border-color .2s, color .2s;
}
.check::before { content: ""; position: absolute; inset: -10px; }
.item.ok .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.item.pop .check { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.item.ok .nome { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.item.ok .ptile { filter: grayscale(.8); opacity: .55; }

.ctl { grid-area: ctl; display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: 56px; }
.qtd { display: flex; align-items: center; flex: none; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.qtd button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-size: 11px; transition: background .15s, transform .1s; }
.qtd button:active { transform: scale(.85); background: var(--surface); }
@media (hover: hover) { .qtd button:hover { background: var(--surface); } }
.qtd span { min-width: 28px; text-align: center; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.preco {
  display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; max-width: 140px;
  height: 38px; padding: 0 12px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid transparent;
  transition: transform .2s var(--ease), border-color .15s, background .15s, box-shadow .15s;
}
.preco span { font-size: 12px; font-weight: 700; color: var(--muted); }
.preco input { width: 100%; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.preco input::placeholder { color: var(--muted); opacity: .6; font-weight: 500; }
.preco:focus-within { transform: scale(1.07); border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.tot { margin-left: auto; text-align: right; flex: none; }
.tot small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tot b { font-size: 14.5px; font-variant-numeric: tabular-nums; }

/* ---------- Vazio ---------- */
.vazio { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 16px; color: var(--muted); }
.vazio-ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 24px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 14px; color: var(--accent); }
.vazio strong { color: var(--text); font-size: 16px; }
.vazio p { margin: 4px 0 0; font-size: 14px; }

/* ---------- Barra de baixo ---------- */
.bottombar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.bottombar .wrap { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }

.btn {
  height: 52px; padding: 0 20px; border-radius: 99px; border: 1.5px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--surface); font-weight: 700; font-size: 15px; white-space: nowrap;
  transition: transform .15s var(--ease), background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.96); }
@media (hover: hover) { .btn:hover { transform: translateY(-1px); } }
.btn.primario { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 12px 24px -12px rgb(242 106 46 / .9); }
.btn.outline { border-color: var(--text); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.perigo { color: var(--danger); }
.btn.perigo-cheio { border-color: var(--danger); color: #fff; background: var(--danger); }
.btn.ghost.perigo:hover { background: var(--danger-soft); }

/* ---------- Toast ---------- */
.toast[popover] { inset: auto; margin: 0; border: 0; overflow: hidden; }
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(420px, calc(100% - 32px));
  padding: 10px 18px 10px 10px; border-radius: 18px; overflow: hidden;
  font-weight: 600; font-size: 14px; line-height: 1.3;
  background: #1f1d1a; color: #fff; box-shadow: 0 18px 40px -14px rgb(0 0 0 / .55), 0 0 0 1px rgb(255 255 255 / .06) inset;
  translate: -50% 16px; scale: .96; opacity: 0; pointer-events: none;
  transition: translate .35s var(--ease), scale .35s var(--ease), opacity .2s;
}
.toast.show { translate: -50% 0; scale: 1; opacity: 1; }
.toast .ti {
  width: 34px; height: 34px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 14px;
  color: #9fd8a8; background: rgb(120 200 140 / .14);
}
.toast.erro .ti { color: #ff9b8a; background: rgb(255 110 90 / .15); }
.toast.info .ti { color: #f7b267; background: rgb(247 178 103 / .15); }
.toast::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: currentColor; opacity: .15; transform-origin: left;
}
.toast.show::after { animation: tempo 2.2s linear forwards; }
@keyframes tempo { to { transform: scaleX(0); } }

/* ---------- Login ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.login-body {
  min-height: 100dvh; padding: 0; display: grid; place-items: center;
  background:
    radial-gradient(60% 50% at 100% 0%, rgb(242 106 46 / .14), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgb(111 143 95 / .14), transparent 70%),
    var(--bg);
}
.login { width: 100%; max-width: 420px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.login-card {
  padding: 28px 24px 22px; border-radius: 28px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: abre .35s var(--ease);
}
.login-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.login-topo .logo { width: 52px; height: 52px; border-radius: 16px; font-size: 21px; }
.login-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.login-tags span {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2);
}
.login-tags i { font-size: 10px; color: var(--accent); }
.login-card h1 { font-size: 26px; letter-spacing: -.03em; }
.login-sub { margin: 4px 0 20px; color: var(--muted); }
.login-erro {
  display: flex; align-items: center; gap: 8px; margin: -6px 0 16px; padding: 10px 12px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: 14px;
  animation: treme .35s ease;
}
.login-card .opcao { margin: 4px 0 18px; }
.login-btn { width: 100%; }
.login-rodape { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 16px 0 0; font-size: 12px; color: var(--muted); }
@keyframes treme { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---------- Dicas (tooltips) ---------- */
@media (hover: hover) {
  [data-tip] { position: relative; }
  [data-tip]::after, [data-tip]::before {
    position: absolute; left: 50%; z-index: 50; pointer-events: none;
    opacity: 0; translate: -50% 4px; transition: opacity .15s, translate .2s var(--ease);
  }
  [data-tip]::after {
    content: attr(data-tip); bottom: calc(100% + 9px);
    padding: 7px 11px; border-radius: 10px; white-space: nowrap;
    background: #1f1d1a; color: #fff; font: 600 12px/1.2 "Plus Jakarta Sans", system-ui, sans-serif; letter-spacing: 0;
    box-shadow: 0 10px 24px -10px rgb(0 0 0 / .5);
  }
  [data-tip]::before {
    content: ""; bottom: calc(100% + 3px); width: 10px; height: 10px; margin-left: -5px; translate: 0 4px;
    background: #1f1d1a; border-radius: 2px; rotate: 45deg;
  }
  [data-tip]:hover::after { opacity: 1; translate: -50% 0; transition-delay: .25s; }
  [data-tip]:hover::before { opacity: 1; translate: 0 0; transition-delay: .25s; }
  .tip-baixo[data-tip]::after { bottom: auto; top: calc(100% + 9px); }
  .tip-baixo[data-tip]::before { bottom: auto; top: calc(100% + 3px); }
  .tip-dir[data-tip]::after { left: auto; right: -4px; translate: 0 4px; }
  .tip-dir[data-tip]:hover::after { translate: 0 0; }
}

/* ---------- Diálogos ---------- */
dialog {
  width: min(460px, calc(100% - 32px)); max-width: none; padding: 22px; border: 0; border-radius: 26px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: abre .25s var(--ease); }
dialog::backdrop { background: rgb(20 18 15 / .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
dialog h2 { margin: 0; font-size: 20px; font-weight: 800; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input { position: relative; }
.input i { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: 13px; pointer-events: none; }
.input input {
  width: 100%; height: 48px; padding: 0 14px 0 40px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface-2); font-size: 16px; outline: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.input input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.dlg-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.loc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; }
.loc-chips:empty { display: none; }
.loc-chips button {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 600;
  transition: transform .12s var(--ease), border-color .12s;
}
.loc-chips button i { font-size: 11px; color: var(--muted); }
.loc-chips button:hover { border-color: var(--accent); }
.loc-chips button:active { transform: scale(.94); }
.opcao { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.opcao input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.nota { margin: 8px 0 4px; font-size: 12.5px; color: var(--muted); }
.dupla { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acoes { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.acoes .esp { flex: 1; }
.menu { display: grid; gap: 4px; }
.top-acoes { display: flex; gap: 8px; }

/* ---------- Categorias: gaveta e lateral ---------- */
dialog.drawer {
  margin: 0; width: min(340px, 88vw); height: 100dvh; max-height: none;
  border-radius: 0 26px 26px 0; padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
}
dialog.drawer[open] { animation: lado .3s var(--ease); }
@keyframes lado { from { transform: translateX(-100%); } }
.cats { display: grid; gap: 4px; }
.cat-op {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 16px;
  background: transparent; text-align: left; transition: background .15s, transform .15s var(--ease);
}
.cat-op:hover { background: var(--surface-2); }
.cat-op:active { transform: scale(.98); }
.cat-op.on { background: var(--c-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 45%, transparent); }
.cat-info { flex: 1; min-width: 0; }
.cat-info b { display: block; font-size: 14.5px; line-height: 1.25; }
.cat-info small { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.cat-bar { display: block; height: 3px; margin-top: 6px; border-radius: 3px; background: color-mix(in srgb, var(--c) 16%, transparent); overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--c); border-radius: 3px; transition: width .4s var(--ease); }
.cat-val { font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lateral { display: none; }
.lateral-head { padding: 4px 6px 10px; }
.lateral-head h2 { margin: 0; font-size: 16px; }
.lateral-head small { font-size: 12px; color: var(--muted); }
#lista { scroll-margin-top: 80px; }

/* ---------- Indicadores ---------- */
#dlgInd { width: min(680px, calc(100% - 32px)); }
.ind-seg { margin: 0 0 14px; }
.ind-seg button.on { background: var(--text); color: var(--surface); box-shadow: none; }
.ind-seg button i { font-size: 12px; }
.ind-corpo { max-height: min(68vh, 680px); overflow-y: auto; margin: 0 -4px; padding: 0 4px 4px; overscroll-behavior: contain; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile-ind { position: relative; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.ti-ic { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; background: var(--accent-soft); color: var(--accent-2); }
.tile-ind small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; padding-right: 32px; }
.tile-ind b { display: block; margin-top: 4px; font-size: 19px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-extra { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.ind-sec { margin-top: 18px; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.ind-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 15px; }
.ind-sec h3 i { color: var(--muted); font-size: 13px; }
.ind-vazio { margin: 4px 0; color: var(--muted); font-size: 13.5px; }
.legenda { display: flex; gap: 14px; margin: -4px 0 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.lg.claro { background: color-mix(in srgb, var(--accent) 28%, var(--surface)); }

.barras { display: grid; gap: 4px; }
.bl { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "rot val" "trilho trilho"; align-items: center; gap: 5px 10px; padding: 6px; margin: 0 -6px; border-radius: 10px; transition: background .15s; }
.bl-rot { grid-area: rot; }
.bl-val { grid-area: val; }
.bl-trilho { grid-area: trilho; }
.bl:hover { background: var(--surface-2); }
.bl-rot { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; font-weight: 600; }
.bl-rot i { width: 14px; flex: none; text-align: center; color: var(--muted); font-size: 12px; }
.bl-rot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-trilho { position: relative; height: 12px; }
.bl-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--accent); transition: width .5s var(--ease); }
.bl-fill.claro { background: color-mix(in srgb, var(--accent) 28%, var(--surface)); }
.bl-fill + .bl-fill { box-shadow: 2px 0 0 var(--surface); }
.bl-val { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.colunas { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.col-b { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: var(--accent); transition: height .5s var(--ease), opacity .15s; }
.colunas:hover .col-b { opacity: .55; }
.colunas .col:hover .col-b { opacity: 1; }
.col-b { position: relative; }
.col-v { position: absolute; bottom: calc(100% + 4px); left: 50%; translate: -50% 0; font-size: 11px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-r { position: absolute; bottom: -20px; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ind-sec:has(.colunas) { padding-bottom: 30px; }

.variacoes { display: grid; gap: 2px; }
.var { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); }
.var:first-child { border-top: 0; }
.var-ic { width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center; font-size: 12px; }
.var.sobe .var-ic { background: var(--danger-soft); color: var(--danger); }
.var.cai .var-ic { background: color-mix(in srgb, #4f8a5b 16%, var(--surface)); color: #3f7a4b; }
.var-nome { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.var-nome small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.var b { font-size: 14px; font-variant-numeric: tabular-nums; }
.var.sobe b { color: var(--danger); }
.var.cai b { color: #3f7a4b; }
@media (prefers-color-scheme: dark) { .var.cai .var-ic, .var.cai b { color: #8fd19e; } }

/* ---------- Histórico ---------- */
#dlgHist { width: min(620px, calc(100% - 32px)); }
.hist { display: grid; gap: 10px; max-height: min(70vh, 640px); overflow-y: auto; margin: 0 -4px; padding: 0 4px 4px; overscroll-behavior: contain; }
.hcard { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); transition: box-shadow .2s, transform .2s var(--ease); }
.hcard[open] { box-shadow: var(--shadow); }
@media (hover: hover) { .hcard:not([open]):hover { transform: scale(1.015); box-shadow: var(--shadow); } }
.hcard summary { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; list-style: none; }
.hcard summary::-webkit-details-marker { display: none; }
.hdata {
  width: 50px; height: 54px; flex: none; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--ink); color: #fff;
}
.hdata b { font-size: 19px; line-height: 1; }
.hdata small { font-size: 11px; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-top: 3px; }
.hinfo { flex: 1; min-width: 0; }
.hinfo > b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.hinfo > small { display: block; color: var(--muted); font-size: 12.5px; }
.hcard .seta { color: var(--muted); font-size: 12px; transition: rotate .25s var(--ease); }
.hcard[open] .seta { rotate: 180deg; }
.hcorpo { padding: 0 12px 12px; }
.hsec { margin-top: 10px; }
.hsec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hsec.nt h3 { color: var(--danger); }
.hrow { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.hrow span { flex: 1; min-width: 0; }
.hrow small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hrow b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hacoes { display: flex; gap: 8px; margin-top: 12px; }
.hacoes .btn { height: 44px; }
.hist-vazio { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 12px; color: var(--muted); gap: 4px; }
.hist-vazio strong { color: var(--text); }
.hist-vazio p { margin: 0; font-size: 14px; }
.menu button { display: flex; align-items: center; gap: 14px; padding: 10px; text-align: left; border: 0; border-radius: 16px; background: transparent; transition: background .15s; }
.menu button:hover, .menu button:active { background: var(--surface-2); }
.menu b { display: block; font-size: 15px; }
.menu small { display: block; font-size: 12.5px; color: var(--muted); }
.confirm { text-align: center; width: min(380px, calc(100% - 32px)); padding: 26px 22px 20px; }
.confirm h2 { font-size: 19px; }
.conf-icone { width: 56px; height: 56px; margin: 4px auto 14px; border-radius: 18px; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); color: var(--accent); }
.conf-icone.perigo { background: var(--danger-soft); color: var(--danger); }
.confirm p { margin: 8px 0 20px; color: var(--muted); white-space: pre-line; }
.conf-botoes { display: grid; gap: 8px; }

@media (max-width: 600px) {
  dialog:not(.confirm):not(.drawer) { width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); }
  dialog:not(.confirm):not(.drawer)::before { content: ""; display: block; width: 42px; height: 5px; margin: 0 auto 14px; border-radius: 9px; background: var(--line); }
  dialog:not(.confirm):not(.drawer)[open] { animation: sobe .32s var(--ease); }
  #dlgInd, #dlgHist { width: 100%; }
}
@media (min-width: 960px) {
  .wrap { max-width: 1180px; }
  main.wrap { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
  .lateral {
    display: block; position: sticky; top: 84px; max-height: calc(100dvh - 190px); overflow-y: auto;
    padding: 12px 8px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
    scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  }
  #ddCat { display: none; }
  .painel { display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 24px; }
  .painel-stats { margin-top: 0; }
  .top-filtros { display: grid; }
  .selects { grid-template-columns: 1fr 1fr; }
  .itens { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; }
  .item + .item::before { display: none; }
  .bottombar .wrap { display: flex; justify-content: flex-end; }
}
@media (max-width: 370px) {
  .wrap { padding: 0 12px; }
  .valor { font-size: 30px; }
  .ctl { padding-left: 0; }
  .seg .n { display: none; }
}

@keyframes pop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
@keyframes entra { from { opacity: .4; transform: scale(.97); } }
@keyframes abre { from { opacity: 0; transform: scale(.94) translateY(8px); } }
@keyframes sobe { from { transform: translateY(100%); } }
@keyframes pulsa { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
