/* ==========================================================
   Wishlist PWA — design tokens
   ========================================================== */
:root {
  --brand-1: #7c5cff;
  --brand-2: #ff5ca8;
  --brand-3: #ffb35c;
  --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 60%, var(--brand-3) 120%);

  --down: #16a34a;
  --down-bg: rgba(22, 163, 74, .12);
  --up: #e11d48;
  --up-bg: rgba(225, 29, 72, .12);
  --gold: #d97706;
  --gold-bg: rgba(217, 119, 6, .14);

  --bg: #f6f5ff;
  --bg-2: #ecebfb;
  --surface: #ffffff;
  --surface-2: #f3f2fc;
  --surface-glass: rgba(255, 255, 255, .72);
  --border: rgba(30, 20, 80, .09);
  --text: #16132e;
  --text-2: #5a5775;
  --text-3: #8e8ba8;
  --shadow-sm: 0 1px 2px rgba(22, 19, 46, .06), 0 2px 8px rgba(22, 19, 46, .05);
  --shadow: 0 10px 30px -10px rgba(40, 20, 120, .25);
  --shadow-lg: 0 30px 60px -20px rgba(40, 20, 120, .35);
  --img-bg: #ffffff;

  --radius: 20px;
  --radius-sm: 12px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0a1f;
    --bg-2: #15122e;
    --surface: #17142f;
    --surface-2: #211d40;
    --surface-glass: rgba(23, 20, 47, .72);
    --border: rgba(255, 255, 255, .08);
    --text: #f2f0ff;
    --text-2: #b4b0d6;
    --text-3: #7d79a3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 14px 34px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
    --down: #34d399;
    --down-bg: rgba(52, 211, 153, .14);
    --up: #fb7185;
    --up-bg: rgba(251, 113, 133, .14);
    --gold: #fbbf24;
    --gold-bg: rgba(251, 191, 36, .14);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0a1f;
  --bg-2: #15122e;
  --surface: #17142f;
  --surface-2: #211d40;
  --surface-glass: rgba(23, 20, 47, .72);
  --border: rgba(255, 255, 255, .08);
  --text: #f2f0ff;
  --text-2: #b4b0d6;
  --text-3: #7d79a3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 14px 34px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .7);
  --down: #34d399;
  --down-bg: rgba(52, 211, 153, .14);
  --up: #fb7185;
  --up-bg: rgba(251, 113, 133, .14);
  --gold: #fbbf24;
  --gold-bg: rgba(251, 191, 36, .14);
}

/* ==========================================================
   Base
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
body::before {
  content: '';
  position: fixed;
  inset: -20vmax -20vmax auto auto;
  width: 60vmax; height: 60vmax;
  background: radial-gradient(closest-side, rgba(124, 92, 255, .22), transparent 70%);
  pointer-events: none;
  z-index: -1;
}
body::after {
  content: '';
  position: fixed;
  inset: auto auto -25vmax -25vmax;
  width: 60vmax; height: 60vmax;
  background: radial-gradient(closest-side, rgba(255, 92, 168, .16), transparent 70%);
  pointer-events: none;
  z-index: -1;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-1); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.splash {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .4s var(--ease), visibility .4s;
}
.splash img { animation: pop 1.2s var(--spring) infinite alternate; filter: drop-shadow(0 20px 40px rgba(124, 92, 255, .45)); }
.splash.gone { opacity: 0; visibility: hidden; }
@keyframes pop { from { transform: scale(.92); } to { transform: scale(1.04); } }

.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  padding: calc(6px + var(--safe-t)) 16px 6px;
  text-align: center; font-size: 13px; font-weight: 600;
  background: #f59e0b; color: #1a1300;
}

/* ==========================================================
   Layout: header + tab bar
   ========================================================== */
.shell { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); }

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: calc(12px + var(--safe-t)) 20px 12px;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand img { width: 34px; height: 34px; }
.brand span { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar .spacer { flex: 1; }
.topnav { display: none; gap: 4px; }
.topnav a {
  padding: 9px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 8px; position: relative;
  transition: background .2s, color .2s;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--text); color: var(--bg); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 14px;
  display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--text);
  position: relative;
  transition: transform .15s var(--ease), background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }
.dot-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--brand-2); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 50;
  height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  position: relative; padding: 6px 0;
  transition: color .2s;
}
.tabbar svg { width: 24px; height: 24px; transition: transform .25s var(--spring); }
.tabbar a.active { color: var(--text); }
.tabbar a.active svg { transform: translateY(-2px) scale(1.08); color: var(--brand-1); }
.tabbar .dot-badge { top: 0; right: calc(50% - 22px); }
.tabbar .fab {
  width: 58px; height: 58px; margin: -26px auto 0; border-radius: 20px;
  background: var(--brand-grad); color: #fff;
  box-shadow: 0 12px 28px -6px rgba(124, 92, 255, .65);
  display: grid; place-items: center;
  transition: transform .2s var(--spring);
}
.tabbar .fab svg { width: 28px; height: 28px; color: #fff; }
.tabbar .fab:active { transform: scale(.9) rotate(90deg); }

.page { width: 100%; margin: 0 auto; padding: 18px 16px; animation: pageIn .45s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: 6px 4px 16px; }
.page-sub { color: var(--text-2); margin: -10px 4px 18px; font-size: 14px; }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .shell { padding-bottom: 40px; }
  .page { padding: 28px 32px; }
  .topbar { padding-left: 32px; padding-right: 32px; }
}

/* ==========================================================
   Hero stats
   ========================================================== */
.hero {
  position: relative; overflow: hidden;
  border-radius: 28px; padding: 22px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 24px 50px -18px rgba(124, 92, 255, .6);
  isolation: isolate;
}
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; z-index: -1;
  background: rgba(255, 255, 255, .14);
}
.hero::before { width: 260px; height: 260px; top: -120px; right: -60px; animation: drift 14s ease-in-out infinite; }
.hero::after { width: 180px; height: 180px; bottom: -90px; left: 30%; animation: drift 18s ease-in-out infinite reverse; }
@keyframes drift { 50% { transform: translate(-30px, 20px) scale(1.1); } }
.hero-label { font-size: 13px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
.hero-value { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.hero-meta { font-size: 14px; opacity: .9; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.hero-chip {
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 16px; padding: 10px 12px;
  backdrop-filter: blur(6px);
}
.hero-chip b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-chip span { font-size: 11.5px; opacity: .9; font-weight: 600; }

@media (min-width: 900px) {
  .hero { padding: 30px 34px; display: grid; grid-template-columns: 1.2fr 1fr; align-items: end; gap: 24px; }
  .hero-value { font-size: 52px; }
  .hero-grid { margin-top: 0; }
}

/* ==========================================================
   Toolbar: search, chips, sort
   ========================================================== */
.toolbar { margin: 20px 0 14px; display: flex; flex-direction: column; gap: 12px; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 0 14px; height: 50px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--brand-1); box-shadow: 0 0 0 4px rgba(124, 92, 255, .15); }
.search svg { width: 20px; height: 20px; color: var(--text-3); flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.search .icon-btn { width: 36px; height: 36px; border-radius: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 38px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all .2s var(--ease);
  white-space: nowrap;
}
.chip .n { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chip.active { background: var(--text); color: var(--bg); border-color: transparent; }
.chip.active .n { background: rgba(255, 255, 255, .2); color: inherit; }
select.chip { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8ba8' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.count-label { white-space: nowrap; font-size: 13px; color: var(--text-3); font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; }
.seg button { height: 32px; padding: 0 10px; border-radius: 9px; color: var(--text-3); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.seg button svg { width: 18px; height: 18px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

@media (min-width: 900px) {
  .toolbar { flex-direction: row; align-items: center; }
  .toolbar .search { flex: 0 0 340px; }
  .chips { margin: 0; padding: 2px; flex: 1; }
}

/* ==========================================================
   Product cards
   ========================================================== */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1400px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
  animation: cardIn .5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
  cursor: pointer;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@media (hover: hover) { .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); } }
.card:active { transform: scale(.98); }
.card.paused { opacity: .6; }

.card-media { position: relative; aspect-ratio: 1 / 1; background: var(--img-bg); display: grid; place-items: center; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: contain; padding: 14px; transition: transform .5s var(--ease); }
@media (hover: hover) { .card:hover .card-media img { transform: scale(1.06); } }
.ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-size: 34px; font-weight: 800; letter-spacing: -.04em;
}
.card-badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.fav {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 12px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(6px);
  display: grid; place-items: center; color: #9a97b5;
  transition: transform .25s var(--spring), color .2s;
  box-shadow: var(--shadow-sm);
}
.fav svg { width: 18px; height: 18px; }
.fav.on { color: #ff3d7f; }
.fav.on svg { fill: currentColor; }
.fav:active { transform: scale(.8); }
.fav.burst { animation: burst .5s var(--spring); }
@keyframes burst { 40% { transform: scale(1.35); } }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .01em;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge.down { background: var(--down); color: #fff; }
.badge.up { background: var(--up); color: #fff; }
.badge.min { background: #111; color: #fff; }
.badge.target { background: var(--gold); color: #fff; }
.badge.out { background: #64748b; color: #fff; }
.badge.soft-down { background: var(--down-bg); color: var(--down); }
.badge.soft-up { background: var(--up-bg); color: var(--up); }
.badge.soft { background: var(--surface-2); color: var(--text-2); }
.badge.soft-gold { background: var(--gold-bg); color: var(--gold); }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-site { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.site-dot { width: 16px; height: 16px; border-radius: 5px; display: grid; place-items: center; font-size: 9px; color: #fff; font-weight: 800; flex: none; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; }
.price { font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.price small { font-size: .62em; font-weight: 700; }
.price-old { font-size: 12px; color: var(--text-3); text-decoration: line-through; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.spark { width: 64px; height: 28px; flex: none; }

/* quick remove and multi-select */
.del {
  position: absolute; top: 50px; right: 8px; width: 36px; height: 36px; border-radius: 12px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(6px);
  display: grid; place-items: center; color: #9a97b5;
  box-shadow: var(--shadow-sm);
  transition: transform .2s var(--spring), color .2s;
}
.del svg { width: 17px; height: 17px; }
.del:active { transform: scale(.85); color: var(--up); }
@media (hover: hover) { .del:hover { color: #e11d48; } }
.tick {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; color: transparent;
  background: rgba(255, 255, 255, .85); border: 2px solid #b9b6d2;
}
.tick svg { width: 16px; height: 16px; }
.card.selected { outline: 3px solid var(--brand-1); outline-offset: -3px; }
.card.selected .tick { background: var(--brand-1); border-color: var(--brand-1); color: #fff; }
.chip.active svg { color: inherit; }
.chip svg { width: 15px; height: 15px; }
.select-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 60;
  max-width: 560px; margin: 0 auto;
  height: var(--tabbar-h); padding: 0 12px;
  display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow-lg);
  animation: toastIn .35s var(--spring);
}

/* list mode */
.grid.list { grid-template-columns: 1fr; gap: 10px; }
.grid.list .card { flex-direction: row; }
.grid.list .card-media { width: 104px; flex: none; aspect-ratio: auto; }
.grid.list .card-media img { padding: 10px; }
.grid.list .fav { width: 30px; height: 30px; top: 6px; right: 6px; }
.grid.list .del { top: auto; bottom: 6px; right: 6px; width: 30px; height: 30px; }
.grid.list .card-badges { top: 6px; left: 6px; }
.grid.list .card-badges .badge:not(:first-child) { display: none; }
.grid.list .card-body { padding-right: 46px; }
.grid.list .card-title { min-height: 0; }
@media (min-width: 900px) { .grid.list { grid-template-columns: repeat(2, 1fr); } }

/* skeleton */
.skeleton { pointer-events: none; animation: none; }
.skeleton .card-media, .sk-line {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-2) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.sk-line { height: 12px; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* empty state */
.empty { text-align: center; padding: 50px 20px; color: var(--text-2); }
.empty .art { width: 120px; height: 120px; margin: 0 auto 18px; border-radius: 36px; background: var(--brand-grad); display: grid; place-items: center; box-shadow: var(--shadow-lg); animation: pop 2s var(--spring) infinite alternate; }
.empty .art svg { width: 58px; height: 58px; color: #fff; }
.empty h3 { color: var(--text); font-size: 20px; margin: 0 0 6px; }
.empty p { margin: 0 auto 20px; max-width: 320px; line-height: 1.5; }

/* pull to refresh */
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--text-3); transition: height .25s var(--ease); }
.ptr svg { width: 22px; height: 22px; }
.ptr.spin svg { animation: spin 0.8s linear infinite; }

/* ==========================================================
   Buttons & forms
   ========================================================== */
.btn {
  height: 48px; padding: 0 20px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  transition: transform .15s var(--ease), filter .2s, opacity .2s;
  position: relative; white-space: nowrap;
}
.btn svg { width: 19px; height: 19px; flex: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--brand-grad); color: #fff; box-shadow: 0 10px 24px -8px rgba(124, 92, 255, .6); }
.btn.dark { background: var(--text); color: var(--bg); }
.btn.danger { background: var(--up-bg); color: var(--up); }
.btn.ghost { background: transparent; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn.loading { color: transparent !important; }
.btn.loading::after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn:not(.primary):not(.dark).loading::after { border-color: var(--text) var(--text) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input {
  height: 50px; padding: 0 14px; border-radius: 14px;
  background: var(--surface-2); border: 1.5px solid transparent;
  font-size: 16px; outline: 0; width: 100%;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
textarea.input { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--brand-1); background: var(--surface); box-shadow: 0 0 0 4px rgba(124, 92, 255, .14); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 48px; }
.input-group .suffix { position: absolute; right: 16px; font-weight: 700; color: var(--text-3); pointer-events: none; }
.input-group .icon-btn { position: absolute; right: 5px; width: 40px; height: 40px; border-radius: 11px; background: var(--surface); }
.hint { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 14px; gap: 4px; }
.segmented button { height: 40px; border-radius: 10px; font-size: 13.5px; font-weight: 700; color: var(--text-2); transition: all .2s; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.quick button { height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--text-2); }
.quick button:active { background: var(--brand-1); color: #fff; }

.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); transition: background .25s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .3s var(--spring); }
.switch input:checked + span { background: var(--brand-1); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ==========================================================
   Bottom sheet / modal
   ========================================================== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(8, 6, 24, .5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fadeIn .25s var(--ease);
}
.sheet-backdrop.closing { animation: fadeOut .25s var(--ease) forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
  max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + var(--safe-b));
  box-shadow: var(--shadow-lg);
  animation: sheetUp .45s var(--spring);
}
.sheet.closing { animation: sheetDown .28s var(--ease) forwards; }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
.sheet-handle { width: 42px; height: 5px; border-radius: 9px; background: var(--border); margin: 0 auto 14px; background: var(--text-3); opacity: .35; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; flex: 1; }
@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(620px, 94vw); max-height: 90dvh;
    border-radius: 28px; padding: 24px 28px 28px;
    transform: translate(-50%, -50%);
    animation: modalIn .4s var(--spring);
  }
  .sheet.closing { animation: modalOut .22s var(--ease) forwards; }
  .sheet-handle { display: none; }
  @keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } }
  @keyframes modalOut { to { opacity: 0; transform: translate(-50%, -48%) scale(.97); } }
  .sheet.wide { width: min(940px, 94vw); }
}

/* detail */
.detail-top { display: grid; gap: 18px; }
.detail-media { border-radius: 22px; background: var(--img-bg); aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; position: relative; border: 1px solid var(--border); }
.detail-media img { width: 100%; height: 100%; object-fit: contain; padding: 18px; }
.detail-title { font-size: 20px; font-weight: 800; line-height: 1.3; letter-spacing: -.01em; margin: 6px 0 10px; }
.detail-price { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail-price .price { font-size: 36px; }
.badges-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
@media (min-width: 720px) { .sheet.wide .detail-top { grid-template-columns: 300px 1fr; align-items: start; } .sheet.wide .detail-media { aspect-ratio: 1; } }

.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: var(--surface-2); border-radius: 16px; padding: 12px; }
.stat span { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.stat b { display: block; font-size: 17px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.good b { color: var(--down); }
.stat.bad b { color: var(--up); }

.section { margin-top: 22px; }
.section-title { font-size: 15px; font-weight: 800; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.chart-box { background: var(--surface-2); border-radius: 20px; padding: 14px 10px 6px; position: relative; }
.chart-box svg { width: 100%; height: 190px; display: block; overflow: visible; touch-action: pan-y; }
.chart-tip {
  position: absolute; top: 8px; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 10px;
  font-size: 12px; font-weight: 700; white-space: nowrap; transform: translateX(-50%);
  transition: opacity .15s;
}
.chart-tip small { display: block; font-weight: 500; opacity: .75; }
.chart-empty { height: 150px; display: grid; place-items: center; color: var(--text-3); font-size: 14px; text-align: center; padding: 0 20px; }

.actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 20px; }
.actions-grid .btn { width: 100%; }
@media (min-width: 720px) { .actions-grid { grid-template-columns: repeat(4, 1fr); } }

.preview-card { display: flex; gap: 14px; padding: 12px; border-radius: 18px; background: var(--surface-2); margin-bottom: 18px; animation: pageIn .4s var(--ease); }
.preview-card .thumb { width: 92px; height: 92px; flex: none; border-radius: 14px; background: var(--img-bg); overflow: hidden; display: grid; place-items: center; }
.preview-card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.preview-card .info { min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.preview-card .title { font-weight: 700; font-size: 14.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.scan {
  height: 160px; border-radius: 20px; background: var(--surface-2); margin-bottom: 18px;
  display: grid; place-items: center; position: relative; overflow: hidden; color: var(--text-2); font-weight: 600; font-size: 14px;
}
.scan::before { content: ''; position: absolute; left: 0; right: 0; height: 60px; background: linear-gradient(180deg, transparent, rgba(124, 92, 255, .25), transparent); animation: scanline 1.4s ease-in-out infinite; }
@keyframes scanline { from { top: -60px; } to { top: 100%; } }
.scan div { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.scan svg { width: 34px; height: 34px; color: var(--brand-1); }

/* ==========================================================
   Lists: notifications, settings
   ========================================================== */
.list-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); position: relative; }
.list-row:last-child { border-bottom: 0; }
button.list-row, a.list-row { width: 100%; text-align: left; transition: background .15s; }
button.list-row:active, a.list-row:active { background: var(--surface-2); }
.list-row .ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.list-row .ico svg { width: 20px; height: 20px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 700; font-size: 14.5px; }
.list-row .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.list-row .chev { color: var(--text-3); width: 18px; height: 18px; }

.notif { align-items: flex-start; cursor: pointer; }
.n-del { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); }
.n-del svg { width: 16px; height: 16px; }
.n-del:active { background: var(--up-bg); color: var(--up); }
.notif .thumb { width: 54px; height: 54px; border-radius: 14px; background: var(--img-bg); overflow: hidden; flex: none; border: 1px solid var(--border); }
.notif .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.notif .t { font-weight: 600; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif .prices { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.notif .prices s { color: var(--text-3); font-weight: 600; }
.notif.unread::before { content: ''; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--brand-2); }
.notif.unread { background: linear-gradient(90deg, rgba(255, 92, 168, .06), transparent); }

.group-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 22px 6px 10px; }

.profile-head { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.avatar { width: 62px; height: 62px; border-radius: 20px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 800; flex: none; }
.role { display: inline-flex; margin-top: 6px; }

.install-card {
  margin-top: 16px; padding: 18px; border-radius: 22px; color: #fff;
  background: linear-gradient(135deg, #1e1b4b, #4c1d95 60%, #9d174d);
  display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow);
}
.install-card .ico { width: 52px; height: 52px; border-radius: 16px; flex: none; }
.install-card p { margin: 2px 0 0; font-size: 13px; opacity: .85; line-height: 1.4; }
.install-card .btn { background: #fff; color: #1e1b4b; }

.ios-steps { counter-reset: step; display: flex; flex-direction: column; gap: 12px; margin: 6px 0 4px; padding: 0; list-style: none; }
.ios-steps li { counter-increment: step; display: flex; gap: 12px; align-items: center; font-size: 15px; line-height: 1.4; }
.ios-steps li::before { content: counter(step); width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--brand-grad); color: #fff; font-weight: 800; }
.ios-steps svg { width: 20px; height: 20px; vertical-align: -4px; color: #0a84ff; }

/* admin */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 800; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
pre.logs { margin: 0; padding: 16px; background: #0b0a1a; color: #c7c3ff; border-radius: 16px; font-size: 12px; line-height: 1.55; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* ==========================================================
   Login
   ========================================================== */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px calc(24px + var(--safe-b));
  position: relative; overflow: hidden; isolation: isolate;
}
.login .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .7; z-index: -1; animation: drift 16s ease-in-out infinite; }
.login .b1 { width: 380px; height: 380px; background: var(--brand-1); top: -120px; left: -120px; }
.login .b2 { width: 320px; height: 320px; background: var(--brand-2); bottom: -100px; right: -80px; animation-delay: -5s; }
.login .b3 { width: 240px; height: 240px; background: var(--brand-3); top: 40%; left: 55%; opacity: .45; animation-delay: -9s; }
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface-glass);
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border); border-radius: 32px;
  padding: 34px 26px 28px; box-shadow: var(--shadow-lg);
  animation: pageIn .6s var(--spring);
}
.login-logo { width: 76px; height: 76px; margin: 0 auto 18px; filter: drop-shadow(0 16px 30px rgba(124, 92, 255, .5)); }
.login h1 { text-align: center; margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.login .tag { text-align: center; color: var(--text-2); margin: 8px 0 26px; font-size: 15px; line-height: 1.45; }
.feature-row { display: flex; justify-content: center; gap: 16px; margin: 0 0 26px; flex-wrap: wrap; }
.feature-row span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.feature-row svg { width: 16px; height: 16px; color: var(--brand-1); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12.5px; font-weight: 600; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.form-error { background: var(--up-bg); color: var(--up); padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; margin-top: 12px; animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ==========================================================
   Toasts
   ========================================================== */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toast-root { bottom: 28px; } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: 460px; padding: 12px 16px; border-radius: 16px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toastIn .4s var(--spring);
}
.toast.out { animation: toastOut .25s var(--ease) forwards; }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.success svg { color: var(--down); }
.toast.error svg { color: var(--up); }
.toast-action { flex: none; margin-left: 6px; padding: 4px 10px; border-radius: 9px; font-weight: 800; font-size: 13.5px; color: var(--brand-2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 130; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--r)); } }

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