:root {
  --black: #0b0b0c;
  --ink-1: #141416;
  --ink-2: #1d1d21;
  --ink-3: #2a2a30;
  --yellow: #ffd400;
  --yellow-2: #ffe55c;
  --yellow-ink: #1a1500;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --dim: #71717a;
  --danger: #ff5c5c;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(28, 28, 32, 0.72);
  --stroke: rgba(255, 255, 255, 0.1);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--black);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h2 { margin: 0; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
small { color: var(--muted); }

/* ---------- background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background:
  radial-gradient(1200px 800px at 50% -20%, #1b1b1f 0%, var(--black) 60%); }
.bg span { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.bg span:nth-child(1) { width: 520px; height: 520px; left: -160px; top: -120px; background: radial-gradient(circle, rgba(255, 212, 0, 0.55), transparent 65%); }
.bg span:nth-child(2) { width: 460px; height: 460px; right: -140px; bottom: -160px; background: radial-gradient(circle, rgba(255, 196, 0, 0.35), transparent 65%); }
.bg span:nth-child(3) { width: 380px; height: 380px; right: 25%; top: 35%; background: radial-gradient(circle, rgba(120, 120, 135, 0.35), transparent 70%); }

/* ---------- glass ---------- */
.glass {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.025));
  border: 1px solid var(--stroke);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 12px 16px 0; padding: 10px 12px 10px 14px;
  border-radius: 999px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; font-size: 0.98rem; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 0.75rem; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--yellow); color: var(--yellow-ink);
  font-weight: 800; font-size: 0.85rem; letter-spacing: 0.02em;
  box-shadow: 0 6px 20px rgba(255, 212, 0, 0.35);
}
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--stroke); }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--yellow); color: var(--yellow-ink); }

main { padding: 18px 16px 120px; max-width: 1240px; margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 650; white-space: nowrap;
  transition: transform 0.08s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--yellow); color: var(--yellow-ink); box-shadow: 0 10px 30px rgba(255, 212, 0, 0.28); }
.btn-primary:hover:not(:disabled) { background: var(--yellow-2); }
.btn-ghost { background: rgba(255, 255, 255, 0.06); border-color: var(--stroke); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.btn-danger { background: rgba(255, 92, 92, 0.12); border-color: rgba(255, 92, 92, 0.3); color: #ffb3b3; }
.btn-danger:hover { background: rgba(255, 92, 92, 0.2); }
.btn-lg { min-height: 58px; font-size: 1.08rem; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 0.88rem; border-radius: 11px; }
.btn-icon { padding: 0; width: 48px; flex: none; }
.row { display: flex; gap: 8px; }
.row > .btn:not(.btn-icon) { flex: 1; }

/* segmented currency toggle */
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--stroke); }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em;
}
.seg button.is-active { background: var(--yellow); color: var(--yellow-ink); }

/* ---------- sell ---------- */
.sell-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.products { display: grid; gap: 18px; }

.product {
  position: relative; overflow: hidden;
  border-radius: var(--radius); padding: 22px;
}
.product-top { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.product-icon {
  flex: none; width: 76px; height: 76px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--ink-3), var(--ink-1));
  border: 1px solid var(--stroke);
}
.product-icon svg { width: 48px; height: 48px; color: var(--yellow); }
.product-name { font-size: 1.45rem; font-weight: 750; letter-spacing: -0.02em; }
.product-price { color: var(--yellow); font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.product-sold { margin-left: auto; text-align: right; color: var(--muted); font-size: 0.8rem; }
.product-sold b { display: block; color: var(--text); font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.size {
  position: relative;
  min-height: 64px; border-radius: 16px;
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--stroke-strong);
  font-weight: 750; font-size: 1.15rem; letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.size:hover { border-color: rgba(255, 212, 0, 0.6); }
.size:active { transform: scale(0.95); }
.size.has-qty { background: rgba(255, 212, 0, 0.14); border-color: var(--yellow); color: var(--yellow); }
.size .badge {
  position: absolute; top: -8px; right: -6px;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px;
  background: var(--yellow); color: var(--yellow-ink);
  font-size: 0.78rem; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.size.pop { animation: pop 0.25s ease; }
@keyframes pop { 50% { transform: scale(1.08); } }

/* cart */
.cart { position: sticky; top: 92px; border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.cart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cart-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 42vh; overflow: auto; }
.cart-line {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke);
}
.cart-line .name { font-weight: 650; }
.cart-line .name span { color: var(--yellow); margin-left: 6px; }
.cart-line .sum { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.cart-line .unit { color: var(--dim); font-size: 0.82rem; }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: rgba(255, 255, 255, 0.05); border-radius: 10px; border: 1px solid var(--stroke); }
.stepper button { width: 34px; height: 32px; border: 0; background: transparent; font-size: 1.1rem; font-weight: 700; color: var(--text); border-radius: 9px; }
.stepper button:hover { background: rgba(255, 255, 255, 0.08); }
.stepper b { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.cart-empty { margin: 0; color: var(--dim); font-size: 0.9rem; text-align: center; padding: 14px 6px; }
.cart-total {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-top: 14px; border-top: 1px dashed var(--stroke-strong);
}
.cart-total span { color: var(--muted); font-weight: 600; }
.cart-total strong { font-size: 2rem; letter-spacing: -0.03em; color: var(--yellow); font-variant-numeric: tabular-nums; }
.cart-actions { display: grid; gap: 8px; }

.mobile-bar { display: none; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { border-radius: var(--radius); padding: 18px 20px; }
.kpi small { display: block; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi strong { display: block; font-size: 1.9rem; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.kpi.accent strong { color: var(--yellow); }

.panel { border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head:not(:first-child) { margin-top: 22px; }

.table-wrap { overflow-x: auto; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 650; }
.matrix tbody td:first-child { font-weight: 700; }
.matrix td.zero { color: var(--dim); }
.matrix tfoot td { font-weight: 800; color: var(--yellow); border-bottom: 0; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sale {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke);
}
.sale-no { font-weight: 800; color: var(--yellow); font-variant-numeric: tabular-nums; min-width: 38px; }
.sale-items { font-weight: 600; }
.sale-meta { color: var(--dim); font-size: 0.82rem; }
.sale-total { font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.sale-total small { display: block; font-weight: 600; font-size: 0.75rem; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.04em; background: rgba(255, 212, 0, 0.14); color: var(--yellow); border: 1px solid rgba(255, 212, 0, 0.3); }
.pill.cash { background: rgba(255, 255, 255, 0.08); color: var(--text); border-color: var(--stroke-strong); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--stroke); background: transparent; color: var(--dim); display: grid; place-items: center; }
.icon-btn:hover { color: var(--danger); border-color: rgba(255, 92, 92, 0.4); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- settings ---------- */
#settings-form { max-width: 760px; margin: 0 auto; }
.price-grid { display: grid; gap: 12px; }
.price-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; align-items: end;
  padding: 14px; border-radius: 16px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke);
}
.price-row .label { font-weight: 750; font-size: 1.1rem; align-self: center; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.field input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--stroke-strong);
  font-size: 1.05rem; font-weight: 650; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 212, 0, 0.2); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 48px; }
.input-suffix em { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--dim); font-weight: 700; font-size: 0.85rem; pointer-events: none; }
.accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.account { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 16px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke); min-width: 0; }
.account strong { display: block; font-variant-numeric: tabular-nums; word-break: break-all; }
.account small { display: block; font-size: 0.8rem; word-break: break-all; }
.settings-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 22px; }
.saved-hint { color: var(--yellow); font-weight: 650; opacity: 0; transition: opacity 0.3s; }
.saved-hint.show { opacity: 1; }

/* ---------- QR dialog ---------- */
.sheet {
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  padding: 22px; border-radius: 28px; color: var(--text);
  background: linear-gradient(160deg, rgba(40, 40, 46, 0.86), rgba(16, 16, 18, 0.92));
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.sheet[open] { animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.sheet-head small { font-weight: 600; }
.qr-amount { display: block; font-size: 2.3rem; letter-spacing: -0.03em; color: var(--yellow); line-height: 1.1; font-variant-numeric: tabular-nums; }
.qr-box {
  background: #fff; border-radius: 22px; padding: 14px;
  box-shadow: 0 0 0 4px rgba(255, 212, 0, 0.9), 0 20px 50px rgba(255, 212, 0, 0.18);
  aspect-ratio: 1; display: grid; place-items: center;
}
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-meta { margin: 16px 0 0; display: grid; gap: 6px; font-size: 0.88rem; }
.qr-meta div { display: grid; grid-template-columns: 76px 1fr; gap: 10px; }
.qr-meta dt { color: var(--dim); }
.qr-meta div[hidden] { display: none; }
.qr-meta dd { margin: 0; font-weight: 600; word-break: break-all; }
.qr-note { margin: 10px 0 0; color: var(--dim); font-size: 0.78rem; }
.qr-note:empty { display: none; }
.sheet-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 12px 12px 18px; border-radius: 16px;
  background: var(--glass-strong);
  transform: translate(-50%, 140%); opacity: 0; transition: transform 0.3s ease, opacity 0.3s;
  max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-undo { border: 0; background: rgba(255, 212, 0, 0.15); color: var(--yellow); font-weight: 700; padding: 8px 12px; border-radius: 10px; }
.toast-undo[hidden] { display: none; }


/* ---------- sync indicator ---------- */
.sync {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.35); color: var(--muted); font-size: 0.8rem; font-weight: 650; white-space: nowrap;
}
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.sync[data-state="ok"] i { background: #3ddc84; box-shadow: 0 0 10px rgba(61, 220, 132, 0.7); }
.sync[data-state="syncing"] i, .sync[data-state="idle"] i { background: var(--yellow); animation: blink 1s infinite; }
.sync[data-state="offline"] i, .sync[data-state="pin"] i { background: #ff9f43; }
.sync[data-state="offline"], .sync[data-state="error"] { color: #ffc58f; border-color: rgba(255, 159, 67, 0.35); }
.sync[data-state="error"] i { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.3; } }

.pill.wait { background: rgba(255, 159, 67, 0.14); color: #ffc58f; border-color: rgba(255, 159, 67, 0.35); }
.sale.is-pending { border-style: dashed; }
.sale.is-pending .sale-no { color: var(--dim); }

.device { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px; border-radius: 16px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke); }
.device small { display: block; font-size: 0.8rem; }

/* ---------- PIN ---------- */
.pin-sheet { width: min(380px, calc(100vw - 24px)); text-align: center; }
.pin-sheet form { display: grid; gap: 14px; justify-items: center; }
.pin-sheet .brand-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 1rem; }
.pin-sheet p { margin: -6px 0 0; color: var(--muted); font-size: 0.9rem; }
.pin-sheet .field { width: 100%; text-align: left; }
.pin-sheet input { text-align: center; font-size: 1.6rem; letter-spacing: 0.4em; }
/* PIN maskovaný bez type=password – jinak Safari nabízí uložená hesla k doméně */
.masked { -webkit-text-security: disc; text-security: disc; }
.pin-sheet .btn { width: 100%; }
.pin-error { color: var(--danger) !important; font-weight: 600; min-height: 1.2em; margin: -4px 0 !important; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sell-grid { grid-template-columns: 1fr; }
  .cart { position: static; }
  .cart-lines { max-height: none; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 15;
    padding: 10px 10px 10px 18px; border-radius: 20px; background: var(--glass-strong);
    transition: transform 0.25s, opacity 0.25s;
  }
  .mobile-bar.hidden { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .mobile-bar small { display: block; font-size: 0.75rem; }
  .mobile-bar strong { font-size: 1.35rem; color: var(--yellow); font-variant-numeric: tabular-nums; }
  .toast { bottom: 96px; }
}
@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; border-radius: 24px; padding: 12px; gap: 12px; }
  .tabs { flex-basis: 100%; }
  .sync { padding: 6px 10px; font-size: 0.74rem; }
  .tabs { justify-content: stretch; }
  .tab { flex: 1; padding: 9px 6px; }
  .brand small { display: none; }
  main { padding: 14px 12px 120px; }
  .product { padding: 16px; }
  .product-icon { width: 60px; height: 60px; border-radius: 16px; }
  .product-icon svg { width: 38px; height: 38px; }
  .product-name { font-size: 1.25rem; }
  .sizes { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .size { min-height: 58px; }
  .price-row { grid-template-columns: 1fr 1fr; }
  .price-row .label { grid-column: 1 / -1; }
  .accounts { grid-template-columns: 1fr; }
  .sale { grid-template-columns: auto 1fr auto; }
  .sale .icon-btn { grid-column: 3; grid-row: 1 / span 2; }
  .sale-total { grid-column: 2; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
