/* =====================================================================
   DG PDV — estilos
   Mobile-first. Tokens por tema em [data-theme]. Sem frameworks.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root,
[data-theme="claro"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaee;
  --border: #e1e4e9;
  --border-strong: #cdd2d9;
  --text: #15181d;
  --text-2: #5c6470;
  --text-3: #8a919c;
  --primary: #0f7a63;
  --primary-strong: #0b604e;
  --primary-soft: #e2f2ec;
  --on-primary: #ffffff;
  --success: #1c8a4b;
  --success-soft: #e3f4ea;
  --warning: #a86a12;
  --warning-soft: #fbf0dc;
  --danger: #cf3a3a;
  --danger-soft: #fbe6e6;
  --info: #2a62d6;
  --info-soft: #e5edfc;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-3: 0 18px 48px rgba(16, 24, 40, .18);
  --overlay: rgba(15, 18, 24, .45);
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
  color-scheme: light;
}

/* Escuro pensado para OLED/AMOLED: fundo preto puro (pixel apagado) e superfícies
   quase pretas, separadas por bordas em vez de cinzas claros. */
[data-theme="escuro"] {
  --bg: #000000;
  --surface: #0b0b0c;
  --surface-2: #121214;
  --surface-3: #1a1a1d;
  --border: #222226;
  --border-strong: #34343a;
  --text: #ededef;
  --text-2: #a3a3ab;
  --text-3: #6f6f78;
  --primary: #36c79f;
  --primary-strong: #5fd8b6;
  --primary-soft: rgba(54, 199, 159, .14);
  --on-primary: #04241b;
  --success: #3fcf7f;
  --success-soft: rgba(63, 207, 127, .14);
  --warning: #f0b45a;
  --warning-soft: rgba(240, 180, 90, .14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, .14);
  --info: #7aa7ff;
  --info-soft: rgba(122, 167, 255, .14);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-3: 0 18px 48px rgba(0, 0, 0, .7);
  --overlay: rgba(0, 0, 0, .65);
  color-scheme: dark;
}

[data-theme="roxo"] {
  --bg: #130f1d;
  --surface: #1c1729;
  --surface-2: #241d35;
  --surface-3: #2e2543;
  --border: #33294b;
  --border-strong: #44385f;
  --text: #f2eefb;
  --text-2: #b5a9d3;
  --text-3: #7f739c;
  --primary: #a77bff;
  --primary-strong: #bf9dff;
  --primary-soft: rgba(167, 123, 255, .16);
  --on-primary: #170b33;
  --success: #49d38b;
  --success-soft: rgba(73, 211, 139, .14);
  --warning: #f2b862;
  --warning-soft: rgba(242, 184, 98, .14);
  --danger: #ff7a95;
  --danger-soft: rgba(255, 122, 149, .15);
  --info: #86a8ff;
  --info-soft: rgba(134, 168, 255, .15);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-3: 0 18px 48px rgba(0, 0, 0, .65);
  --overlay: rgba(6, 3, 14, .65);
  color-scheme: dark;
}

[data-theme="creme"] {
  --bg: #f5efe4;
  --surface: #fffbf4;
  --surface-2: #f1e9db;
  --surface-3: #e9dfcd;
  --border: #e3d7c2;
  --border-strong: #d2c3a9;
  --text: #2a2217;
  --text-2: #6c5d48;
  --text-3: #9a8a72;
  --primary: #9b5a2c;
  --primary-strong: #7d4520;
  --primary-soft: #f2e1d0;
  --on-primary: #ffffff;
  --success: #3d7d3a;
  --success-soft: #e4efd9;
  --warning: #a8701a;
  --warning-soft: #f6e6c6;
  --danger: #b8402f;
  --danger-soft: #f5dcd5;
  --info: #3d6a9e;
  --info-soft: #e0e8f1;
  --shadow-1: 0 1px 2px rgba(60, 40, 10, .06);
  --shadow-2: 0 4px 16px rgba(60, 40, 10, .08);
  --shadow-3: 0 18px 48px rgba(60, 40, 10, .18);
  --overlay: rgba(40, 28, 10, .4);
  color-scheme: light;
}

:root {
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --tap: 48px;
  --tap-sm: 40px;
  --nav-h: 64px;
  --top-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 650; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.primary-text { color: var(--primary); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.oculto { display: none !important; }

/* Fotos de produto */
.foto-produto { width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-3); }
.foto-produto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-produto.grande { width: 96px; height: 96px; border-radius: var(--radius); border: 1px dashed var(--border-strong); }
.foto-produto.destaque { width: 100%; height: auto; max-height: 260px; aspect-ratio: 4 / 3; border-radius: var(--radius); }
.campo-foto { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.campo-foto label.btn { cursor: pointer; }

/* Leitor pela câmera */
.camera-leitor { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.camera-leitor video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-leitor .mira { position: absolute; left: 10%; right: 10%; top: 35%; bottom: 35%; border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); pointer-events: none; }
.camera-leitor .lanterna { position: absolute; right: 10px; bottom: 10px; }
.ultima-leitura { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); margin-top: 12px; min-height: 52px; }
.ultima-leitura.ok { background: var(--success-soft); color: var(--success); }
.ultima-leitura.erro { background: var(--danger-soft); color: var(--danger); }
.ultima-leitura .texto { flex: 1; min-width: 0; color: var(--text); }
.leitor-conectado { display: inline-flex; align-items: center; gap: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Ícones (Lucide via máscara CSS) ---------- */
.icon {
  display: inline-block;
  width: 20px; height: 20px;
  flex: 0 0 auto;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }
.icon.xl { width: 32px; height: 32px; }

/* ---------- Layout do app ---------- */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--top-h) + var(--safe-top));
  padding: var(--safe-top) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .loja-btn {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto;
  height: 44px; padding: 0 8px; margin-left: -8px; border: 0; background: transparent; border-radius: var(--radius-sm);
  text-align: left;
}
.topbar .loja-btn:hover { background: var(--surface-2); }
.marca {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); font-weight: 750; font-size: 13px; letter-spacing: -.02em;
}
.loja-btn .nome { font-weight: 650; font-size: 15px; }
.loja-btn .papel { font-size: 12px; color: var(--text-3); }
.topbar .acoes { display: flex; align-items: center; gap: 4px; }

.conteudo {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px calc(16px + var(--safe-right)) calc(var(--nav-h) + var(--safe-bottom) + 24px) calc(16px + var(--safe-left));
}
.conteudo.sem-nav { padding-bottom: calc(24px + var(--safe-bottom)); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--border);
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: transparent; color: var(--text-3); text-decoration: none;
  font-size: 11.5px; font-weight: 600; min-height: var(--tap);
}
.bottom-nav .ativo { color: var(--primary); }
.bottom-nav .ativo .icon { transform: translateY(-1px); }

.sidebar { display: none; }

@media (min-width: 1024px) {
  .shell { flex-direction: row; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh; width: 248px; flex: 0 0 248px;
    padding: 16px 12px; border-right: 1px solid var(--border); background: var(--surface);
    overflow-y: auto;
  }
  .sidebar .loja-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: transparent; border-radius: var(--radius-sm); text-align: left; margin-bottom: 12px; }
  .sidebar .loja-btn:hover { background: var(--surface-2); }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a {
    display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--radius-sm);
    color: var(--text-2); text-decoration: none; font-weight: 550; font-size: 14.5px;
  }
  .sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
  .sidebar nav a.ativo { background: var(--primary-soft); color: var(--primary); }
  .sidebar .rodape { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
  .principal { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
  .topbar { display: none; }
  .bottom-nav { display: none; }
  .conteudo { padding: 24px 32px 40px; }
}

/* ---------- Cabeçalho de tela ---------- */
.cabecalho { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cabecalho .titulo { min-width: 0; }
.cabecalho .titulo p { margin-top: 2px; color: var(--text-2); font-size: 13.5px; }
.cabecalho .acoes { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 599px) {
  .cabecalho .acoes { width: 100%; }
  .cabecalho .acoes > .btn { flex: 1 1 auto; }
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 600; font-size: 15px; line-height: 1;
  background: var(--surface-2); color: var(--text);
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .08s var(--ease), opacity .15s;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primario { background: var(--primary); color: var(--on-primary); }
.btn-primario:hover:not(:disabled) { background: var(--primary-strong); }
.btn-secundario { background: var(--surface); border-color: var(--border-strong); }
.btn-secundario:hover:not(:disabled) { background: var(--surface-2); }
.btn-fantasma { background: transparent; color: var(--text-2); }
.btn-fantasma:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-perigo { background: var(--danger-soft); color: var(--danger); }
.btn-perigo:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-perigo-solido { background: var(--danger); color: #fff; }
.btn-sucesso { background: var(--success); color: #fff; }
.btn-lg { min-height: 56px; font-size: 16.5px; border-radius: var(--radius-lg); padding: 0 22px; }
.btn-sm { min-height: var(--tap-sm); padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-icone { width: var(--tap); padding: 0; }
.btn-icone.btn-sm { width: var(--tap-sm); }
.btn-bloco { width: 100%; }
.btn .carregando { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: girar .7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.link-btn { border: 0; background: none; padding: 6px 0; color: var(--primary); font-weight: 600; font-size: 14px; min-height: 36px; }

/* ---------- Formulários ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.campo > label, .rotulo { font-size: 13px; font-weight: 600; color: var(--text-2); }
.campo .ajuda { font-size: 12.5px; color: var(--text-3); }
.campo .erro { font-size: 12.5px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap);
  padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 16px; /* 16px evita zoom automático no iOS */
  transition: border-color .15s, box-shadow .15s;
}
.textarea { padding: 12px 14px; min-height: 88px; resize: vertical; line-height: 1.4; }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input.num { text-align: right; }
.input-grupo { position: relative; display: flex; align-items: center; }
.input-grupo > .icon { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; }
.input-grupo > .input { padding-left: 44px; }
.input-grupo > .sufixo { position: absolute; right: 6px; }
.prefixo-wrap { position: relative; }
.prefixo-wrap > .prefixo { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 15px; pointer-events: none; }
.prefixo-wrap > .input { padding-left: 42px; }
.linha-campos { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .linha-campos.duas { grid-template-columns: 1fr 1fr; } .linha-campos.tres { grid-template-columns: 1fr 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: 0 0 auto; }

/* Controle segmentado */
.segmentos { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 12px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmentos::-webkit-scrollbar { display: none; }
.segmentos button { border: 0; background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; min-height: 40px; padding: 0 14px; border-radius: 9px; white-space: nowrap; }
.segmentos button.ativo { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmentos.bloco { display: flex; width: 100%; }
.segmentos.bloco button { flex: 1 1 0; }

/* ---------- Superfícies ---------- */
.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.cartao.pad { padding: 16px; }
.cartao .cartao-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.secao { margin-bottom: 20px; }
.secao-titulo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.secao-titulo h2, .secao-titulo h3 { font-size: 15px; }
.grade { display: grid; gap: 12px; }
@media (min-width: 760px) { .grade.duas { grid-template-columns: 1fr 1fr; } .grade.tres { grid-template-columns: repeat(3, 1fr); } }

/* Listas (substituem tabelas no celular) */
.lista { display: flex; flex-direction: column; }
.lista > .item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 60px;
  border-bottom: 1px solid var(--border); background: transparent; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; color: inherit;
}
.lista > .item:last-child { border-bottom: 0; }
button.item:hover, a.item:hover { background: var(--surface-2); }
.lista .item .principal-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lista .item .titulo-item { font-weight: 600; }
.lista .item .meta { font-size: 13px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lista .item .valor-col { text-align: right; flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.lista .item .valor { font-weight: 650; font-variant-numeric: tabular-nums; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: 0 0 auto; font-weight: 650; }

/* Tabela (desktop) */
.tabela-wrap { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabela td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela td.num, .tabela th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela tbody tr.clicavel { cursor: pointer; }
.tabela tbody tr.clicavel:hover { background: var(--surface-2); }
.so-desktop { display: none; }
.so-largo { display: none !important; }
@media (min-width: 1024px) { .so-largo { display: flex !important; } .so-estreito { display: none !important; } }
@media (min-width: 900px) { .so-desktop { display: block; } .so-mobile { display: none !important; } }

/* Tags / pílulas */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tag.ok { background: var(--success-soft); color: var(--success); }
.tag.alerta { background: var(--warning-soft); color: var(--warning); }
.tag.perigo { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.primaria { background: var(--primary-soft); color: var(--primary); }

/* Indicadores */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
.kpi { padding: 14px; }
.kpi .rotulo { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .valor { font-size: clamp(16px, 4.8vw, 21px); font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .rodape { margin-top: 6px; font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi.destaque { grid-column: 1 / -1; }
.kpi.destaque .valor { font-size: 28px; }
@media (min-width: 900px) { .kpi.destaque { grid-column: span 2; } }
.variacao { display: inline-flex; align-items: center; gap: 2px; font-weight: 650; font-size: 12px; }
.variacao.sobe { color: var(--success); }
.variacao.desce { color: var(--danger); }

/* Estados */
.vazio { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--text-2); }
.vazio .icone-vazio { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); margin-bottom: 4px; }
.vazio h3 { color: var(--text); }
.vazio p { max-width: 340px; font-size: 14px; }
.esqueleto { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: brilho 1.3s ease infinite; border-radius: 8px; }
@keyframes brilho { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.carregando-tela { display: grid; place-items: center; min-height: 50vh; color: var(--text-3); gap: 12px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--primary); animation: girar .8s linear infinite; }

/* Faixas de aviso */
.faixa { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; font-weight: 500; margin-bottom: 12px; }
.faixa.alerta { background: var(--warning-soft); color: var(--warning); }
.faixa.perigo { background: var(--danger-soft); color: var(--danger); }
.faixa.info { background: var(--info-soft); color: var(--info); }
.faixa.ok { background: var(--success-soft); color: var(--success); }
.faixa .btn { margin-left: auto; }
.faixa-global { position: sticky; top: calc(var(--top-h) + var(--safe-top)); z-index: 39; margin: 0; border-radius: 0; justify-content: center; }
@media (min-width: 1024px) { .faixa-global { top: 0; } }

/* Status de sincronização */
.sync { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 0; }
.sync .ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.sync.online .ponto { background: var(--success); }
.sync.conectando .ponto { background: var(--warning); animation: pulsar 1.2s ease infinite; }
.sync.offline { background: var(--danger-soft); color: var(--danger); }
.sync.offline .ponto { background: var(--danger); }
@keyframes pulsar { 50% { opacity: .35; } }

/* ---------- Modal / folha ---------- */
.modal-fundo {
  position: fixed; inset: 0; z-index: 100; background: var(--overlay);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparecer .18s var(--ease);
}
.modal {
  width: 100%; max-height: calc(100dvh - var(--safe-top) - 24px);
  background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex; flex-direction: column; box-shadow: var(--shadow-3);
  animation: subir .24s var(--ease);
  padding-bottom: var(--safe-bottom);
}
.modal.cheio { max-height: calc(100dvh - var(--safe-top)); height: calc(100dvh - var(--safe-top)); }
.modal-topo { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 20px; border-bottom: 1px solid var(--border); }
.modal-topo h2 { flex: 1 1 auto; font-size: 17px; min-width: 0; }
.modal-corpo { padding: 16px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; flex: 1 1 auto; }
.modal-rodape { display: flex; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.modal-rodape .btn { flex: 1 1 0; }
.modal-alca { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; }
@media (min-width: 640px) {
  .modal-fundo { align-items: center; padding: 24px; }
  .modal { max-width: 520px; border-radius: var(--radius-xl); max-height: min(88vh, 860px); padding-bottom: 0; animation: zoom .2s var(--ease); }
  .modal.largo { max-width: 760px; }
  .modal.cheio { height: auto; }
  .modal-alca { display: none; }
}
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(40px); opacity: .6; } }
@keyframes zoom { from { transform: scale(.97); opacity: 0; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 200; left: 0; right: 0; top: calc(var(--safe-top) + 10px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%; padding: 12px 14px; border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: var(--shadow-3); font-size: 14.5px; font-weight: 500; animation: descer .22s var(--ease); }
.toast.ok { background: var(--success); color: #fff; }
.toast.erro { background: var(--danger); color: #fff; }
.toast.alerta { background: var(--warning); color: #fff; }
@keyframes descer { from { transform: translateY(-12px); opacity: 0; } }
@media (min-width: 1024px) { .toasts { top: auto; bottom: 20px; } }

/* ---------- Login ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
.auth .caixa-auth { width: 100%; max-width: 400px; }
.auth .marca-grande { width: 56px; height: 56px; border-radius: 16px; font-size: 20px; margin-bottom: 16px; }
.auth h1 { margin-bottom: 4px; }
.auth .sub { color: var(--text-2); margin-bottom: 24px; }
.auth .cartao { padding: 20px; }
.auth .rodape-auth { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* =====================================================================
   Tela de Caixa
   ===================================================================== */
.caixa-tela { display: flex; flex-direction: column; gap: 12px; }
.caixa-carrinho { order: 1; }
.caixa-busca { order: 2; position: sticky; top: calc(var(--top-h) + var(--safe-top) + 8px); z-index: 20; }
.caixa-produtos { order: 3; }
@media (min-width: 1024px) {
  .caixa-tela { display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto 1fr; gap: 16px; align-items: start; }
  .caixa-busca { grid-column: 1; grid-row: 1; top: 16px; order: 0; }
  .caixa-produtos { grid-column: 1; grid-row: 2; order: 0; }
  .caixa-carrinho { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 24px; order: 0; }
}
.busca-caixa { display: flex; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); }
.busca-caixa .input-grupo { flex: 1 1 auto; }
.busca-caixa .input { border-color: transparent; background: var(--surface-2); }
.busca-caixa .input:focus { background: var(--surface); }
.sugestoes { margin-top: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); overflow: hidden; max-height: 50vh; overflow-y: auto; }
.sugestoes .item { min-height: 56px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; min-height: 40px; padding: 0 14px; font-size: 13.5px; font-weight: 600; }
.chip.ativo { background: var(--text); color: var(--surface); border-color: var(--text); }

.grade-produtos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
@media (min-width: 1280px) { .grade-produtos { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }
.produto-tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  min-height: 96px; padding: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  transition: border-color .12s, transform .08s, background .12s;
  touch-action: manipulation;
}
.produto-tile .foto-tile { display: block; margin: -4px -4px 0; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.produto-tile .foto-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.produto-tile:hover:not(:disabled) { border-color: var(--primary); }
.produto-tile:active:not(:disabled) { transform: scale(.98); background: var(--primary-soft); }
.produto-tile:disabled { opacity: .45; cursor: not-allowed; }
.produto-tile .nome { font-weight: 600; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.produto-tile .rodape-tile { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.produto-tile .preco { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; font-size: 14.5px; }
.produto-tile .est { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.produto-tile .est.baixo { color: var(--warning); font-weight: 600; }
.produto-tile .qtd-badge { position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 700; display: grid; place-items: center; box-shadow: var(--shadow-2); }

/* Carrinho */
.carrinho { display: flex; flex-direction: column; overflow: hidden; }
.carrinho-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.carrinho-topo h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.carrinho-itens { max-height: 38vh; overflow-y: auto; overscroll-behavior: contain; }
.carrinho.recolhido .carrinho-itens { display: none; }
@media (min-width: 1024px) { .carrinho-itens { max-height: calc(100vh - 380px); min-height: 160px; } .carrinho.recolhido .carrinho-itens { display: block; } }
.linha-carrinho { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.linha-carrinho:last-child { border-bottom: 0; }
.linha-carrinho .nome { font-weight: 600; font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.linha-carrinho .unit { font-size: 12.5px; color: var(--text-3); }
.linha-carrinho .total-linha { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.linha-carrinho .controles { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; height: 40px; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--surface-2); display: grid; place-items: center; color: var(--text); }
.stepper button:active { background: var(--surface-3); }
.stepper input { width: 64px; height: 40px; border: 0; text-align: center; font-weight: 650; background: var(--surface); font-size: 16px; font-variant-numeric: tabular-nums; }
.stepper input:focus { outline: none; box-shadow: inset var(--focus); }
.stepper .unid { padding: 0 8px 0 0; font-size: 13px; color: var(--text-3); background: var(--surface); height: 40px; display: grid; place-items: center; }
.carrinho-resumo { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.resumo-linha { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.resumo-total { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 600; }
.resumo-total .valor-total { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.carrinho-acoes { display: flex; gap: 8px; padding: 0 16px 16px; }
.carrinho-acoes .btn-cobrar { flex: 1 1 auto; }

/* Barra fixa de cobrança no celular */
.barra-cobrar {
  position: fixed; left: 0; right: 0; z-index: 44;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  padding: 10px calc(12px + var(--safe-right)) 10px calc(12px + var(--safe-left));
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
}
.barra-cobrar .btn-cobrar { flex: 1 1 auto; justify-content: space-between; }
.conteudo.com-barra { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 96px); }
@media (min-width: 1024px) { .barra-cobrar { display: none; } .conteudo.com-barra { padding-bottom: 40px; } }

/* Pagamento */
.formas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 420px) { .formas { grid-template-columns: repeat(4, 1fr); } }
.forma-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 72px; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--text); }
.forma-btn.ativo { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.forma-btn:disabled { opacity: .45; }
.notas-rapidas { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.notas-rapidas button { min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.total-pagar { text-align: center; padding: 8px 0 16px; }
.total-pagar .rotulo { font-size: 13px; color: var(--text-2); font-weight: 600; }
.total-pagar .valor { font-size: 36px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.parcela { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); margin-bottom: 6px; }
.parcela .nome-forma { flex: 1 1 auto; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.destaque-troco { padding: 12px 14px; border-radius: var(--radius); background: var(--success-soft); color: var(--success); font-weight: 650; display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; }
.destaque-troco.falta { background: var(--danger-soft); color: var(--danger); }

/* Cupom / recibo */
.recibo { font-variant-numeric: tabular-nums; }
.recibo .cab { text-align: center; padding-bottom: 12px; border-bottom: 1px dashed var(--border-strong); margin-bottom: 10px; }
.recibo .cab .ok-icone { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 10px; background: var(--success-soft); color: var(--success); }
.recibo .linha { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; }
.recibo .linha .desc { min-width: 0; overflow-wrap: anywhere; }
.recibo .sep { border-top: 1px dashed var(--border-strong); margin: 8px 0; }
.recibo .total { font-size: 18px; font-weight: 750; }

/* Gráficos */
.grafico { width: 100%; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .eixo { fill: var(--text-2); font-size: 12px; }
.grafico .grade-linha { stroke: var(--border); stroke-width: 1; }
.grafico .barra { fill: var(--primary); }
.grafico .barra.vazia { fill: var(--surface-3); }
.grafico .barra:hover { fill: var(--primary-strong); }
.barras-h { display: flex; flex-direction: column; gap: 10px; }
.barra-h .topo { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; margin-bottom: 4px; }
.barra-h .topo .nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.barra-h .topo .val { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.barra-h .trilho { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.barra-h .preenche { height: 100%; border-radius: 4px; background: var(--primary); }
.barra-h .preenche.f-dinheiro { background: var(--success); }
.barra-h .preenche.f-pix { background: var(--info); }
.barra-h .preenche.f-cartao { background: var(--primary); }
.barra-h .preenche.f-fiado { background: var(--warning); }
.dica-grafico { font-size: 12.5px; color: var(--text-2); min-height: 18px; text-align: center; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Filtros de período */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filtros .segmentos { flex: 0 1 auto; }
.navegar-periodo { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; }
.navegar-periodo .rotulo-periodo { flex: 1; min-width: 0; text-align: center; font-weight: 600; display: flex; flex-direction: column; line-height: 1.2; }
.navegar-periodo .rotulo-periodo small { font-weight: 400; color: var(--text-2); font-size: 12px; }

/* Barra de busca de listas */
.barra-lista { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.barra-lista .input-grupo { flex: 1 1 220px; }
.barra-lista > .flex { flex: 1 1 260px; min-width: 0; }
.barra-lista .select { flex: 0 1 200px; width: auto; }
@media (max-width: 599px) { .barra-lista .select { flex: 1 1 140px; } }

.paginacao { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }

/* Menu "Mais" */
.menu-mais { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menu-mais a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 88px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 600; font-size: 13.5px; text-align: center; padding: 8px; }
.menu-mais a.ativo { background: var(--primary-soft); color: var(--primary); }

/* Descrição (pares rótulo/valor) */
.pares { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.pares dt { color: var(--text-2); }
.pares dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.pares .total { font-weight: 750; font-size: 16px; color: var(--text); }

/* Linha do tempo (histórico) */
.timeline { display: flex; flex-direction: column; }
.timeline .ev { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: start; }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .ev .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.timeline .ev .ic.deb { background: var(--danger-soft); color: var(--danger); }
.timeline .ev .ic.cred { background: var(--success-soft); color: var(--success); }
.timeline .ev .ic.neutro { background: var(--surface-2); color: var(--text-3); }
.timeline .ev .val { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline .ev .sub-itens { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }

/* Utilidades de espaçamento */
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .col { flex-direction: column; } .center { align-items: center; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { text-align: right; }
.divisor { height: 1px; background: var(--border); margin: 12px 0; border: 0; }

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

/* Impressão (cupom e fechamento) */
@media print {
  body { background: #fff; color: #000; }
  .shell, .toasts, .modal-topo, .modal-rodape, .nao-imprimir { display: none !important; }
  .modal-fundo { position: static; background: none; display: block; }
  .modal { box-shadow: none; max-height: none; border-radius: 0; max-width: none; animation: none; }
  .modal-corpo { overflow: visible; }
}
