/* =========================================================================
   Дизайн-система тендерной площадки.
   Источник: docs/design/README.md и мокапы docs/design/screens/*.dc.html.

   Этот файл меняет только S1 (фундамент). Сессии S2–S4 кладут свои стили
   в отдельные файлы (static/css/<app>.css) и используют токены и классы
   отсюда. Список компонентов — docs/architecture.md, раздел «CSS».

   Цвета бренда сети подставляются в :root инлайн-стилем из Organization
   (templates/partials/brand_style.html): --brand, --brand-dark,
   --brand-soft, --brand-ring, --on-brand.
   ========================================================================= */

/* --- Шрифт Inter (variable, свои файлы; кириллица и казахские буквы) ---- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/inter-cyrillic-ext-wght-normal.251d36f2b5a6.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/inter-cyrillic-wght-normal.de93fdc85e3d.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/inter-latin-ext-wght-normal.1ad231aac0a8.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+20B8;
}

/* --- Токены --------------------------------------------------------------- */
:root {
  /* Бренд сети (значения по умолчанию; сеть переопределяет) */
  --brand: #E30613;
  --brand-dark: #B0000E;
  --brand-soft: #FFECEC;
  --brand-ring: rgba(227, 6, 19, .2);
  --on-brand: #FFFFFF;

  /* Акцент: таймеры и предупреждения */
  --accent: #FECD27;
  --accent-soft: #FFF4CC;
  --accent-border: #F2D675;
  --accent-fg: #6B4D00;
  --accent-fg-strong: #4A3600;

  /* Смысловые цвета: зелёный — только «лидер / лучшая цена / успех» */
  --success: #13804A;
  --success-dark: #0B5A32;
  --success-soft: #E7F5EC;
  --success-border: #BFE5CC;
  --success-cell: #DFF3E6;
  --danger: #B42318;
  --danger-soft: #FEECEB;
  --info: #1D4F8A;
  --info-soft: #E7F0FA;
  --selected-row: #FFF7D6;
  --draft-row: #FFFBEA;

  /* Нейтральные */
  --bg: #F5F5F5;
  --surface: #FFFFFF;
  --surface-2: #FAFAFA;
  --muted-bg: #F0F0F0;
  --fg: #1E1E1E;
  --fg-2: #333333;
  --muted: #5E5E5E;
  --subtle: #6B6B6B;
  --faint: #8C8C8C;
  --line: #E6E6E6;
  --line-soft: #F0F0F0;
  --border: #D2D2D2;
  --border-strong: #C4C4C4;

  /* Тёмная боковая панель (панель закупа, консоль) */
  --side-bg: #1E1E1E;
  --side-fg: #E0E0E0;
  --side-muted: #BDBDBD;
  --side-hover: rgba(255, 255, 255, .06);

  /* Форма */
  --radius-card: 20px;
  --radius-lg: 30px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-pop: 0 8px 32px rgba(0, 0, 0, .08);
  --shadow-bar: 0 -4px 16px rgba(0, 0, 0, .08);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fs: 15px;
  --lh: 1.5;

  /* Размеры касания и полей (Safari: поля не меньше 16px, цели не меньше 44px) */
  --tap: 44px;
  --control-h: 48px;
  --control-h-lg: 52px;
  --control-fs: max(16px, 1rem);

  /* Безопасные зоны iPhone и клавиатура (--kb-inset выставляет static/js/app.js) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --kb-inset: 0px;

  --container: 1320px;
  --gutter: 24px;
  --header-h: 64px;
  --bottom-nav-h: 64px;
  --sidebar-w: 248px;

  color-scheme: light;
}

@media (max-width: 767px) {
  :root {
    --gutter: 16px;
    --radius-card: 16px;
  }
}

/* --- Основа ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--header-h) + var(--safe-top));
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

img, svg, video { max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

h1, .h1 { font-size: 30px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
h2, .h2 { font-size: 22px; font-weight: 800; line-height: 1.25; }
h3, .h3 { font-size: 17px; font-weight: 700; line-height: 1.3; }
@media (max-width: 767px) {
  h1, .h1 { font-size: 24px; }
  h2, .h2 { font-size: 19px; }
}

a { color: var(--brand); text-underline-offset: 3px; }
@media (hover: hover) { a:hover { color: var(--brand-dark); } }

input, select, textarea, button { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

.i { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tnum, .num { font-variant-numeric: tabular-nums; }

/* --- Утилиты --------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-left: max(var(--gutter), var(--safe-left));
  padding-right: max(var(--gutter), var(--safe-right));
}
.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); }
.stack-sm { --gap: 8px; }
.stack-lg { --gap: 24px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 12px); }
.cluster-between { justify-content: space-between; }
.grid { display: grid; gap: var(--gap, 16px); grid-template-columns: repeat(auto-fit, minmax(min(var(--min, 280px), 100%), 1fr)); }
.spacer { flex: 1; }
.text-muted { color: var(--muted); }
.text-subtle { color: var(--subtle); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-brand { color: var(--brand); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (max-width: 767px) { .hide-mobile { display: none !important; } }
@media (min-width: 768px) { .show-mobile { display: none !important; } }
@media (max-width: 1023px) { .hide-tablet { display: none !important; } }

/* --- Кнопки (форма «таблетки», цель ≥ 44px) ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--fg);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: filter .12s, background-color .12s, border-color .12s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
@media (hover: hover) { .btn:not(:disabled):hover { filter: brightness(.94); color: inherit; } }
.btn--primary { background: var(--brand); color: var(--on-brand); }
@media (hover: hover) { .btn--primary:not(:disabled):hover { color: var(--on-brand); } }
.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--fg); }
.btn--ghost { background: transparent; color: var(--fg); }
@media (hover: hover) { .btn--ghost:not(:disabled):hover { background: var(--bg); filter: none; } }
.btn--soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn--muted { background: var(--muted-bg); color: var(--fg-2); }
.btn--dark { background: var(--fg); color: #FFFFFF; }
.btn--success { background: var(--success-soft); color: var(--success-dark); border-color: var(--success-border); }
.btn--danger { background: var(--danger); color: #FFFFFF; }
.btn--link {
  min-height: 0; padding: 0; border: 0; background: none; color: var(--brand);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn--lg { min-height: var(--control-h-lg); padding: 0 28px; font-size: 16px; }
.btn--block { display: flex; width: 100%; }
@media (pointer: coarse) { .btn--sm { min-height: var(--tap); } }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg-2);
  position: relative; cursor: pointer; touch-action: manipulation;
}
.btn-icon--plain { border-color: transparent; background: transparent; }

/* --- Поля ввода ----------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 14px; font-weight: 600; color: var(--fg-2); }
.field__hint { font-size: 13px; color: var(--subtle); }
.field__error { font-size: 13px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--control-fs); /* Safari не приближает страницу при фокусе */
  line-height: 1.3;
  appearance: none;
  -webkit-appearance: none;
}
.textarea { min-height: 112px; padding: 12px 18px; border-radius: 16px; resize: vertical; }
.select {
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235E5E5E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.input[aria-invalid="true"], .is-invalid .input { border-color: var(--danger); }
.input--lg { min-height: var(--control-h-lg); }
.input--code { letter-spacing: .35em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .i { position: absolute; left: 16px; color: var(--subtle); pointer-events: none; }
.input-group > .input { padding-left: 44px; }

.check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

/* --- Карточки -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
  min-width: 0;
}
.card--tight { padding: 16px; }
.card--flush { padding: 0; overflow: hidden; }
.card--pop { box-shadow: var(--shadow-pop); border-radius: var(--radius-lg); padding: 36px; }
.card__header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__title { font-size: 18px; font-weight: 800; }
@media (max-width: 767px) {
  .card { padding: 16px; }
  .card--pop { padding: 24px 20px; }
}

/* --- Бейджи, статусы, чипы ------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--muted-bg); color: var(--fg-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.badge--brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge--success { background: var(--success-soft); color: var(--success-dark); }
.badge--warning { background: var(--accent-soft); color: var(--accent-fg); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--draft { background: var(--surface); color: var(--muted); border: 1px dashed var(--border-strong); }
.badge--solid { background: var(--brand); color: var(--on-brand); }
.badge--count { height: 20px; min-width: 20px; padding: 0 6px; justify-content: center; font-size: 12px; font-weight: 700; }

/* Статусы торга (auctions.models.AuctionStatus) */
.status--draft { background: var(--surface); color: var(--muted); border: 1px dashed var(--border-strong); }
.status--scheduled { background: var(--info-soft); color: var(--info); }
.status--live { background: var(--brand-soft); color: var(--brand-dark); }
.status--review { background: var(--accent-soft); color: var(--accent-fg); }
.status--completed { background: var(--muted-bg); color: var(--fg-2); }
.status--cancelled { background: var(--muted-bg); color: var(--faint); text-decoration: line-through; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot--online { background: var(--success); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--fg-2);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; touch-action: manipulation;
}
.chip[aria-pressed="true"], .chip.is-active { background: var(--fg); border-color: var(--fg); color: #FFFFFF; }
@media (pointer: coarse) { .chip { min-height: var(--tap); } }

/* --- Вкладки и переключатели ---------------------------------------------- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 14px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab .badge--count { background: var(--muted-bg); color: var(--fg-2); }
.tab[aria-selected="true"] .badge--count { background: var(--brand-soft); color: var(--brand-dark); }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius-pill); background: var(--muted-bg); }
.seg--block { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; width: 100%; }
.seg__btn {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--fg-2); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.seg__btn[aria-pressed="true"], .seg__btn[aria-selected="true"] {
  background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
@media (pointer: coarse) { .seg__btn { min-height: 40px; } }

/* --- Таблицы ---------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 2;
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); background: var(--surface); vertical-align: middle; }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.is-selected td { background: var(--selected-row); }
.table tr.is-draft td { background: var(--draft-row); }
@media (hover: hover) { .table--hover tbody tr:hover td { background: var(--surface-2); } }
/* Закреплённая первая колонка (матрица цен на планшете/телефоне) */
.table--sticky-first th:first-child,
.table--sticky-first td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--line); }
.table--sticky-first th:first-child { z-index: 3; }
.cell--best { background: var(--success-cell) !important; color: var(--success-dark); font-weight: 700; }
.cell--empty { color: var(--faint); }

/* --- Таймер торга ------------------------------------------------------------ */
.timer {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--fg);
  font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.timer--urgent { background: var(--brand); color: var(--on-brand); }
.timer--muted { background: var(--muted-bg); color: var(--muted); }
.timer--lg { height: 44px; padding: 0 18px; font-size: 20px; }

/* --- Уведомления и сообщения --------------------------------------------- */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); font-size: 14px;
}
.notice--warning { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-fg-strong); }
.notice--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-dark); }
.notice--danger { background: var(--danger-soft); border-color: #F5C2BD; color: var(--danger); }
.notice--info { background: var(--info-soft); border-color: #C9DCF2; color: var(--info); }

.toasts {
  position: fixed; z-index: 100;
  right: max(16px, var(--safe-right)); bottom: calc(16px + var(--safe-bottom) + var(--kb-inset));
  display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px));
}
.toast { padding: 12px 16px; border-radius: var(--radius); background: var(--fg); color: #FFFFFF; box-shadow: var(--shadow-pop); font-size: 14px; }
.toast--success { background: var(--success-dark); }
.toast--error { background: var(--danger); }

/* --- Прочее: аватар, прогресс, пустое состояние, разделитель ---------------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 14px;
}
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress__bar { height: 100%; background: var(--brand); border-radius: inherit; }
.progress__bar--success { background: var(--success); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.divider { height: 1px; background: var(--line-soft); border: 0; margin: 0; }
.kbd { padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; background: var(--surface-2); }
.code-block {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
  overflow-x: auto;
}

/* --- Заголовок страницы --------------------------------------------------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-subtitle { color: var(--muted); }

/* --- Логотип сети ------------------------------------------------------------ */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; }
.brand__mark {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--brand); color: var(--on-brand);
  display: flex; align-items: center; justify-content: center;
}
.brand__logo { height: 32px; width: auto; max-width: 160px; object-fit: contain; flex: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand__name { font-weight: 800; font-size: 16px; }
.brand__sub { font-size: 12px; color: var(--muted); }

.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius-pill); background: var(--muted-bg); }
.lang-switch button {
  min-height: 36px; min-width: 44px; padding: 0 10px; border: 0; border-radius: var(--radius-pill);
  background: transparent; font-size: 13px; font-weight: 700; color: var(--muted);
}
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
@media (pointer: coarse) { .lang-switch button { min-height: 40px; } }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); min-width: 0;
}
.user-chip__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-chip__name { font-size: 14px; font-weight: 600; }
.user-chip__sub { font-size: 12px; color: var(--muted); }

/* =========================================================================
   Оболочки
   ========================================================================= */

/* --- Верхняя шапка (портал, кабинет поставщика) -------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}
.app-header__inner {
  min-height: var(--header-h);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding-block: 8px;
}
.topnav {
  display: flex; gap: 4px; flex: 1; min-width: 0; font-size: 15px; font-weight: 500;
  overflow-x: auto; scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
@media (max-width: 1199px) { .shell-supplier .app-header .user-chip__text { display: none; } }
.topnav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--fg-2); text-decoration: none; white-space: nowrap;
}
@media (hover: hover) { .topnav a:hover { color: var(--fg); background: var(--surface-2); } }
.topnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

/* --- Портал сети (вход) ------------------------------------------------------ */
.shell-portal .app-header { box-shadow: 0 2px 12px rgba(0, 0, 0, .05); border-bottom: 0; }
.portal-main {
  flex: 1; width: 100%; max-width: 1240px; margin-inline: auto;
  padding: 32px max(var(--gutter), var(--safe-right)) calc(48px + var(--safe-bottom)) max(var(--gutter), var(--safe-left));
  display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch;
}
.portal-hero {
  flex: 1 1 440px; min-width: 0;
  background: var(--brand); color: var(--on-brand);
  border-radius: 40px; padding: 48px 48px 40px;
  display: flex; flex-direction: column; gap: 36px; justify-content: space-between;
}
.portal-hero a { color: var(--on-brand); font-weight: 600; }
.portal-hero__title { font-size: 40px; line-height: 1.12; letter-spacing: -.02em; }
.portal-hero__lead { font-size: 17px; }
.portal-hero__tag {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 16px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--fg); font-size: 14px; font-weight: 700;
}
.portal-steps { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.portal-steps li { display: flex; gap: 14px; align-items: flex-start; }
.portal-steps__n {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.portal-auth { flex: 1 1 420px; min-width: 0; max-width: 100%; display: flex; align-items: center; justify-content: center; }
.portal-auth > .card { width: 100%; max-width: 480px; }
@media (max-width: 767px) {
  .portal-main { padding-top: 16px; gap: 16px; }
  .portal-hero { border-radius: 24px; padding: 28px 20px; gap: 24px; }
  .portal-hero__title { font-size: 28px; }
  .portal-auth { order: -1; }  /* на телефоне сначала форма входа */
}

/* --- Кабинет поставщика ------------------------------------------------------ */
.page-main {
  padding-top: 28px;
  padding-bottom: calc(48px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 24px;
}
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  min-height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding: 4px max(8px, var(--safe-left)) var(--safe-bottom) max(8px, var(--safe-right));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap); color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none;
}
.bottom-nav a[aria-current="page"] { color: var(--brand); }
@media (max-width: 767px) {
  .shell-supplier .topnav { display: none; }
  .shell-supplier .page-main { padding-top: 16px; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 24px); gap: 16px; }
}
@media (min-width: 768px) { .bottom-nav { display: none; } }

/* Нижняя панель действий (панель ставок) — над клавиатурой iPhone через --kb-inset */
.bottom-bar {
  position: fixed; left: 0; right: 0; z-index: 40;
  bottom: var(--kb-inset);
  padding: 12px max(16px, var(--safe-right)) calc(12px + var(--safe-bottom)) max(16px, var(--safe-left));
  background: var(--surface); box-shadow: var(--shadow-bar);
  transition: bottom .1s;
}
.has-bottom-bar .page-main { padding-bottom: calc(96px + var(--safe-bottom) + var(--kb-inset)); }
@media (max-width: 767px) {
  .shell-supplier .bottom-bar { bottom: max(var(--kb-inset), calc(var(--bottom-nav-h) + var(--safe-bottom))); padding-bottom: 12px; }
  body.kb-open .bottom-nav { display: none; }
}

/* --- Панель закупа и консоль площадки (тёмная боковая панель) ----------- */
.shell-side { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; flex: none;
  width: var(--sidebar-w); height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--side-bg); color: #FFFFFF;
  padding: calc(20px + var(--safe-top)) 14px calc(20px + var(--safe-bottom)) max(14px, var(--safe-left));
  display: flex; flex-direction: column; gap: 24px;
}
.sidebar .brand { padding: 0 8px; }
.sidebar .brand__sub { color: var(--side-muted); }
.sidenav { display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 500; }
.sidenav a {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 0 10px; border-radius: var(--radius-pill);
  color: var(--side-fg); text-decoration: none;
}
@media (hover: hover) { .sidenav a:hover { background: var(--side-hover); color: #FFFFFF; } }
@media (pointer: coarse) { .sidenav a { min-height: var(--tap); } }
.sidenav a[aria-current="page"] { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.sidenav__count { margin-left: auto; font-size: 12px; color: var(--side-muted); }
.sidenav__badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: var(--fg); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidenav__section { margin-top: 12px; padding: 0 10px; font-size: 12px; color: var(--side-muted); text-transform: uppercase; letter-spacing: .04em; }
.sidebar__user {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px; background: var(--side-hover);
}
.sidebar__user .avatar { background: #FFFFFF; color: var(--fg); }
.sidebar .lang-switch { align-self: flex-start; margin-left: 8px; background: var(--side-hover); }
.sidebar .lang-switch button { color: var(--side-muted); }
.sidebar .lang-switch button[aria-pressed="true"] { background: #FFFFFF; color: var(--fg); }
.sidebar__user .user-chip__sub { color: var(--side-muted); }

.side-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-topbar {
  display: none; position: sticky; top: 0; z-index: 20;
  align-items: center; gap: 12px;
  min-height: calc(56px + var(--safe-top));
  padding: var(--safe-top) max(16px, var(--safe-right)) 0 max(8px, var(--safe-left));
  background: var(--side-bg); color: #FFFFFF;
}
.side-topbar .btn-icon { background: transparent; border-color: transparent; color: #FFFFFF; }
.side-content {
  flex: 1; width: 100%; max-width: 1440px;
  padding: 28px 32px calc(48px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 24px;
}
.sidebar-backdrop { display: none; }

@media (max-width: 1023px) {
  .shell-side { display: block; }
  .side-topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-pop);
  }
  .sidebar[data-open="true"] { transform: none; }
  .sidebar-backdrop[data-open="true"] { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .4); }
  .side-content { padding: 16px max(16px, var(--safe-right)) calc(32px + var(--safe-bottom)) max(16px, var(--safe-left)); gap: 16px; }
}

/* Консоль площадки — нейтральная тема, без бренда сети */
.shell-platform { --brand: #1E1E1E; --brand-dark: #000000; --brand-soft: #EDEDED; --brand-ring: rgba(30, 30, 30, .2); --on-brand: #FFFFFF; }
.shell-platform .sidebar { background: #111214; }
.shell-platform .sidenav a[aria-current="page"] { background: #FFFFFF; color: #111214; }

/* --- Нейтральная страница (неизвестный адрес) ------------------------------ */
.neutral {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(24px, var(--safe-top)) 16px max(24px, var(--safe-bottom));
  text-align: center;
}
.neutral .card { max-width: 440px; }

/* --- Заглушки S1 ------------------------------------------------------------ */
.stub {
  border: 2px dashed var(--border); border-radius: var(--radius-card);
  padding: 32px 24px; text-align: center; color: var(--muted); background: var(--surface);
}

/* --- Индикатор живого соединения (live.js) ------------------------------- */
.live-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.live-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-status[data-state="open"]::before { background: var(--success); }
.live-status[data-state="connecting"]::before,
.live-status[data-state="polling"]::before { background: var(--accent); }
.live-status[data-state="offline"]::before { background: var(--danger); }

/* --- Печать и уменьшение движения --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .sidebar, .side-topbar, .app-header, .bottom-nav, .bottom-bar, .toasts { display: none !important; }
  body { background: #FFFFFF; }
}
