:root {
  --red: #d9272e;
  --red-dark: #ad1820;
  --yellow: #ffc928;
  --yellow-soft: #fff1a8;
  --cream: #fff9ea;
  --paper: #ffffff;
  --ink: #241f20;
  --muted: #756d6e;
  --line: #eadfca;
  --green: #27864f;
  --shadow: 0 18px 46px rgba(92, 48, 24, 0.12);
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 84% 5%, #fff1aa 0, transparent 23rem), var(--cream); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; padding-bottom: 88px; }
.container { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 249, 234, .92); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(234, 223, 202, .8); }
.topbar-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand-logo { width: 190px; height: auto; max-height: 60px; object-fit: contain; object-position: left center; }
.xepa-logo { width: 190px; }
.location { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-weight: 800; font-size: 14px; }
.location::before { content: "●"; color: var(--red); font-size: 12px; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { background: var(--paper); color: var(--ink); padding: 56px clamp(28px, 6vw, 90px); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; border-right: 1px solid var(--line); }
.auth-brand::after { content: "%"; position: absolute; right: -34px; bottom: -115px; font-size: 360px; line-height: 1; font-weight: 900; color: rgba(217, 39, 46, .055); transform: rotate(-8deg); }
.auth-brand .brand-logo { width: 360px; max-width: 82%; height: auto; max-height: none; object-fit: contain; object-position: left center; filter: drop-shadow(0 10px 18px rgba(0,0,0,.08)); }
.auth-pitch { max-width: 520px; position: relative; z-index: 1; }
.auth-pitch h1 { font-size: clamp(38px, 5vw, 70px); line-height: .98; margin: 0 0 22px; letter-spacing: -.045em; }
.auth-pitch p { font-size: 19px; line-height: 1.55; margin: 0; max-width: 460px; }
.auth-form-wrap { padding: 44px clamp(24px, 6vw, 84px); display: grid; place-items: center; }
.auth-form { width: min(470px, 100%); }
.eyebrow { color: var(--red); text-transform: uppercase; font-size: 12px; letter-spacing: .13em; font-weight: 900; }
h1, h2, h3, p { margin-top: 0; }
.auth-form h2 { font-size: 38px; line-height: 1.05; margin: 10px 0 12px; }
.subtle { color: var(--muted); line-height: 1.5; }

.form-grid { display: grid; gap: 16px; margin-top: 28px; }
.field { display: grid; gap: 7px; }
.field label { font-weight: 800; font-size: 14px; }
.field input, .field select, .search-input { width: 100%; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 14px; padding: 13px 14px; outline: none; }
.field input:focus, .field select:focus, .search-input:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(217, 39, 46, .1); }
.field select:disabled { opacity: 1; color: var(--ink); background: #f6efe2; }
.field-hint { color: var(--muted); font-size: 12px; }
.auth-switch { display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--muted); font-size: 14px; font-weight: 700; }
.auth-switch .btn { min-height: 40px; padding-inline: 8px; }

.btn { border: 0; border-radius: 14px; min-height: 48px; padding: 12px 18px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--red); color: white; box-shadow: 0 10px 24px rgba(217,39,46,.22); }
.btn-primary:hover { background: var(--red-dark); }
.btn-yellow { background: var(--yellow); color: var(--ink); box-shadow: 0 10px 24px rgba(255,201,40,.22); }
.btn-secondary { background: var(--paper); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--red); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.page { padding: 34px 0 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
.page-head h1 { font-size: clamp(30px, 5vw, 48px); margin: 4px 0 6px; letter-spacing: -.035em; }
.page-head p { margin-bottom: 0; }

.demo-banner { background: var(--yellow-soft); border: 1px solid #ead06a; border-radius: 14px; padding: 10px 14px; font-size: 13px; font-weight: 800; margin-bottom: 20px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); }
.panel-title { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 16px; }
.panel-title h2 { font-size: 21px; margin: 0; }
.count-badge { padding: 5px 10px; background: var(--yellow-soft); border-radius: 999px; font-size: 12px; font-weight: 900; }

.add-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 16px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.suggestion { border: 1px solid var(--line); background: #fffdf7; border-radius: 999px; padding: 8px 11px; font-size: 13px; font-weight: 800; }
.suggestion:hover { border-color: var(--red); color: var(--red); }
.smart-tools { margin: 8px 0 18px; border: 1px solid var(--line); border-radius: 15px; background: #fffdf7; }
.smart-tools summary { cursor: pointer; padding: 12px 14px; color: var(--red); font-weight: 900; }
.smart-tools-body { padding: 0 14px 14px; display: grid; gap: 10px; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset-card { text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 10px; color: var(--ink); }
.preset-card:hover { border-color: var(--red); }
.preset-card strong, .preset-card span { display: block; }
.preset-card span { color: var(--muted); font-size: 11px; margin-top: 4px; }
.import-label { font-size: 13px; font-weight: 900; }
#import-list { resize: vertical; min-height: 88px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font: inherit; }

.list-items { display: grid; gap: 10px; }
.empty { text-align: center; padding: 50px 20px; border: 2px dashed var(--line); border-radius: 18px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 5px; }
.list-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 16px; padding: 11px 12px; }
.product-icon { width: 44px; height: 44px; border-radius: 13px; background: var(--yellow-soft); display: grid; place-items: center; font-size: 21px; }
.product-name { font-weight: 900; }
.product-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.qty { display: flex; align-items: center; background: #f8f2e7; border-radius: 11px; overflow: hidden; }
.qty button { border: 0; background: transparent; width: 34px; height: 36px; font-weight: 900; }
.qty span { width: 26px; text-align: center; font-weight: 900; }
.remove { border: 0; background: transparent; color: var(--muted); font-size: 20px; padding: 7px; }

.market-grid { display: grid; gap: 9px; }
.market-choice { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; font-weight: 800; }
.market-choice input { accent-color: var(--red); width: 18px; height: 18px; }
.compare-summary { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.compare-summary p { color: var(--muted); font-size: 13px; margin-bottom: 13px; }

.results-grid { display: grid; gap: 14px; }
.result-card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 19px; box-shadow: var(--shadow); position: relative; }
.result-card.best { border: 2px solid var(--red); }
.best-ribbon { position: absolute; right: 16px; top: -11px; background: var(--yellow); color: var(--ink); border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 900; }
.result-main { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; align-items: start; }
.market-name { font-size: 20px; font-weight: 900; }
.coverage { color: var(--muted); font-size: 13px; margin-top: 3px; }
.price { font-size: 26px; font-weight: 900; letter-spacing: -.03em; white-space: nowrap; }
.saving { display: inline-block; color: var(--green); background: #eaf7ee; padding: 5px 9px; border-radius: 8px; font-size: 12px; font-weight: 900; margin-top: 12px; }
.partial { display: inline-block; color: #9c5e00; background: #fff2d7; padding: 5px 9px; border-radius: 8px; font-size: 12px; font-weight: 900; margin-top: 12px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }

.detail-list { display: grid; gap: 10px; }
.detail-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.detail-row:last-child { border-bottom: 0; }
.detail-source { color: var(--red); background: transparent; border: 0; padding: 0; font-weight: 900; font-size: 12px; margin-top: 6px; }
.flyer-list { display: grid; gap: 12px; margin: 16px 0; }
.flyer-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.flyer-status { flex: none; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 900; background: #fff2d7; color: #946000; }
.flyer-active { background: #eaf7ee; color: var(--green); }
.flyer-expired { background: #f2eeee; color: var(--muted); }
.flyer-scheduled { background: #e9f1ff; color: #275caa; }
.missing-price { color: var(--muted); font-weight: 800; }
.back { border: 0; background: transparent; padding: 0; color: var(--red); font-weight: 900; margin-bottom: 16px; }

.profile-grid { display: grid; gap: 18px; }
.profile-row { display: flex; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.profile-row span { color: var(--muted); }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; background: var(--ink); padding: 6px; border-radius: 18px; box-shadow: 0 18px 45px rgba(36,31,32,.28); }
.nav-btn { border: 0; background: transparent; color: #ddd5d6; border-radius: 13px; min-width: 105px; padding: 10px 14px; font-weight: 900; }
.nav-btn.active { background: var(--yellow); color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 11px 16px; border-radius: 12px; font-weight: 800; font-size: 13px; transition: .2s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 780px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { min-height: 310px; padding: 28px 24px; }
  .auth-brand .brand-logo { width: 250px; height: auto; }
  .auth-pitch h1 { font-size: 42px; }
  .auth-pitch p { font-size: 16px; }
  .auth-form-wrap { padding: 34px 22px 50px; }
  .layout { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .location { font-size: 0; padding: 9px 11px; }
  .location::after { content: "RJ"; font-size: 13px; }
  .brand-logo { width: 150px; height: auto; max-height: 52px; }
  .bottom-nav { width: calc(100% - 28px); }
  .nav-btn { flex: 1; min-width: 0; font-size: 13px; }
}

@media (max-width: 480px) {
  .container { width: min(100% - 22px, 1120px); }
  .panel { padding: 16px; border-radius: 18px; }
  .list-item { grid-template-columns: 40px minmax(0,1fr) auto; }
  .product-icon { width: 40px; height: 40px; }
  .remove { grid-column: 3; grid-row: 1; font-size: 18px; padding: 2px; align-self: start; }
  .qty { grid-column: 2 / 4; justify-self: start; }
  .add-row { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: 1fr; }
  .result-main { grid-template-columns: 1fr; }
  .price { font-size: 24px; }
}
