:root {
  --primary: #ee4d2d;
  --primary-dark: #d6420f;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #14161a;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

/* The [hidden] attribute's UA rule (display:none) has the same specificity as class
   rules below like .state-box{display:flex} — without !important here, whichever CSS
   rule loads later in the file wins the cascade, so an element with both `hidden` and
   a display-setting class (state-box/step/bumps-card) rendered VISIBLE even while
   .hidden was true in JS. This one rule makes `hidden` always win, for every element. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.shopee-logo { height: 18px; width: auto; }
.pix-logo { height: 20px; width: 20px; vertical-align: middle; }
.icon-btn {
  border: none; background: none; font-size: 20px; cursor: pointer;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.icon-btn-spacer { width: 32px; }

.main { flex: 1; padding: 14px; padding-bottom: 96px; }

.state-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: var(--text-secondary); gap: 12px;
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 12px;
}

.product-card { display: flex; align-items: center; gap: 12px; }
.product-thumb {
  width: 56px; height: 56px; border-radius: 8px; object-fit: cover;
  background: var(--bg); border: 1px solid var(--border); flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name { margin: 0; font-size: 14px; font-weight: 500; line-height: 1.3; }
.product-qty { margin: 2px 0 0; font-size: 12px; color: var(--text-secondary); }
.product-price { margin: 0; font-size: 14px; font-weight: 700; color: var(--primary); white-space: nowrap; }

.section-title { font-size: 14px; font-weight: 700; margin: 4px 0 12px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 12px; color: var(--text-secondary); }
.field > span { font-weight: 500; }
.field input {
  border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px;
  font-size: 14px; color: var(--text); background: var(--surface); width: 100%;
}
.field input:focus { outline: none; border-color: var(--primary); }
.field input.invalid { border-color: var(--danger); }
.field-error { color: var(--danger); min-height: 14px; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.field-small { flex: 0 0 110px !important; }
.field-tiny { flex: 0 0 70px !important; }

.delivery-note {
  font-size: 12px; color: var(--text-secondary); margin: 4px 0 0;
  display: flex; align-items: center; gap: 6px;
}

.summary-card { padding: 14px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); padding: 4px 0; }
.summary-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 15px; font-weight: 700; color: var(--text); }
.summary-total span:last-child { color: var(--primary); }

.payment-method-option {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--primary); border-radius: 8px; padding: 12px;
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.payment-method-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.payment-method-badge {
  margin-left: auto; font-size: 11px; color: var(--success); font-weight: 600;
  background: #f0fdf4; border-radius: 999px; padding: 3px 8px;
}
.payment-method-option input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }

.bump-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-top: 1px dashed var(--border);
}
.bump-item:first-child { border-top: none; padding-top: 0; }
.bump-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--border);
}
.bump-info { flex: 1; min-width: 0; }
.bump-title { margin: 0; font-size: 13px; font-weight: 500; }
.bump-desc { margin: 2px 0 0; font-size: 11px; color: var(--text-secondary); }
.bump-price { margin: 2px 0 0; font-size: 13px; font-weight: 700; color: var(--primary); }
.bump-checkbox { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--primary); }

.form-error {
  color: var(--danger); background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 0 0 12px;
}

.footer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--border); padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.btn {
  width: 100%; border: none; border-radius: 8px; padding: 13px; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }

/* Pay step */
.pay-total-card { display: flex; align-items: center; justify-content: space-between; }
.pay-total-card span { font-size: 13px; color: var(--text-secondary); }
.pay-total-card strong { font-size: 18px; color: var(--primary); }

.pay-timer-card { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 2px; }
.pay-timer-card span { font-size: 12px; color: var(--text-secondary); align-self: flex-start; margin-bottom: -18px; }
.pay-timer-card strong { font-size: 18px; color: var(--primary); font-variant-numeric: tabular-nums; }
.pay-timer-card small { font-size: 11px; color: var(--text-secondary); }

.pix-card { text-align: center; }
.pix-brand {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 600; font-size: 15px; margin-bottom: 10px;
}
.pix-dot { width: 10px; height: 10px; border-radius: 3px; background: #32bcad; display: inline-block; }
.pix-label { font-size: 12px; color: var(--text-secondary); margin: 0 0 8px; }
.pix-code {
  background: var(--bg); border: 1px dashed var(--border); border-radius: 8px;
  padding: 12px; font-size: 12px; color: var(--text-secondary);
  word-break: break-all; margin-bottom: 12px; max-height: 70px; overflow: hidden;
  text-overflow: ellipsis;
}
.pix-qr { width: 180px; height: 180px; margin: 14px auto 0; display: block; }

.instructions-card { }
.instructions-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-secondary); }
.instructions-list li { margin-bottom: 8px; }

.pay-status { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
.pay-status.success { color: var(--success); font-weight: 600; }

.trust-badges { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.trust-badge {
  display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-secondary);
  font-weight: 500;
}
.trust-badge svg { color: var(--success); flex-shrink: 0; }
