@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-variable-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo-variable-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --bg: #F5F2EE;
  --panel: #FFFFFF;
  --border: #E5DDD3;
  --border-strong: #D6CABA;
  --text: #1C1512;
  --muted: #8B7D71;
  --espresso: #1C1512;
  --accent: #A8501A;
  --accent-dark: #7E3B12;
  --wheat: #E8A34A;
  --kraft: #EFE7DB;
  --crust-wash: #FBEFE1;
  --danger: #A33124;
  --danger-wash: #FBEDEB;
  --success: #4A6B2F;
  --success-wash: #EDF2E5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 21, 18, 0.04), 0 6px 20px rgba(28, 21, 18, 0.06);
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Archivo', 'Segoe UI', system-ui, sans-serif;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 {
  font-family: var(--font-display);
  font-variation-settings: 'wdth' 108;
  letter-spacing: -0.015em;
  margin: 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.app { min-height: 100vh; min-height: 100dvh; }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--espresso);
  color: #F5F2EE;
}
.login-logo { width: 56px; height: 56px; margin-bottom: 16px; }
.login h1 { font-size: 24px; text-align: center; }
.login p { color: #BFB1A4; margin: 6px 0 24px; text-align: center; }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.pin-input {
  width: 100%;
  font-size: 28px;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid #4A3B31;
  background: #2A1F19;
  color: #fff;
}
.pin-input:focus { outline: 2px solid var(--wheat); outline-offset: 1px; }
.login .error { color: #F2B8A9; text-align: center; min-height: 20px; font-size: 14px; }

/* ---------- topo e navegação ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--espresso);
  color: #F5F2EE;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title strong { font-family: var(--font-display); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title span { font-size: 12px; color: #BFB1A4; }
.topbar button {
  background: transparent;
  border: 1px solid #4A3B31;
  color: #E8DCCF;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}

.content {
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  height: var(--nav-h);
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  position: relative;
}
.bottom-nav button svg { width: 22px; height: 22px; }
.bottom-nav button.active { color: var(--accent); font-weight: 600; }
.nav-badge {
  position: absolute;
  top: 8px;
  left: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- blocos ---------- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 4px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-row + .card-row { margin-top: 6px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.money { font-weight: 700; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.hero {
  background: var(--espresso);
  color: #F5F2EE;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}
.hero span { color: #BFB1A4; font-size: 13px; }
.hero strong { display: block; font-family: var(--font-display); font-size: 32px; margin-top: 4px; }
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.hero-grid div { background: #2A1F19; border-radius: 10px; padding: 10px; }
.hero-grid b { display: block; font-size: 17px; margin-top: 2px; }
.hero-grid .late b { color: #F2B8A9; }

.alert-card { border-color: var(--wheat); background: var(--crust-wash); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--kraft);
  color: var(--text);
  white-space: nowrap;
}
.badge-pendente, .badge-aguardando, .badge-aberto { background: var(--crust-wash); color: var(--accent-dark); }
.badge-confirmado, .badge-quitado { background: var(--success-wash); color: var(--success); }
.badge-contestado, .badge-recusado, .badge-atrasado { background: var(--danger-wash); color: var(--danger); }
.badge-cancelado { background: #EEE; color: #777; text-decoration: line-through; }

.item-list { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--border); list-style: none; }
.item-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 3px 0; }
.note { margin-top: 8px; font-size: 14px; color: var(--muted); font-style: italic; }
.contest { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--danger-wash); color: var(--danger); font-size: 14px; }

/* ---------- botões e campos ---------- */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 600;
  font-size: 15px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:disabled { opacity: 0.5; }
.btn-danger { color: var(--danger); border-color: #E8C2BC; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.btn-sm { padding: 7px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field input, .field select, .field textarea {
  font-size: 16px;
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  width: 100%;
}
.field textarea { min-height: 70px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); }
.field input.field-readonly {
  background: var(--kraft);
  color: var(--muted);
  border-style: dashed;
}

/* ---------- novo pedido ---------- */
.product-rows { display: flex; flex-direction: column; gap: 8px; }
.product-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.product-row.has-qty { border-color: var(--accent); background: var(--crust-wash); }
.product-name { font-weight: 600; }
.product-price { font-size: 13px; color: var(--muted); }
.product-price button { font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  font-size: 20px;
  line-height: 1;
}
.stepper input {
  width: 62px;
  height: 38px;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
}
.price-input {
  width: 80px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  font-size: 14px;
}
.quick-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.order-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  z-index: 15;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  box-shadow: 0 -6px 20px rgba(28, 21, 18, 0.06);
}
.order-footer-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.order-footer-total { flex: 1; }
.order-footer-total span { font-size: 12px; color: var(--muted); display: block; }
.order-footer-total strong { font-size: 20px; font-family: var(--font-display); }
.content.with-footer { padding-bottom: calc(var(--nav-h) + 110px + env(safe-area-inset-bottom)); }

/* ---------- abas internas ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  white-space: nowrap;
}
.chip.active { background: var(--espresso); color: #fff; border-color: var(--espresso); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 21, 18, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: var(--panel);
  width: 100%;
  max-width: 520px;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-size: 19px; margin-bottom: 12px; }
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 16px; }
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(70px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-12px);
  background: var(--espresso);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.fech-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; margin-top: 8px; font-size: 14px; }
.fech-grid span { color: var(--muted); }
.fech-grid b { text-align: right; }
