/* Ketabdaar — restrained RTL UI inspired by shadcn primitives. */

:root {
  color-scheme: light;
  --background: #fbfaf8;
  --foreground: #191715;
  --card: #ffffff;
  --card-foreground: #191715;
  --popover: #ffffff;
  --muted: #f1efeb;
  --muted-foreground: #706a62;
  --border: #dfdad3;
  --input: #dfdad3;
  --ring: rgba(215, 70, 48, .24);
  --primary: #d74630;
  --primary-foreground: #fffaf5;
  --primary-soft: #fff0eb;
  --primary-strong: #b93423;
  --success: #15803d;
  --success-soft: #e9f8ef;
  --warning: #b45309;
  --warning-soft: #fff4df;
  --danger: #b91c1c;
  --danger-soft: #fff0f0;
  --shadow: 0 1px 2px rgba(25, 23, 21, .06), 0 1px 1px rgba(25, 23, 21, .04);
  --shadow-lg: 0 18px 48px rgba(25, 23, 21, .12);
  --radius: 8px;
  --radius-sm: 6px;
  --container: 1120px;
  --container-narrow: 760px;
  --sidebar-w: 260px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #151312;
  --foreground: #f7f1ea;
  --card: #1f1c1a;
  --card-foreground: #f7f1ea;
  --popover: #24201d;
  --muted: #2b2724;
  --muted-foreground: #b8aea3;
  --border: #3b3530;
  --input: #4a423b;
  --ring: rgba(255, 120, 94, .26);
  --primary: #ff795d;
  --primary-foreground: #1f100c;
  --primary-soft: #3a211c;
  --primary-strong: #ffa08b;
  --success: #6ee7a5;
  --success-soft: #183526;
  --warning: #f6c56f;
  --warning-soft: #342719;
  --danger: #fca5a5;
  --danger-soft: #3c1f20;
  --shadow: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-lg: 0 18px 54px rgba(0, 0, 0, .38);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  color: var(--foreground);
  background:
    linear-gradient(180deg, rgba(215, 70, 48, .055), transparent 360px),
    var(--background);
  direction: rtl;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .45em; line-height: 1.35; color: var(--foreground); font-weight: 850; letter-spacing: 0; }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.75rem); }
h2 { font-size: clamp(1.45rem, 2.5vw, 2.1rem); }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; color: var(--muted-foreground); }
ul { margin: 0 0 1em; padding-inline-start: 1.25em; }
summary { cursor: pointer; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: var(--container-narrow); }
.section { padding: 66px 0; }
.section.alt { background: color-mix(in srgb, var(--muted) 72%, transparent); border-block: 1px solid var(--border); }
.section.tight { padding: 38px 0; }
.center { text-align: center; }
.small { font-size: .86rem; }
.muted { color: var(--muted-foreground); }
.hidden { display: none !important; }
.flex { display: flex; }
.between { justify-content: space-between; }
.gap { gap: 14px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--primary);
  font-weight: 800;
  font-size: .84rem;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.brand, .app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--foreground);
  font-weight: 900;
  font-size: 1.2rem;
}
.brand:hover, .app-brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 8px 24px rgba(215, 70, 48, .22);
}
.brand-mark img { width: 25px; height: 25px; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  color: var(--muted-foreground);
  font-weight: 700;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.nav-links a:hover { background: var(--muted); color: var(--foreground); text-decoration: none; }
.nav-links a.active { background: var(--primary-soft); color: var(--primary-strong); }
.nav-cta { display: flex; align-items: center; gap: 8px; }
@media (max-width: 780px) {
  .nav-links { display: none; }
  .nav-inner { height: auto; min-height: 64px; padding-block: 10px; }
  .nav-cta { gap: 6px; }
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible, .input:focus-visible, .textarea:focus-visible, .select:focus-visible, .theme-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-color: var(--primary);
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: var(--primary-foreground); }
.btn-ghost { border-color: var(--border); background: color-mix(in srgb, var(--card) 74%, transparent); }
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-soft { background: var(--primary-soft); color: var(--primary-strong); border-color: color-mix(in srgb, var(--primary) 20%, var(--border)); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-soft) 78%, var(--primary) 8%); }
.btn-lg { min-height: 46px; padding: 12px 22px; font-size: 1rem; }
.btn-sm { min-height: 32px; padding: 7px 12px; font-size: .84rem; }
.btn-block { width: 100%; display: flex; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card.hover { transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease; }
.card.hover:hover { border-color: color-mix(in srgb, var(--primary) 38%, var(--border)); box-shadow: var(--shadow-lg); }
.card.featured { border-color: color-mix(in srgb, var(--primary) 58%, var(--border)); position: relative; }
.card.featured::before {
  content: "پیشنهادی";
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  color: var(--primary-foreground);
  background: var(--primary);
  font-size: .72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
}
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 880px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.ico { width: 21px; height: 21px; flex: 0 0 auto; stroke-width: 2; }
.ico-lg { width: 30px; height: 30px; }
.icon-badge {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  margin-bottom: 14px;
}
.icon-badge .ico { width: 24px; height: 24px; }

.hero { padding: 28px 0 48px; }
.hero .lead { max-width: 700px; margin-inline: auto; font-size: 1.12rem; }
.hero-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-note { margin-top: 18px; display: inline-flex; gap: 8px; align-items: center; color: var(--muted-foreground); }
.hero-note::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--success); }

.preview-card { overflow: hidden; min-height: 324px; padding: 0; display: flex; flex-direction: column; }
.preview-art {
  height: 178px;
  padding: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 78%, var(--card)), var(--card));
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.preview-art svg { width: 100%; height: 100%; }
.preview-body { padding: 18px; }

/* Animated preview cards */
.screen-fill { fill: var(--card); }
.screen-line { stroke: var(--border); }
.screen-muted { fill: var(--muted); }
.screen-primary { fill: var(--primary); }
.screen-primary-soft { fill: var(--primary-soft); }
.screen-text { fill: var(--foreground); opacity: .82; }
.barcode-line { stroke: var(--foreground); stroke-width: 2; opacity: .78; }

/* Input field typing animation */
.screen-input-anim { animation: inputPulse 2.5s ease-in-out infinite; }
@keyframes inputPulse {
  0%, 100% { opacity: .6; }
  50% { opacity: 1; }
}

/* Blinking cursor in input field */
.screen-cursor { animation: cursorBlink 1s step-end infinite; }
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Search button pulse */
.screen-btn-anim { animation: btnPulse 2.5s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { opacity: .75; }
  50% { opacity: 1; transform: scale(1.03); }
}

/* Scan line sweep */
.screen-scan-line { animation: scanSweep 2s ease-in-out infinite; }
@keyframes scanSweep {
  0% { transform: translateY(-20px); opacity: 0; }
  20% { opacity: .8; }
  80% { opacity: .8; }
  100% { transform: translateY(20px); opacity: 0; }
}

/* Barcode shimmer */
.barcode-line { animation: barcodeShimmer 1.8s ease-in-out infinite; }
.barcode-line:nth-child(2) { animation-delay: .1s; }
.barcode-line:nth-child(3) { animation-delay: .2s; }
.barcode-line:nth-child(4) { animation-delay: .3s; }
.barcode-line:nth-child(5) { animation-delay: .4s; }
.barcode-line:nth-child(6) { animation-delay: .5s; }
.barcode-line:nth-child(7) { animation-delay: .6s; }
.barcode-line:nth-child(8) { animation-delay: .7s; }
@keyframes barcodeShimmer {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

/* File rows fade in */
.screen-file-row { opacity: 0; animation: fileRowIn .4s ease forwards; }
.screen-file-row:nth-child(1) { animation-delay: .2s; }
.screen-file-row:nth-child(2) { animation-delay: .5s; }
.screen-file-row:nth-child(3) { animation-delay: .8s; }
.screen-file-row:nth-child(4) { animation-delay: 1.1s; }
@keyframes fileRowIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: .85; transform: translateX(0); }
}

.field { margin-bottom: 17px; }
.label { display: block; color: var(--foreground); font-weight: 800; margin-bottom: 7px; font-size: .9rem; }
.input, .textarea, .select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--foreground);
  padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input.invalid, .input:invalid.invalid {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px rgba(190, 18, 60, .14);
}
.textarea { min-height: 116px; resize: vertical; }
.hint { font-size: .8rem; color: var(--muted-foreground); margin-top: 6px; }
.input-affix { position: relative; }
.input-affix .suffix {
  position: absolute;
  inset-inline-start: 12px;
  top: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  color: var(--muted-foreground);
  font-size: .82rem;
  font-weight: 800;
}
.input-affix .input { padding-inline-start: 62px; }

.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card);
}
.qty-btn {
  width: 42px;
  min-width: 42px;
  border: 0;
  background: var(--muted);
  color: var(--foreground);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.qty-btn:hover { background: color-mix(in srgb, var(--primary) 14%, var(--muted)); }
.qty-input {
  width: 56px;
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-inline: 1px solid var(--input);
  text-align: center;
  background: var(--card);
  color: var(--foreground);
  font-weight: 900;
}
.qty-input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 0; background: var(--muted); border-radius: var(--radius) var(--radius) 0 0; padding: 4px 4px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted-foreground);
  background: transparent;
  font-weight: 850;
  font-size: .92rem;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: background-color .12s ease, color .12s ease;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab:hover { color: var(--foreground); background: color-mix(in srgb, var(--card) 50%, transparent); }
.tab.active { color: var(--primary); background: var(--card); border-bottom-color: var(--primary); }
@media (min-width: 560px) { .tab { flex: 1 1 0; } }
.tab-panel { display: none; padding: 22px; }
.tab-panel.active { display: block; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 850;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--primary-soft); color: var(--primary-strong); }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: .92rem;
  font-weight: 900;
}
.pill .num { font-size: 1.03rem; }
.step-num{width:36px;height:36px;display:grid;place-items:center;border-radius:50%;background:var(--primary-soft);color:var(--primary-strong);font-weight:900;}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 13px 15px; text-align: right; }
.tbl thead th { background: var(--muted); color: var(--muted-foreground); border-bottom: 1px solid var(--border); font-size: .82rem; white-space: nowrap; }
.tbl tbody td { border-bottom: 1px solid var(--border); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--muted) 54%, transparent); }
.tbl .book-cell { display: flex; align-items: center; gap: 12px; }
.thumb { width: 38px; height: 50px; border-radius: 5px; object-fit: cover; background: var(--muted); flex: 0 0 auto; }

/* History: table on wide screens, stacked cards on mobile. */
.danger-text { color: var(--danger); }
.hist-cards { display: none; }
.hist-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--card); }
@media (max-width: 640px) {
  .hist-table { display: none; }
  .hist-cards { display: flex; }
}

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app-sidebar {
  background: var(--card);
  border-inline-start: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app-brand { padding: 4px 8px 22px; }
.app-brand .brand-mark { width: 35px; height: 35px; }
.app-nav { display: flex; flex-direction: column; gap: 4px; }
.app-nav .label-group { color: var(--muted-foreground); font-size: .72rem; font-weight: 850; padding: 14px 10px 4px; }
.app-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-foreground);
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  font-weight: 750;
}
.app-nav a:hover { background: var(--muted); color: var(--foreground); text-decoration: none; }
.app-nav a.active { background: var(--primary-soft); color: var(--primary-strong); }
.app-nav a .ico { width: 20px; height: 20px; }
.app-main { padding: 28px 32px 60px; min-width: 0; }
.app-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.app-topbar h1 { font-size: 1.6rem; margin: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: var(--radius); display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-strong); font-weight: 900; }
.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  background: var(--card);
  cursor: pointer;
}
.menu-btn:hover { background: var(--muted); }
.mobile-bottom-nav {
  display: none;
}
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  color: #fff8e8;
  background: #7c2d12;
  box-shadow: var(--shadow);
  font-size: .88rem;
  font-weight: 800;
}
.impersonation-banner form { margin: 0; }
.impersonation-banner .btn { color: #7c2d12; background: #fff8e8; border-color: transparent; }
.admin-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.admin-metric { min-height: 142px; display: flex; flex-direction: column; justify-content: space-between; }
.admin-metric span, .admin-metric small { color: var(--muted-foreground); }
.admin-metric strong { font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1; }
.admin-search { display: flex; gap: 8px; min-width: min(100%, 360px); }
.admin-search input { min-width: 0; flex: 1; }
.admin-settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-settings-form .flex { grid-column: 1 / -1; }
.admin-users-table td { vertical-align: middle; }
.admin-trends { overflow: hidden; }
.admin-chart-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted-foreground); font-size: .86rem; }
.admin-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; }
.legend-dot.register { background: #2563eb; }
.legend-dot.insert { background: #16a34a; }
.admin-chart {
  display: grid;
  grid-template-columns: repeat(30, minmax(10px, 1fr));
  gap: 7px;
  min-height: 230px;
  align-items: end;
  padding: 14px 2px 2px;
  border-top: 1px solid var(--border);
}
.admin-chart-day { min-width: 0; text-align: center; }
.admin-chart-bars {
  height: 176px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding-inline: 1px;
}
.admin-chart .bar {
  display: block;
  width: 45%;
  min-height: 0;
  border-radius: 5px 5px 0 0;
}
.admin-chart .bar.register { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.admin-chart .bar.insert { background: linear-gradient(180deg, #4ade80, #16a34a); }
.admin-chart-day small { display: block; min-height: 1.2em; color: var(--muted-foreground); font-size: .68rem; white-space: nowrap; }
.source-bars { display: grid; gap: 12px; }
.source-bar-row { display: grid; grid-template-columns: 128px 1fr 48px; gap: 12px; align-items: center; }
.source-bar-row > span { font-weight: 800; color: var(--foreground); }
.source-bar-row > strong { text-align: end; font-size: .95rem; }
.source-bar-track { height: 12px; border-radius: 999px; overflow: hidden; background: var(--muted); border: 1px solid var(--border); }
.source-bar-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #f59e0b)); }
.admin-log-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.admin-log-card h2 { font-size: 1.1rem; margin: 0 0 12px; }
.admin-log-list { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.admin-log-list li { min-width: 0; padding-block: 2px 10px; border-bottom: 1px solid var(--border); }
.admin-log-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.admin-log-list span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.admin-log-list small { display: block; margin-top: 3px; color: var(--muted-foreground); line-height: 1.7; }
.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; }
@media (max-width: 1050px) { .admin-metrics, .admin-log-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    z-index: 200;
    width: min(82vw, 304px);
    transform: translateX(-110%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
    border-inline-start: 0;
    border-inline-end: 1px solid var(--border);
  }
  [dir="rtl"] .app-sidebar { transform: translateX(110%); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .app-main { padding: 20px 16px calc(108px + env(safe-area-inset-bottom)); }
  .app-topbar h1 { font-size: 1.35rem; }
  .mobile-bottom-nav {
    position: fixed;
    left: 10px;
    right: auto;
    bottom: 10px;
    width: calc(100vw - 20px);
    z-index: 140;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    direction: ltr;
    padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
    border-radius: calc(var(--radius) + 10px);
    background: color-mix(in srgb, var(--card) 92%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px) saturate(145%);
  }
  .mobile-bottom-nav a {
    min-width: 0;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--radius);
    color: var(--muted-foreground);
    font-size: .74rem;
    font-weight: 900;
    line-height: 1.05;
    text-decoration: none;
    transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
    direction: rtl;
  }
  .mobile-bottom-nav a:hover {
    background: var(--muted);
    color: var(--foreground);
    text-decoration: none;
  }
  .mobile-bottom-nav a.active {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 26%, transparent);
  }
  .mobile-bottom-nav .ico {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
  }
  .mobile-bottom-nav span {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .impersonation-banner { position: relative; flex-wrap: wrap; text-align: center; gap: 8px; }
}
@media (max-width: 560px) {
  .admin-metrics, .admin-log-grid, .admin-settings-form { grid-template-columns: 1fr; }
  .admin-search { width: 100%; }
  .admin-chart { gap: 4px; overflow-x: auto; grid-template-columns: repeat(30, minmax(14px, 1fr)); }
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, .46);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.stat { display: flex; align-items: center; gap: 14px; }
.stat .icon-badge { margin-bottom: 0; }
.stat .v { font-size: 1.5rem; font-weight: 900; line-height: 1.1; }
.stat .k { color: var(--muted-foreground); font-size: .84rem; }

.book-card { display: grid; grid-template-columns: 130px 1fr; gap: 22px; align-items: start; }
.book-cover { width: 130px; height: 180px; border-radius: var(--radius); object-fit: cover; background: var(--muted); border: 1px solid var(--border); }
.cover-placeholder {
  width: 130px;
  height: 180px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--primary-soft), var(--muted));
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--primary);
}
.cover-placeholder img { width: 58px; height: 58px; }
.book-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin-top: 10px; }
.book-meta dt { color: var(--muted-foreground); font-size: .82rem; }
.book-meta dd { margin: 0; color: var(--foreground); font-weight: 750; font-size: .92rem; }
@media (max-width: 620px) {
  .book-card { grid-template-columns: 1fr; }
  .book-cover, .cover-placeholder { width: 112px; height: 156px; }
  .book-meta { grid-template-columns: 1fr; }
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--card);
  transition: border-color .15s ease, background-color .15s ease;
}
.result-item:hover { border-color: color-mix(in srgb, var(--primary) 42%, var(--border)); background: var(--muted); text-decoration: none; }
.result-item .t { color: var(--foreground); font-weight: 850; }
.result-item .s { color: var(--muted-foreground); font-size: .84rem; }

/* Rich result cards */
.result-card {
  display: flex;
  align-items: stretch;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--card);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  cursor: pointer;
  text-align: right;
  width: 100%;
  font: inherit;
  color: inherit;
}
.result-card:hover {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
  box-shadow: var(--shadow-lg);
  background: var(--muted);
  text-decoration: none;
}
.result-cover {
  width: 72px;
  min-height: 100px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--muted);
  border: 1px solid var(--border);
}
.result-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-fallback {
  width: 100%;
  height: 100%;
  min-height: 100px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-soft), var(--muted));
  color: var(--primary);
  font-weight: 900;
  font-size: 1.4rem;
}
.result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.result-title {
  font-weight: 850;
  color: var(--foreground);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-author {
  color: var(--muted-foreground);
  font-size: .88rem;
}
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.result-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .result-card { flex-direction: column; }
  .result-cover { width: 100%; min-height: 140px; }
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 38px 22px;
  text-align: center;
  background: var(--muted);
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .icon-badge { margin: 0 auto 14px; }

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.theme-option {
  min-width: 66px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 850;
  cursor: pointer;
}
.theme-ico { width: 17px; height: 17px; flex: 0 0 auto; stroke-width: 2; }
.theme-option:hover { color: var(--foreground); background: var(--muted); }
.theme-option.active { color: var(--primary-foreground); background: var(--primary); }

.footer {
  background: #171412;
  color: #e8ded2;
  padding: 46px 0 30px;
  margin-top: 40px;
}
.footer .brand { color: #fff7ef; }
.footer .brand-mark { box-shadow: none; }
.footer a { color: #e8ded2; }
.footer a:hover { color: #ffffff; }
.footer p, .footer span { color: #bdb2a6; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1.35fr; gap: 30px; }
.footer-heading { color: #fff7ef; display: block; margin-bottom: 12px; font-weight: 900; }
.footer-bottom {
  border-top: 1px solid #4a423b;
  margin-top: 30px;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  font-size: .84rem;
  flex-wrap: wrap;
  gap: 10px;
}
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }

.alert { padding: 13px 15px; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 17px; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 24%, var(--border)); }
.alert.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 24%, var(--border)); }
.alert.warn { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 24%, var(--border)); }
.divider { height: 1px; background: var(--border); border: 0; margin: 24px 0; }
.list-check { list-style: none; padding: 0; }
.list-check li { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; color: var(--muted-foreground); }
.list-check .tick { color: var(--success); flex: 0 0 auto; margin-top: 3px; }
.callout { background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border)); color: var(--primary-strong); padding: 13px 15px; border-radius: var(--radius-sm); font-size: .92rem; }
.empty { text-align: center; padding: 48px 18px; color: var(--muted-foreground); }
.empty .icon-badge { margin: 0 auto 16px; }
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spinner { margin-inline-start: 4px; }

body.sheet-locked { overflow: hidden; }

/* Review-gift bottom sheet: used on dashboard + wallet. */
.review-gift-wrap { margin-bottom: 24px; }
.review-gift-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--success) 30%, var(--border));
  background:
    radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--success) 17%, transparent) 0 150px, transparent 151px),
    linear-gradient(135deg, color-mix(in srgb, var(--success-soft) 86%, var(--card)) 0%, var(--card) 78%);
  box-shadow: 0 12px 34px color-mix(in srgb, var(--success) 13%, transparent), var(--shadow);
}
.review-gift-card::after {
  content: "";
  position: absolute;
  inset-inline-start: -36px;
  inset-block-start: -48px;
  width: 138px;
  height: 138px;
  border-radius: 36px;
  background: color-mix(in srgb, var(--success) 12%, transparent);
  transform: rotate(-14deg);
  pointer-events: none;
}
.review-gift-card > * { position: relative; z-index: 1; }
.review-gift-card h3 { margin: 8px 0 4px; }
.review-gift-card p { margin: 0; max-width: 680px; }
.review-gift-card .btn-primary,
.review-gift-foot .btn-primary {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.review-gift-card .btn-primary:hover,
.review-gift-foot .btn-primary:hover {
  background: color-mix(in srgb, var(--success) 86%, #000);
  border-color: color-mix(in srgb, var(--success) 86%, #000);
  color: #fff;
}
.review-gift-sheet {
  position: fixed;
  inset: 0;
  z-index: 980;
}
.review-gift-sheet[hidden] { display: none; }
.review-gift-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.42);
  animation: reviewGiftFadeIn .22s ease;
}
.review-gift-panel {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  margin-inline: auto;
  width: 100%;
  height: 100dvh;
  max-width: 560px;
  color: var(--card-foreground);
  --fs-foot-h: 92px;
  --fs-card-h: 62vh;
  --fs-y: 0px;
  animation: reviewGiftSheetUp .26s cubic-bezier(.16,1,.3,1);
}
.review-gift-sheet-card {
  position: absolute;
  inset-inline: 0;
  bottom: var(--fs-foot-h);
  height: var(--fs-card-h);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-top-left-radius: var(--fs-radius,22px);
  border-top-right-radius: var(--fs-radius,22px);
  box-shadow: var(--shadow-lg,0 -10px 48px rgba(0,0,0,.28));
  transform: translateY(var(--fs-y));
  transition: transform .26s cubic-bezier(.16,1,.3,1), border-radius .26s cubic-bezier(.16,1,.3,1);
  z-index: 1;
  overflow: hidden;
}
.review-gift-panel.sheet-dragging .review-gift-sheet-card { transition: none; will-change: transform; }
.review-gift-sheet.closing .review-gift-backdrop { animation: reviewGiftFadeOut .2s ease forwards; }
.review-gift-sheet.closing .review-gift-panel { animation: reviewGiftSheetDown .2s ease forwards; }
.review-gift-handle {
  display: block;
  width: 46px;
  height: 5px;
  border: 0;
  border-radius: 999px;
  background: var(--border);
  margin: 10px auto 4px;
  padding: 0;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
}
.review-gift-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.review-gift-head h2 { margin: 8px 0 0; font-size: 1.22rem; }
.review-gift-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 16px 20px 18px;
  display: grid;
  gap: 14px;
}
.review-gift-scroll::-webkit-scrollbar { display: none; }
.review-gift-scroll p { margin: 0; color: var(--muted-foreground); line-height: 1.9; }
.review-gift-amount {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px dashed color-mix(in srgb, var(--success) 36%, var(--border));
  background: var(--success-soft);
  color: var(--success);
  border-radius: 16px;
  padding: 14px;
}
.review-gift-amount strong { font-size: 1.1rem; }
.review-gift-foot {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 18px max(14px,env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--card);
  transform: translateY(var(--fs-foot-y,0px));
  transition: transform .26s cubic-bezier(.22,.61,.36,1);
}
.review-gift-foot form { display: contents; }
.review-gift-foot .btn { justify-content: center; }
.review-gift-panel.sheet-dragging .review-gift-foot { transition: none; }
.review-gift-panel.expanded .review-gift-foot { box-shadow: 0 -6px 20px rgba(0,0,0,.10); }
@keyframes reviewGiftFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes reviewGiftFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes reviewGiftSheetUp { from { transform: translateY(48px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes reviewGiftSheetDown { from { transform: translateY(0); opacity: 1; } to { transform: translateY(42px); opacity: 0; } }
@media (min-width: 880px) {
  .review-gift-sheet { display: grid; place-items: center; padding: 24px; }
  .review-gift-panel {
    position: relative;
    inset: auto;
    margin-inline: 0;
    width: min(560px,100%);
    max-width: 560px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,.26);
    overflow: hidden;
    animation: reviewGiftSheetPop .2s cubic-bezier(.16,1,.3,1);
  }
  .review-gift-sheet-card {
    position: static;
    bottom: auto;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    transform: none !important;
    transition: none;
    border-radius: 0;
    box-shadow: none;
  }
  .review-gift-foot { position: static; transform: none !important; box-shadow: none; }
  .review-gift-handle { display: none; }
  @keyframes reviewGiftSheetPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
}
@media (max-width: 640px) {
  .review-gift-card { align-items: stretch; flex-direction: column; }
  .review-gift-card .btn { justify-content: center; }
  .review-gift-foot { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .review-gift-backdrop,
  .review-gift-panel,
  .review-gift-sheet-card,
  .review-gift-foot,
  .review-gift-sheet.closing .review-gift-backdrop,
  .review-gift-sheet.closing .review-gift-panel {
    animation: none !important;
    transition: none !important;
  }
}

/* App-styled confirmation dialog */
.logout-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.logout-dialog[hidden] { display: none; }
.logout-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 16, .44);
  backdrop-filter: blur(8px);
  animation: dialogFadeIn .16s ease forwards;
}
.logout-dialog.closing .logout-dialog__backdrop { animation: dialogFadeOut .16s ease forwards; }
.logout-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
  padding: 22px;
  text-align: center;
  animation: dialogPopIn .18s cubic-bezier(.22,.61,.36,1) forwards;
}
.logout-dialog.closing .logout-dialog__panel { animation: dialogPopOut .16s ease forwards; }
.logout-dialog__icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}
.logout-dialog__icon svg { width: 23px; height: 23px; stroke-width: 2; }
.logout-dialog__panel h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}
.logout-dialog__panel p {
  margin: 0;
  color: var(--muted-foreground);
  line-height: 1.8;
}
.logout-dialog__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.logout-dialog__actions .btn {
  flex: 1;
  justify-content: center;
}
@keyframes dialogFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes dialogPopIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes dialogPopOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 480px) {
  .logout-dialog { align-items: end; padding: 12px; }
  .logout-dialog__panel { border-radius: calc(var(--radius) + 4px); padding: 20px; }
  .logout-dialog__actions { flex-direction: column-reverse; }
}

/* PWA install banner */
.install-banner {
  display: none;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 10px 0;
  font-size: .88rem;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 60;
}
.install-banner.visible { display: block; }
.install-banner .btn-primary { background: #fff; color: var(--primary); border-color: #fff; }
.install-banner .btn-primary:hover { background: #f0e8e4; }
.install-banner .btn-ghost { border-color: rgba(255,255,255,.3); color: var(--primary-foreground); background: transparent; }
.install-banner .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* Offline fallback page */
.offline-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px;
}
.offline-page .icon-badge { margin: 0 auto 20px; width: 72px; height: 72px; }
.offline-page h1 { margin-bottom: 12px; }
.offline-page p { max-width: 380px; margin-inline: auto; }

/* Smooth page transitions */
.app-main { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Back button */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-foreground);
  font-weight: 700;
  font-size: .88rem;
  padding: 6px 0;
  margin-bottom: 12px;
  transition: color .12s ease;
}
.back-link:hover { color: var(--primary); text-decoration: none; }
.back-link svg { width: 18px; height: 18px; }

/* Pricing cards */
.pricing-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pricing-card .price-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0;
}
.pricing-card .price-num {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}
.pricing-card .price-unit {
  color: var(--muted-foreground);
  font-size: .92rem;
  font-weight: 700;
}
.pricing-card .price-note {
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 700;
  text-align: center;
}

/* Standalone mode adjustments (PWA) */
@media (display-mode: standalone) {
  .nav { display: none; }
  body { padding-top: env(safe-area-inset-top); }
  .footer { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
}

/* Scroll-reveal + hero entrance (landing) */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .5s ease, transform .5s cubic-bezier(.22,.61,.36,1); }
.reveal.in { opacity: 1; transform: none; }
.grid .reveal:nth-child(2) { transition-delay: .08s; }
.grid .reveal:nth-child(3) { transition-delay: .16s; }
.hero-rise { opacity: 0; transform: translateY(14px); animation: heroRise .55s cubic-bezier(.22,.61,.36,1) forwards; }
@keyframes heroRise { to { opacity: 1; transform: none; } }
.screen-file-row { animation-timing-function: cubic-bezier(.22,.61,.36,1); }

/* Hero scene illustration: scan → book info → Basalam booth (RTL: right→left) */
.hero-visual { margin: 30px auto 0; max-width: 560px; }
.hv-scene { width: 100%; height: auto; }
.hv-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 8px auto 0;
  max-width: 520px;
  padding: 0 6px;
  color: var(--muted-foreground);
  font-size: .76rem;
  font-weight: 800;
}
.hv-labels span { flex: 1 1 0; text-align: center; }
/* RTL flow: rightmost label = scan, leftmost = booth */
.hv-labels span:first-child { color: var(--primary); }

/* Stage entrance: each block fades/lifts in, staggered right→left */
.hv-stage { opacity: 0; animation: hvStageIn .6s cubic-bezier(.22,.61,.36,1) forwards; }
.hv-scan { animation-delay: .35s; }
.hv-result { animation-delay: .75s; }
.hv-booth { animation-delay: 1.15s; }
@keyframes hvStageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scan line sweep inside the phone */
.hv-scan-line { animation: hvScanSweep 4.5s cubic-bezier(.22,.61,.36,1) infinite; }
@keyframes hvScanSweep {
  0% { transform: translateY(-26px); opacity: 0; }
  3% { opacity: .9; }
  12% { transform: translateY(26px); opacity: .9; }
  16%, 100% { transform: translateY(26px); opacity: 0; }
}

/* Flow arrows: pulse in sequence to suggest motion right→left */
.hv-arrow { animation: hvArrowPulse 4.5s cubic-bezier(.22,.61,.36,1) infinite; }
.hv-arrow-1 { animation-delay: .9s; }
.hv-arrow-2 { animation-delay: 2.4s; }
@keyframes hvArrowPulse {
  0%, 100% { opacity: .3; }
  10% { opacity: 1; }
  30% { opacity: .3; }
}

/* "Added" check pulse on the result card — fires as the book arrives */
.hv-check { transform-box: fill-box; transform-origin: center; animation: hvCheckPulse 4.5s cubic-bezier(.22,.61,.36,1) infinite; }
@keyframes hvCheckPulse {
  0%, 38% { transform: scale(0); opacity: 0; }
  46% { transform: scale(1.18); opacity: 1; }
  56%, 100% { transform: scale(1); opacity: 1; }
}

/* Book lands on the booth shelf */
.hv-shelf-book { transform-box: fill-box; transform-origin: bottom; animation: hvShelfBook 4.5s cubic-bezier(.22,.61,.36,1) infinite; }
@keyframes hvShelfBook {
  0%, 78% { transform: translateY(-8px) scaleY(0); opacity: 0; }
  88% { transform: translateY(0) scaleY(1); opacity: 1; }
  100% { transform: translateY(0) scaleY(1); opacity: 1; }
}

/* The star of the show: a book that rides the whole flow on a loop. */
.hv-traveler { animation: hvTravel 4.5s cubic-bezier(.5,0,.5,1) infinite; will-change: transform, opacity; }
@keyframes hvTravel {
  0%, 6%   { transform: translate(0, 0);         opacity: 0; }
  12%      { transform: translate(0, 0);         opacity: 1; }
  40%      { transform: translate(-197px, -2px); opacity: 1; }   /* arrives at info card */
  52%      { transform: translate(-197px, -2px); opacity: 1; }   /* dwells while card "fills" */
  84%      { transform: translate(-362px, 36px); opacity: 1; }   /* arrives at the booth shelf */
  92%,100% { transform: translate(-362px, 36px); opacity: 0; }   /* settles, fades, loop */
}

@media (max-width: 520px) {
  .hero-visual { margin-top: 24px; }
  .hv-labels { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce){*,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important;}}
/* Reduced-motion users still see revealed/hero content (no stuck opacity:0) */
@media (prefers-reduced-motion: reduce){.reveal,.hero-rise{opacity:1!important;transform:none!important;}}
/* Hero scene: show every stage/element in its final state under reduced motion */
@media (prefers-reduced-motion: reduce){
  .hv-stage,.hv-check,.hv-shelf-book,.hv-scan-line{opacity:1!important;transform:none!important;}
  .hv-arrow{opacity:.55!important;}
  .hv-traveler{opacity:0!important;}
}
