/* Shared tokens, reset and controls for the shop and the admin. */
:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --surface: #141922;
  --surface-2: #1b212c;
  --surface-3: #252c39;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f6;
  --text-2: #b0b8c6;
  --text-3: #8790a1;
  --accent: #00e57a;
  --accent-hover: #2cf192;
  --accent-ink: #03150b;
  --accent-soft: rgba(0, 229, 122, 0.12);
  --accent-line: rgba(0, 229, 122, 0.38);
  --accent-text: #4af59f;
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, 0.13);
  --danger: #ff5f6b;
  --danger-soft: rgba(255, 95, 107, 0.13);
  --info: #6aa8ff;
  --info-soft: rgba(106, 168, 255, 0.13);
  --viz-series: #19a866;
  --viz-series-hover: #2cc07a;
  --viz-muted: #364051;
  --viz-grid: rgba(255, 255, 255, 0.07);
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Syne", "DM Sans", system-ui, sans-serif;
  --tap: 46px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 0.95rem; text-decoration: none;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); border-color: rgba(255, 95, 107, 0.35); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 95, 107, 0.22); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: var(--radius); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.85rem; }
.btn.is-busy { pointer-events: none; opacity: 0.8; }
.btn.is-busy::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: var(--tap); height: var(--tap); border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.icon-btn svg { width: 20px; height: 20px; }

/* ── stepper ──────────────────────────────────────────────────────────── */
.stepper {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 3px;
}
.stepper button {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: transparent; color: var(--text); cursor: pointer;
  display: grid; place-items: center; transition: background 0.15s;
}
.stepper button:hover { background: var(--surface-3); }
.stepper button:disabled { opacity: 0.3; cursor: not-allowed; }
.stepper button svg { width: 18px; height: 18px; }
.stepper output, .stepper input {
  min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
}
.stepper input {
  width: 52px; background: transparent; border: 0; padding: 0; font-size: 1.05rem;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── forms ────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 7px; }
.field + .field { margin-top: 16px; }
.label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.hint { font-size: 0.82rem; color: var(--text-3); }
.input, .select {
  width: 100%; min-height: 50px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text); font-size: 1rem; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23b0b8c6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-weight: 600; pointer-events: none;
}
.input-prefix > .input { padding-left: 34px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative; flex: none; width: 52px; height: 30px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong); transition: background 0.2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--text-2); transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── pills / badges ───────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill svg { width: 13px; height: 13px; }
.pill-ok { background: var(--accent-soft); color: var(--accent-text); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }

/* ── product photo tile (same look in shop + admin) ───────────────────── */
.photo {
  position: relative; overflow: hidden; flex: none;
  background: #f4f5f7; border-radius: var(--radius-sm);
  display: grid; place-items: center;
}
.photo img { width: 100%; height: 100%; object-fit: contain; padding: 8%; }
.photo-empty {
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2));
  color: var(--text-3); font: 800 1.4rem/1 var(--font-display);
}
/* the real photo loads hidden on top of the initials, then takes over */
.photo-loading img { position: absolute; inset: 0; visibility: hidden; }

/* ── toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); z-index: 90;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 420px); padding: 12px 18px; border-radius: 14px;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  font-size: 0.92rem; font-weight: 500; text-align: center;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-bad { border-color: rgba(255, 95, 107, 0.45); color: #ffd5d8; }

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