/* Distributor storefront — a stock sheet, not a shop.
 * One family (IBM Plex Sans), tabular figures wherever a number appears.
 * `--accent` is the only thing that changes between distributors
 * (sites/<slug>.json). */

:root {
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, white);
  --bg: #f6f7f5;
  --card: #ffffff;
  --well: #eef0ec;
  --ink: #17201b;
  --muted: #6b726e;
  --line: #e1e5e1;
  --line-strong: #c9cfca;
  --ok: #1e7a46;
  --ok-soft: #e4f3ea;
  --warn: #9a5b00;
  --warn-soft: #fbeedb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23,32,27,.05), 0 8px 24px -12px rgba(23,32,27,.18);
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
/* Class rules like .grid { display: grid } would outrank the UA's [hidden]. */
[hidden] { display: none !important; }
html { color-scheme: light; scroll-padding-top: 130px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; border-top: 3px solid var(--accent); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }
.num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── Header ─────────────────────────────────────────────────────────── */
.hdr { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 6; }
.hdr__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 62px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.brand__logo { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 17px; overflow: hidden; flex: none; }
/* A real logo sits on white, fitted; the initial-letter fallback keeps the accent tile. */
.brand__logo:has(img) { background: #fff; border: 1px solid var(--line); }
.brand__logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand__name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__where { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr__actions { display: flex; align-items: center; gap: 14px; flex: none; }
.powered { font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.powered b { font-weight: 600; color: var(--ink); }
.powered:hover b { color: var(--accent); }
.iconbtn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px; font-weight: 500; text-decoration: none; }
.iconbtn svg { width: 17px; height: 17px; color: #128c4a; }
.iconbtn:hover { border-color: var(--line-strong); background: var(--bg); }
@media (max-width: 640px) { .hdr .powered { display: none; } .iconbtn span { display: none; } .iconbtn { padding: 8px; } }

/* ── Lead: the stock count is the hero ──────────────────────────────── */
.lead { padding-block: 30px 6px; }
.lead__count { margin: 0; font-size: clamp(30px, 5vw, 46px); line-height: 1.05; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.lead__count em { font-style: normal; color: var(--accent); }
.lead__sub { margin: 8px 0 0; color: var(--muted); font-size: 15px; max-width: 64ch; }
.sk--lead { display: inline-block; width: 12ch; height: .9em; border-radius: 4px; vertical-align: middle; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 22px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(auto-fill, minmax(150px, 236px)); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat__n { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__l { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat--warn .stat__n { color: var(--warn); }

/* ── Toolbar ────────────────────────────────────────────────────────── */
.toolbar { position: sticky; top: 62px; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); padding-block: 16px 10px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.toolbar__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { position: relative; flex: 1 1 260px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; translate: 0 -50%; color: var(--muted); }
.search input { width: 100%; height: 40px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.field select { height: 40px; max-width: 200px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%236b726e' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 9px center / 16px; appearance: none; color: var(--ink); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); margin-left: auto; }
.seg__btn { width: 40px; height: 40px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.seg__btn + .seg__btn { border-left: 1px solid var(--line); }
.seg__btn svg { width: 18px; height: 18px; }
.seg__btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 10px; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; line-height: 1.2; }
.chip b { font-weight: 500; color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--line-strong); }
.chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-selected="true"] b { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
@media (max-width: 640px) {
  /* Three rows of controls must not eat a third of a phone screen: not sticky here. */
  .toolbar { position: static; backdrop-filter: none; }
  .search { flex: 1 1 100%; }
  .field { flex: 1 1 0; min-width: 0; }
  .field span { display: none; }
  .field select { width: 100%; max-width: none; }
  .seg { margin-left: 0; }
}

/* ── Results line ───────────────────────────────────────────────────── */
.results { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-block: 14px 4px; }
.results__count { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.results__filters { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12px; }
.tag button { border: 0; background: var(--well); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; display: grid; place-items: center; color: var(--muted); }
.tag button:hover { background: var(--line); color: var(--ink); }
.tag--clear { border-color: transparent; background: transparent; color: var(--accent); cursor: pointer; padding: 3px 6px; }

/* ── Grid ───────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; padding-top: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 236px)); gap: 14px; justify-content: start; } }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; cursor: pointer; min-width: 0; overflow: hidden; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.item:hover, .item:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); outline: none; }
/* The image is absolutely positioned inside a fixed-ratio box. As a grid
 * item, an <img> with height:100% sizes the auto row to its natural height
 * and spills out of the box; pinned to the box's edges it cannot. */
.item__img { aspect-ratio: 1; position: relative; display: grid; place-items: center; background: #fff; overflow: hidden; }
.item__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; opacity: 0; transition: opacity .2s ease; }
.item__img img.fit-cover { object-fit: cover; padding: 0; opacity: 1; }
.item__img img.fit-contain { opacity: 1; }
.ph { font-weight: 600; font-size: 36px; color: #b9c0bb; }
.veg { position: absolute; top: 10px; left: 10px; width: 14px; height: 14px; border: 1.5px solid; border-radius: 3px; display: grid; place-items: center; background: #fff; }
.veg::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.veg--y { color: var(--ok); } .veg--n { color: #b3261e; }
.badge { position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.item__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.brandline { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__name { margin: 0; font-size: 14px; font-weight: 500; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item__sub { font-size: 12px; color: var(--muted); min-height: 1.4em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__foot { margin-top: auto; padding-top: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.price { font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 2px; }
.stock { font-size: 12px; color: var(--ok); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock--low { color: var(--warn); }
.bar { height: 3px; border-radius: 2px; background: var(--well); margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 2px; }
.bar--low span { background: var(--warn); }

/* ── List (stock sheet) view ────────────────────────────────────────── */
.list { padding-top: 10px; overflow-x: auto; }
.sheet-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.sheet-table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg); white-space: nowrap; }
.sheet-table th.num, .sheet-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sheet-table tr:last-child td { border-bottom: 0; }
.sheet-table tbody tr { cursor: pointer; }
.sheet-table tbody tr:hover td { background: var(--accent-soft); }
.sheet-table tbody tr:focus-visible { outline-offset: -2px; }
.col-img { width: 56px; }
.col-name { width: 44%; }
.col-pack { width: 22%; }
.thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--well); display: grid; place-items: center; overflow: hidden; }
.thumb { background: #fff; border: 1px solid var(--line); }
.thumb { position: relative; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 2px; opacity: 0; transition: opacity .2s ease; }
.thumb img.fit-cover { object-fit: cover; padding: 0; opacity: 1; }
.thumb img.fit-contain { opacity: 1; }
.thumb .ph { font-size: 16px; }
.cell-name { font-weight: 500; line-height: 1.3; }
.cell-brand { font-size: 12px; color: var(--muted); }
.col-pack, .col-cat { color: var(--muted); font-size: 13px; }
.col-price { font-weight: 600; white-space: nowrap; }
.col-stock { white-space: nowrap; }
.col-stock .stock { font-size: 13px; }
.stock--inline { display: none; font-weight: 400; margin-top: 2px; }
@media (max-width: 720px) {
  .col-cat, .col-pack { display: none; }
  .col-name { width: auto; }
  .sheet-table { font-size: 13px; }
  .sheet-table td, .sheet-table th { padding-inline: 8px; }
  .col-stock { display: none; }
  .stock--inline { display: block; }
  .cell-brand { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
}

.nomatch { margin: 28px 0; color: var(--muted); }
.nomatch a { color: var(--accent); }

/* ── Skeleton ───────────────────────────────────────────────────────── */
.sk { background: linear-gradient(90deg, #e8ebe7 25%, #f3f5f2 50%, #e8ebe7 75%); background-size: 200% 100%; animation: sh 1.2s infinite; }
.item--sk { pointer-events: none; }
.item--sk .item__img { background: var(--well); }
.item--sk .sk { height: 11px; border-radius: 3px; margin: 5px 0; }
.sk--w40 { width: 40%; } .sk--w50 { width: 50%; } .sk--w70 { width: 70%; } .sk--gap { margin-top: 12px !important; }
@keyframes sh { to { background-position: -200% 0; } }

/* ── Pagination ─────────────────────────────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; padding: 26px 0 10px; }
.pager button { min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums; }
.pager button:hover:not(:disabled) { border-color: var(--line-strong); }
.pager button[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pager button:disabled { color: var(--line-strong); cursor: default; }
.pager .gap { color: var(--muted); padding: 0 4px; }
.pager__info { width: 100%; text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; padding: 12px 18px; font-weight: 500; text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(.94); }
.btn--ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--bg); border-color: var(--line-strong); }
.btn--sm { padding: 8px 12px; font-size: 13px; }

/* ── Empty / error / not found ──────────────────────────────────────── */
.panel { margin: 22px 0 56px; max-width: 560px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px 26px 24px; }
.panel h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.panel p { margin: 0 0 18px; color: var(--muted); }
.panel__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.ftr { border-top: 1px solid var(--line); margin-top: 36px; background: var(--card); }
.ftr__row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px 24px; padding-block: 22px 30px; font-size: 13px; color: var(--muted); }
.ftr__contact { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.ftr__contact b { color: var(--ink); font-weight: 600; }
.ftr__contact a { color: var(--ink); text-decoration: none; }
.ftr__contact a:hover { text-decoration: underline; }
.ftr__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }

/* ── Detail sheet ───────────────────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(23,32,27,.42); }
.sheet__card { position: absolute; right: 0; top: 0; bottom: 0; width: min(470px, 100%); background: var(--card); overflow-y: auto; border-left: 1px solid var(--line); animation: slide .18s ease-out; display: flex; flex-direction: column; }
@keyframes slide { from { translate: 24px 0; opacity: .5; } }
@media (max-width: 600px) {
  .sheet__card { top: auto; width: 100%; max-height: 92vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; animation: rise .2s ease-out; }
  @keyframes rise { from { translate: 0 32px; opacity: .5; } }
  .sheet__img { max-height: 30vh; }
}
.sheet__close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; z-index: 1; }
.sheet__close svg { width: 18px; height: 18px; }
.sheet__img { position: relative; aspect-ratio: 1; max-height: 40vh; background: #fff; display: grid; place-items: center; border-bottom: 1px solid var(--line); flex: none; overflow: hidden; }
.sheet__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 24px; }
.sheet__img .ph { font-size: 64px; }
.sheet__body { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sheet__body h2 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.25; }
.d-sub { color: var(--muted); font-size: 13px; }
.d-pricerow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 8px; }
.d-price { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.d-price small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.d-stock { font-size: 14px; font-weight: 500; color: var(--ok); font-variant-numeric: tabular-nums; white-space: nowrap; }
.d-stock.stock--low { color: var(--warn); }
#d-bar { margin-top: 4px; height: 4px; }
.specs { display: grid; grid-template-columns: max-content 1fr; gap: 0 18px; margin: 14px 0 12px; font-size: 13px; border-top: 1px solid var(--line); }
.specs dt, .specs dd { padding: 7px 0; border-bottom: 1px solid var(--line); margin: 0; }
.specs dt { color: var(--muted); }
.specs dd { font-variant-numeric: tabular-nums; }
.sheet__share { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet__cta { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.sheet__cta .btn { width: 100%; }
.d-note { font-size: 12px; color: var(--muted); margin: 0; }

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 30; box-shadow: var(--shadow); }
