/* PokeLab — Apple-inspired UI. System fonts, translucent chrome, size-tuned type. */
:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.55);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --accent: #ffcb05;
  --accent-press: #e6b800;
  --on-accent: #1c1c1e;
  --green: #34c759;
  --red: #ff3b30;
  --amber: #ff9f0a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --blur: saturate(180%) blur(20px);
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"],
@media (prefers-color-scheme: dark) {
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --surface: rgba(28, 28, 30, 0.72);
    --surface-2: rgba(44, 44, 46, 0.55);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8e8e93;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.18);
    --accent: #ffcb05;
    --accent-press: #f2c200;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 50px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --surface: rgba(28, 28, 30, 0.72);
  --surface-2: rgba(44, 44, 46, 0.55);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #8e8e93;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #ffcb05;
  --accent-press: #f2c200;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 50px rgba(0, 0, 0, 0.7);
}

/* Liquid-glass tokens */
:root { --glass: rgba(255, 255, 255, 0.58); --glass-2: rgba(255, 255, 255, 0.4); --glass-brd: rgba(255, 255, 255, 0.65); --hl: rgba(255, 255, 255, 0.75); --glass-blur: saturate(180%) blur(16px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --glass: rgba(50, 50, 54, 0.5); --glass-2: rgba(60, 60, 66, 0.38); --glass-brd: rgba(255, 255, 255, 0.14); --hl: rgba(255, 255, 255, 0.14); }
}
:root[data-theme="dark"] { --glass: rgba(50, 50, 54, 0.5); --glass-2: rgba(60, 60, 66, 0.38); --glass-brd: rgba(255, 255, 255, 0.14); --hl: rgba(255, 255, 255, 0.14); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(900px 500px at 15% -8%, rgba(255, 203, 5, 0.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(10, 132, 255, 0.08), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { letter-spacing: -0.021em; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 650; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }
input, select, textarea { font: inherit; color: var(--text); }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 700px at 50% -10%, rgba(255, 203, 5, 0.18), transparent 60%), var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--bg-elevated);
  border-radius: 24px; padding: 40px 32px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); text-align: center;
}
.login-logo { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--text-2); margin: 6px 0 28px; }
.login-card label { display: block; text-align: left; font-size: 0.85rem; color: var(--text-2); margin-bottom: 14px; }
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.15); }
.login-error { color: var(--red); font-size: 0.85rem; margin-top: 12px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid transparent; border-radius: 980px; padding: 9px 18px;
  font-weight: 550; font-size: 0.95rem; cursor: pointer; background: var(--surface-2);
  color: var(--text); transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.15s, opacity 0.15s;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(255, 59, 48, 0.3); }
.btn-block { display: block; width: 100%; margin-top: 8px; padding: 12px; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 12px;
  background: var(--surface); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.2rem; letter-spacing: -0.03em; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 4px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none; background: transparent; color: var(--text-2); padding: 7px 14px;
  border-radius: 980px; cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-sm); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.container { max-width: 1200px; margin: 0 auto; padding: 22px max(16px, env(safe-area-inset-left)) 80px; }
.view { animation: fade 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Stat cards ────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat .label { color: var(--text-2); font-size: 0.82rem; font-weight: 500; }
.stat .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.stat .sub { font-size: 0.85rem; margin-top: 2px; }

/* ── Toolbar (filters) ─────────────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 980px;
  border: 1px solid var(--line-strong); background: var(--bg-elevated); color: var(--text-2);
  cursor: pointer; font-size: 0.88rem; font-weight: 500; transition: all 0.15s;
}
.chip img { height: 16px; width: auto; }
.chip.active { background: var(--text); color: var(--bg-elevated); border-color: var(--text); }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 980px; padding: 3px; border: 1px solid var(--line); }
.seg button { border: none; background: transparent; padding: 6px 14px; border-radius: 980px; cursor: pointer; color: var(--text-2); font-weight: 500; transition: all 0.15s; }
.seg button.active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-sm); }
.search {
  padding: 9px 14px; border-radius: 980px; border: 1px solid var(--line-strong);
  background: var(--bg-elevated); min-width: 200px; transition: box-shadow 0.2s, border-color 0.2s;
}
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.12); }

/* ── Product grid / list ───────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-img { aspect-ratio: 1/1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; position: relative; padding: 12px; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-img .placeholder { color: var(--text-3); font-size: 2.4rem; }
.card-badge { position: absolute; top: 8px; left: 8px; height: 22px; background: var(--surface); backdrop-filter: var(--blur); padding: 3px 6px; border-radius: 8px; display: flex; align-items: center; }
.card-badge img { height: 15px; }
.card-body { padding: 12px 14px 14px; }
.card-name { font-weight: 600; font-size: 0.95rem; line-height: 1.25; margin-bottom: 2px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-set { color: var(--text-3); font-size: 0.78rem; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-price { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.pl { font-size: 0.82rem; font-weight: 600; padding: 2px 7px; border-radius: 7px; }
.pl.up { color: var(--green); background: rgba(52, 199, 89, 0.12); }
.pl.down { color: var(--red); background: rgba(255, 59, 48, 0.12); }
.pl.flat { color: var(--text-3); background: var(--surface-2); }
.qty-pill { font-size: 0.75rem; color: var(--text-2); background: var(--surface-2); padding: 2px 8px; border-radius: 980px; }

/* list mode */
.list .card { display: grid; grid-template-columns: 56px 1.6fr 1fr 1fr auto; align-items: center; gap: 14px; padding: 10px 16px; border-radius: var(--radius-sm); }
.list .card:hover { transform: none; }
.list .card-img { aspect-ratio: 1; width: 56px; height: 56px; border-radius: 10px; padding: 4px; }
.list .card-img img { object-fit: contain; }
.list .card-body { padding: 0; }
.list .card-set { margin: 0; }
.list .card-mini-chart { width: 90px; height: 34px; }
.list-hide { }
@media (max-width: 720px) { .list .card { grid-template-columns: 48px 1fr auto; } .list .list-hide { display: none; } }

.sparkline { width: 100%; height: 34px; display: block; }

/* ── Detail / modal ────────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 100;
  display: grid; place-items: center; padding: 20px; opacity: 0;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: scrimIn 0.25s forwards;
}
@keyframes scrimIn { to { opacity: 1; } }
.sheet {
  background: var(--bg-elevated); border-radius: 22px; width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  transform: translateY(16px) scale(0.98); opacity: 0; animation: sheetIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes sheetIn { to { transform: none; opacity: 1; } }
.sheet-head { position: sticky; top: 0; background: var(--surface); backdrop-filter: var(--blur); padding: 16px 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); z-index: 2; }
.sheet-head h2 { flex: 1; }
.sheet-body { padding: 22px; }
.close-x { border: none; background: var(--surface-2); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--text-2); font-size: 1.1rem; line-height: 1; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 0.82rem; color: var(--text-2); font-weight: 500; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--bg); transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.12); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 0.78rem; color: var(--text-3); margin-top: 5px; }
.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 22px; text-align: center;
  color: var(--text-2); cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone img { max-height: 160px; border-radius: 10px; }

/* PC candidate picker */
.pc-list { border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto; margin-top: 8px; }
.pc-opt { padding: 10px 13px; cursor: pointer; border-bottom: 1px solid var(--line); transition: background 0.12s; }
.pc-opt:last-child { border-bottom: none; }
.pc-opt:hover { background: var(--surface-2); }
.pc-opt.sel { background: rgba(255, 203, 5, 0.1); }
.pc-opt .n { font-weight: 600; font-size: 0.92rem; }
.pc-opt .s { color: var(--text-3); font-size: 0.8rem; }
.pc-opt .p { float: right; font-weight: 600; }

/* ── Chart ─────────────────────────────────────────────────────────────── */
.chart-wrap { position: relative; margin: 8px 0 4px; }
.chart-svg { width: 100%; height: 220px; display: block; overflow: visible; touch-action: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: url(#plgrad); opacity: 0.9; }
.chart-dot { fill: var(--accent); stroke: var(--bg-elevated); stroke-width: 2.5; }
.chart-crosshair { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg-elevated);
  padding: 7px 10px; border-radius: 10px; font-size: 0.8rem; font-weight: 500; white-space: nowrap;
  transform: translate(-50%, -120%); box-shadow: var(--shadow-lg); opacity: 0; transition: opacity 0.12s;
}
.chart-tip .d { opacity: 0.7; font-size: 0.72rem; }
.chart-empty { display: grid; place-items: center; height: 220px; color: var(--text-3); }

/* detail meta */
.detail-top { display: grid; grid-template-columns: 130px 1fr; gap: 20px; margin-bottom: 18px; }
.detail-img { aspect-ratio: 1/1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; padding: 8px; }
.detail-img img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.card-img img[data-zoom] { cursor: zoom-in; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; }
.big-pl { font-size: 1.4rem; font-weight: 700; }

/* ── POS ───────────────────────────────────────────────────────────────── */
.pos-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .pos-grid { grid-template-columns: 1fr; } .detail-top { grid-template-columns: 100px 1fr; } .pos-grid { } }
.pos-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 60vh; overflow-y: auto; padding: 2px; }
.pos-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; cursor: pointer; background: var(--bg-elevated); transition: transform 0.12s, border-color 0.15s; }
.pos-item:active { transform: scale(0.97); }
.pos-item.out { opacity: 0.4; pointer-events: none; }
.pos-item .n { font-weight: 600; font-size: 0.85rem; line-height: 1.2; }
.pos-item .p { color: var(--text-2); font-size: 0.8rem; margin-top: 3px; }
.cart { background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: sticky; top: 78px; }
.cart-line { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 24px; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cl-thumb { width: 40px; height: 40px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; padding: 3px; font-size: 1rem; }
.cl-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cl-main { min-width: 0; }
.cart-line .nm { font-size: 0.9rem; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-line .qty { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; }
.cart-line .qty button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer; font-size: 1.05rem; line-height: 1; display: grid; place-items: center; color: var(--text); }
.cart-line .qty button:active { background: var(--surface-2); }
.cl-price { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); padding: 0 7px; }
.cl-price .rp { color: var(--text-3); font-size: 0.78rem; flex: 0 0 auto; }
.cl-price input { width: 84px; padding: 7px 0; border: none; background: transparent; text-align: right; font-weight: 600; font-size: 0.9rem; }
.cl-price input:focus { outline: none; }
.cl-rm { border: none; background: transparent; color: var(--text-3); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.cl-rm:active { background: var(--surface-2); color: var(--red); }
.cl-rm .ic { width: 18px; height: 18px; }
.cart-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.2rem; margin: 14px 0; }
.req { color: var(--accent); font-weight: 600; font-size: 0.78rem; }
.empty { text-align: center; color: var(--text-3); padding: 40px 20px; }

/* ── Sales history ─────────────────────────────────────────────────────── */
.sale { background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.sale-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.sale-head .buyer { font-weight: 650; }
.sale-head .when { color: var(--text-3); font-size: 0.82rem; }
.sale-items { font-size: 0.9rem; color: var(--text-2); }
.sale-item-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; }
.sale-item-name { display: flex; align-items: center; gap: 10px; }
.sale-item-row .thumb {
  width: 38px; height: 38px; border-radius: 9px; background: var(--surface-2); flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden; padding: 4px; font-size: 1rem;
}
.sale-item-row .thumb img { width: 100%; height: 100%; object-fit: contain; }

/* ── Name row + language chip ──────────────────────────────────────────── */
.card-name-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 2px; }
.card-name-row .card-name { flex: 1; min-width: 0; margin-bottom: 0; }
.lang-chip {
  flex: 0 0 auto; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 6px; line-height: 1.5;
}
.lang-seg { display: inline-flex; }
.lang-seg button { font-size: 0.85rem; }

/* POS pick cards mirror the inventory card image container */
.pos-item { padding: 0; overflow: hidden; }
.pos-item .card-img { aspect-ratio: 1 / 1; width: 100%; height: auto; border-radius: 0; padding: 10px; }
.pos-info { padding: 9px 11px 11px; }
.pos-info .s { font-size: 0.72rem; margin: 1px 0 3px; }
.pos-info .p { font-weight: 700; font-size: 0.9rem; }

/* ── Buy lots ──────────────────────────────────────────────────────────── */
.lots-section { margin: 18px 0 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.lot-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lot-row:last-child { border-bottom: none; }

/* ── Prices lookup view ────────────────────────────────────────────────── */
.price-search { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.price-thumb {
  width: 46px; height: 46px; border-radius: var(--radius-sm); background: var(--surface-2); flex: 0 0 auto;
  display: grid; place-items: center; overflow: hidden; padding: 5px; color: var(--text-3);
}
.price-thumb img { width: 100%; height: 100%; object-fit: contain; }
.price-search .search { flex: 1; order: 1; }
.price-thumb { order: 2; }
.pc-opt-img { float: left; width: 40px; height: 40px; object-fit: contain; margin: -2px 10px 0 0; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.price-card { background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); margin-top: 6px; }
.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.grade { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--bg); }
.grade-label { font-size: 0.78rem; color: var(--text-2); font-weight: 500; }
.grade-price { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 3px; }
.seg-ico { display: inline-flex; align-items: center; gap: 5px; }
.seg-ico .ic { width: 15px; height: 15px; vertical-align: 0; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg-elevated); padding: 12px 20px; border-radius: 980px; box-shadow: var(--shadow-lg); opacity: 0; z-index: 200; transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); font-weight: 500; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.muted { color: var(--text-2); }
.up-text { color: var(--green); }
.down-text { color: var(--red); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Icons ─────────────────────────────────────────────────────────────── */
.ic { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* ── Search with leading icon ──────────────────────────────────────────── */
.search-wrap { position: relative; display: inline-flex; align-items: center; flex: 1; min-width: 160px; }
.search-wrap .ic { position: absolute; left: 13px; color: var(--text-3); pointer-events: none; }
.search-wrap .search { width: 100%; padding-left: 38px; }

/* ── Filter button + badge ─────────────────────────────────────────────── */
.filter-btn { display: inline-flex; align-items: center; gap: 7px; }
.filter-badge { background: var(--accent); color: var(--on-accent); font-size: 0.72rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 980px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.filter-badge[hidden] { display: none; }
.icon-seg button { display: inline-flex; align-items: center; padding: 7px 12px; }
.icon-seg .ic { width: 17px; height: 17px; vertical-align: 0; }

/* ── Active filter chips ───────────────────────────────────────────────── */
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.active-filters:empty { display: none; }
.active-filters .chip .x { display: inline-flex; margin-left: 2px; opacity: 0.8; }
.active-filters .chip .x .ic { width: 14px; height: 14px; vertical-align: 0; }

/* ── Filter modal ──────────────────────────────────────────────────────── */
.filter-sheet { max-width: 460px; }
.filter-group { margin-bottom: 20px; }
.filter-label { font-size: 0.78rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.opt-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.opt-row {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: none; cursor: pointer;
  background: var(--bg-elevated); color: var(--text); font-size: 0.96rem; text-align: left;
  border-bottom: 1px solid var(--line); min-height: 48px; transition: background 0.12s;
}
.opt-row:last-child { border-bottom: none; }
.opt-row:hover { background: var(--surface-2); }
.opt-row.sel { color: var(--accent); font-weight: 600; }
.opt-row img { height: 20px; width: auto; max-width: 40px; object-fit: contain; }
.opt-row span { flex: 1; }
.opt-row .ic { color: var(--accent); }
.filter-actions { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-top: 1px solid var(--line); }
.filter-actions .btn-primary { flex: 1; }

/* ── Home quick-nav tiles ──────────────────────────────────────────────── */
.home-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 6px; }
.home-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 16px; border-radius: var(--radius); cursor: pointer; text-align: left; color: var(--text); transition: transform 0.14s cubic-bezier(0.2, 0.8, 0.2, 1); }
.home-tile:active { transform: scale(0.97); }
.home-tile .ic { width: 24px; height: 24px; color: var(--accent); }
.home-tile > span { font-weight: 650; font-size: 1rem; }
.home-tile small { color: var(--text-2); font-size: 0.8rem; }

/* Prices results grid reuses the inventory card look */
.price-grid .card-price { margin-top: 6px; font-weight: 700; }

/* ── Liquid glass surfaces ─────────────────────────────────────────────── */
.stat, .card, .home-tile, .cart, .sale, .price-card, .lots-section, .grade,
.pos-item, .cl-price, .filter-sheet .opt-list, .pc-list {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--hl);
}
/* Larger / fewer surfaces get the real frosted blur */
.stat, .home-tile, .cart, .price-card, .sale, .grade {
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.btn { box-shadow: inset 0 1px 0 var(--hl); }
.btn-primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 8px rgba(255, 203, 5, 0.3); }
.chip, .seg, .search, .search-wrap, .field input, .field select {
  box-shadow: inset 0 1px 0 var(--hl);
}
.topbar, .tabs { background: var(--glass); }
@media (prefers-reduced-transparency: reduce) {
  .stat, .card, .home-tile, .cart, .sale, .price-card, .lots-section, .grade, .pos-item {
    background: var(--bg-elevated); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
}

/* ── Customer catalogue ────────────────────────────────────────────────── */
.cat-hero { margin: 6px 0 20px; }
.cat-hero h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.cat-hero h1 span { color: var(--accent); }
.cat-hero p { margin: 8px 0 0; max-width: 560px; }
.cat-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-actions .btn { flex: 1 1 92px; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap; overflow: hidden; }

/* Catalogue list view */
.cat-list { display: flex; flex-direction: column; gap: 10px; }
.cat-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--glass-brd); border-radius: var(--radius-sm);
  background: var(--glass); box-shadow: var(--shadow-sm), inset 0 1px 0 var(--hl); cursor: pointer;
}
.cat-row .card-img { width: 48px; height: 66px; flex: 0 0 auto; padding: 3px; border-radius: 8px; }
.cat-row-main { flex: 1; min-width: 0; }
.cat-row-main .card-set { margin-bottom: 2px; }
.cat-row-main .card-price { font-weight: 700; }
.cat-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.cat-row-actions .btn-wa { padding: 8px 10px; }
.btn-wa { background: #25d366; color: #fff; border-color: transparent; }
.btn-wa:active { background: #1eb457; }
.btn-wa .ic { width: 16px; height: 16px; }
.cat-card .card:hover { transform: none; }
/* Card fills its grid cell; price + action buttons pinned to the bottom */
.cat-card.card { display: flex; flex-direction: column; }
.cat-card .card-body { flex: 1; display: flex; flex-direction: column; }
.cat-card .card-price { margin-top: auto; }
/* Robustly fit card images inside their 1:1 box (percentage heights are
   unreliable inside flex-column cards, so center with max-size + margin auto). */
.grid .card-img, .pos-item .card-img { position: relative; }
.grid .card-img > img, .pos-item .card-img > img {
  position: absolute; inset: 10px; margin: auto; width: auto; height: auto;
  max-width: calc(100% - 20px); max-height: calc(100% - 20px); object-fit: contain;
}
.cat-cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  display: flex; align-items: center; gap: 10px;
  padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom));
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--glass-brd); box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}
.cat-cartbar .btn-wa { flex: 0 0 auto; padding: 12px 20px; }
.cartbar-list { flex: 1; text-align: left; border: none; background: transparent; color: var(--text); font-weight: 600; font-size: 0.95rem; cursor: pointer; }

/* Keep the catalogue Filter button on the same row, to the right of search */
#cat .toolbar { flex-wrap: nowrap; }
#cat .toolbar .search-wrap { flex: 1 1 auto; min-width: 0; order: 0; }
#cat .filter-btn { flex: 0 0 auto; }

/* Banner carousel */
.carousel { position: relative; border-radius: var(--radius); overflow: hidden; margin: 6px 0 18px; box-shadow: var(--shadow-sm); }
.carousel-track { display: flex; transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); touch-action: pan-y; }
.slide { flex: 0 0 100%; aspect-ratio: 16 / 6; background-size: cover; background-position: center; background-color: var(--surface-2); display: flex; align-items: flex-end; }
.slide[data-link] { cursor: pointer; }
.slide-default { background: linear-gradient(120deg, var(--accent), var(--amber)); }
.slide-cap { padding: 14px 18px; color: #fff; width: 100%; background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent); }
.slide-default .slide-cap { background: none; color: var(--on-accent); }
.slide-title { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.slide-sub { font-size: 0.85rem; opacity: 0.92; margin-top: 2px; }
.carousel-dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; }
.carousel-dots button { width: 7px; height: 7px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.55); cursor: pointer; padding: 0; transition: width 0.2s, background 0.2s; }
.carousel-dots button.on { background: #fff; width: 18px; border-radius: 4px; }

/* Banner manager rows */
.banner-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.banner-row:last-child { border-bottom: none; }
.banner-thumb { width: 76px; height: 42px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; flex: 0 0 auto; }
.banner-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Bottom nav (mobile only; body-level so `fixed` maps to viewport) ───── */
.bottomnav { display: none; }

/* ── Mobile (≤640px) — Apple-style bottom tab bar + bottom sheets ───────── */
@media (max-width: 640px) {
  .topbar { gap: 10px; }
  .brand { font-size: 1.15rem; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn { padding: 9px 13px; min-height: 40px; }
  /* FAB covers "add" on mobile, so drop the top +Add button */
  #add-btn { display: none; }

  /* Top tab strip hidden; navigation lives in the bottom bar */
  .tabs { display: none; }

  /* Translucent bottom bar (body-level, so `fixed` maps to the viewport) */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    align-items: stretch; justify-content: space-around;
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    border-top: 1px solid var(--line);
  }
  .bottomnav button[data-view] {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: none; background: transparent; cursor: pointer; color: var(--text-3);
    font-size: 0.64rem; font-weight: 550; letter-spacing: -0.01em; min-height: 50px; padding: 4px 0;
    transition: color 0.15s;
  }
  .bottomnav button[data-view] svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .bottomnav button[data-view].active { color: var(--accent); }

  /* Center FAB — big accent circle popping up out of the bar (slight overlap) */
  .bottomnav .fab {
    flex: 0 0 auto; width: 72px; height: 72px; margin: 0 6px; align-self: flex-start;
    transform: translateY(-14px);
    border: 5px solid var(--bg); border-radius: 50%; background: var(--accent); color: var(--on-accent);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 10px 26px rgba(255, 203, 5, 0.5);
    transition: transform 0.14s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.15s;
  }
  .bottomnav .fab svg { width: 33px; height: 33px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
  .bottomnav .fab:active { transform: translateY(-14px) scale(0.9); background: var(--accent-press); }

  .container { padding: 16px max(14px, env(safe-area-inset-left)) calc(104px + env(safe-area-inset-bottom)); }

  /* Two-up stat cards, tighter type */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .stat { padding: 14px 15px; }
  .stat .value { font-size: 1.32rem; }
  h1 { font-size: 1.5rem; }

  /* Keep search + Filter + view toggle on one row (controls to the right) */
  .toolbar { gap: 8px; flex-wrap: nowrap; }
  .search-wrap { flex: 1 1 auto; min-width: 0; order: 0; }
  .filter-btn { order: 1; min-height: 40px; flex: 0 0 auto; }
  .icon-seg { order: 2; flex: 0 0 auto; }
  .chip { min-height: 38px; padding: 8px 14px; }
  .seg button { min-height: 38px; }

  /* Two-column gallery on phones */
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-name { font-size: 0.9rem; }

  /* Forms: one field per row, bigger inputs (no iOS zoom at 16px) */
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .field input, .field select, .field textarea,
  .login-card input, .search, .cart-line input { font-size: 16px; padding: 13px 14px; }

  /* Modals slide up as bottom sheets */
  .scrim { align-items: flex-end; padding: 0; }
  .sheet {
    max-width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0;
    -webkit-overflow-scrolling: touch;
    animation: sheetUp 0.34s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
  }
  .sheet-body { padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); }
  .close-x { width: 34px; height: 34px; }
  .detail-top { grid-template-columns: 96px 1fr; gap: 14px; }
  .chart-svg { height: 200px; }

  /* POS: cart is not sticky when stacked; give room */
  .pos-pick { max-height: none; }
  .cart { position: static; top: auto; }
  .pos-item { min-height: 64px; }

  /* Toast clears the bottom bar */
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@keyframes sheetUp { from { transform: translateY(100%); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* Small-phone: single-column gallery for legibility */
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
  .stat .value { font-size: 1.2rem; }
}

/* ── Card lightbox (zoomable) ──────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.82); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  touch-action: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none;
  opacity: 0; animation: lbIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes lbIn { to { opacity: 1; } }
.lightbox.closing { animation: lbOut 0.22s ease forwards; }
@keyframes lbOut { to { opacity: 0; } }
.lightbox-img {
  max-width: 90vw; max-height: 88vh; border-radius: 12px; touch-action: none;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6); will-change: transform;
  transform: translate(0, 0) scale(1); cursor: grab; -webkit-user-drag: none;
}
.lightbox-img.springing { transition: transform 0.34s cubic-bezier(0.2, 0.85, 0.25, 1); }
.lightbox-img.grabbing { cursor: grabbing; }
.lightbox-close {
  position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; z-index: 2;
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: grid; place-items: center;
}
.lightbox-close .ic { width: 22px; height: 22px; }
.lightbox-hint { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, 0.55); font-size: 0.8rem; pointer-events: none; }

/* ── Rendering virtualization (native, offscreen items skipped) ─────────── */
.grid .card { content-visibility: auto; contain-intrinsic-size: auto 300px; }
.list .card { content-visibility: auto; contain-intrinsic-size: auto 76px; }
.pos-item { content-visibility: auto; contain-intrinsic-size: auto 240px; }
.pc-opt { content-visibility: auto; contain-intrinsic-size: auto 60px; }
.sale { content-visibility: auto; contain-intrinsic-size: auto 130px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.05ms !important; }
  .lightbox-img.springing { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .tabs, .sheet-head, .btn, .card-badge { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg-elevated); }
}
