/* icubix — design system. Token-driven: every value comes from a scale below.
   Visual language: rounded, geometric, monochrome — matched to the logo. */
:root {
  /* -- Color -------------------------------------------------------------- */
  --paper:   #EDEAE2;
  --surface: #FBFAF6;
  --ink:     #272727;
  --ink-2:   #565551;
  --muted:   #6E6B62;              /* darkened from #8C8980 to pass WCAG AA on paper */
  --line:    rgba(39,39,39,.13);
  --line-2:  rgba(39,39,39,.075);
  --wash:    rgba(39,39,39,.04);
  --on-ink:  rgba(255,255,255,.22);  /* subtle layer on dark ink (e.g. nav count) */

  /* -- Semantic state (desaturated, tuned to warm paper — accent, not noise) */
  --ok:        #3F7A55;  --ok-bg:     rgba(63,122,85,.13);
  --warn:      #9A6B1E;  --warn-bg:   rgba(154,107,30,.14);
  --danger:    #9B3B36;  --danger-bg: rgba(155,59,54,.12);

  /* -- Breakpoints (literal — CSS @media can't read vars; keep these two only)
        --bp-md 760px (tablet: collapse multi-column)
        --bp-sm 560px (phone: stack tables into cards) ------------------------ */

  /* -- Elevation ---------------------------------------------------------- */
  --e-1: 0 1px 2px rgba(39,39,39,.05), 0 14px 34px -16px rgba(39,39,39,.16);
  --e-2: 0 8px 18px -6px rgba(39,39,39,.45);

  /* -- Radius / borders --------------------------------------------------- */
  --r-sm: 10px; --r-el: 14px; --r-card: 22px; --r-pill: 999px;
  --bw: 1px; --bw-2: 1.5px;
  --header-h: 76px;   /* sticky masthead height — sticky sidebars clear it */

  /* -- Spacing scale ------------------------------------------------------ */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-7: 28px; --s-8: 32px; --s-9: 40px; --s-10: 56px;

  /* -- Typography --------------------------------------------------------- */
  --font-display: 'Onest', sans-serif;
  --font-body: 'Onest', sans-serif;
  --fs-3xs: 9px;  --fs-2xs: 10px; --fs-xs: 11px; --fs-sm: 12px; --fs-base: 13px;
  --fs-md: 14px;  --fs-lg: 15px;  --fs-xl: 16px; --fs-2xl: 18px; --fs-3xl: 21px;
  --fs-4xl: 25px; --fs-5xl: 30px;
  --fs-display-md: clamp(26px, 4vw, 38px);
  --fs-display-lg: clamp(34px, 6vw, 58px);
  --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700; --fw-extrabold: 800;
  --tracking-label: .1em;

  /* -- Motion ------------------------------------------------------------- */
  --dur: .12s; --dur-slow: .25s; --ease: ease; --ease-out: cubic-bezier(.2,.7,.2,1);

  /* -- Focus -------------------------------------------------------------- */
  --focus-ring: 2px solid var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { touch-action: manipulation; }  /* убирает 300ms tap-delay на тач */
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-weight: var(--fw-medium); -webkit-font-smoothing: antialiased;
}
body::before {  /* faint paper grain */
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Accessibility: one global focus treatment for every interactive element. */
:focus { outline: none; }
:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 var(--s-7); }
.topbar { height: 6px; background: var(--ink); }
a { color: inherit; text-decoration: none; }

/* == Masthead + nav ======================================================= */
/* sticky so navigation + global search stay reachable while scrolling long pages */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-5) 0; flex-wrap: wrap; position: sticky; top: 0; z-index: 50;
  background: var(--paper); border-bottom: var(--bw) solid var(--line); }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-3); }
/* global search (injected into masthead by mountGlobalSearch) */
.gsearch { flex: 1 1 200px; max-width: 380px; display: flex; align-items: center; gap: var(--s-2);
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-pill);
  padding: 3px 3px 3px var(--s-4); box-shadow: var(--e-1); }
.gsearch:focus-within { border-color: var(--ink); }
.gsearch-input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--ink);
  font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-base); padding: var(--s-2) 0; }
.gsearch-input::placeholder { color: var(--muted); font-weight: var(--fw-medium); }
.logo { height: 30px; width: auto; display: block; }
.tagline { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); }
.brand-social { display: flex; gap: var(--s-2); margin-top: var(--s-1); }
.brand-social a { display: inline-flex; color: var(--muted); transition: color var(--dur) var(--ease); }
.brand-social a:hover { color: var(--ink); }
.brand-social svg { width: 19px; height: 19px; display: block; }
.nav { display: flex; gap: var(--s-2); align-items: center; }
.nav a { font-weight: var(--fw-bold); font-size: var(--fs-base); padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill); color: var(--ink-2); border: var(--bw) solid transparent; transition: all var(--dur) var(--ease);
  display: inline-flex; align-items: center; gap: var(--s-2); }
.nav a .ic { width: 18px; height: 18px; flex: none; }
.ic-xs { width: 15px; height: 15px; flex: none; vertical-align: -2px; }
.lockbar span { display: inline-flex; align-items: center; gap: var(--s-2); }
.nav a:hover { background: var(--wash); }
.nav a.is-active { background: var(--ink); color: var(--surface); }
.nav .count { font-family: var(--font-display); font-weight: var(--fw-bold); margin-left: var(--s-2);
  background: var(--surface); color: var(--ink); border-radius: var(--r-pill); padding: 0 var(--s-2); font-size: var(--fs-sm); }
.nav a.is-active .count { background: var(--on-ink); color: var(--surface); }

/* == Headings ============================================================= */
.page-title { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-display-md);
  letter-spacing: -.01em; margin: var(--s-7) 0 var(--s-1); }
.page-sub { font-weight: var(--fw-medium); font-size: var(--fs-lg); color: var(--ink-2); margin: 0 0 var(--s-7); }

/* == Buttons ==============================================================
   Block .btn · variants --dark / --ghost / --quiet · sizes --lg / --xs
   states :disabled, .is-selected */
.btn { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-md); cursor: pointer;
  border-radius: var(--r-pill); padding: var(--s-3) var(--s-6); border: var(--bw) solid var(--ink);
  background: transparent; color: var(--ink); white-space: nowrap;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease), color var(--dur) var(--ease); }
.btn--dark { background: var(--ink); color: var(--surface); }
.btn--dark:hover { transform: translateY(-1px); box-shadow: var(--e-2); }
.btn--ghost:hover { background: var(--wash); }
.btn--quiet { border-color: var(--line); color: var(--ink-2); }
.btn--quiet:hover { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn--lg { font-size: var(--fs-lg); padding: var(--s-3) var(--s-8); }
.btn--xs { font-size: var(--fs-xs); padding: var(--s-1) var(--s-3); }
.btn.is-selected { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* == Panels & KPIs ======================================================== */
.panel { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--e-1); padding: var(--s-6) var(--s-7); margin-bottom: var(--s-4); }
.panel-h { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-2xl); margin: 0 0 var(--s-1); }
.panel-sub { font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--muted); margin: 0 0 var(--s-4); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); margin-bottom: var(--s-4); }
.kpi { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--e-1); padding: var(--s-5); }
.kpi .label { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-5xl); margin-top: var(--s-2); }
.kpi .unit { font-family: var(--font-body); font-weight: var(--fw-bold); font-size: var(--fs-md); color: var(--muted); margin-left: var(--s-1); }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* == Switcher (fake login) ================================================ */
.switcher { display: inline-flex; align-items: center; gap: var(--s-3); background: var(--surface);
  border: var(--bw) solid var(--line); border-radius: var(--r-pill); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); box-shadow: var(--e-1); }
.switcher .who { font-weight: var(--fw-bold); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.switcher select { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-md); border: 0;
  background: var(--wash); border-radius: var(--r-pill); padding: var(--s-2) var(--s-4); color: var(--ink); cursor: pointer; }

/* == Tables =============================================================== */
table { width: 100%; border-collapse: collapse; }
thead th { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--muted); text-align: left; padding: var(--s-2) var(--s-3) var(--s-3) 0; border-bottom: var(--bw) solid var(--line); }
tbody td { padding: var(--s-4) var(--s-3) var(--s-4) 0; border-bottom: var(--bw) solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.cell-name { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.cell-sub { font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s-1); }
.cell-mono { font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--ink-2); }
/* numeric cell — shared by cabinet tables and offer rows */
.cell-num, .price-cell { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); white-space: nowrap; }
.stock-cell { font-weight: var(--fw-bold); font-size: var(--fs-md); white-space: nowrap; }

/* == Badge — the one small-pill primitive ================================
   Neutral by default (labels: тип, формат, раздел). A tone modifier turns it
   into a status pill (stronger emphasis + colour). */
.badge {
  display: inline-block; font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap; border: var(--bw) solid var(--line);
  border-radius: var(--r-pill); padding: 2px var(--s-2); color: var(--muted); }
.badge--link { cursor: pointer; }
.badge--link:hover { border-color: var(--ink); color: var(--ink); }
/* toned variants = status pills: stronger weight + a touch more padding */
.badge--solid, .badge--ghost, .badge--ok, .badge--warn, .badge--danger {
  font-weight: var(--fw-extrabold); letter-spacing: .06em; padding: 3px var(--s-3); }
.badge--solid  { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.badge--ghost  { background: transparent; color: var(--ink-2); border-color: var(--line); }
.badge--ok     { background: var(--ok-bg);     color: var(--ok);     border-color: transparent; }
.badge--warn   { background: var(--warn-bg);   color: var(--warn);   border-color: transparent; }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

/* round source markers — trust encoded by fill, not colour. Modifier = data enum. */
.mark { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.mark--primary { background: var(--ink); }
.mark--own_warehouse { border: var(--bw-2) solid var(--ink); background: linear-gradient(135deg, var(--ink) 0 50%, transparent 50%); }
.mark--transmitted { border: var(--bw-2) solid var(--ink); background: transparent; }
.mark--on_order { border: var(--bw-2) dotted var(--muted); }
.src { display: flex; align-items: center; gap: var(--s-2); }
.src-label { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }

/* == Misc ================================================================= */
.empty-box, .search-empty { text-align: center; color: var(--muted); font-weight: var(--fw-bold); font-size: var(--fs-md); }
.empty-box { padding: var(--s-9) 0; }
.search-empty { display: none; padding: var(--s-10) 0; }
.row-actions { display: flex; gap: var(--s-2); align-items: center; justify-content: flex-end; }
.qty { display: inline-flex; align-items: center; border: var(--bw) solid var(--line); border-radius: var(--r-pill); overflow: hidden; }
.qty button { border: 0; background: transparent; cursor: pointer; font-family: var(--font-display);
  font-weight: var(--fw-bold); font-size: var(--fs-lg); width: 30px; height: 30px; color: var(--ink); }
.qty button:hover { background: var(--wash); }
.qty span { font-family: var(--font-display); font-weight: var(--fw-bold); min-width: 30px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: var(--s-7); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--surface); font-weight: var(--fw-bold); font-size: var(--fs-base);
  padding: var(--s-3) var(--s-6); border-radius: var(--r-pill); box-shadow: var(--e-1); opacity: 0;
  transition: all var(--dur-slow) var(--ease); pointer-events: none; z-index: 10000; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
footer { margin: var(--s-10) 0 var(--s-9); padding-top: var(--s-6); border-top: var(--bw) solid var(--line);
  font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--muted); line-height: 1.7; }

/* == Search page ========================================================== */
.hero { padding: var(--s-9) 0 var(--s-7); }
.hero h1 { font-family: var(--font-display); font-weight: var(--fw-extrabold); line-height: 1.02; letter-spacing: -.01em;
  margin: 0 0 var(--s-4); font-size: var(--fs-display-lg); max-width: 15ch; }
.hero p { font-size: var(--fs-xl); font-weight: var(--fw-medium); color: var(--ink-2); margin: 0 0 var(--s-8); max-width: 52ch; line-height: 1.5; }
.search { display: flex; align-items: center; gap: var(--s-2); background: var(--surface); border: var(--bw) solid var(--line);
  border-radius: var(--r-el); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-5); box-shadow: var(--e-1); }
.search:focus-within { border-color: var(--ink); }
.search input { flex: 1; border: 0; background: transparent; outline: none; color: var(--ink);
  font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-xl); padding: var(--s-2) 0; }
.search input::placeholder { font-weight: var(--fw-medium); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); }
.hero-row { display: flex; align-items: center; gap: var(--s-9); }
.hero-text { flex: 1; min-width: 0; }
.hero-art { flex: none; width: 184px; }
.hero-art img { width: 100%; height: auto; display: block; }
@media (max-width: 760px) { .hero-row { display: block; } .hero-art { display: none; } }
.chip { font-weight: var(--fw-bold); font-size: var(--fs-base); color: var(--ink-2); border: var(--bw) solid var(--line); background: transparent;
  border-radius: var(--r-pill); padding: var(--s-2) var(--s-4); cursor: pointer; transition: all var(--dur) var(--ease); }
.chip:hover { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.ledger { display: none; margin: var(--s-4) 0 var(--s-7); font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); }
.ledger b { font-family: var(--font-display); font-weight: var(--fw-bold); color: var(--ink); }
.ledger .flag { background: var(--ink); color: var(--surface); border-radius: var(--r-pill); padding: 3px var(--s-3); white-space: nowrap; }
.ledger .flag b { color: var(--surface); }
.results { display: flex; flex-direction: column; gap: var(--s-4); }
.card { border: var(--bw) solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--e-1);
  overflow: hidden; animation: rise .5s var(--ease-out) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.card-head { display: grid; grid-template-columns: 64px 1fr auto; align-items: start; gap: var(--s-4);
  padding: var(--s-6) var(--s-7); }
.card-thumb { width: 56px; height: 56px; border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  background: #fff; display: grid; place-items: center; }
.card-thumb img { width: 64%; height: 64%; object-fit: contain; opacity: .8; }
.title { display: inline-block; font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-3xl); letter-spacing: -.005em; }
.title:hover { text-decoration: underline; }
.subtitle { font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--muted); margin-top: var(--s-1); }
.attrs { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.attr { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--ink-2); background: var(--wash); border-radius: var(--r-sm); padding: var(--s-1) var(--s-3); }
.metrics { font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); margin-top: var(--s-4); }
.metrics b { font-family: var(--font-display); font-weight: var(--fw-bold); color: var(--ink); }
.price-side { text-align: right; white-space: nowrap; }
.price-cap { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.price { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-4xl); margin-top: 1px; }
.toggle { border: 0; background: transparent; padding: 0; cursor: pointer; font-family: var(--font-body);
  font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--ink-2); margin-top: var(--s-3); }
.toggle:hover { color: var(--ink); }
.offers { display: none; padding: var(--s-1) var(--s-7) var(--s-6) var(--s-7); overflow-x: auto; }
.offers tbody td { vertical-align: top; padding: var(--s-4) var(--s-3) var(--s-4) 0; }
.offers td.cell-mono { min-width: 130px; }
.sup-name { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.sup-type { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  border: var(--bw) solid var(--line); border-radius: var(--r-pill); padding: 2px var(--s-2); margin-left: var(--s-2); }
.raw { font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s-1); max-width: 44ch; }
.updated { font-weight: var(--fw-medium); font-size: var(--fs-2xs); color: var(--muted); margin-top: var(--s-1); }
.excluded { font-weight: var(--fw-extrabold); font-size: var(--fs-3xs); letter-spacing: .12em; border: var(--bw-2) solid var(--muted); color: var(--muted);
  border-radius: var(--r-pill); padding: 2px var(--s-2); display: inline-block; margin-top: var(--s-2); }
.note { font-weight: var(--fw-semibold); font-size: var(--fs-xs); color: var(--ink-2); margin-top: var(--s-2); }
tr.row--transmitted td { color: var(--muted); }
tr.row--transmitted { background: var(--wash); }
.row--on-order td { color: var(--muted); }
.struck { text-decoration: line-through; color: var(--muted); }

/* == Catalog page ========================================================= */
.catalog { display: grid; grid-template-columns: 240px 1fr; gap: var(--s-6); align-items: start; margin-top: var(--s-1); }
.sidebar { position: sticky; top: calc(var(--header-h) + var(--s-3)); display: flex; flex-direction: column; gap: var(--s-4); }
.fgroup { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-card); box-shadow: var(--e-1); padding: var(--s-3); }
.fgroup h4 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-sm); margin: 0 0 var(--s-2); padding: 2px var(--s-2);
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fitem { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer; font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-base);
  color: var(--ink-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.fitem:hover { background: var(--wash); }
.fitem.is-active { background: var(--ink); color: var(--surface); }
/* two-level: раздел header (bolder) → indented categories beneath it */
.fitem--section { font-weight: var(--fw-bold); color: var(--ink); margin-top: var(--s-1); }
.fitem--sub { padding-left: var(--s-5); font-size: var(--fs-sm); }
.fitem--sub > span:first-child::before { content: "└ "; color: var(--muted); }
.fitem--sub.is-active > span:first-child::before { color: var(--surface); }
.fitem .c { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--muted); }
.fitem.is-active .c { color: var(--surface); opacity: .85; }
.catalog-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap; }
.catalog-bar .cnt { font-family: var(--font-display); font-weight: var(--fw-bold); color: var(--ink); font-size: var(--fs-xl); }
.sortsel { font-family: var(--font-body); font-weight: var(--fw-bold); font-size: var(--fs-base); border: var(--bw) solid var(--line); background: var(--surface);
  border-radius: var(--r-pill); padding: var(--s-2) var(--s-4); color: var(--ink); cursor: pointer; box-shadow: var(--e-1); }
@media (max-width: 760px) {
  .catalog { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .fgroup { flex: 1 1 240px; min-width: 0; }
  .gsearch-input, .sortsel { font-size: 16px; }  /* >=16px: не даём iOS зумить при фокусе */
  .sortsel { max-width: 100%; }  /* 16px-шрифт раздувал select — не даём вылезти за вьюпорт */
}

/* == Product page ========================================================= */
.crumbs { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); margin: var(--s-6) 0 var(--s-5); }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.product { display: grid; grid-template-columns: 420px 1fr; gap: var(--s-7); align-items: start; }
.gallery { display: flex; flex-direction: column; gap: var(--s-3); }
.gallery-main { aspect-ratio: 4 / 3; background: #fff; border: var(--bw) solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--e-1); display: grid; place-items: center; }
.gallery-main img { width: 46%; height: 46%; object-fit: contain; opacity: .85; }
.gallery-thumbs { display: flex; gap: var(--s-2); }
.gallery-thumbs div { flex: 1; aspect-ratio: 1 / 1; background: #fff; border: var(--bw) solid var(--line);
  border-radius: var(--r-sm); display: grid; place-items: center; }
.gallery-thumbs img { width: 52%; height: 52%; opacity: .7; }
.gallery-note { font-weight: var(--fw-medium); font-size: var(--fs-xs); color: var(--muted); }
.pinfo h1 { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-4xl);
  letter-spacing: -.01em; margin: 0 0 var(--s-2); }
.meta-tags { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-5); }
.price-block { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-2); }
.price-block .p { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-5xl); }
.avail { font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); margin-bottom: var(--s-5); }
.avail b { color: var(--ink); }
.cta { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-6); }
.spec td { padding: var(--s-3) 0; border-bottom: var(--bw) solid var(--line-2); }
.spec tr:last-child td { border-bottom: 0; }
.spec td:first-child { color: var(--muted); font-weight: var(--fw-semibold); font-size: var(--fs-base); width: 44%; }
.spec td:last-child { font-weight: var(--fw-semibold); }
@media (max-width: 760px) { .product { grid-template-columns: minmax(0, 1fr); } .gallery { max-width: 100%; } }

/* == Auth / price lock ==================================================== */
.authbox { display: inline-flex; align-items: center; gap: var(--s-3); margin-left: var(--s-2); }
/* thin divider splitting browse axes from the personal zone (positioned by renderAuth) */
.nav-sep { flex: none; width: var(--bw); height: 22px; background: var(--line);
  border-radius: var(--r-pill); margin: 0 var(--s-1); }
.authlink { font-weight: var(--fw-bold); font-size: var(--fs-base); padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill); border: var(--bw) solid var(--ink); color: var(--ink); }
.authlink:hover { background: var(--ink); color: var(--surface); }
.authuser { font-weight: var(--fw-bold); font-size: var(--fs-base); color: var(--ink); }
.authout { border: 0; background: transparent; cursor: pointer; font-family: var(--font-body);
  font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); }
.authout:hover { color: var(--ink); }
.switch-name { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-md); color: var(--ink); }
.lock { font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }
a.lock:hover { color: var(--ink); text-decoration: underline; }
.lockbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap;
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-card); box-shadow: var(--e-1);
  padding: var(--s-4) var(--s-6); font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); }

/* == Login page =========================================================== */
.login-wrap { max-width: 420px; margin: var(--s-10) auto 0; }
.login-card { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--e-1); padding: var(--s-7); }
.login-card h1 { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-3xl); margin: 0 0 var(--s-2); }
.login-card .sub { font-weight: var(--fw-medium); font-size: var(--fs-base); color: var(--muted); margin: 0 0 var(--s-6); }
.field { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-4); }
.field label { font-weight: var(--fw-bold); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field input { font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-md); color: var(--ink);
  background: var(--paper); border: var(--bw) solid var(--line); border-radius: var(--r-el); padding: var(--s-3) var(--s-4); outline: none; }
.field input:focus { border-color: var(--ink); }
.login-err { display: none; color: var(--ink); font-weight: var(--fw-bold); font-size: var(--fs-sm);
  background: var(--wash); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); margin-bottom: var(--s-3); }
.demo { margin-top: var(--s-6); padding-top: var(--s-5); border-top: var(--bw) solid var(--line);
  font-size: var(--fs-sm); color: var(--muted); font-weight: var(--fw-medium); line-height: 1.9; }
.demo b { color: var(--ink-2); font-weight: var(--fw-bold); }
.demo code { font-family: var(--font-body); background: var(--wash); border-radius: 6px; padding: 1px 7px;
  font-weight: var(--fw-bold); color: var(--ink); cursor: pointer; }

/* == Requests (RFQ ↔ supplier response) =================================== */
.req-list { display: flex; flex-direction: column; gap: var(--s-3); }
.req { border: var(--bw) solid var(--line); border-radius: var(--r-sm); padding: var(--s-4) var(--s-5); background: var(--paper); }
.req-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); }
.req-buyer { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.req-date { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); }
.req-items { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--s-2); }
.req-note { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: var(--s-3); }
.req-form { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: var(--s-2); }
.req-in { font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--ink);
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-el); padding: var(--s-2) var(--s-3); outline: none; width: 130px; }
.req-in:focus { border-color: var(--ink); }
.req-in--sm { width: 96px; }
.req-in--grow { flex: 1; min-width: 180px; width: auto; }
.req-response { background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4); margin-top: var(--s-2); }
.req-resp-h { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: var(--s-1); }
.req-resp-line { font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); }
.req-resp-line b { font-family: var(--font-display); color: var(--ink); }
.req-msg { font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--ink-2); margin-top: var(--s-1); }
.req-wait { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s-2); }
.rfq-note { width: 100%; box-sizing: border-box; margin-top: var(--s-4); min-height: 60px; resize: vertical;
  font-family: var(--font-body); font-weight: var(--fw-medium); font-size: var(--fs-base); color: var(--ink);
  background: var(--paper); border: var(--bw) solid var(--line); border-radius: var(--r-el); padding: var(--s-3) var(--s-4); outline: none; }
.rfq-note:focus { border-color: var(--ink); }

/* Open requests — board + create */
.open-create { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.open-resp { font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); padding: var(--s-1) 0; }
.open-resp-sup { font-family: var(--font-display); font-weight: var(--fw-bold); color: var(--ink); }
.open-resp b { font-family: var(--font-display); color: var(--ink); }
.open-contact { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--ink-2); margin: var(--s-2) 0; }
.board-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.quota { font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--ink-2); background: var(--wash);
  border-radius: var(--r-pill); padding: var(--s-2) var(--s-4); }

/* == Cabinet tabs ========================================================= */
.tabs { display: flex; gap: var(--s-4); align-items: center; margin: var(--s-2) 0 var(--s-6);
  border-bottom: var(--bw) solid var(--line); }
.tab { border: 0; background: transparent; cursor: pointer; font-family: var(--font-display); font-weight: var(--fw-bold);
  font-size: var(--fs-lg); color: var(--muted); padding: var(--s-3) var(--s-1); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color var(--dur) var(--ease); }
.tab:hover { color: var(--ink-2); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }

/* sticky tab-nav for the admin console (sits under the sticky masthead) */
.adm-tabs { position: sticky; top: var(--header-h); z-index: 40; background: var(--paper);
  margin-bottom: var(--s-5); padding-top: var(--s-2); }
.adm-toolbar--row { display: flex; gap: var(--s-3); align-items: center; }
.adm-toolbar--row .adm-search { flex: 1; }
@media (max-width: 560px) { .adm-tabs { position: static; flex-wrap: wrap; } }

/* == Marketplaces ========================================================= */
.mp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); }
.mp-card { border: var(--bw) solid var(--line); border-radius: var(--r-sm); padding: var(--s-4); background: var(--paper); }
.mp-name { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.mp-stat { margin-top: var(--s-2); }
.mp-count { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s-2); }
.mp-list { display: flex; flex-direction: column; margin-top: var(--s-3); max-height: 300px; overflow-y: auto;
  border: var(--bw) solid var(--line); border-radius: var(--r-sm); }
.mp-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border-bottom: var(--bw) solid var(--line-2); font-weight: var(--fw-semibold); font-size: var(--fs-base); cursor: pointer; }
.mp-item:last-child { border-bottom: 0; }
.mp-item-title { flex: 1; }
.mp-item-art { font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--muted); }
.mp-act { margin-top: var(--s-3); }
.cab-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.cab-sync { margin: 0; }
.empty-box--cta { text-align: center; line-height: 1.6; padding: var(--s-6) var(--s-4); font-size: var(--fs-md); }
.mp-form { max-width: 460px; }
.mp-form select { font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-md);
  color: var(--ink); padding: var(--s-2) var(--s-3); border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  background: var(--paper); }
.mp-form select:focus { border-color: var(--ink); }

/* == Flash messages ======================================================= */
.flash { padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); font-weight: var(--fw-semibold);
  font-size: var(--fs-base); margin-bottom: var(--s-4); border: var(--bw) solid var(--line); }
.flash--ok { background: color-mix(in srgb, var(--ok, #18794e) 12%, var(--paper)); border-color: var(--ok, #18794e); }
.flash--err { background: color-mix(in srgb, var(--danger, #c0392b) 12%, var(--paper)); border-color: var(--danger, #c0392b); }

/* == Cabinet bits (КП total, data-quality) ================================ */
.kp-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-top: var(--s-5); flex-wrap: wrap; }
.kp-total { font-weight: var(--fw-semibold); }
.kp-total b { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-3xl); }
.q-score { font-weight: var(--fw-semibold); font-size: var(--fs-lg); }
.q-score b { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-3xl); }
.q-note { font-weight: var(--fw-semibold); font-size: var(--fs-base); color: var(--ink-2); margin-top: var(--s-3); }

/* == Brand pages ========================================================== */
.brand-head { display: flex; align-items: center; gap: var(--s-5); margin-top: var(--s-7); }
.brand-head .page-title, .brand-head .page-sub { margin-top: 0; }
.brand-head .page-title { margin-bottom: var(--s-1); }
.brand-mark { flex: none; width: 64px; height: 64px; border-radius: var(--r-el); background: var(--ink);
  color: var(--surface); display: grid; place-items: center; font-family: var(--font-display);
  font-weight: var(--fw-extrabold); font-size: var(--fs-3xl); letter-spacing: -.02em; }
.group-h { display: flex; align-items: baseline; gap: var(--s-3); margin: var(--s-7) 0 var(--s-4); }
.group-h > span:first-child { font-family: var(--font-display); font-weight: var(--fw-extrabold);
  font-size: var(--fs-2xl); }
.group-c { color: var(--muted); font-weight: var(--fw-bold); font-size: var(--fs-md); }
.subtitle-link { color: inherit; font-weight: var(--fw-bold); }
.subtitle-link:hover { color: var(--ink); text-decoration: underline; }
.fgroup-link:hover { color: var(--ink); }

/* brands index grid */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }
.brand-card { display: flex; align-items: center; gap: var(--s-4); background: var(--surface);
  border: var(--bw) solid var(--line); border-radius: var(--r-card); box-shadow: var(--e-1);
  padding: var(--s-5); transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.brand-card:hover { transform: translateY(-2px); box-shadow: var(--e-2); }
.brand-card .brand-mark { width: 48px; height: 48px; border-radius: var(--r-sm); font-size: var(--fs-xl); }
.brand-card-name { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-xl); }
.brand-card-meta { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); margin-top: 1px; }
.brand-card-secs { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: var(--s-2); }

/* == Admin / operator console ============================================= */
.adm-sel { font-family: var(--font-body); font-weight: var(--fw-bold); font-size: var(--fs-sm);
  border: var(--bw) solid var(--line); background: var(--paper); border-radius: var(--r-pill);
  padding: var(--s-1) var(--s-3); color: var(--ink); cursor: pointer; outline: none; }
.adm-sel:hover { border-color: var(--ink); }
.adm-sel:focus { border-color: var(--ink); }
.adm-flags { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.adm-flag { font-weight: var(--fw-extrabold); font-size: var(--fs-3xs); letter-spacing: .06em; text-transform: uppercase;
  border: var(--bw-2) solid var(--ink); border-radius: var(--r-pill); padding: 2px var(--s-2); color: var(--ink); white-space: nowrap; }
.adm-flag--soft { border: var(--bw) solid var(--line); color: var(--muted); }
.adm-sec { font-weight: var(--fw-bold); font-size: var(--fs-3xs); letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--muted); margin-bottom: var(--s-1); }
.adm-name-btn { border: 0; background: transparent; cursor: pointer; padding: 0; text-align: left;
  font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); color: var(--ink); }
.adm-name-btn:hover { text-decoration: underline; }
.adm-detail { border: var(--bw) solid var(--line); border-radius: var(--r-card); background: var(--paper);
  padding: var(--s-5) var(--s-6); }
.adm-detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); }
.adm-detail .adm-sec { margin-top: var(--s-4); }
.adm-num { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.adm-num small { font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); }
.adm-q { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-4); }
.adm-q-item { border: var(--bw) solid var(--line); border-radius: var(--r-el); padding: var(--s-4); background: var(--paper); }
.adm-q-item .v { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-4xl); }
.adm-q-item .l { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--muted); margin-top: var(--s-1); }
.adm-q-item .h { font-weight: var(--fw-medium); font-size: var(--fs-xs); color: var(--ink-2); margin-top: var(--s-2); line-height: 1.4; }
/* clickable signal (filters the clusters table) */
button.adm-q-item { width: 100%; font: inherit; text-align: left; cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease); }
button.adm-q-item:hover { border-color: var(--ink); }
.adm-q-item.is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--wash); }
.adm-filter { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4);
  font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--ink-2); }
.adm-filter b { font-family: var(--font-display); color: var(--ink); }
/* table toolbar (search) + pagination */
.adm-toolbar { margin-bottom: var(--s-4); }
.adm-search { width: 100%; max-width: 360px; font-family: var(--font-body); font-weight: var(--fw-semibold);
  font-size: var(--fs-base); color: var(--ink); background: var(--paper); border: var(--bw) solid var(--line);
  border-radius: var(--r-pill); padding: var(--s-2) var(--s-4); outline: none; }
.adm-search::placeholder { font-weight: var(--fw-medium); color: var(--muted); }
.adm-search:focus { border-color: var(--ink); }
.adm-pager { display: flex; align-items: center; justify-content: center; gap: var(--s-4);
  margin-top: var(--s-4); padding-top: var(--s-4); border-top: var(--bw) solid var(--line-2); }
.adm-pager-info { font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* == Utilities ============================================================ */
.t-scroll { overflow-x: auto; }           /* wrapper for wide tables */
.is-hidden { display: none !important; }   /* JS-toggled visibility */
/* visually-hidden but readable by screen readers */
.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; }

/* == Loading skeletons ==================================================== */
@keyframes shimmer { 0% { background-position: -460px 0; } 100% { background-position: 460px 0; } }
.skeleton { border-radius: var(--r-sm); background: var(--wash);
  background-image: linear-gradient(90deg, transparent 0, rgba(255,255,255,.45) 50%, transparent 100%);
  background-size: 460px 100%; background-repeat: no-repeat; animation: shimmer 1.15s var(--ease) infinite; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.sk-line { height: 12px; margin: var(--s-2) 0; }
.sk-card { height: 96px; margin-bottom: var(--s-4); border: var(--bw) solid var(--line); border-radius: var(--r-card); }
.sk-row { height: 44px; margin-bottom: var(--s-2); }
.sk-kpi { height: 92px; border-radius: var(--r-card); }
.sk-w-40 { width: 40%; } .sk-w-60 { width: 60%; } .sk-w-80 { width: 80%; }

/* == Empty state ========================================================== */
.empty { text-align: center; color: var(--muted); font-weight: var(--fw-bold); font-size: var(--fs-md);
  padding: var(--s-9) var(--s-4); border: var(--bw-2) dashed var(--line); border-radius: var(--r-card); }
.empty .empty-emoji { font-size: var(--fs-3xl); opacity: .5; display: block; margin-bottom: var(--s-2); }

/* == Mobile (phones) ====================================================== */
@media (max-width: 560px) {
  .wrap { padding: 0 var(--s-4); }
  /* nav wraps to its own full-width line; auth drops below it */
  .masthead { gap: var(--s-3); position: static; }   /* tall wrapped header — don't pin on phones */
  .gsearch { max-width: none; flex-basis: 100%; order: 3; }   /* full-width on its own line */
  .nav { flex-wrap: wrap; gap: var(--s-1) var(--s-2); width: 100%; }
  .nav a { padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
  .nav-sep { display: none; }   /* nav wraps on phones — authbox gets a top border instead */
  .authbox { width: 100%; margin-left: 0; padding-left: 0; border-left: 0;
    border-top: var(--bw) solid var(--line); padding-top: var(--s-2); margin-top: var(--s-2); }
  /* search stacks: input over a full-width button */
  .search { flex-direction: column; align-items: stretch; gap: var(--s-2); padding: var(--s-3); }
  .search input { flex: none; }
  .search .btn { width: 100%; }
  /* product/result card: drop the price column under the title, shrink thumb */
  .card-head { grid-template-columns: 40px minmax(0, 1fr); }
  .title { overflow-wrap: anywhere; }  /* длинный артикул/слово в названии не распирает карточку */
  .card-thumb { width: 40px; height: 40px; }
  .price-side { grid-column: 1 / -1; text-align: left; margin-top: var(--s-2); }
  /* dense tables (.t-stack) become stacked «label: value» cards — no horizontal scroll */
  table.t-stack thead { display: none; }
  table.t-stack tbody, table.t-stack tr, table.t-stack td { display: block; width: 100%; }
  table.t-stack tr { border: var(--bw) solid var(--line); border-radius: var(--r-sm);
    padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3); background: var(--paper); }
  table.t-stack td { border-bottom: 0; padding: 3px 0; min-width: 0; white-space: normal; }
  table.t-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted);
    font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .04em; text-transform: uppercase; margin-right: var(--s-1); }
  table.t-stack .cell-num, table.t-stack .stock-cell, table.t-stack .cell-mono { white-space: normal; }
  table.t-stack td:first-child { padding-bottom: var(--s-2); margin-bottom: var(--s-2);
    border-bottom: var(--bw) solid var(--line-2); }
  table.t-stack .raw { max-width: none; }
  table.t-stack .src { display: inline-flex; }
}

/* == Blog ================================================================= */
.blog-cats { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-7); }
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-5); }
.blog-card { display: flex; flex-direction: column; background: var(--surface); border: var(--bw) solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--e-1); overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.blog-card:hover { transform: translateY(-2px); box-shadow: var(--e-2); }
.blog-cover { display: block; aspect-ratio: 16 / 9; background: var(--paper); overflow: hidden; }
.blog-cover img { width: 100%; height: 100%; object-fit: cover; }
.blog-body { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-5); flex: 1; }
.blog-cat { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.blog-card h2 { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-2xl); line-height: 1.2; margin: 0; }
.blog-card h2 a:hover { text-decoration: underline; }
.blog-excerpt { font-weight: var(--fw-medium); font-size: var(--fs-base); color: var(--ink-2); line-height: 1.5; }
.blog-meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: var(--s-3); font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--muted); }
.pager { display: flex; gap: var(--s-4); align-items: center; justify-content: center; margin: var(--s-9) 0; }
.pager-info { font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--ink-2); }

/* article (single post) */
.article { max-width: 760px; margin: 0 auto; }
.article-kicker { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.article h1 { font-family: var(--font-display); font-weight: var(--fw-extrabold); font-size: var(--fs-5xl);
  line-height: 1.08; letter-spacing: -.01em; margin: var(--s-3) 0 var(--s-4); }
.article-meta { display: flex; flex-wrap: wrap; gap: var(--s-4); font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  color: var(--muted); padding-bottom: var(--s-5); border-bottom: var(--bw) solid var(--line); }
.article-meta b { color: var(--ink); }
.article-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-card); margin: var(--s-6) 0; }
.article-tags { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-7); padding-top: var(--s-5); border-top: var(--bw) solid var(--line); }

/* article body — markdown-rendered HTML (no utility classes), styled by element */
.article-body { font-size: var(--fs-xl); line-height: 1.75; color: var(--ink); font-weight: var(--fw-medium); }
.article-body > :first-child { margin-top: 0; }
.article-body h2 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-4xl); line-height: 1.2; margin: var(--s-8) 0 var(--s-3); }
.article-body h3 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--fs-2xl); margin: var(--s-6) 0 var(--s-2); }
.article-body p { margin: 0 0 var(--s-5); }
.article-body ul, .article-body ol { margin: 0 0 var(--s-5) var(--s-6); }
.article-body ul { list-style: disc; }
.article-body ol { list-style: decimal; }
.article-body li { margin-bottom: var(--s-2); }
.article-body a { text-decoration: underline; text-underline-offset: 2px; }
.article-body a:hover { color: var(--ink-2); }
.article-body strong { font-weight: var(--fw-bold); }
.article-body blockquote { margin: var(--s-6) 0; padding: var(--s-1) var(--s-5); font-style: italic;
  border-left: var(--bw-2) solid var(--ink); color: var(--ink-2); }
.article-body code { background: var(--wash); padding: 1px var(--s-2); border-radius: 6px; font-size: .9em; }
.article-body img { max-width: 100%; border-radius: var(--r-el); }
.article-body table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-5); }
.article-body th, .article-body td { border: var(--bw) solid var(--line); padding: var(--s-2) var(--s-3); text-align: left; }
@media (max-width: 560px) { .blog-grid { grid-template-columns: 1fr; } }

/* ── Админка: Емайлы / общение ─────────────────────────────────────────── */
/* под-табы внутри раздела (Почта / Диалоги) */
.subtabs { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); }
.subtab { font-weight: var(--fw-bold); font-size: var(--fs-sm); padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill); color: var(--ink-2); background: transparent;
  border: var(--bw) solid var(--line); cursor: pointer; transition: all var(--dur) var(--ease); }
.subtab:hover { border-color: var(--ink); }
.subtab.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* строка письма/диалога в списке */
.mail-row { cursor: pointer; }
.mail-row:hover { background: var(--wash); }
.mail-sub { font-weight: var(--fw-bold); font-size: var(--fs-base); color: var(--ink); }
.mail-unread .mail-sub::before { content: "●"; color: var(--danger); font-size: .7em;
  vertical-align: middle; margin-right: var(--s-2); }
.mail-snip { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }

/* лента треда / диалога — пузыри */
.thread { display: flex; flex-direction: column; gap: var(--s-3); margin: var(--s-4) 0; }
.bubble { max-width: 78%; border: var(--bw) solid var(--line); border-radius: var(--r-el);
  padding: var(--s-3) var(--s-4); background: var(--surface); }
.bubble--in { align-self: flex-start; border-bottom-left-radius: var(--r-sm); }
.bubble--out { align-self: flex-end; background: var(--ink); color: var(--surface);
  border-color: var(--ink); border-bottom-right-radius: var(--r-sm); }
.bubble--sys { align-self: center; max-width: 90%; background: var(--wash);
  color: var(--muted); font-size: var(--fs-sm); text-align: center; }
.bubble-meta { font-weight: var(--fw-bold); font-size: var(--fs-3xs); letter-spacing: .06em;
  text-transform: uppercase; opacity: .7; margin-bottom: var(--s-1); }
.bubble-body { font-size: var(--fs-base); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bubble-att { margin-top: var(--s-2); font-size: var(--fs-sm); opacity: .85; }

/* форма ответа / нового письма */
.mail-form { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-4);
  padding-top: var(--s-4); border-top: var(--bw) solid var(--line); }
.mail-form input, .mail-form textarea, .mail-form select {
  font-family: var(--font-body); font-size: var(--fs-base); color: var(--ink);
  background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3); width: 100%; box-sizing: border-box; }
.mail-form textarea { min-height: 100px; resize: vertical; }
.mail-form input:focus, .mail-form textarea:focus, .mail-form select:focus {
  outline: none; border-color: var(--ink); }
.mail-form-row { display: flex; gap: var(--s-3); align-items: center; }
.mail-chan { font-weight: var(--fw-bold); font-size: var(--fs-2xs); letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); }
