/* =================================================================================
   Semeadores PDV — identidade visual
   Tema: a parábola do semeador. Fundo linho, verde broto, ação em amarelo milho.
   Títulos e números em Bricolage Grotesque; texto em Atkinson Hyperlegible
   (desenhada para baixa visão: voluntários de todas as idades, muitas vezes no sol).
   ================================================================================= */

:root {
    --bg: #F1F3EC;
    --surface: #FFFFFF;
    --surface-2: #E8EBE1;
    --ink: #26221C;
    --muted: #5C574E;
    --line: #DADFD2;
    --line-strong: #CBD1C1;
    --broto: #3B7A1E;
    --broto-ink: #2F6418;
    --broto-soft: #DCEBCF;
    --milho: #F2C230;
    --milho-ink: #5E4100;
    --milho-soft: #FBEFC2;
    --anil: #2D4F9E;
    --erro: #B3261E;
    --erro-soft: #FBE3E0;
    --on-color: #FFFFFF;
    --seed: #A9A493;
    --furrow: #C9C3AE;
    --stand: var(--broto);

    --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
    --r-s: 10px;
    --r-m: 14px;
    --r-l: 22px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #171A14; --surface: #22261E; --surface-2: #2B3026; --ink: #ECEFE6; --muted: #A9AE9F;
        --line: #363B30; --line-strong: #4A5042; --broto: #7DBA5A; --broto-ink: #9BD27A; --broto-soft: #2A3A20;
        --milho-ink: #F5D774; --milho-soft: #3A3218; --anil: #9DB4EE; --erro: #F2867D; --erro-soft: #3A201D;
        --seed: #6B6F62; --furrow: #4A5042;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #171A14; --surface: #22261E; --surface-2: #2B3026; --ink: #ECEFE6; --muted: #A9AE9F;
    --line: #363B30; --line-strong: #4A5042; --broto: #7DBA5A; --broto-ink: #9BD27A; --broto-soft: #2A3A20;
    --milho-ink: #F5D774; --milho-soft: #3A3218; --anil: #9DB4EE; --erro: #F2867D; --erro-soft: #3A201D;
    --seed: #6B6F62; --furrow: #4A5042;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.45;
    min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.015em; line-height: 1.1; }
h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 24px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
a { color: var(--anil); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--anil); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.wordmark { font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: -.02em; font-variation-settings: 'wdth' 85; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 16px; border-radius: var(--r-s);
    border: 1.5px solid var(--line-strong); background: transparent;
    font-weight: 700; font-size: 15px; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn-primary { background: var(--milho); border-color: var(--milho); color: #26221C; }
.btn-primary:hover:not(:disabled) { background: #E5B520; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-dark:hover:not(:disabled) { background: var(--ink); opacity: .9; }
.btn-danger { color: var(--erro); border-color: currentColor; }
.btn-link { border: 0; background: none; color: var(--anil); padding: 0 4px; min-height: 44px; }
.btn-link:hover:not(:disabled) { background: none; text-decoration: underline; }
.btn-block { width: 100%; }
.btn-lg { min-height: 60px; font-size: 17px; border-radius: var(--r-m); padding: 0 20px; }
.icon-btn { width: 44px; height: 44px; padding: 0; border-radius: var(--r-s); border: 1.5px solid var(--line-strong); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 700; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.input, select.input, textarea.input {
    width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-s);
    border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { outline: none; border-color: var(--anil); box-shadow: 0 0 0 3px color-mix(in srgb, var(--anil) 25%, transparent); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--broto); }

/* ---------- Estrutura ---------- */
.topbar { height: 6px; background: var(--stand); transition: background .25s; }
.page { max-width: 1240px; margin: 0 auto; padding: 20px clamp(16px, 3vw, 40px) 64px; display: flex; flex-direction: column; gap: 28px; }
.app-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.app-header .context { display: flex; flex-direction: column; gap: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: transparent; font-weight: 700; font-size: 15px; color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.cols { display: flex; flex-wrap: wrap; gap: 32px; }
.cols > * { flex: 1 1 320px; min-width: 0; }
.cols > .wide { flex: 2 1 520px; }
.panel { background: var(--surface); border-radius: var(--r-m); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.empty { border: 2px dashed var(--line-strong); border-radius: var(--r-m); padding: 24px; text-align: center; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li > .grow { flex: 1 1 200px; min-width: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge-stand { color: var(--on-color); }
.badge-warn { background: var(--milho-soft); color: var(--milho-ink); }
.badge-ok { background: var(--broto-soft); color: var(--broto-ink); }
.badge-erro { background: var(--erro-soft); color: var(--erro); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.notice { background: var(--milho-soft); color: var(--milho-ink); border-radius: var(--r-m); padding: 12px 16px; line-height: 1.4; }

/* Indicadores em linha (sem cartões) */
.kpis { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); border-top: 2px solid var(--ink); }
.kpis > div { padding: 14px 20px 4px 0; display: flex; flex-direction: column; gap: 2px; }
.kpis dt { font-size: 15px; color: var(--muted); }
.kpis dd { margin: 0; }
.kpis .value { font-family: var(--font-display); font-size: 38px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpis .delta { font-size: 14px; color: var(--muted); }

/* Tabelas */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r-m); }
table.table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 600px; }
.table th { text-align: left; font-weight: 400; color: var(--muted); font-size: 14px; padding: 12px 16px; }
.table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table .right { text-align: right; }
.table .strong { font-weight: 700; }

/* Gráfico de barras por hora */
.bars { height: 200px; display: flex; align-items: flex-end; gap: 6px; border-bottom: 1.5px solid var(--ink); }
.bars > div { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.bars span.bar { width: 100%; max-width: 44px; border-radius: 6px 6px 0 0; background: var(--broto); min-height: 2px; }
.bars span.bar.peak { background: var(--milho); }
.bar-labels { display: flex; gap: 6px; }
.bar-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--broto); }
.spark { height: 32px; display: flex; align-items: flex-end; gap: 3px; min-width: 140px; }
.spark span { flex: 1; border-radius: 2px; min-height: 2px; }
.stack { display: flex; height: 14px; gap: 3px; }
.stack span { border-radius: 4px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 22px; }
.auth-card .brand { display: flex; flex-direction: column; gap: 6px; }
.auth-card .brand .wordmark { font-size: 44px; line-height: 1; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.choice { display: grid; gap: 10px; }

/* Seleção de stands (cartões grandes, cor do stand) */
.stand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.stand-card { text-align: left; border: 0; border-radius: var(--r-m); padding: 18px; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; background: var(--surface); color: var(--ink); border-top: 6px solid var(--c, var(--broto)); }
.stand-card:hover { background: var(--surface-2); }
.stand-card strong { font-family: var(--font-display); font-size: 22px; line-height: 1.1; }

/* ---------- PDV (celular primeiro) ---------- */
.pdv { max-width: 760px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.pdv-header { padding: 12px 16px 10px; display: flex; flex-direction: column; gap: 12px; }
.pdv-header .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.turno { text-align: right; line-height: 1.2; }
.turno .num { font-weight: 700; font-size: 17px; }
.stand-switch { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.stand-switch button { flex: 1 0 auto; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line-strong); background: transparent; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.stand-switch button[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: var(--on-color); }
.stand-switch .count { min-width: 20px; height: 20px; border-radius: 999px; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--c); color: var(--on-color); }
.pdv-tools { display: flex; gap: 8px; }
.pdv-tools .input { min-height: 44px; }
.pdv-main { flex: 1; padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.cat-title { font-size: 14px; color: var(--muted); font-weight: 700; margin: 4px 0 -4px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { position: relative; text-align: left; border-radius: var(--r-s); padding: 12px; min-height: 124px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1.5px solid var(--surface); color: var(--ink); }
.tile .name { font-weight: 700; line-height: 1.2; min-height: 38px; padding-right: 26px; }
.tile .price { font-family: var(--font-display); font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .stock { font-size: 13px; color: var(--muted); }
.tile .stock.low { color: var(--milho-ink); font-weight: 700; }
.tile .qty { position: absolute; top: 8px; right: 10px; font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1; color: var(--stand); }
.tile.in-cart { border: 3px solid var(--stand); padding: 10.5px; }
.tile.out { background: transparent; border: 1.5px dashed var(--line-strong); }
.tile.special { background: var(--broto-soft); border-color: var(--broto-soft); }
.cart-bar { position: sticky; bottom: 0; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.cart-bar .btn-lg { justify-content: space-between; height: 64px; }
.cart-bar .total { font-family: var(--font-display); font-weight: 800; font-size: 24px; }

/* Cobrança */
.lines { display: flex; flex-direction: column; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line .grow { flex: 1; min-width: 0; }
.line .sub { width: 84px; text-align: right; font-weight: 700; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; gap: 12px; flex-wrap: wrap; }
.total-row .num { font-size: 44px; font-weight: 800; letter-spacing: -.02em; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 52px; border-radius: 12px; border: 2px solid var(--surface); background: var(--surface); font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.cash-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.cash-opts button { min-height: 48px; border-radius: 12px; border: 2px solid var(--surface); background: var(--surface); font-weight: 700; }
.cash-opts button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.troco { display: flex; justify-content: space-between; align-items: center; background: var(--milho-soft); color: var(--milho-ink); border-radius: var(--r-m); padding: 12px 16px; }
.troco .num { font-size: 30px; font-weight: 800; }
.pix-box { display: flex; gap: 14px; align-items: center; background: var(--surface); border-radius: var(--r-m); padding: 14px; }
.pix-box .qr { width: 148px; height: 148px; flex: none; background: #FFFFFF; border-radius: 8px; padding: 6px; display: grid; place-items: center; }
.pix-box .qr img, .pix-box .qr svg { width: 100%; height: 100%; image-rendering: pixelated; }

/* Venda concluída + canteiro */
.done { padding: 8px 18px 24px; display: flex; flex-direction: column; gap: 18px; flex: 1; }
.canteiro { display: grid; grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr)); gap: 4px; }
.canteiro span { aspect-ratio: 1; display: flex; align-items: flex-end; justify-content: center; border-bottom: 2px solid var(--furrow); padding-bottom: 2px; }
.canteiro i { width: 5px; height: 5px; border-radius: 50%; background: var(--seed); margin-bottom: 4px; }
.canteiro svg { width: 82%; height: auto; color: var(--broto); }
.canteiro svg.today { color: #B8860B; }
.canteiro svg.nova { animation: brotar .7s cubic-bezier(.2, .8, .3, 1.3) both; color: #B8860B; }
@keyframes brotar { 0% { transform: scale(0) translateY(6px); opacity: 0; } 70% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); } }

/* ---------- Modais / bottom sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 18, 14, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: var(--r-l) var(--r-l) 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; animation: sheet-in .22s ease-out; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: var(--r-l); }
}
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toast { position: fixed; z-index: 60; left: 50%; top: 16px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: var(--r-m); font-weight: 700; background: var(--ink); color: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.erro { background: var(--erro); color: #FFFFFF; }
.offline-pill { position: fixed; z-index: 55; right: 12px; bottom: 12px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; }
/* No topo, colado à faixa colorida, para não cobrir botões de ação embaixo */
.env-pill { position: fixed; z-index: 55; left: 50%; top: 6px; transform: translateX(-50%); background: var(--milho); color: #26221C; font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 0 0 8px 8px; pointer-events: none; }

/* ---------- Telão ---------- */
.telao { min-height: 100vh; padding: clamp(24px, 4vw, 64px) clamp(24px, 5vw, 88px); display: flex; flex-direction: column; gap: 4vh; }
.telao .hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 24px; }
.telao .valor { font-family: var(--font-display); font-size: clamp(64px, 10vw, 190px); font-weight: 800; letter-spacing: -.045em; line-height: .86; font-variant-numeric: tabular-nums; }
.telao .mudas { font-family: var(--font-display); font-size: clamp(36px, 4.6vw, 88px); font-weight: 800; color: var(--broto); letter-spacing: -.03em; line-height: .9; }
.telao .canteiro { flex: 1; gap: 6px 10px; }
.telao .canteiro span { border-bottom-width: 4px; }
.telao .rank { display: flex; flex-wrap: wrap; gap: 16px 40px; font-size: clamp(18px, 1.6vw, 30px); }
.telao .rank > div { display: flex; align-items: center; gap: 12px; }

/* ---------- Impressão (prestação de contas) ---------- */
.print-only { display: none; }
@media print {
    body { background: #FFFFFF; color: #000000; }
    body > *:not(#printArea) { display: none !important; }
    #printArea { display: block !important; padding: 0; }
    .relatorio h1 { font-size: 26pt; }
    .relatorio table { width: 100%; border-collapse: collapse; font-size: 11pt; }
    .relatorio th, .relatorio td { border-bottom: 1px solid #999999; padding: 6px 4px; text-align: left; }
    .relatorio .right { text-align: right; }
    .relatorio section { break-inside: avoid; margin-top: 18pt; }
}
