/* Zakupy Na Medal — app styles. Tokens first, then components. */

@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/assets/fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/assets/fonts/inter-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-display: swap; font-weight: 200 800; src: url(/assets/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-display: swap; font-weight: 200 800; src: url(/assets/fonts/bricolage-grotesque-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --navy: #15213B;
  --gold: #F2B035;
  --gold-soft: #FCF4E2;
  --silver: #B9C2CF;
  --bronze: #C98A5B;
  --danger: #C8323F;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #F3F5F8;
  --text: #15213B;
  --text-2: #3A4660;
  --muted: #5B6579;
  --line: #E4E7EC;
  --line-2: #EEF0F4;
  --ring: #C4CBD7;
  --hero: #15213B;
  --hero-muted: #B7C0D0;
  --shadow: 0 1px 2px rgba(21, 33, 59, 0.06);
  --shadow-lg: 0 18px 48px rgba(21, 33, 59, 0.18);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mark-sheet: #15213B;
  --mark-line: #FFFFFF;
  --mark-tick: #F2B035;
  --btn-strong: #15213B;
  --btn-strong-text: #FFFFFF;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0E1628; --surface: #18233A; --surface-2: #212C42; --text: #F1F3F7; --text-2: #C9D0DC; --muted: #A9B3C5;
    --line: #26324A; --line-2: #212C42; --ring: #4A5672; --hero: #1F2B44; --gold-soft: rgba(242, 176, 53, 0.13);
    --shadow: none; --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5); --mark-sheet: #FFFFFF; --mark-line: #15213B; --mark-tick: #15213B; --btn-strong: #F1F3F7; --btn-strong-text: #15213B; color-scheme: dark;
  }
}
:root[data-theme='dark'], .force-dark {
  --bg: #0E1628; --surface: #18233A; --surface-2: #212C42; --text: #F1F3F7; --text-2: #C9D0DC; --muted: #A9B3C5;
  --line: #26324A; --line-2: #212C42; --ring: #4A5672; --hero: #1F2B44; --gold-soft: rgba(242, 176, 53, 0.13);
  --shadow: none; --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5); --mark-sheet: #FFFFFF; --mark-line: #15213B; --mark-tick: #15213B; --btn-strong: #F1F3F7; --btn-strong-text: #15213B; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 540px; margin: 0 auto; min-height: 100dvh; position: relative; }
@media (min-width: 600px) {
  body { background: color-mix(in srgb, var(--bg) 85%, var(--navy)); }
  #app { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
}

/* ---------- layout ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.pad { padding-left: 20px; padding-right: 20px; }
.top-safe { padding-top: calc(var(--safe-top) + 14px); }
.with-tabbar { padding-bottom: calc(96px + var(--safe-bottom)); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- type ---------- */
.eyebrow { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.title-xl { margin: 0; font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.02; }
.title-lg { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.05; }
.title-md { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.label {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 20px;
  border: 0; border-radius: 16px; font-size: 16px; font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-lg { height: 56px; font-size: 17px; border-radius: 18px; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-gold { background: var(--gold); color: #15213B; }
.btn-navy { background: var(--btn-strong); color: var(--btn-strong-text); }
.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn-danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--line); }
.btn-text { background: none; border: 0; padding: 10px 4px; font-size: 14px; font-weight: 600; color: var(--text); }

.icon-btn {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 22px; background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.icon-btn.plain { background: transparent; }
.icon-btn.gold { background: var(--gold); color: #15213B; }
.icon-btn.navy { background: var(--btn-strong); color: var(--btn-strong-text); }

/* ---------- avatars ---------- */
.avatar {
  flex: none; border-radius: 50%; color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; position: relative; text-transform: uppercase;
}
.avatar .live {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--gold);
  border: 2px solid var(--surface);
}
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--stack-ring, var(--surface)); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); }
.hero {
  display: block; position: relative; overflow: hidden; text-decoration: none; color: #FFFFFF; background: var(--hero);
  border-radius: 24px; padding: 20px; --stack-ring: var(--hero);
}
.hero .watermark { position: absolute; right: -54px; top: -64px; opacity: 0.07; transform: rotate(14deg); pointer-events: none; }
.presence {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1);
  font-size: 12px; font-weight: 600;
}
.dot-live {
  width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(242, 176, 53, 0.25);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(242, 176, 53, 0.08); } }

.progress { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--gold); transition: width 0.35s ease; }
.hero .progress { background: rgba(255, 255, 255, 0.14); }

.list-card {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 18px; background: var(--surface);
  box-shadow: var(--shadow); text-decoration: none; color: inherit;
}
.list-card:active { transform: scale(0.99); }

.cat-tile {
  flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px;
  background: var(--tint); color: var(--ink);
}
:root[data-theme='dark'] .cat-tile, .force-dark .cat-tile { background: color-mix(in srgb, var(--ink) 26%, transparent); color: color-mix(in srgb, var(--ink) 45%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .cat-tile { background: color-mix(in srgb, var(--ink) 26%, transparent); color: color-mix(in srgb, var(--ink) 45%, white); } }

/* ---------- list screen ---------- */
.list-head { background: var(--surface); border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--hero); color: #FFFFFF;
  font-size: 13px; border: 0; text-align: left; width: 100%;
}
.banner strong { font-weight: 700; }
.banner .act { margin-left: auto; font-weight: 700; color: var(--gold); white-space: nowrap; }
.banner.soft { background: var(--gold-soft); color: var(--text); }
.banner.soft .act { color: var(--text); }

.group { margin-top: 18px; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 0 4px 8px; }
.group-head .count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); }
.group-card { background: var(--surface); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.item-row { display: flex; align-items: center; gap: 6px; padding: 6px 16px 6px 6px; min-height: 60px; position: relative; }
.item-row + .item-row { border-top: 1px solid var(--line-2); }
.item-row .body { flex: 1; min-width: 0; padding: 6px 0; background: none; border: 0; text-align: left; }
.item-name { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.item-note { margin-top: 2px; font-size: 13px; color: var(--muted); }
.item-qty { font-size: 15px; color: var(--muted); white-space: nowrap; }
.item-row.done .item-name { color: var(--muted); text-decoration: line-through; font-size: 16px; }
.item-row.done { min-height: 52px; }
.item-row.fresh { animation: fresh 1.4s ease; }
@keyframes fresh { 0% { background: var(--gold-soft); } 100% { background: transparent; } }

.check { width: 44px; height: 44px; flex: none; border: 0; padding: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.check .ring { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ring); transition: border-color 0.15s; }
.check:hover .ring { border-color: var(--gold); }
.check svg.pop { animation: pop 0.35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 0% { transform: scale(0.4); } 100% { transform: scale(1); } }

.addbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 540px; z-index: 20;
  padding: 12px 16px calc(12px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.addbar .fake-input {
  flex: 1; height: 50px; padding: 0 14px; border-radius: 16px; background: var(--surface-2); border: 0; display: flex; align-items: center;
  gap: 10px; color: var(--muted); font-size: 16px; text-align: left;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 540px; z-index: 20;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 0 calc(8px + var(--safe-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; text-decoration: none; color: var(--muted);
  font-size: 11px; font-weight: 600; background: none; border: 0;
}
.tab[aria-current='page'] { color: var(--text); font-weight: 700; }
.tab[aria-current='page'] .tab-dot { background: var(--gold); }
.tab-dot { width: 4px; height: 4px; border-radius: 2px; background: transparent; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 17px; color: var(--text); outline: none;
}
.input:focus { border-color: var(--text); }
.input-big { height: 58px; border-width: 2px; border-color: var(--text); border-radius: 18px; font-size: 18px; font-weight: 500; }
.search { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 8px 0 16px; border-radius: 18px; border: 2px solid var(--text); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 18px; font-weight: 500; outline: none; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 38px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--gold-soft); border-color: var(--gold); }
.chip.dashed { border-style: dashed; border-color: var(--ring); background: transparent; color: var(--text-2); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg button { height: 40px; border: 0; border-radius: 10px; background: transparent; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
:root[data-theme='dark'] .seg button[aria-pressed='true'] { background: #2A3753; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .seg button[aria-pressed='true'] { background: #2A3753; } }

.switch { width: 52px; height: 32px; flex: none; border-radius: 16px; border: 0; padding: 0; background: var(--ring); position: relative; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #FFFFFF; transition: transform 0.2s; }
.switch[aria-checked='true'] { background: var(--btn-strong); }
.switch[aria-checked='true']::after { transform: translateX(20px); background: var(--gold); }

/* ---------- sheets ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(14, 22, 40, 0.55); display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease;
}
.sheet {
  width: 100%; max-width: 540px; max-height: calc(100dvh - var(--safe-top) - 24px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 20px calc(24px + var(--safe-bottom));
  animation: up 0.28s cubic-bezier(.2, .9, .3, 1);
}
.sheet.full { height: 100dvh; max-height: none; border-radius: 0; padding-top: calc(var(--safe-top) + 10px); display: flex; flex-direction: column; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.menu { display: flex; flex-direction: column; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 4px; border: 0; background: none; text-align: left;
  font-size: 16px; font-weight: 500; color: var(--text); text-decoration: none;
}
.menu > * + * { border-top: 1px solid var(--line-2); }
.menu .danger { color: var(--danger); }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + var(--safe-bottom)); z-index: 60; width: calc(100% - 32px); max-width: 508px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: #15213B; color: #FFFFFF; font-size: 14px; box-shadow: var(--shadow-lg); animation: up 0.25s ease;
}
:root[data-theme='dark'] .toast, .force-dark .toast { background: #F1F3F7; color: #15213B; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .toast { background: #F1F3F7; color: #15213B; } }
.toast button { margin-left: auto; border: 0; background: none; font-weight: 700; color: var(--gold); padding: 6px; }
:root[data-theme='dark'] .toast button, .force-dark .toast button { color: #8A5A0C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .toast button { color: #8A5A0C; } }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--gold-soft);
  font-size: 12px; font-weight: 600; color: var(--text);
}

/* ---------- store mode ---------- */
.store { min-height: 100dvh; background: var(--bg); color: var(--text); padding-bottom: calc(110px + var(--safe-bottom)); }
.store-row { position: relative; border-radius: 20px; overflow: hidden; background: var(--gold); touch-action: pan-y; user-select: none; }
.store-row.left { background: var(--danger); }
.store-row .under { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; color: #15213B; font-size: 14px; font-weight: 700; }
.store-row.left .under { color: #FFFFFF; }
.store-row .over {
  position: relative; min-height: 76px; display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--surface);
  border-radius: 20px; transition: transform 0.25s cubic-bezier(.2, .9, .3, 1);
}
.store-row .over.dragging { transition: none; }
.store-row .name { font-size: 21px; font-weight: 600; overflow-wrap: anywhere; }
.store-row .qty { font-size: 18px; color: var(--muted); white-space: nowrap; }
.store-check { width: 44px; height: 44px; margin: -5px; flex: none; border: 0; background: none; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.store-check span { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--ring); }
.segments { display: grid; gap: 4px; }
.segments i { height: 8px; border-radius: 4px; background: var(--line); }
.segments i.on { background: var(--gold); }

/* ---------- done / medal ---------- */
.medal-hero {
  position: relative; overflow: hidden; background: #15213B; color: #FFFFFF; border-radius: 0 0 36px 36px;
  padding: calc(var(--safe-top) + 48px) 24px 76px; text-align: center;
}
.medal-hero .spark { position: absolute; animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.25; transform: scale(0.7); } }
.medal-hero .medal { animation: medal 0.9s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes medal { from { transform: translateY(-30px) rotate(-12deg) scale(0.6); opacity: 0; } }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: -48px 16px 0; position: relative; }
.stat { background: var(--surface); border-radius: 20px; padding: 16px 8px; text-align: center; box-shadow: var(--shadow-lg); }
.stat b { display: block; font-family: var(--display); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 32px 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr { background: #FFFFFF; padding: 14px; border-radius: 18px; display: inline-block; line-height: 0; }
.qr svg, .qr img { width: 200px; height: 200px; image-rendering: pixelated; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.skeleton { padding: 80px 20px; text-align: center; color: var(--muted); }
