/* ==========================================================================
   Product Data Platform - dashboard styles
   Colours, radii and shadows are defined once in :root; dark mode follows
   the visitor's system setting. Change the brand by editing --accent*.
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e5e7ef;
  --border-strong: #d5d9e4;
  --text: #0e1525;
  --text-2: #3b4559;
  --muted: #6b7489;
  --accent: #5046e5;
  --accent-2: #8b5cf6;
  --accent-soft: #eeedfd;
  --accent-text: #ffffff;
  --gradient: linear-gradient(135deg, #5046e5 0%, #8b5cf6 55%, #d946ef 100%);
  --ok: #0f9d58;
  --ok-soft: #e6f6ee;
  --warn: #c27803;
  --warn-soft: #fdf4e3;
  --bad: #d93a3a;
  --bad-soft: #fdecec;
  --neutral-soft: #eef0f5;
  --sidebar-bg: #0e1120;
  --sidebar-text: #a7aec2;
  --sidebar-active: #ffffff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0c14;
    --surface: #121521;
    --surface-2: #161a28;
    --surface-3: #1d2233;
    --border: #232a3d;
    --border-strong: #2f374d;
    --text: #e8eaf2;
    --text-2: #c3c8d6;
    --muted: #8a92a8;
    --accent: #7c74ff;
    --accent-2: #a78bfa;
    --accent-soft: #1f1d3d;
    --ok: #34c77b;
    --ok-soft: #10291d;
    --warn: #f0b03c;
    --warn-soft: #2b2310;
    --bad: #f26b6b;
    --bad-soft: #2e1616;
    --neutral-soft: #1d2233;
    --sidebar-bg: #080a11;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; margin: 32px 0 14px; }
h3 { font-size: 15px; font-weight: 650; margin: 0; }
code { font: 12px/1.4 var(--mono); background: var(--surface-3); padding: 2px 6px; border-radius: 6px; color: var(--text-2); }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .error-text { color: var(--bad); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- app shell: sidebar + content ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text); padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 26px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--gradient);
  display: grid; place-items: center; color: #fff; box-shadow: 0 6px 18px rgba(124, 92, 246, .45);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.2; }
.brand-name small { display: block; font-weight: 500; font-size: 11.5px; color: var(--sidebar-text); }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 8px; color: #5f6780; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: var(--sidebar-text); font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(124, 116, 255, .16); color: var(--sidebar-active); }
.nav a.active .icon { color: #a5a0ff; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .07); padding: 16px 6px 0; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--gradient); color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.user-chip .who { min-width: 0; }
.user-chip .who strong { display: block; color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { font-size: 11.5px; text-transform: capitalize; }
.logout-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  background: transparent; border: 0; color: var(--sidebar-text); font: inherit; font-weight: 500; cursor: pointer; justify-content: flex-start;
}
.logout-btn:hover { background: rgba(255, 255, 255, .05); color: #fff; }

.content { min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 32px 36px 56px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.crumbs { margin: 0 0 18px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--text); text-decoration: none; }

/* ---------- cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.card + .card { margin-top: 16px; }
.narrow { max-width: 520px; margin: 60px auto; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty .icon { color: var(--border-strong); margin-bottom: 10px; }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.feature { background: var(--gradient); border: 0; color: #fff; }
.stat.feature .stat-top, .stat.feature .stat-sub { color: rgba(255, 255, 255, .82); }
.stat.feature .stat-icon { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- forms & buttons ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
label small { font-size: 12px; font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.btn, button {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover, button:hover { border-color: var(--muted); text-decoration: none; }
.btn:active, button:active { transform: translateY(1px); }
.btn.primary, button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.primary:hover, button.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
button.wide { width: 100%; }
button[disabled] { opacity: .65; cursor: progress; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; }
form.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- filter bar ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search-field { position: relative; flex: 1 1 320px; }
.search-field .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { width: 100%; padding-left: 40px; min-height: 44px; border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-sm); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 16px 18px; margin-bottom: 22px; }
.filters label { min-width: 140px; }
.filters .range { display: flex; gap: 6px; }
.filters .range input { width: 84px; }
.filter-buttons { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.result-line { display: flex; justify-content: space-between; align-items: center; margin: 0 0 14px; color: var(--muted); font-size: 13px; gap: 12px; flex-wrap: wrap; }
.result-line strong { color: var(--text); }

/* ---------- product grid ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.product-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: inherit; box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: transparent; text-decoration: none; }
.product-media { position: relative; aspect-ratio: 4 / 5; background: var(--surface-3); overflow: hidden; }
.product-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.product-card:hover .product-media img { transform: scale(1.04); }
.product-media .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--border-strong); }
.product-media .pill { position: absolute; top: 12px; left: 12px; }
.product-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-type { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-title { font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.product-meta { display: flex; justify-content: space-between; align-items: baseline; margin-top: auto; padding-top: 8px; }
.price { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.units { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stock-bar { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.stock-bar span { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.stock-caption { font-size: 11.5px; color: var(--muted); }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px; background: var(--neutral-soft); color: var(--text-2); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.plain::before { display: none; }
.pill.in, .pill.success { background: var(--ok-soft); color: var(--ok); }
.pill.low, .pill.running { background: var(--warn-soft); color: var(--warn); }
.pill.out, .pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.running::before { animation: pulse 1.2s ease-in-out infinite; }
.product-media .pill { backdrop-filter: blur(6px); background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow-sm); }
.product-media .pill.in { color: var(--ok); } .product-media .pill.low { color: var(--warn); } .product-media .pill.out { color: var(--bad); }
@keyframes pulse { 50% { opacity: .25; } }
.tag { display: inline-block; font-size: 11.5px; background: var(--surface-3); border-radius: 6px; padding: 2px 8px; margin: 0 6px 6px 0; color: var(--text-2); }

/* ---------- tables ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
th:first-child { border-top-left-radius: var(--radius); } th:last-child { border-top-right-radius: var(--radius); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.inactive { opacity: .5; }
td.thumb { width: 64px; padding-right: 0; }
td.thumb img, td.thumb .ph { width: 44px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--surface-3); display: block; }
.cell-title a { font-weight: 600; color: var(--text); }
.cell-title a:hover { color: var(--accent); text-decoration: none; }
details summary { cursor: pointer; color: var(--warn); font-weight: 500; }
details ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 28px 0 0; }
.pager a, .pager span.disabled {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager span.disabled { opacity: .45; }
.pager .count { color: var(--muted); padding: 0 12px; font-variant-numeric: tabular-nums; }

/* ---------- flash messages ---------- */
.flash {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 500;
}
.flash.success { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); color: var(--ok); }
.flash.error { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-soft); color: var(--bad); }
.flash.info { border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: var(--accent-soft); color: var(--accent); }

/* ---------- login ---------- */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; background: #0b0d1a; color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::before {
  content: ""; position: absolute; inset: -30%;
  background: radial-gradient(circle at 25% 30%, rgba(124, 92, 246, .55), transparent 45%),
              radial-gradient(circle at 80% 70%, rgba(217, 70, 239, .35), transparent 45%),
              radial-gradient(circle at 60% 10%, rgba(80, 70, 229, .45), transparent 40%);
  filter: blur(20px);
}
.auth-brand > * { position: relative; }
.auth-brand .brand { padding: 0; }
.auth-brand h2 { font-size: 38px; line-height: 1.12; letter-spacing: -.03em; margin: 0 0 16px; max-width: 460px; font-weight: 750; }
.auth-brand p { color: rgba(255, 255, 255, .72); max-width: 420px; font-size: 15px; margin: 0; }
.auth-points { display: grid; gap: 12px; margin-top: 30px; }
.auth-points div { display: flex; align-items: center; gap: 10px; color: rgba(255, 255, 255, .86); font-weight: 500; }
.auth-points .icon { color: #b9b4ff; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.login { width: 100%; max-width: 400px; display: grid; gap: 18px; padding: 36px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.login h1 { font-size: 24px; }
.login p { margin: -8px 0 4px; }
.login button { min-height: 46px; margin-top: 4px; }
.login .secure { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ---------- product detail ---------- */
.product-hero { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 32px; align-items: start; }
.gallery .main { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius-lg); background: var(--surface-3); box-shadow: var(--shadow); }
.thumbs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 10px; }
.thumbs img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 8px; border: 2px solid transparent; transition: border-color .15s; }
.thumbs a:hover img { border-color: var(--accent); }
.info h1 { font-size: 28px; margin: 6px 0 10px; }
.info .lead-price { font-size: 24px; font-weight: 700; margin: 4px 0 16px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.mini-stats div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.mini-stats strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 12px; color: var(--muted); }
.facts { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 13px; margin: 14px 0; }
.description { white-space: pre-line; color: var(--text-2); line-height: 1.7; }

/* ---------- jobs ---------- */
.store-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 20px; margin-bottom: 8px; }
.store-card { padding: 22px; }
.store-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.store-card h3 { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.store-card h3 .stat-icon { width: 36px; height: 36px; }
.store-card .facts { grid-template-columns: 170px 1fr; margin-bottom: 18px; }
.progress { margin: 4px 0 6px; }
.progress .bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--gradient); border-radius: 99px; transition: width .6s ease; background-size: 200% 100%; animation: shimmer 2.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.progress p { margin: 8px 0 0; }

/* ---------- admin ---------- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: 11px; margin: 4px 0 22px; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; align-items: end; }
.store-form { max-width: 760px; }
.store-form fieldset { border: 0; margin: 0; padding: 0 0 22px; display: grid; gap: 16px; }
.store-form fieldset + fieldset { border-top: 1px solid var(--border); padding-top: 22px; }
.store-form legend { font-weight: 650; font-size: 15px; color: var(--text); padding: 0; margin-bottom: 4px; float: left; width: 100%; }
.lookup { display: grid; gap: 16px; max-width: 680px; padding: 26px; }
.new-key { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); margin-bottom: 20px; }
.new-key h3 { color: var(--ok); }
.copy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.copy-row code { font-size: 13px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-hero { grid-template-columns: 1fr; }
  .gallery { max-width: 460px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
  .brand { padding: 0 8px 0 0; }
  .nav-label, .sidebar-foot .user-chip { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .nav a { padding: 8px 10px; }
  .nav a span { display: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .logout-btn span { display: none; }
  .page { padding: 22px 16px 40px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 32px 24px; }
  .auth-brand h2 { font-size: 28px; }
  .auth-points { display: none; }
  .store-cards { grid-template-columns: 1fr; }
  .facts, .store-card .facts { grid-template-columns: 1fr; gap: 2px 0; }
  .facts dt { font-weight: 600; margin-top: 8px; }
  .filter-buttons { margin-left: 0; }
  .mini-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 22px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

/* ==========================================================================
   Motion & interactions
   ========================================================================== */

/* Smooth cross-page transitions (browsers that support View Transitions). */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .18s ease both; }
::view-transition-new(root) { animation: vt-in .28s ease both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }

/* Elements with .reveal fade up when they appear (page load or AJAX update).
   Pure CSS, so content always ends up visible even if JavaScript fails;
   app.js only sets --i to stagger them. */
.reveal { animation: reveal-up .55s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes reveal-up { from { opacity: 0; transform: translateY(12px); } }

/* Images fade in once loaded. */
.js .fade-img { opacity: 0; filter: blur(8px); transition: opacity .5s ease, filter .6s ease, transform .4s ease; }
.js .fade-img.loaded { opacity: 1; filter: none; }
/* Safety net: if app.js never runs, show images anyway after 3s. */
.js .fade-img:not(.loaded) { animation: img-show 0s linear 3s forwards; }
@keyframes img-show { to { opacity: 1; filter: none; } }

/* Stock bar grows to its value. */
.stock-bar span { width: var(--w, 0%); animation: bar-grow 1s cubic-bezier(.2, .7, .2, 1) .2s both; }
@keyframes bar-grow { from { width: 0; } }

/* Product card extras */
.card-cta {
  position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 9px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: #fff;
  background: rgba(14, 17, 32, .72); backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease;
}
.product-card:hover .card-cta { opacity: 1; transform: none; }
.sizes { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 4px; }
.size {
  font-size: 11px; font-weight: 600; min-width: 26px; text-align: center; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface);
}
.size.no { color: var(--muted); opacity: .55; text-decoration: line-through; border-style: dashed; }
.size.more { border-style: dashed; color: var(--muted); }

/* Clickable table rows */
tr.row-link { cursor: pointer; }

/* Search shortcut hint */
.search-field .kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font: 600 11px/1 var(--font); color: var(--muted); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 7px; background: var(--surface-2); pointer-events: none;
}
.search-field input:focus + .kbd, .search-field input:not(:placeholder-shown) + .kbd { opacity: 0; }

/* Active filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; transition: background .15s, border-color .15s, transform .15s;
}
.chip span { font-size: 15px; line-height: 1; opacity: .7; }
.chip:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.chip.clear { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.chip.clear:hover { color: var(--text); border-color: var(--muted); }

/* AJAX loading state */
.results { position: relative; transition: opacity .2s ease; min-height: 200px; }
.results.loading { opacity: .45; pointer-events: none; }
.results.loading::after {
  content: ""; position: absolute; left: 50%; top: 120px; width: 34px; height: 34px; margin-left: -17px;
  border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.js .js-hide { display: none; }

/* Top progress line for in-page loads */
.loadbar { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 50; background: var(--gradient); box-shadow: 0 0 12px rgba(124, 92, 246, .6); opacity: 0; }
.loadbar.active { opacity: 1; width: 70%; transition: width 2.5s cubic-bezier(.1, .7, .2, 1); }
.loadbar.done { opacity: 0; width: 100%; transition: width .2s ease, opacity .4s ease .2s; }

/* Toast notifications */
.toasts { position: fixed; top: 20px; right: 20px; z-index: 60; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast {
  margin: 0; box-shadow: var(--shadow-lg); padding-right: 40px; position: relative;
  animation: toast-in .45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast.hide { animation: toast-out .35s ease both; }
.toast-close {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%); min-height: 0; width: 26px; height: 26px; padding: 0;
  border: 0; background: transparent; color: inherit; font-size: 18px; opacity: .6; border-radius: 6px;
}
.toast-close:hover { opacity: 1; background: rgba(127, 127, 127, .12); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* Buttons: loading spinner while a slow form submits */
button.busy { position: relative; }
button.busy::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
button.busy .icon { display: none; }

/* Gallery */
.main-wrap { overflow: hidden; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.main-wrap .main { box-shadow: none; border-radius: 0; transition: opacity .25s ease, transform .5s ease; }
.main-wrap:hover .main { transform: scale(1.02); }
.main-wrap .main.swapping { opacity: 0; }
.thumbs a.active img { border-color: var(--accent); }

/* Micro-interactions */
.stat { transition: transform .2s ease, box-shadow .2s ease; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.nav a .icon { transition: transform .2s ease; }
.nav a:hover .icon { transform: translateX(2px); }
.btn.primary .icon, button.primary .icon { transition: transform .2s ease; }
.btn.primary:hover .icon, button.primary:hover .icon { transform: translateY(-1px); }

/* Ratings from the store's reviews app */
.rating { display: flex; align-items: center; gap: 5px; font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.rating strong { color: var(--text); font-weight: 600; }
.star { color: var(--warn); }
.rating-lg { font-size: 15px; gap: 8px; margin: 12px 0 0; }
.stars { display: inline-block; font-size: 18px; letter-spacing: 2px; line-height: 1; }
.stars::before {
  content: "\2605\2605\2605\2605\2605";
  background: linear-gradient(90deg, var(--warn) calc(var(--r, 0) / 5 * 100%), var(--neutral-soft) 0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
td.nowrap { white-space: nowrap; }

/* People who prefer less motion get none. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  @view-transition { navigation: none; }
}
