/* Vó Irene Salgados — cores tiradas do logo:
   laranja da faixa, vinho do traço do retrato, mostarda do "SALGADOS", creme do fundo. */
:root {
  --orange: #E8650F;
  --orange-strong: #C4500A;   /* botões com texto branco (contraste) */
  --wine: #7A2412;
  --wine-soft: #9B3A22;
  --mustard: #F2B230;
  --mustard-soft: #FCEBC2;
  --red: #C62828;
  --red-soft: #FBE3E1;
  --green: #2E7D32;
  --bg: #FFF6E8;
  --card: #FFFFFF;
  --ink: #3A1A10;
  --muted: #7D6457;
  --line: #EADBC8;
  --chip: #F7E8D4;
  --shadow: 0 1px 2px rgba(122, 36, 18, .08), 0 2px 8px rgba(122, 36, 18, .06);
  --radius: 14px;
  --serif: "Optima", "Candara", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --orange: #F27A2C;
    --orange-strong: #D9600F;
    --wine: #4E170B;
    --wine-soft: #E39A7E;
    --mustard: #F2B230;
    --mustard-soft: #4A3713;
    --red: #EF6A5E;
    --red-soft: #4A1E1A;
    --green: #7BC67F;
    --bg: #1B110E;
    --card: #281915;
    --ink: #F7E9DC;
    --muted: #C2A896;
    --line: #3F2A24;
    --chip: #3A2620;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 var(--sans);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* cabeçalho */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--wine); color: #fff;
}
.logo { width: 40px; height: 40px; border-radius: 50%; background: #fff; }
.brand { display: flex; flex-direction: column; line-height: 1.1; flex: 1; }
.brand strong { font-family: var(--serif); font-size: 20px; letter-spacing: .04em; text-transform: uppercase; }
.brand span { font-size: 12px; color: var(--mustard); letter-spacing: .12em; text-transform: uppercase; }
.live { width: 10px; height: 10px; border-radius: 50%; background: #999; }
.live.on { background: #7BE07F; box-shadow: 0 0 0 3px rgba(123, 224, 127, .25); }
.gingham {
  height: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(198, 40, 40, .85) 0 8px, transparent 8px 16px),
    repeating-linear-gradient(0deg, rgba(198, 40, 40, .45) 0 4px, #fff 4px 8px);
}

main { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; outline: none; }
h1 { font-family: var(--serif); font-size: 22px; margin: 8px 0 12px; color: var(--wine-soft); }
@media (prefers-color-scheme: light) { h1 { color: var(--wine); } }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* barra inferior */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; text-decoration: none; font-size: 12px; color: var(--muted);
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--orange); font-weight: 600; }

/* cartões e listas */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { padding: 10px 12px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.hero { grid-column: span 2; display: flex; justify-content: space-between; align-items: baseline; }
.kpi.hero .value { font-size: 26px; }
.kpi .value small { font-size: 14px; font-weight: 500; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; background: none; border: 0; text-align: left; cursor: pointer;
  min-height: 60px;
}
.item:active { background: var(--chip); }
.item .name { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }

.stock { min-width: 56px; text-align: right; }
.stock b { display: block; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.stock small { font-size: 11px; color: var(--muted); }
.low { background: linear-gradient(90deg, var(--mustard-soft), transparent 70%); }
.out { background: linear-gradient(90deg, var(--red-soft), transparent 70%); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; vertical-align: 2px; }
.badge.low { background: var(--mustard); color: #3A1A10; }
.badge.out { background: var(--red); color: #fff; }
.badge.void { background: var(--chip); color: var(--muted); }

/* botões e formulários */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--orange-strong); border-color: var(--orange-strong); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.big { width: 100%; min-height: 58px; font-size: 18px; border-radius: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--orange); }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--chip); cursor: pointer; font-size: 14px;
}
.chip.on { background: var(--wine); border-color: var(--wine); color: #fff; }
@media (prefers-color-scheme: dark) { .chip.on { background: var(--orange-strong); border-color: var(--orange-strong); } }

label.f { display: block; margin: 10px 0; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input.in, select.in, textarea.in {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
}
textarea.in { min-height: 70px; }
input.in:focus, select.in:focus, textarea.in:focus, .btn:focus-visible, .chip:focus-visible, .item:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 1px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }

/* folha inferior (bottom sheet) */
.backdrop { position: fixed; inset: 0; background: rgba(30, 10, 5, .45); z-index: 30; animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; animation: up .18s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 8px; }
.sheet h3 { margin: 4px 0 2px; font-size: 20px; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* venda */
.qty { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 8px; }
.qty .step { width: 60px; height: 60px; border-radius: 50%; font-size: 30px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.qty input { width: 110px; text-align: center; font-size: 40px; font-weight: 800; border: 0; background: transparent; font-variant-numeric: tabular-nums; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick button { min-height: 56px; font-size: 20px; font-weight: 800; border-radius: 14px; border: 2px solid var(--orange); background: var(--card); color: var(--orange); cursor: pointer; }
.quick button.on { background: var(--orange); color: #fff; }
.line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.line .x, .extra .x { border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; width: 36px; height: 36px; flex: none; }
.extra { padding: 10px 0; border-bottom: 1px dashed var(--line); }

/* toast */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 560px; margin: 0 auto;
  padding: 12px 16px; border-radius: 12px; background: #2B1610; color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.toast button { background: none; border: 0; color: var(--mustard); font-weight: 700; cursor: pointer; padding: 4px; }
.toast.err { background: var(--red); }
.toast.err button { color: #fff; }

/* tabelas */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; }
.scroll-x { overflow-x: auto; }

/* gráficos */
.chart { position: relative; padding: 12px 8px 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--orange); }
.chart .bar.dim { fill: var(--mustard); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.sel { fill: var(--orange-strong); }
.tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%);
  background: #2B1610; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap;
}
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.hbar .track { height: 14px; }
.hbar .fill { height: 14px; background: var(--orange); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.login { max-width: 360px; margin: 32px auto; padding: 20px; }
.login img { display: block; width: 120px; height: 120px; margin: 0 auto 12px; border-radius: 50%; }
.section { padding: 4px 14px 10px; }
.menu .item { font-weight: 600; }
.menu .item svg { width: 22px; height: 22px; fill: none; stroke: var(--orange); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chev { color: var(--muted); }
.note { font-size: 13px; color: var(--muted); padding: 8px 12px; background: var(--chip); border-radius: 10px; }
