@font-face {
  font-family: "Far Nazanin";
  src: url("/fonts/Far-Nazanin.ttf?v=14.3.0") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --red: #ef233c;
  --red-dark: #d90429;
  --red-soft: #fff0f2;
  --red-line: #ffd3d9;
  --ink: #321d20;
  --muted: #806c70;
  --line: #eee5e7;
  --surface: #ffffff;
  --soft: #faf8f8;
  --green: #15946a;
  --green-soft: #eaf9f3;
  --amber: #a86600;
  --amber-soft: #fff7df;
  --shadow: 0 18px 55px rgba(65, 22, 29, .09);
  --shadow-soft: 0 8px 28px rgba(65, 22, 29, .07);
  font-family: "Far Nazanin", Tahoma, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #fff; }
body { min-height: 100vh; margin: 0; background: #fff; color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.boot-loader { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot-loader span { width: 34px; height: 34px; border: 3px solid var(--red-line); border-top-color: var(--red); border-radius: 50%; animation: spin .75s linear infinite; }
.boot-loader p { margin: 0; font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(440px, 1.1fr); background: #fff; }
.login-visual { position: relative; overflow: hidden; display: grid; place-items: center; min-height: 100vh; padding: 50px; color: #fff; background: linear-gradient(145deg, #ff314c 0%, #e5092d 50%, #b90020 100%); }
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; }
.login-visual::before { width: 560px; height: 560px; right: -300px; top: -170px; }
.login-visual::after { width: 410px; height: 410px; left: -220px; bottom: -160px; }
.visual-brand { position: relative; z-index: 1; text-align: center; }
.visual-logo { width: 178px; height: 178px; margin: 0 auto 28px; padding: 15px; border-radius: 44px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(86,0,13,.3); }
.visual-logo img { width: 100%; height: 100%; object-fit: contain; }
.visual-brand h1 { margin: 0; font-size: clamp(40px, 5vw, 68px); letter-spacing: -.05em; }
.visual-brand p { margin: 12px 0 28px; color: rgba(255,255,255,.82); }
.visual-feature { display: inline-flex; align-items: center; gap: 10px; padding: 11px 16px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.login-panel { min-height: 100vh; display: grid; place-items: center; padding: 36px; }
.login-card { width: min(460px, 100%); }
.mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 30px; }
.mobile-brand img { width: 58px; height: 58px; object-fit: contain; border: 1px solid var(--red-line); border-radius: 16px; padding: 5px; }
.mobile-brand strong { font-size: 22px; color: var(--red-dark); }
.eyebrow { display: inline-flex; color: var(--red); background: var(--red-soft); padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.login-heading h2 { margin: 17px 0 8px; font-size: clamp(34px, 5vw, 52px); letter-spacing: -.045em; }
.login-heading p { margin: 0 0 32px; color: var(--muted); line-height: 1.8; }
.field { display: grid; gap: 9px; margin-bottom: 18px; text-align: right; font-weight: 700; }
.field > span { font-size: 14px; }
.field input, .select-field, .search-input { width: 100%; height: 54px; border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink); outline: 0; padding: 0 16px; transition: border-color .2s, box-shadow .2s; }
.field input:focus, .select-field:focus, .search-input:focus { border-color: #ff8b9b; box-shadow: 0 0 0 4px rgba(239,35,60,.09); }
.password-wrap { position: relative; }
.password-wrap input { padding-left: 52px; }
.password-toggle { position: absolute; left: 8px; top: 8px; width: 38px; height: 38px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 11px; }
.primary-button { width: 100%; min-height: 56px; border: 0; border-radius: 17px; padding: 12px 20px; color: #fff; background: linear-gradient(135deg, #ff3049, var(--red-dark)); font-weight: 900; box-shadow: 0 14px 28px rgba(217,4,41,.2); }
.form-error { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--red-line); border-radius: 13px; color: var(--red-dark); background: var(--red-soft); font-size: 13px; }

/* Main shell */
.app-shell { min-height: 100vh; background: #fff; }
.app-header { position: sticky; top: 0; z-index: 30; height: 76px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); backdrop-filter: blur(14px); }
.header-inner { width: min(1180px, calc(100% - 32px)); height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand-lockup { display: flex; direction: ltr; align-items: center; gap: 11px; }
.brand-lockup img { width: 50px; height: 50px; object-fit: contain; border: 1px solid var(--red-line); border-radius: 14px; padding: 4px; background: #fff; }
.brand-copy { display: grid; direction: rtl; text-align: left; }
.brand-copy strong { color: var(--red-dark); font-size: 19px; }
.brand-copy span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.header-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #ff4a61, var(--red-dark)); font-weight: 900; }
.user-copy { min-width: 0; display: grid; gap: 3px; }
.user-copy strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.user-copy span { color: var(--green); font-size: 11px; }
.page-main { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 calc(125px + env(safe-area-inset-bottom)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading h1 { margin: 9px 0 5px; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.045em; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.8; font-size: 14px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; border: 1px solid #cceee2; border-radius: 999px; padding: 9px 13px; color: #137b5a; background: #f3fcf9; font-size: 12px; font-weight: 700; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: #1bb57d; box-shadow: 0 0 0 5px rgba(27,181,125,.11); }

/* Home */
.home-actions { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.scan-card { min-height: 180px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px; border: 0; border-radius: 25px; color: #fff; text-align: right; background: linear-gradient(135deg, #ff3b53, #df0026); box-shadow: 0 20px 40px rgba(217,4,41,.16); overflow: hidden; position: relative; }
.scan-card::before, .scan-card::after { content: ""; position: absolute; border-radius: 50%; border: 26px solid rgba(255,255,255,.08); }
.scan-card::before { width: 170px; height: 170px; left: -80px; bottom: -115px; }
.scan-card::after { width: 100px; height: 100px; right: -55px; top: -70px; }
.scan-card-icon { width: 70px; height: 70px; flex: 0 0 70px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 22px; background: rgba(255,255,255,.13); }
.scan-card-copy { position: relative; z-index: 1; display: grid; gap: 8px; margin-left: auto; }
.scan-card-copy strong { font-size: 27px; }
.scan-card-copy small { color: rgba(255,255,255,.8); font-size: 13px; }
.scan-card-arrow { position: relative; z-index: 1; font-size: 30px; }
.manual-card { min-height: 180px; display: grid; align-content: center; gap: 22px; padding: 25px; border: 1px solid var(--red-line); border-radius: 25px; background: #fff; box-shadow: var(--shadow-soft); }
.section-title { display: flex; align-items: center; gap: 11px; }
.section-title > span { width: 44px; height: 44px; display: grid; place-items: center; color: var(--red); border-radius: 14px; background: var(--red-soft); }
.section-title div { display: grid; gap: 4px; }
.section-title strong { font-size: 17px; }
.section-title small { color: var(--muted); }
.code-entry { display: grid; grid-template-columns: 1fr auto; gap: 10px; direction: ltr; }
.code-entry input { min-width: 0; height: 54px; border: 1px solid var(--line); border-radius: 15px; padding: 0 15px; outline: 0; font-size: 17px; direction: ltr; }
.code-entry input:focus { border-color: #ff8b9b; box-shadow: 0 0 0 4px rgba(239,35,60,.09); }
.code-entry button { min-width: 105px; border: 0; border-radius: 15px; padding: 0 17px; color: #fff; background: var(--red); font-weight: 800; }
.empty-state { min-height: 155px; margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 15px; border: 1px dashed #dfd4d6; border-radius: 24px; background: var(--soft); color: var(--muted); text-align: right; }
.empty-state > span { width: 55px; height: 55px; display: grid; place-items: center; border-radius: 18px; background: #fff; color: #a69498; }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 6px 0 0; font-size: 13px; }
.notice-card { margin-top: 20px; padding: 16px 18px; border: 1px solid var(--red-line); border-radius: 17px; color: var(--red-dark); background: var(--red-soft); }

/* Products and result */
.result-card { margin-top: 22px; border: 1px solid var(--red-line); border-radius: 26px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.result-head { display: flex; align-items: flex-start; gap: 14px; padding: 24px; border-bottom: 1px solid var(--line); }
.success-mark { width: 47px; height: 47px; flex: 0 0 47px; display: grid; place-items: center; color: #fff; border-radius: 15px; background: var(--green); }
.result-title { min-width: 0; flex: 1; }
.result-title > span { color: var(--green); font-size: 12px; font-weight: 800; }
.result-title h2 { margin: 7px 0 0; font-size: clamp(20px, 4vw, 30px); line-height: 1.65; }
.favorite-button { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border: 1px solid var(--red-line); border-radius: 14px; color: #a99296; background: #fff; }
.favorite-button.is-active { color: var(--red); background: var(--red-soft); }
.barcode-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: #fcfbfb; color: var(--muted); font-size: 12px; }
.barcode-row strong { color: var(--ink); letter-spacing: .1em; font-size: 14px; }
.product-tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 24px 0; }
.tag { padding: 7px 11px; border-radius: 999px; background: #f4f1f1; color: #6f5d60; font-size: 11px; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; padding: 20px 24px 24px; }
.price-box { min-height: 135px; display: grid; place-content: center; justify-items: center; gap: 9px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; text-align: center; }
.price-box > span { color: var(--muted); font-size: 12px; }
.price-box strong { font-size: clamp(25px, 5vw, 37px); letter-spacing: -.02em; direction: ltr; }
.price-box small { font-weight: 700; }
.price-box.personal { border-color: #ffc7cf; color: var(--red-dark); background: linear-gradient(145deg, #fff 0%, #fff1f3 100%); }
.price-box.purchase { border-color: #d8eee6; color: #126c50; background: #f4fcf9; }
.price-flip-shell { min-width: 0; min-height: 135px; position: relative; display: block; border: 0; padding: 0; border-radius: 20px; color: inherit; background: transparent; perspective: 1000px; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; }
.price-flip-inner { width: 100%; min-height: 135px; position: relative; display: block; transform-style: preserve-3d; transition: transform .52s cubic-bezier(.2,.72,.2,1); }
.price-flip-shell.is-flipped .price-flip-inner { transform: rotateY(180deg); }
.price-face { width: 100%; min-height: 135px; position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.price-purchase-face { transform: rotateY(180deg); }
.price-flip-shell:focus-visible { outline: 3px solid rgba(239,35,60,.2); outline-offset: 3px; }
.result-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 24px; border-top: 1px solid var(--line); background: #fcfbfb; }
.result-foot span { color: var(--muted); font-size: 12px; }
.text-button { border: 0; border-radius: 12px; padding: 10px 14px; color: var(--red-dark); background: var(--red-soft); font-weight: 800; }

.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 240px auto; gap: 10px; margin-bottom: 14px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; right: 16px; top: 16px; color: #aa999c; }
.search-wrap .search-input { padding-right: 48px; }
.search-button { min-width: 95px; border: 0; border-radius: 16px; padding: 0 18px; color: #fff; background: var(--red); font-weight: 800; }
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 20px; padding: 4px; border-radius: 16px; background: #f3f0f1; }
.segment { min-height: 44px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; font-weight: 800; }
.segment.is-active { color: var(--red-dark); background: #fff; box-shadow: 0 4px 16px rgba(54,25,30,.07); }
.list-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 13px; color: var(--muted); font-size: 12px; }
.product-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.product-card { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 13px; align-items: center; min-height: 126px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: #fff; text-align: right; box-shadow: 0 5px 18px rgba(55,22,28,.04); transition: transform .16s, border-color .16s, box-shadow .16s; }
.product-card:hover { transform: translateY(-2px); border-color: #ffc4cc; box-shadow: var(--shadow-soft); }
.product-card-main { min-width: 0; }
.product-card h3 { margin: 0 0 10px; font-size: 15px; line-height: 1.75; }
.product-card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 11px; }
.product-card-meta span[dir=ltr] { letter-spacing: .06em; }
.product-card-price { margin-top: 12px; display: flex; align-items: baseline; gap: 5px; color: var(--red-dark); }
.product-card-price > span { color: var(--muted); font-size: 9px; }
.product-card-price strong { font-size: 19px; direction: ltr; }
.product-card-price small { font-size: 10px; }
.card-sale-price { margin-top: 4px; color: var(--muted); font-size: 9px; }
.product-card .favorite-button { align-self: start; width: 39px; height: 39px; flex-basis: 39px; }
.load-more { width: 100%; min-height: 49px; margin-top: 14px; border: 1px solid var(--red-line); border-radius: 16px; color: var(--red-dark); background: #fff; font-weight: 800; }
.loading-list { min-height: 180px; display: grid; place-items: center; color: var(--muted); }
.empty-list { min-height: 240px; display: grid; place-content: center; justify-items: center; gap: 12px; border: 1px dashed #dfd5d6; border-radius: 22px; color: var(--muted); text-align: center; }
.empty-list span { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; color: var(--red); background: var(--red-soft); }
.empty-list strong { color: var(--ink); }
.empty-list p { margin: 0; font-size: 12px; }

/* History */
.history-toolbar { grid-template-columns: minmax(210px, 1fr) 180px 210px auto; }
.danger-outline { min-height: 54px; border: 1px solid var(--red-line); border-radius: 16px; padding: 0 17px; color: var(--red-dark); background: #fff; font-weight: 800; }
.retention-note { display: flex; align-items: center; gap: 9px; margin-bottom: 17px; padding: 11px 14px; border-radius: 14px; color: #785b1d; background: var(--amber-soft); font-size: 12px; }
.history-list { display: grid; gap: 10px; }
.history-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 17px 18px; border: 1px solid var(--line); border-radius: 19px; background: #fff; text-align: right; }
.history-card.is-clickable:hover { border-color: #ffc4cc; box-shadow: var(--shadow-soft); }
.history-main { min-width: 0; }
.history-topline { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 6px; }
.history-topline time { color: var(--muted); font-size: 10px; }
.method-badge, .change-badge, .user-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 9px; font-weight: 800; }
.method-badge { color: #67575a; background: #f2eeee; }
.change-badge { color: var(--red-dark); background: var(--red-soft); }
.user-badge { color: #126c50; background: var(--green-soft); }
.history-card h3 { margin: 0; font-size: 14px; line-height: 1.75; }
.history-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.history-price { min-width: 140px; display: grid; justify-items: left; gap: 5px; text-align: left; }
.history-price span { color: var(--muted); font-size: 9px; }
.history-price strong { color: var(--red-dark); font-size: 18px; direction: ltr; }
.history-price small { font-size: 9px; }
.history-price em { color: var(--green); font-size: 10px; font-style: normal; font-weight: 800; }
.history-card:disabled { cursor: default; opacity: 1; }
.unavailable { color: #9a8589 !important; }

/* Account */
.account-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 18px; }
.profile-card, .account-actions { border: 1px solid var(--line); border-radius: 24px; padding: 24px; background: #fff; box-shadow: var(--shadow-soft); }
.profile-avatar { width: 78px; height: 78px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 24px; color: #fff; background: linear-gradient(135deg, #ff5067, var(--red-dark)); font-size: 29px; font-weight: 900; }
.profile-card h2 { margin: 0 0 6px; font-size: 23px; }
.profile-card > p { margin: 0; color: var(--muted); }
.profile-details { display: grid; gap: 0; margin-top: 23px; border-top: 1px solid var(--line); }
.profile-details div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.profile-details span { color: var(--muted); }
.account-actions { display: grid; align-content: start; gap: 10px; }
.account-link { min-height: 66px; display: flex; align-items: center; gap: 13px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); background: #fff; text-align: right; }
.account-link > span:first-child { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 13px; color: var(--red); background: var(--red-soft); }
.account-link div { flex: 1; display: grid; gap: 4px; }
.account-link strong { font-size: 14px; }
.account-link small { color: var(--muted); font-size: 10px; }
.account-link > svg { color: #baaeb0; }
.logout-link { color: var(--red-dark); }
.version-note { margin-top: 11px; color: #ad9da0; text-align: center; font-size: 10px; }

/* Bottom navigation */
.bottom-nav-wrap { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; padding: 0 14px calc(10px + env(safe-area-inset-bottom)); pointer-events: none; }
.bottom-nav { width: min(720px, 100%); min-height: 72px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; padding: 8px 7px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.97); box-shadow: 0 -4px 30px rgba(62,21,28,.11); backdrop-filter: blur(18px); pointer-events: auto; }
.nav-item { min-width: 0; height: 55px; display: grid; place-content: center; justify-items: center; gap: 4px; border: 0; border-radius: 15px; color: #907e82; background: transparent; font-size: 9px; font-weight: 800; }
.nav-item.is-active { color: var(--red); background: var(--red-soft); }
.nav-scan-slot { position: relative; height: 55px; }
.nav-scan { position: absolute; width: 66px; height: 66px; left: 50%; bottom: 4px; transform: translateX(-50%); display: grid; place-items: center; border: 5px solid #fff; border-radius: 22px; color: #fff; background: linear-gradient(135deg, #ff3d55, var(--red-dark)); box-shadow: 0 12px 25px rgba(217,4,41,.3); }
.nav-scan-label { position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%); color: var(--red-dark); font-size: 9px; font-weight: 900; white-space: nowrap; }

/* Scanner and modal */
.overlay { position: fixed; z-index: 100; inset: 0; }
.scanner-overlay { background: #080606; color: #fff; }
.camera-video { width: 100%; height: 100%; object-fit: cover; }
.camera-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,.06) 34%, rgba(0,0,0,.08) 64%, rgba(0,0,0,.7)); pointer-events: none; }
.scanner-top { position: absolute; z-index: 2; top: max(18px, env(safe-area-inset-top)); left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scanner-brand { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 800; text-shadow: 0 2px 10px #000; }
.scanner-brand img { width: 39px; height: 39px; object-fit: contain; padding: 3px; border-radius: 11px; background: #fff; }
.round-button { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 14px; color: #fff; background: rgba(0,0,0,.38); backdrop-filter: blur(8px); }
.scanner-center { position: absolute; z-index: 2; inset: 20% 0 auto; display: grid; justify-items: center; gap: 20px; padding: 0 22px; }
.scan-frame { position: relative; width: min(430px, 88vw); aspect-ratio: 1.75; border: 1px solid rgba(255,255,255,.28); border-radius: 22px; }
.scan-frame i { position: absolute; width: 40px; height: 40px; border-color: #ff314b; border-style: solid; }
.scan-frame i:nth-child(1) { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 18px 0 0; }
.scan-frame i:nth-child(2) { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 18px 0 0 0; }
.scan-frame i:nth-child(3) { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 18px 0; }
.scan-frame i:nth-child(4) { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 18px; }
.scan-line { position: absolute; left: 7%; right: 7%; top: 12%; height: 2px; background: #ff354f; box-shadow: 0 0 14px #ff354f; animation: scanline 2.1s ease-in-out infinite alternate; }
@keyframes scanline { to { top: 86%; } }
.scanner-status { max-width: 430px; margin: 0; text-align: center; color: rgba(255,255,255,.85); font-size: 12px; line-height: 1.8; text-shadow: 0 2px 8px #000; }
.scanner-bottom { position: absolute; z-index: 2; left: 18px; right: 18px; bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px)); display: flex; justify-content: center; }
.torch-button { min-height: 49px; display: flex; align-items: center; gap: 9px; border: 1px solid rgba(255,255,255,.25); border-radius: 16px; padding: 0 17px; color: #fff; background: rgba(0,0,0,.42); backdrop-filter: blur(10px); font-weight: 700; }
.torch-button.is-on { color: #2e2100; background: #ffd65d; border-color: #ffd65d; }
.modal-backdrop { display: grid; place-items: center; padding: 18px; background: rgba(43,15,20,.38); backdrop-filter: blur(6px); }
.product-modal { width: min(660px, 100%); max-height: min(90vh, 820px); overflow: auto; border: 1px solid var(--red-line); border-radius: 26px; background: #fff; box-shadow: 0 30px 100px rgba(49,9,17,.3); }
.modal-top { position: sticky; z-index: 2; top: 0; display: flex; justify-content: flex-end; padding: 11px; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
.modal-close { color: var(--red-dark); background: var(--red-soft); border-color: var(--red-line); }
.product-modal .result-card { margin: 0; border: 0; border-radius: 0; box-shadow: none; }

#toast-root { position: fixed; z-index: 200; left: 18px; bottom: calc(100px + env(safe-area-inset-bottom)); display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: min(360px, calc(100vw - 36px)); padding: 12px 15px; border-radius: 14px; color: #fff; background: #332326; box-shadow: 0 12px 34px rgba(35,12,16,.25); font-size: 12px; animation: toast-in .22s ease-out; }
.toast.error { background: var(--red-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { padding: 28px 22px; }
  .mobile-brand { display: flex; }
  .home-actions { grid-template-columns: 1fr; }
  .history-toolbar { grid-template-columns: 1fr 1fr; }
  .history-toolbar .search-wrap { grid-column: 1 / -1; }
  .account-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-header { height: 66px; }
  .header-inner, .page-main { width: min(100% - 24px, 1080px); }
  .brand-lockup img { width: 43px; height: 43px; border-radius: 12px; }
  .brand-copy strong { font-size: 16px; }
  .brand-copy span { display: none; }
  .user-avatar { width: 37px; height: 37px; flex-basis: 37px; border-radius: 12px; font-size: 13px; }
  .user-copy strong { max-width: 105px; font-size: 12px; }
  .page-main { padding-top: 25px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { margin-top: 8px; }
  .status-pill { display: none; }
  .scan-card { min-height: 154px; padding: 22px; border-radius: 21px; }
  .scan-card-icon { width: 60px; height: 60px; flex-basis: 60px; border-radius: 19px; }
  .scan-card-copy strong { font-size: 22px; }
  .manual-card { min-height: 166px; padding: 20px; border-radius: 21px; }
  .result-head, .barcode-row, .product-tags, .price-grid, .result-foot { padding-left: 17px; padding-right: 17px; }
  .result-head { padding-top: 18px; padding-bottom: 18px; }
  .result-card { border-radius: 21px; }
  .toolbar { grid-template-columns: 1fr auto; }
  .toolbar .search-wrap { grid-column: 1 / -1; }
  .toolbar .select-field { min-width: 0; }
  .product-list { grid-template-columns: 1fr; }
  .history-toolbar { grid-template-columns: 1fr 1fr; }
  .history-card { grid-template-columns: minmax(0, 1fr); }
  .history-price { min-width: 0; justify-items: right; text-align: right; }
  .bottom-nav-wrap { padding-left: 8px; padding-right: 8px; }
  .bottom-nav { min-height: 68px; border-radius: 21px; }
  .nav-scan { width: 62px; height: 62px; border-radius: 20px; }
  #toast-root { left: 12px; right: 12px; justify-items: center; }
}

@media (max-width: 400px) {
  .brand-copy strong { font-size: 14px; }
  .user-copy span { display: none; }
  .page-heading h1 { font-size: 26px; }
  .code-entry { grid-template-columns: 1fr 82px; }
  .code-entry button { min-width: 0; padding: 0 8px; }
  .price-grid { grid-template-columns: 1fr; }
  .history-toolbar { grid-template-columns: 1fr; }
  .history-toolbar > * { grid-column: 1 !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
