:root {
    --bg: #fff4e4;
    --panel: #fffaf1;
    --ink: #2b1d14;
    --muted: #755f4c;
    --brand: #b8321d;
    --brand-dark: #7f2115;
    --gold: #f2b32c;
    --line: #ead8bf;
    --ok: #147a3d;
}

* { box-sizing: border-box; }
html { background: #3f361a; }
body { max-width: 430px; min-height: 100vh; margin: 0 auto; font-family: Arial, sans-serif; background: radial-gradient(circle at top, #ffe4ac 0, var(--bg) 280px); color: var(--ink); padding: 112px 14px 36px; }
button, input, textarea { font: inherit; }

.app-header { position: relative; z-index: 5; margin: 0 0 22px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 16px 12px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,250,241,.94); backdrop-filter: blur(12px); box-shadow: 0 10px 28px rgba(43,29,20,.08); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; }
.brand img { width: 54px; height: 54px; border-radius: 50%; box-shadow: 0 4px 14px rgba(184,50,29,.22); }
.brand span { display: grid; gap: 2px; min-width: 0; }
.brand strong { display: block; font-size: 18px; line-height: 1.05; }
.brand small { color: var(--muted); font-size: 13px; }
.cart-button, .primary { border: 0; border-radius: 10px; background: var(--brand); color: #fff; padding: 11px 14px; font-weight: 800; }
.install-button { border: 1px solid var(--brand); border-radius: 10px; background: #fff; color: var(--brand); padding: 10px 11px; font-weight: 800; }
.cart-button { position: fixed; left: max(18px, calc((100vw - 430px) / 2 + 18px)); right: max(18px, calc((100vw - 430px) / 2 + 18px)); top: calc(18px + env(safe-area-inset-top)) !important; bottom: auto !important; z-index: 15; display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 12px; row-gap: 2px; min-height: 58px; text-align: left; border-radius: 16px; box-shadow: 0 14px 34px rgba(127,33,21,.32); transition: .2s ease; }
.pwa-install-box { position: fixed; left: max(18px, calc((100vw - 430px) / 2 + 18px)); right: max(18px, calc((100vw - 430px) / 2 + 18px)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 16; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,250,241,.98); box-shadow: 0 -10px 28px rgba(43,29,20,.14); backdrop-filter: blur(12px); }
.pwa-install-box[hidden] { display: none; }
.pwa-install-box div { display: grid; gap: 2px; min-width: 0; }
.pwa-install-box strong { font-size: 15px; }
.pwa-install-box span { color: var(--muted); font-size: 13px; line-height: 1.25; }
.pwa-install-box button { flex: 0 0 auto; border: 0; border-radius: 10px; background: var(--brand); color: #fff; padding: 10px 12px; font-weight: 900; }
.cart-icon { position: relative; grid-row: span 2; width: 26px; height: 23px; border: 2px solid #fff; border-top: 0; border-radius: 3px 3px 6px 6px; }
.cart-icon::before { content: ""; position: absolute; left: -5px; top: -8px; width: 11px; height: 9px; border-top: 2px solid #fff; border-left: 2px solid #fff; transform: skewX(-18deg); }
.cart-icon::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: -7px; height: 5px; background: radial-gradient(circle at left center, #fff 0 3px, transparent 3px), radial-gradient(circle at right center, #fff 0 3px, transparent 3px); }
.cart-button strong { display: inline-grid; place-items: center; justify-self: start; min-height: 24px; border-radius: 999px; background: #fff; color: var(--brand); padding: 3px 10px; font-size: 13px; white-space: nowrap; }
.cart-button em { grid-column: 2; color: #ffe8ce; font-size: 12px; font-style: normal; font-weight: 800; }
.cart-button small { grid-column: 3; grid-row: 1 / span 2; color: #fff; font-size: 16px; font-weight: 900; white-space: nowrap; }
.cart-button.cart-attention { animation: cartPulse 1.8s ease; }
@keyframes cartPulse {
    0%, 100% { transform: translateY(0) scale(1); }
    18% { transform: translateY(-5px) scale(1.02); box-shadow: 0 18px 42px rgba(127,33,21,.42); }
    36% { transform: translateY(0) scale(1); }
    54% { transform: translateY(-3px) scale(1.01); }
}

main { margin: 0 auto; padding: 0 0 16px; }
.hero { display: grid; grid-template-columns: 86px 1fr; align-items: center; gap: 14px; margin: 22px 0 20px; padding: 16px; border: 1px solid rgba(184,50,29,.18); border-radius: 18px; background: linear-gradient(135deg, #fffaf1 0%, #ffe2a4 100%); box-shadow: 0 10px 28px rgba(127,33,21,.08); }
.hero img { width: 86px; height: 86px; border-radius: 50%; box-shadow: 0 8px 22px rgba(184,50,29,.22); }
.hero span { display: inline-flex; margin-bottom: 7px; border-radius: 999px; padding: 5px 9px; background: #fff; color: var(--brand); font-size: 12px; font-weight: 800; }
.hero h1 { margin: 0 0 8px; font-size: 30px; line-height: 1; }
.hero p { margin: 0; color: var(--muted); line-height: 1.4; }
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 8px; }
.section-title h2 { margin: 0; font-size: 20px; }
.section-title small { color: var(--muted); text-align: right; }
.tracking-section { margin: 0 0 18px; }
.tracking-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.tracking-form button { border: 0; border-radius: 10px; background: var(--brand); color: #fff; padding: 11px 14px; font-weight: 900; }
.tracking-result { margin-top: 10px; }
.tracking-card { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,250,241,.96); padding: 14px; box-shadow: 0 6px 18px rgba(43,29,20,.05); }
.tracking-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.tracking-card strong { color: var(--brand); }
.tracking-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.35; }
.status-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.status-steps span { border-radius: 999px; padding: 6px 7px; background: #f1e6da; color: var(--muted); font-size: 11px; font-weight: 800; text-align: center; }
.status-steps span.active { background: #e7f4eb; color: var(--ok); }

.categories { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.categories button { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 10px 13px; color: var(--ink); font-weight: 800; box-shadow: 0 4px 12px rgba(43,29,20,.05); }
.categories button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.products { display: grid; gap: 10px; }
.product { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,250,241,.96); box-shadow: 0 6px 18px rgba(43,29,20,.05); cursor: pointer; }
.product:active { transform: scale(.99); }
.product h3 { margin: 0 0 5px; font-size: 17px; }
.product p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.product strong { display: inline-flex; margin-top: 10px; border-radius: 999px; padding: 5px 8px; background: #fff1cc; color: var(--brand-dark); }
.product button { align-self: center; border: 0; border-radius: 999px; width: 42px; height: 42px; background: var(--gold); color: var(--ink); font-size: 24px; font-weight: 900; box-shadow: 0 6px 16px rgba(242,179,44,.28); }

.drawer { position: fixed; inset: 0; z-index: 40; pointer-events: none; background: rgba(43, 29, 20, .25); opacity: 0; transition: .2s; }
.drawer.open { pointer-events: auto; opacity: 1; }
.drawer-panel { position: absolute; inset: auto 0 0; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; background: var(--panel); padding: 16px; box-shadow: 0 -20px 50px rgba(43,29,20,.18); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-header h2 { margin: 0; }
.drawer-header button, .secondary { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 9px 11px; }

.cart-items { display: grid; gap: 8px; margin: 14px 0; }
.empty-cart { margin: 0; border-radius: 12px; padding: 18px; background: #fff; border: 1px dashed var(--line); color: var(--muted); text-align: center; }
.cart-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.cart-item small { display: block; margin-top: 4px; color: var(--muted); }
.cart-item > div:first-child span { display: block; margin-top: 4px; font-weight: 800; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 30px; height: 30px; border-radius: 999px; border: 0; background: var(--brand); color: #fff; }
.total-row { display: flex; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--line); font-size: 18px; }

.checkout-form { display: grid; gap: 12px; }
.form-section { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fffdf8; }
.form-section h3 { margin: 0; font-size: 15px; }
.delivery-fee-notice { margin: 0; border-radius: 10px; padding: 10px 12px; background: #fff4d8; border: 1px solid #f0c46b; color: #5d4218; font-weight: 800; }
.checkout-form label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; font-size: 13px; }
.field-status { display: block; margin-top: -4px; color: var(--ok); font-size: 12px; font-weight: 800; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 11px; background: #fff; color: var(--ink); }
select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 11px 42px 11px 12px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b8321d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--ink); font-weight: 800; appearance: none; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
legend { color: var(--muted); font-weight: 800; }
.choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pay-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset label { display: flex !important; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink) !important; }
fieldset input { width: auto; }
.address-box, .saved-address-box { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 14px; background: #fffdf8; }
.saved-address-box { border-style: solid; background: #fff8e9; }
.saved-address-label { color: var(--ink) !important; }
.selected-address-preview { display: grid; gap: 4px; border-radius: 12px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); }
.selected-address-preview strong { color: var(--brand); font-size: 13px; }
.selected-address-preview span { color: var(--muted); line-height: 1.35; }
.result { margin-top: 12px; padding-bottom: 10px; }
.result .ok { border-radius: 10px; background: #e7f4eb; color: var(--ok); padding: 12px; word-break: break-word; }
.result .ok strong { display: block; font-size: 18px; margin-bottom: 4px; }
.result .bad { border-radius: 10px; background: #fae8e6; color: #9f1d1d; padding: 12px; }
.result a { color: var(--brand); font-weight: 800; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: 16px; background: rgba(43, 29, 20, .32); opacity: 0; pointer-events: none; transition: .2s; }
.modal.open { opacity: 1; pointer-events: auto; }
.modal-panel { width: min(440px, 100%); border-radius: 18px; background: var(--panel); border: 1px solid var(--line); padding: 18px; box-shadow: 0 24px 60px rgba(43,29,20,.22); }
.modal-kicker { display: inline-flex; border-radius: 999px; padding: 6px 9px; background: #e7f4eb; color: var(--ok); font-size: 12px; }
.modal-panel h2 { margin: 12px 0 6px; }
.modal-panel p { margin: 0; color: var(--muted); line-height: 1.35; }
.modal-price { margin: 14px 0; font-size: 20px; font-weight: 800; }
.modal-qty { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.modal-qty button { width: 42px; height: 42px; border: 0; border-radius: 999px; background: var(--brand); color: #fff; font-size: 24px; font-weight: 800; }
.modal-qty strong { min-width: 42px; text-align: center; font-size: 22px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.pix-modal { place-items: center; background: rgba(43, 29, 20, .58); }
.pix-panel { width: min(380px, calc(100% - 26px)); text-align: center; }
.pix-panel h2 { margin-bottom: 12px; }
.pix-qr { display: grid; place-items: center; min-height: 260px; margin: 14px 0; border-radius: 14px; background: #fff; border: 1px solid var(--line); padding: 12px; }
.pix-qr img { width: min(260px, 100%); height: auto; image-rendering: pixelated; }
.pix-code-label { display: grid; gap: 6px; text-align: left; color: var(--muted); font-weight: 800; font-size: 13px; }
.pix-code-label textarea { min-height: 92px; font-size: 12px; resize: none; }
.history-panel { max-height: min(760px, 88vh); overflow: auto; }
.history-list { display: grid; gap: 10px; margin-top: 12px; text-align: left; }
.history-item { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px; }
.history-item header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-item span { color: var(--brand); font-weight: 900; }
.history-item ul { margin: 8px 0; padding-left: 18px; }
.history-item p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.alert-modal { place-items: center; background: rgba(43, 29, 20, .5); }
.alert-panel { width: min(360px, calc(100% - 32px)); text-align: left; }
.alert-panel h2 { margin-bottom: 8px; }
.alert-panel p { white-space: pre-line; }
.alert-panel .modal-actions { grid-template-columns: 1fr; }
.alert-panel .modal-actions.two-actions { grid-template-columns: 1fr 1fr; }

@media (max-width: 430px) {
    html { background: var(--bg); }
    body { width: auto; max-width: none; margin: 0; padding: calc(112px + env(safe-area-inset-top)) 22px calc(36px + env(safe-area-inset-bottom)); }
    .app-header { margin-bottom: 30px; gap: 8px; padding: 14px 12px 12px; }
    .brand img { width: 46px; height: 46px; }
    .brand strong { font-size: 15px; }
    .brand small { display: none; }
    .brand { flex: 1 1 auto; }
    .install-button { padding: 9px; font-size: 12px; }
    .cart-button { left: 22px; right: 22px; top: calc(16px + env(safe-area-inset-top)) !important; bottom: auto !important; min-width: 0; padding: 11px 12px; column-gap: 9px; }
    .pwa-install-box { left: 22px; right: 22px; bottom: calc(14px + env(safe-area-inset-bottom)); }
    .cart-icon { width: 22px; height: 20px; }
    main { padding: 0 0 16px; }
    .hero { grid-template-columns: 64px 1fr; padding: 12px; margin-top: 26px; }
    .hero img { width: 64px; height: 64px; }
    .hero h1 { font-size: 25px; }
    .section-title { align-items: flex-start; flex-direction: column; gap: 3px; }
    .section-title small { text-align: left; }
    .pay-grid { grid-template-columns: 1fr; }
}
