:root {
  --bg: #f7f3f5;
  --surface: #ffffff;
  --surface-soft: #fdf7fa;
  --primary: #b01256;
  --primary-hover: #8c0d43;
  --primary-tint: #fce4ec;
  --primary-tint-text: #880e4f;
  --text: #1a1417;
  --text-muted: #5a4c53;
  --border: #e5d8df;
  --danger: #b71c1c;
  --danger-hover: #8e1313;
  --danger-bg: #fdecea;
  --warning-bg: #fff4d6;
  --warning-border: #d97706;
  --warning-text: #663c00;
  --success: #1b6e35;
  --success-bg: #e6f4ea;
  --shadow-sm: 0 2px 8px rgba(42, 12, 26, 0.06);
  --shadow-lg: 0 10px 28px rgba(42, 12, 26, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

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

.app-shell {
  min-height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view-center {
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.muted-text {
  color: var(--text-muted);
  margin: 0;
}

.muted-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 6px 0 0;
}

/* Spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--primary-tint);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Botões (todos mínimo 48px para uso com uma mão) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 48px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.12s ease, transform 0.08s ease, opacity 0.12s ease;
  touch-action: manipulation;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-xl {
  min-height: 56px;
  font-size: 1.1rem;
  border-radius: var(--radius);
}

.btn-sm {
  min-height: 48px;
  padding: 8px 14px;
  font-size: 0.95rem;
}

.btn-xs {
  min-height: 48px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-tint);
}

.btn-light {
  background: #ffffff;
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #eab8b8;
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Inputs */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.field-error {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--danger);
}

.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
}

.input:focus {
  border-color: var(--primary);
}

.input-lg {
  min-height: 54px;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-btn {
  padding-right: 92px;
}

.btn-icon-inline {
  position: absolute;
  right: 4px;
  min-height: 48px;
  min-width: 48px;
  padding: 0 12px;
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 8px;
}

/* Alertas */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f2c0c0;
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid #f2cf7e;
  border-left: 6px solid var(--warning-border);
}

.liberacao-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.alert-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alert-title {
  font-size: 0.95rem;
}

.alert-text {
  margin: 0;
  font-weight: 600;
}

.btn-icon-dismiss {
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
}

/* Login */
.view-login {
  justify-content: center;
  padding: 20px 16px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  border-radius: 14px;
  flex-shrink: 0;
}

.brand-kicker {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.brand-title {
  margin: 2px 0 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-seller {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-name {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title {
  margin: 0;
  font-size: 1.1rem;
}

.header-spacer {
  width: 48px;
}

/* Pedido principal */
.pedido-main {
  flex: 1;
  padding: 16px;
  padding-bottom: 112px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-order-card {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.section-heading {
  margin: 0;
  font-size: 1.25rem;
}

.order-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.badge-order {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary-tint-text);
  font-weight: 700;
  font-size: 0.9rem;
}

/* Busca */
.search-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  padding-right: 52px;
}

.btn-clear-search {
  position: absolute;
  right: 2px;
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 8px;
}

.search-results-panel {
  background: var(--surface);
  border: 1.5px solid var(--primary-tint);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary-tint-text);
}

.empty-inline {
  margin: 0;
  padding: 18px 16px;
  text-align: center;
  color: var(--text-muted);
}

.product-list,
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.product-row + .product-row {
  border-top: 1px solid var(--border);
}

.product-btn {
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  background: var(--surface);
  border: none;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.product-btn:hover:not(:disabled) {
  background: var(--surface-soft);
}

.product-btn:disabled {
  opacity: 0.58;
  background: #f4f1f3;
  cursor: not-allowed;
}

.product-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.product-name {
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.product-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.product-right {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.product-price {
  font-weight: 700;
  color: var(--primary);
}

.product-price-old {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

.badge-blocked {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
}

/* Itens do pedido */
.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
}

.empty-items-box {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.item-desc {
  font-weight: 600;
  word-break: break-word;
}

.item-unit {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.btn-remove-item {
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-remove-item:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-remove-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-soft);
}

.btn-qty {
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-qty:hover:not(:disabled) {
  background: var(--primary-tint);
}

.btn-qty:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qty-value {
  min-width: 42px;
  padding: 0 8px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.item-total {
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Rodapé fixo */
.pedido-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 600px;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(42, 12, 26, 0.08);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.footer-total-col {
  display: flex;
  flex-direction: column;
}

.footer-total-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-total-value {
  font-size: 1.3rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.btn-footer-cta {
  min-width: 140px;
  min-height: 50px;
  font-size: 1.05rem;
}

/* Subviews: Finalizar e Código */
.subview-main {
  padding: 20px 16px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-row-total {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
}

.total-highlight {
  font-size: 1.35rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.view-codigo {
  justify-content: center;
}

.code-screen-main {
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.code-success-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-subtitle {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text);
}

.code-number {
  width: 100%;
  padding: 20px 16px;
  border-radius: var(--radius);
  background: var(--primary-tint);
  color: var(--primary-tint-text);
  border: 2px solid var(--primary);
  font-size: clamp(3.2rem, 17vw, 5.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.code-summary {
  width: 100%;
  text-align: left;
}

/* Scanner Overlay */
.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0d0a0c;
  color: #ffffff;
  display: flex;
  flex-direction: column;
}

.scanner-top {
  padding: 18px 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
}

.scanner-instruction {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
}

.scanner-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reticle {
  position: absolute;
  width: min(80vw, 320px);
  height: 150px;
  border: 3px solid #f48fb1;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.scanner-bottom {
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.72);
}

/* Modal de confirmação */
.confirm-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(92vw, 400px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.confirm-dialog::backdrop {
  background: rgba(20, 10, 15, 0.55);
}

.confirm-box {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.confirm-title {
  margin: 0;
  font-size: 1.15rem;
}

.confirm-message {
  margin: 0;
  color: var(--text-muted);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(90vw, 440px);
  padding: 12px 18px;
  border-radius: 999px;
  background: #23181e;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

/* total como primeira linha do card (tela do código): sem a linha divisória de cima */
.summary-row-total:first-child {
  padding-top: 0;
  border-top: 0;
}
