/* ==========================================================================
   Gases Vendas — design system mobile-first (CSS puro)
   ========================================================================== */

:root {
  --white: #FFFFFF;
  --black: #111111;
  --red: #D71920;
  --red-dark: #A61018;
  --red-soft: #FDECEC;
  --gray-bg: #F5F5F5;
  --gray-border: #E5E5E5;
  --gray-text: #6B6B6B;
  --gray-mid: #9A9A9A;
  --green: #137A3A;
  --green-soft: #E7F5EC;
  --amber: #8A5A00;
  --amber-soft: #FFF4DB;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 2px 8px rgba(17, 17, 17, .05);
  --shadow-lg: 0 -4px 24px rgba(17, 17, 17, .12);

  --header-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;
  --max-w: 560px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--black);
  background: var(--gray-bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

img, svg { max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.icon { width: 22px; height: 22px; flex-shrink: 0; vertical-align: middle; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 28px; height: 28px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estrutura do app ---------- */

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  padding-top: var(--safe-top);
}
.app-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 var(--gutter);
}
.app-header.has-back .app-header-inner { padding-left: 4px; }
.app-header h1 {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--red); color: var(--white);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-mark .icon { width: 18px; height: 18px; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--gutter) var(--gutter) calc(var(--nav-h) + var(--safe-bottom) + 24px);
}
.no-nav .app-main { padding-bottom: calc(var(--safe-bottom) + 24px); }
.has-action-bar .app-main { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ---------- Navegação inferior ---------- */

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--white);
  border-top: 1px solid var(--gray-border);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-mid);
  min-width: 0;
}
.nav-item.is-active { color: var(--black); }
.nav-item.is-active .icon { color: var(--red); }
.nav-item-cta { position: relative; }
.nav-cta-circle {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  display: grid; place-items: center;
  margin-top: -22px;
  box-shadow: 0 6px 16px rgba(215, 25, 32, .35);
  border: 4px solid var(--white);
}
.nav-cta-circle .icon { width: 26px; height: 26px; stroke-width: 2.5; }
.nav-item-cta > span:last-child { color: var(--red); }
.nav-item-cta:active .nav-cta-circle { background: var(--red-dark); }

/* ---------- Tipografia utilitária ---------- */

.page-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--gray-text); margin: 24px 2px 10px;
}
.section-title a { color: var(--red); text-transform: none; letter-spacing: 0; font-size: 14px; }
.muted { color: var(--gray-text); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.text-red { color: var(--red); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--gray-border); margin: 12px 0; border: 0; }

/* ---------- Cards ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.card-flush { padding: 0; overflow: hidden; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
  width: 100%;
  text-align: left;
  transition: transform .08s ease, border-color .15s;
}
button.list-card { cursor: pointer; }
.list-card:active { transform: scale(.985); border-color: #d0d0d0; }
.list-card .chev { color: var(--gray-mid); }
.list-card.is-selected { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-soft); }
.list-card.is-inactive { opacity: .6; }
.list-title { font-weight: 700; font-size: 15px; }
.list-sub { font-size: 13px; color: var(--gray-text); }
.list-value { font-weight: 800; font-size: 15px; white-space: nowrap; }

.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--gray-bg); color: var(--black);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  border: 1px solid var(--gray-border);
}
.avatar-red { background: var(--red-soft); color: var(--red); border-color: transparent; }

/* ---------- Indicadores (dashboard) ---------- */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--gray-text); display: flex; align-items: center; gap: 6px; }
.stat-label .icon { width: 16px; height: 16px; color: var(--red); }
.stat-value { font-size: 20px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.stat-hero {
  grid-column: 1 / -1;
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.stat-hero .stat-label { color: #BDBDBD; }
.stat-hero .stat-value { font-size: 30px; }
.stat-hero .stat-foot { font-size: 13px; color: #BDBDBD; margin-top: 2px; }

.alert-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--amber-soft); color: var(--amber);
  border-radius: var(--radius); padding: 12px 14px; font-weight: 600; font-size: 14px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; line-height: 1;
  padding: 5px 8px; border-radius: 999px;
  background: var(--gray-bg); color: var(--gray-text);
  white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }
.badge-success { background: var(--green-soft); color: var(--green); }
.badge-warning { background: var(--amber-soft); color: var(--amber); }
.badge-danger { background: var(--red-soft); color: var(--red-dark); }
.badge-dark { background: var(--black); color: var(--white); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--white);
  color: var(--black);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, transform .08s;
  position: relative;
  text-align: center;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:active { background: var(--red-dark); }
.btn-dark { background: var(--black); color: var(--white); }
.btn-outline { border-color: var(--gray-border); background: var(--white); }
.btn-outline-red { border-color: var(--red); color: var(--red); background: var(--white); }
.btn-ghost { background: transparent; color: var(--red); padding: 0 10px; }
.btn-danger { background: var(--white); color: var(--red-dark); border-color: #F3C4C6; }
.btn-whatsapp { background: #128C4A; color: var(--white); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 14px; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-group { display: grid; gap: 10px; }
.btn-group-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px;
  border: 2.5px solid currentColor; border-radius: 50%;
  border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) rgba(255,255,255,.9) transparent;
  animation: spin .7s linear infinite;
}
.btn-outline.is-loading::after, .btn-danger.is-loading::after, .btn-outline-red.is-loading::after { border-color: var(--red) var(--red) var(--red) transparent; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--black);
  display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { background: var(--gray-bg); }
.icon-btn-red { color: var(--red); }

/* ---------- Formulários ---------- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 14px; font-weight: 700; }
.field .hint { font-size: 12px; color: var(--gray-text); }
.req { color: var(--red); }
.input, .select, .textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-border);
  border-radius: 12px;
  background: var(--white);
  font-size: 16px; /* evita zoom no iOS */
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}
.textarea { min-height: 96px; resize: vertical; }
.select {
  background-image: linear-gradient(45deg, transparent 50%, #6B6B6B 50%), linear-gradient(135deg, #6B6B6B 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--black); box-shadow: 0 0 0 3px rgba(17,17,17,.06); }
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid { border-color: var(--red); }
.field-error { font-size: 13px; color: var(--red-dark); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.form-actions { display: grid; gap: 10px; margin-top: 8px; }
.fieldset-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-text); margin-top: 8px; }

.input-group { position: relative; }
.input-group .input { padding-left: 44px; }
.input-group .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-mid); pointer-events: none; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--gray-text); pointer-events: none; }
.input-prefix .input { padding-left: 44px; }

.check {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1.5px solid var(--gray-border); border-radius: 12px; background: var(--white);
  font-size: 15px; cursor: pointer;
}
.check input { width: 22px; height: 22px; accent-color: var(--red); margin: 0; flex-shrink: 0; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--gray-bg); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  min-height: 42px; display: grid; place-items: center; border-radius: 9px;
  font-weight: 700; font-size: 14px; color: var(--gray-text); cursor: pointer; text-align: center;
}
.segmented input:checked + label { background: var(--white); color: var(--black); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 2px solid var(--black); }

.search-bar { position: sticky; top: calc(var(--header-h) + var(--safe-top)); z-index: 5; background: var(--gray-bg); padding: 4px 0 12px; margin-top: -4px; }

/* ---------- Chips (filtros) ---------- */

.chips {
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) 10px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  min-height: 38px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px;
  border: 1.5px solid var(--gray-border);
  background: var(--white);
  font-size: 14px; font-weight: 700; color: var(--black);
  cursor: pointer;
}
.chip.is-active { background: var(--black); border-color: var(--black); color: var(--white); }

/* ---------- Pares chave/valor ---------- */

.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--gray-border); font-size: 15px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row dt, .kv-row .k { color: var(--gray-text); flex-shrink: 0; }
.kv-row dd, .kv-row .v { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; min-width: 0; }

/* ---------- Itens da venda ---------- */

.item-card { background: var(--white); border: 1px solid var(--gray-border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.item-head { display: flex; align-items: flex-start; gap: 8px; }
.item-name { flex: 1; font-weight: 700; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.item-controls { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: end; margin-top: 12px; }
.item-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--gray-border); font-size: 14px; color: var(--gray-text); }
.item-total strong { color: var(--black); font-size: 17px; }
.price-changed { font-size: 12px; color: var(--amber); font-weight: 600; }

.qty { display: inline-grid; grid-template-columns: 44px 56px 44px; border: 1.5px solid var(--gray-border); border-radius: 12px; overflow: hidden; height: 50px; }
.qty button { border: 0; background: var(--gray-bg); display: grid; place-items: center; cursor: pointer; color: var(--black); }
.qty button:active { background: var(--gray-border); }
.qty input { border: 0; text-align: center; font-weight: 800; font-size: 17px; width: 100%; outline: none; background: var(--white); -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.totals { background: var(--white); border: 1px solid var(--gray-border); border-radius: var(--radius); padding: 4px 16px; }
.totals .kv-row.total { font-size: 20px; font-weight: 800; }
.totals .kv-row.total .v, .totals .kv-row.total .k { color: var(--black); }

table.items { width: 100%; border-collapse: collapse; font-size: 14px; }
table.items th { text-align: left; font-size: 12px; color: var(--gray-text); font-weight: 700; padding: 8px 4px; border-bottom: 1.5px solid var(--black); }
table.items td { padding: 10px 4px; border-bottom: 1px solid var(--gray-border); vertical-align: top; }
table.items .num { text-align: right; white-space: nowrap; }

/* ---------- Assistente de venda ---------- */

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.step-dot { display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 700; color: var(--gray-mid); text-align: center; }
.step-dot::before { content: ""; height: 4px; border-radius: 4px; background: var(--gray-border); }
.step-dot.is-done::before, .step-dot.is-current::before { background: var(--red); }
.step-dot.is-current { color: var(--black); }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--white);
  border-top: 1px solid var(--gray-border);
  box-shadow: var(--shadow-lg);
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
}
.action-bar-inner { max-width: var(--max-w); margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.action-bar .total-box { flex: 1; min-width: 0; }
.action-bar .total-box small { display: block; font-size: 12px; color: var(--gray-text); font-weight: 600; }
.action-bar .total-box strong { font-size: 20px; font-weight: 800; white-space: nowrap; }
.action-bar .btn { flex-shrink: 0; }

.selected-client { border-color: var(--black); }
.draft-banner { display: flex; align-items: center; gap: 10px; background: var(--amber-soft); color: var(--amber); border-radius: var(--radius); padding: 10px 12px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.draft-banner .grow { color: var(--amber); }

/* ---------- Assinatura ---------- */

.signature-wrap { position: relative; background: var(--white); border: 2px dashed #C9C9C9; border-radius: var(--radius); overflow: hidden; touch-action: none; }
.signature-canvas { display: block; width: 100%; height: 260px; touch-action: none; cursor: crosshair; background: var(--white); }
.signature-line { position: absolute; left: 24px; right: 24px; bottom: 56px; border-bottom: 1.5px solid #BDBDBD; pointer-events: none; }
.signature-placeholder { position: absolute; left: 0; right: 0; bottom: 24px; text-align: center; font-size: 13px; color: var(--gray-mid); pointer-events: none; }
.signature-wrap.has-ink .signature-placeholder { display: none; }
.signature-legal { font-size: 12px; color: var(--gray-text); line-height: 1.4; }
@media (orientation: landscape) and (max-height: 500px) {
  .signature-canvas { height: 200px; }
}

/* ---------- Bottom sheet / modal ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(17,17,17,.45);
  opacity: 0; transition: opacity .2s;
}
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: var(--max-w); margin: 0 auto;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  max-height: calc(100vh - var(--safe-top) - 24px);
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  box-shadow: var(--shadow-lg);
}
@supports (height: 100dvh) {
  .sheet { max-height: calc(100dvh - var(--safe-top) - 24px); }
}
.sheet.is-open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 5px; border-radius: 4px; background: var(--gray-border); margin: 8px auto 0; flex-shrink: 0; }
.sheet-header { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px var(--gutter); flex-shrink: 0; }
.sheet-header h2 { flex: 1; font-size: 18px; font-weight: 800; }
.sheet-body { padding: 4px var(--gutter) calc(var(--gutter) + var(--safe-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-footer { padding: 12px var(--gutter) calc(12px + var(--safe-bottom)); border-top: 1px solid var(--gray-border); flex-shrink: 0; }
body.sheet-open { overflow: hidden; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed; z-index: 90;
  left: 0; right: 0; top: calc(var(--safe-top) + 8px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 12px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  width: 100%; max-width: 520px;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--black); color: var(--white);
  padding: 12px 14px; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  font-size: 14px; font-weight: 600;
  animation: toast-in .25s ease;
}
.toast .icon { width: 20px; height: 20px; }
.toast-success .icon { color: #5BD68A; }
.toast-error { background: var(--red-dark); }
.toast-info .icon { color: #FFC857; }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---------- Loading ---------- */

.loading-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(255,255,255,.75);
  display: grid; place-items: center;
}
.spinner { width: 40px; height: 40px; border: 4px solid var(--gray-border); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-center, .loading-overlay .spinner { margin: 0 auto; }
.loading-overlay p { margin-top: 12px; font-weight: 700; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Estados vazios ---------- */

.empty { text-align: center; padding: 36px 16px; color: var(--gray-text); }
.empty .icon { width: 44px; height: 44px; color: #C9C9C9; margin-bottom: 8px; }
.empty strong { display: block; color: var(--black); font-size: 16px; margin-bottom: 4px; }

/* ---------- Paginação ---------- */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 14px; color: var(--gray-text); }

/* ---------- Menu ---------- */

.menu-list { background: var(--white); border: 1px solid var(--gray-border); border-radius: var(--radius); overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 0 16px; min-height: 58px; border-bottom: 1px solid var(--gray-border); font-weight: 600; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; text-align: left; font-size: 16px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item .icon:first-child { color: var(--red); }
.menu-item .chev { margin-left: auto; color: var(--gray-mid); }
.menu-item:active { background: var(--gray-bg); }
.profile-card { display: flex; align-items: center; gap: 14px; }

/* ---------- Login ---------- */

.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--white); padding: calc(var(--safe-top) + 32px) 24px calc(var(--safe-bottom) + 24px); }
.auth-inner { width: 100%; max-width: 420px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.auth-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--red); color: var(--white); display: grid; place-items: center; margin-bottom: 24px; }
.auth-logo .icon { width: 34px; height: 34px; }
.auth h1 { font-size: 28px; font-weight: 800; }
.auth .lead { color: var(--gray-text); margin: 6px 0 28px; }
.auth-foot { margin-top: auto; padding-top: 24px; text-align: center; font-size: 12px; color: var(--gray-mid); }

/* ---------- Sucesso ---------- */

.success-hero { text-align: center; padding: 24px 8px 8px; }
.success-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 0 auto 16px; }
.success-icon .icon { width: 42px; height: 42px; stroke-width: 2.5; }
.success-hero h2 { font-size: 24px; font-weight: 800; }
.success-total { font-size: 34px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -.02em; }

/* ---------- Recibo (HTML) ---------- */

.receipt { background: var(--white); border: 1px solid var(--gray-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.receipt-head { background: var(--black); color: var(--white); padding: 18px 16px; display: flex; gap: 12px; align-items: center; }
.receipt-head img { max-height: 72px; max-width: 96px; background: var(--white); border-radius: 8px; padding: 4px; }
.receipt-head .company { flex: 1; min-width: 0; }
.receipt-head .company strong { display: block; font-size: 16px; }
.receipt-head .company span { display: block; font-size: 12px; color: #C9C9C9; overflow-wrap: anywhere; }
.receipt-band { background: var(--red); color: var(--white); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: 800; gap: 8px; }
.receipt-section { padding: 14px 16px; border-bottom: 1px solid var(--gray-border); }
.receipt-section:last-child { border-bottom: 0; }
.receipt-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--red); margin-bottom: 8px; }
.receipt-total { display: flex; justify-content: space-between; align-items: center; font-size: 22px; font-weight: 800; }
.receipt-signature { text-align: center; }
.receipt-signature img { max-width: 100%; max-height: 140px; border-bottom: 1.5px solid var(--black); }
.receipt-cancelled { background: var(--red-soft); color: var(--red-dark); font-weight: 800; text-align: center; padding: 10px; letter-spacing: .06em; }

/* ---------- WhatsApp ---------- */

.wa-log { display: flex; flex-direction: column; gap: 8px; }
.wa-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; padding: 10px 12px; background: var(--gray-bg); border-radius: 10px; }
.wa-item .muted { font-size: 12px; }
.wa-error { font-size: 12px; color: var(--red-dark); margin-top: 2px; }

/* ---------- Erro ---------- */

.error-page { text-align: center; padding: 48px 16px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--red); line-height: 1; }

/* ---------- Telas maiores (tablet/desktop apenas como fallback) ---------- */
@media (min-width: 600px) {
  body { background: #EDEDED; }
}

@media (max-width: 350px) {
  :root { --gutter: 12px; }
  .stat-value { font-size: 17px; }
  .stat-hero .stat-value { font-size: 26px; }
  .btn { padding: 0 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .action-bar .total-box strong { font-size: 17px; }
  .qty { grid-template-columns: 40px 48px 40px; }
}

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

.stat-wide { grid-column: 1 / -1; }
.text-center { text-align: center; }
details.card summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 24px; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "+"; font-size: 22px; font-weight: 400; color: var(--gray-text); }
details.card[open] summary::after { content: "–"; }
.profile-card { color: inherit; }
.badges-center { justify-content: center; }
.logo-preview { max-height: 80px; margin: 0 auto; }

.brand-logo { width: 38px; height: 30px; object-fit: contain; flex-shrink: 0; }
.auth-brand { display: block; width: 210px; max-width: 70%; height: auto; margin: 0 auto 20px; }
.auth h1 { text-align: center; }
.auth .lead { text-align: center; }

/* Mostrar/ocultar senha */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 52px; }
.pw-toggle {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px;
  display: grid; place-items: center; color: var(--gray-text); cursor: pointer;
}
.pw-toggle:active { background: var(--gray-bg); }
.input-group .pw-toggle .icon { position: static; transform: none; color: var(--gray-text); }
.input-group > .icon { z-index: 2; }
