/* ============================================================
   DGS — дизайн-система r2 (перенос прототипа в боевой фронтенд)
   Тёмная тема: глубокие нейтрали + один синий акцент.
   Данные — JetBrains Mono, UI — Satoshi, заголовки — Cabinet Grotesk.
   Имена классов и data-testid сохранены: админка и тесты не ломаются.
   ============================================================ */

:root {
  /* Поверхности (старые имена → новая палитра прототипа) */
  --surface-dim: #0c0d10;
  --surface: #0c0d10;
  --surface-bright: #2b3140;
  --surface-container-lowest: #0c0d10;
  --surface-container-low: #12141a;
  --surface-container: #171a21;
  --surface-container-high: #1d212b;
  --surface-container-highest: #20242f;

  /* Текст и границы */
  --on-surface: #e8eaf0;
  --on-surface-variant: #9aa1b2;
  --outline: #626a7c;
  --outline-variant: #232833;

  /* Акцент */
  --primary: #5b93ff;
  --primary-hover: #7aa8ff;
  --on-primary: #0a1a38;
  --primary-container: #5b93ff;
  --on-primary-container: #ffffff;
  --primary-soft: rgba(91, 147, 255, 0.13);
  --tertiary: #e8b44a;
  --on-tertiary: #3d2c00;
  --error: #ef6a6a;
  --on-error: #450a0a;
  --error-container: #7f1d1d;
  --green: #4ecb71;
  --red: #ef6a6a;
  --yellow: #e8b44a;
  --success: #4ecb71;
  --info: #5ec4d8;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 999px;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);

  --font-ui: 'Satoshi', 'Inter', system-ui, sans-serif;
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', 'SFMono-Regular', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--on-surface);
  background-color: var(--surface-container-lowest);
}

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: rgba(91, 147, 255, 0.3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3140; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

a, button, input, select, textarea {
  transition: background 160ms cubic-bezier(0.16, 1, 0.3, 1), color 160ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 160ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ===== Типографика ===== */
.t-headline-lg { font-family: var(--font-display); font-size: 1.75rem; line-height: 2.125rem; letter-spacing: -0.01em; font-weight: 700; }
.t-headline-md { font-family: var(--font-display); font-size: 1.375rem; line-height: 1.75rem; letter-spacing: -0.01em; font-weight: 700; }
.t-headline-sm { font-family: var(--font-display); font-size: 1.0625rem; line-height: 1.375rem; letter-spacing: -0.005em; font-weight: 700; }
.t-body-md { font-size: 0.875rem; line-height: 1.375rem; font-weight: 400; }
.t-body-sm { font-size: 0.8125rem; line-height: 1.25rem; font-weight: 400; }
.t-label-ui { font-size: 0.75rem; line-height: 1rem; letter-spacing: 0.02em; font-weight: 500; font-family: var(--font-ui); }
.t-code-lg { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; font-family: var(--font-code); }
.t-code-md { font-size: 0.8125rem; line-height: 1.25rem; font-weight: 500; font-family: var(--font-code); }
.t-code-sm { font-size: 0.75rem; line-height: 1rem; font-weight: 400; font-family: var(--font-code); }

.uppercase { text-transform: uppercase; }
.muted { color: var(--on-surface-variant); }
.faint { color: var(--outline); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-primary { color: var(--primary); }
.mono { font-family: var(--font-code); }

/* ===== Каркас: сайдбар + верхняя панель ===== */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }

.side {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface-container-low);
  border-right: 1px solid var(--outline-variant);
  padding: var(--space-lg) var(--space-md);
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: var(--space-sm);
  color: var(--on-surface);
  user-select: none; text-decoration: none !important;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem; letter-spacing: -0.01em;
  cursor: pointer;
}
.side .brand { margin-bottom: var(--space-lg); }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius-md); flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #3f6fd9);
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 0.9375rem;
}
.brand-sub { display: block; font-family: var(--font-ui); font-weight: 400; font-size: 0.75rem; color: var(--outline); }

.topnav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.topnav a {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  color: var(--on-surface-variant); font-size: 0.875rem; font-weight: 500;
  text-decoration: none !important; white-space: nowrap;
  border-bottom: none;
}
.topnav a svg { flex: none; opacity: 0.85; }
.topnav a:hover { background: var(--surface-container-highest); color: var(--on-surface); }
.topnav a.active { background: var(--primary-soft); color: var(--primary-hover); }
.nav-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px;
  background: var(--error); color: #fff; font-size: 10px; text-align: center; margin-left: auto; padding: 0 4px;
}
.nav-badge[hidden] { display: none; }

.side-foot { margin-top: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); }
.balance-chip {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-container);
  border: 1px solid #2b3140;
  border-radius: var(--radius-xl);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
}
.balance-chip:hover { border-color: var(--primary); }
.balance-chip .lbl { font-size: 0.75rem; text-transform: none; color: var(--outline); }
.balance-chip .val { font-family: var(--font-code); font-size: 1.0625rem; font-weight: 600; color: var(--on-surface); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: color-mix(in srgb, var(--surface-container-lowest) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--outline-variant);
  height: auto; flex-wrap: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-sm); }
.burger { display: none; }

.cart-link {
  position: relative; width: 36px; height: 36px; border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--on-surface-variant);
  border: 1px solid #2b3140; background: var(--surface-container);
}
.cart-link:hover { color: var(--on-surface); border-color: var(--outline); text-decoration: none; }
.cart-count {
  position: absolute; top: -4px; right: -5px;
  min-width: 15px; height: 15px; padding: 0 4px;
  background: var(--primary); color: #fff;
  border-radius: 8px; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
.notif-badge { position: relative; }
.notif-badge .n {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--tertiary); border: 2px solid var(--surface-container);
}

main { padding-top: 0; min-height: 100dvh; }
.page {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding: var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-md);
}

/* Заголовок страницы */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.page-sub { color: var(--on-surface-variant); font-size: 0.875rem; margin-top: 4px; max-width: 62ch; }

/* Панель инструментов списка (поиск + фильтры-чипы) */
.toolbar { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--outline); pointer-events: none; }
.toolbar .search .input { padding-left: 34px; }

/* Пресеты сумм (пополнение) */
.preset {
  min-width: 64px; padding: var(--space-sm) var(--space-sm);
  border: 1px solid #2b3140; border-radius: var(--radius);
  background: var(--surface-container);
  font-family: var(--font-code); font-size: 0.875rem; text-align: center; cursor: pointer;
}
.preset:hover { border-color: var(--outline); }
.preset.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-hover); }

/* Админка: shell() рендерит .topbar без .side — сохраняем компактную плавающую шапку */
#app > .topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 48px;
  background: var(--surface-container-low);
}
#app > .topbar .topnav { flex-direction: row; align-items: center; gap: 2px; }
#app > .topbar .topnav a { padding: 6px var(--space-sm); }
#app > .topbar ~ main { padding-top: 64px; }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem; font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none !important;
  white-space: nowrap;
}
.btn svg { flex: none; }
.btn-sm { min-height: 30px; height: auto; padding: 4px var(--space-sm); font-size: 0.75rem; }
.btn-xs { min-height: 24px; height: auto; padding: 2px 8px; font-size: 0.72rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--on-surface); border-color: #2b3140; }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--on-surface-variant); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-container-highest); color: var(--on-surface); }
.btn-danger { background: transparent; color: var(--error); border-color: #2b3140; }
.btn-danger:hover:not(:disabled) { border-color: var(--error); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn .spinner { width: 12px; height: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--radius); display: grid; place-items: center; color: var(--on-surface-variant); }
.icon-btn:hover { background: var(--surface-container-highest); color: var(--on-surface); text-decoration: none; }

/* Фильтры-чипы (списки) */
.fchip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  border: 1px solid #2b3140; background: var(--surface-container);
  font-size: 0.75rem; font-weight: 600; color: var(--on-surface-variant);
  cursor: pointer;
}
.fchip:hover { border-color: var(--outline); color: var(--on-surface); }
.fchip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-hover); }

/* Длинные значения в таблицах: обрезка с раскрытием */
.val-wrap { max-height: 2.6em; overflow: hidden; position: relative; overflow-wrap: anywhere; }
.val-wrap.open { max-height: none; }
.val-toggle { font-size: 0.75rem; color: var(--primary); cursor: pointer; background: none; padding: 0; }
.val-toggle:hover { text-decoration: underline; }

/* ===== Панели ===== */
.panel {
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--outline-variant);
}
.panel-body { padding: var(--space-lg); }

/* ===== Телеметрическая строка (home) ===== */
.telemetry {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-md);
  padding: var(--space-sm) var(--space-md);
}
.telemetry .divider { width: 1px; height: 14px; background: var(--outline-variant); }
.copy-btn {
  font-family: var(--font-code); font-size: 0.75rem;
  padding: 3px var(--space-sm); border-radius: var(--radius);
  border: 1px solid #2b3140;
  background: var(--surface-container); color: var(--on-surface-variant);
  transition: color 180ms, border-color 180ms;
}
.copy-btn:hover { color: var(--on-surface); border-color: var(--primary); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }

/* ===== Таблицы ===== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; text-align: left; border-collapse: collapse; }
table.data thead tr {
  background: var(--surface-container);
  border-bottom: 1px solid var(--outline-variant);
}
table.data th {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--outline); white-space: nowrap;
}
table.data td { padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--outline-variant); vertical-align: middle; }
table.data tbody tr { transition: background 180ms; }
table.data tbody tr:hover { background: var(--surface-container); }
table.data tbody tr:last-child td { border-bottom: none; }
/* r1-84: виртуализованная таблица результата — внутренняя прокрутка страниц
   (в DOM живёт одна страница строк), шапка прилипает к верху контейнера. */
.table-virt { max-height: 72vh; overflow: auto; }
.table-virt thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-container); }
.num { text-align: right; white-space: nowrap; }

/* ===== Чипы статусов ===== */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: var(--surface-container);
  font-family: var(--font-code); font-size: 0.75rem; white-space: nowrap;
}
.chip.text-green { background: rgba(78, 203, 113, 0.13); color: var(--green); }
.chip.text-red { background: rgba(239, 106, 106, 0.13); color: var(--red); }
.chip.text-yellow { background: rgba(232, 180, 74, 0.13); color: var(--yellow); }
.chip.text-primary { background: var(--primary-soft); color: var(--primary-hover); }

/* ===== Карточки товаров ===== */
.market-layout { display: grid; grid-template-columns: 240px 1fr; gap: var(--space-md); align-items: start; }
@media (max-width: 900px) { .market-layout { grid-template-columns: 1fr; } }
.filters { position: sticky; top: 60px; display: flex; flex-direction: column; }
@media (max-width: 900px) { .filters { position: static; } }
.cat-item {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 7px var(--space-sm); border-radius: var(--radius);
  color: var(--on-surface-variant); text-align: left;
  transition: background 180ms, color 180ms;
}
.cat-item:hover { background: var(--surface-container); color: var(--on-surface); }
.cat-item.active { background: var(--surface-container); color: var(--on-surface); box-shadow: inset 2px 0 0 var(--primary); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-md); }
.product-card {
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 180ms;
}
.product-card:hover { border-color: #2b3140; }
.product-card .thumb {
  aspect-ratio: 16/9; background: var(--surface-container);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: var(--outline);
}
.product-card .thumb svg { width: 36px; height: 36px; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .body { padding: var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card .title { font-weight: 600; font-size: 0.9375rem; }
.product-card .desc { color: var(--on-surface-variant); font-size: 0.8125rem; line-height: 1.25rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--space-sm); }
.price { font-family: var(--font-code); font-weight: 600; font-size: 0.9375rem; }

/* ===== Формы ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--on-surface-variant); }
.input, .select, .textarea {
  width: 100%;
  background: var(--surface-container);
  border: 1px solid #2b3140;
  border-radius: var(--radius);
  color: var(--on-surface);
  padding: 0 var(--space-md);
  height: 38px;
  font-family: var(--font-code); font-size: 0.8125rem;
  transition: border-color 180ms, box-shadow 180ms;
}
.textarea { height: auto; padding: var(--space-sm) var(--space-md); resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.invalid { border-color: var(--error-container); }
.input::placeholder { color: var(--outline); }
.select { font-family: var(--font-ui); }
.field-error { display: flex; align-items: center; gap: 4px; color: var(--error); font-size: 0.75rem; }
.hint { display: flex; align-items: center; gap: 6px; color: var(--outline); font-size: 0.8125rem; }

/* ===== Экран входа ===== */
.auth-shell { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-lg); }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  display: flex; flex-direction: column; gap: var(--space-md);
}
.auth-header { position: fixed; top: 0; left: 0; right: 0; height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-lg); }
.auth-footer { position: fixed; bottom: 0; left: 0; right: 0; height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-lg); color: var(--outline); font-size: 0.75rem; }

.token-display {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  background: var(--surface-container);
  border: 1px solid #2b3140;
  border-radius: var(--radius);
  padding: 10px var(--space-sm);
  font-family: var(--font-code); font-size: 0.875rem; font-weight: 500;
  user-select: all; word-break: break-all;
}
.warning-strip {
  display: flex; align-items: center; gap: var(--space-sm);
  border-left: 3px solid var(--tertiary);
  background: color-mix(in srgb, var(--tertiary) 10%, transparent);
  padding: 10px var(--space-sm);
  color: var(--tertiary);
  font-size: 0.8125rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.checkline { display: flex; align-items: center; gap: var(--space-sm); color: var(--on-surface-variant); cursor: pointer; }
.checkline input { accent-color: var(--primary); width: 15px; height: 15px; }

/* ===== Услуги: список карточек ===== */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-md); }
.service-card {
  display: flex; flex-direction: column; gap: var(--space-sm);
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  transition: border-color 180ms, transform 180ms;
}
.service-card.clickable:hover { border-color: var(--primary); }
.service-card .svc-icon {
  width: 42px; height: 42px; border-radius: var(--radius-md); flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-hover);
}
.service-card .svc-icon svg { width: 20px; height: 20px; }
.service-card h2 { font-family: var(--font-display); }
.svc-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-top: auto; padding-top: var(--space-sm); border-top: 1px solid var(--outline-variant); }

/* Мастер запуска услуги */
.steps { display: flex; gap: var(--space-sm); }
.step {
  flex: 1; display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md); border-radius: var(--radius);
  background: var(--surface-container-low); border: 1px solid var(--outline-variant);
  font-size: 0.875rem; color: var(--outline); font-weight: 500;
}
.step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-container-high); font-size: 0.75rem; font-family: var(--font-code); flex: none; }
.step.active { border-color: var(--primary); color: var(--on-surface); }
.step.active .n { background: var(--primary); color: #fff; }
.step.done { color: var(--on-surface-variant); }
.step.done .n { background: rgba(78, 203, 113, 0.13); color: var(--green); }

/* ===== Заказы: список ===== */
.order-item {
  display: grid; grid-template-columns: 88px 1fr auto auto; gap: var(--space-md); align-items: center;
  background: var(--surface-container-low); border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
  padding: var(--space-md) var(--space-lg); cursor: pointer;
  transition: border-color 180ms, background 180ms;
}
.order-item:hover { border-color: #2b3140; background: var(--surface-container); }
.order-item + .order-item { margin-top: var(--space-sm); }
.order-item.expanded { border-color: var(--primary); }
.oi-id { font-family: var(--font-code); font-weight: 600; font-size: 0.875rem; }
.oi-main { min-width: 0; }
.oi-title { font-weight: 600; font-size: 0.875rem; }
.oi-sub { font-size: 0.75rem; color: var(--outline); margin-top: 2px; overflow-wrap: anywhere; }
.oi-amount { font-family: var(--font-code); font-weight: 600; text-align: right; }
.oi-amount small { display: block; color: var(--outline); font-weight: 400; }

/* Рабочий стол заказа (детали, раскрытые под карточкой) */
.order-focus-slot { margin-top: var(--space-sm); }
.order-head {
  background: linear-gradient(160deg, var(--surface-container-low) 0%, var(--surface-container) 100%);
  border: 1px solid var(--outline-variant); border-radius: var(--radius-xl);
  padding: var(--space-lg);
}
.order-head-top { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-md); }
.order-id { font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; }
.order-head-actions { margin-left: auto; display: flex; gap: var(--space-sm); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-sm); }
.kpi { background: var(--surface-container); border: 1px solid var(--outline-variant); border-radius: var(--radius); padding: var(--space-sm) var(--space-md); }
.kpi .v { font-family: var(--font-code); font-size: 1.125rem; font-weight: 600; }
.kpi .k { font-size: 0.75rem; color: var(--outline); margin-top: 2px; }
.kpi.ok .v { color: var(--green); }
.kpi.bad .v { color: var(--red); }
.kpi.accent .v { color: var(--primary-hover); }

/* Панель действий над выбранными строками результата */
.action-bar {
  position: sticky; bottom: var(--space-md); z-index: 20;
  display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface-container-high) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid #2b3140; border-radius: var(--radius-xl);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-lg);
  margin-top: var(--space-md);
}
.ab-summary { display: flex; flex-direction: column; }
.ab-summary b { font-size: 0.875rem; }
.ab-summary span { font-size: 0.75rem; color: var(--on-surface-variant); font-family: var(--font-code); }
.ab-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-left: auto; }

/* ===== Выдача / заказ ===== */
.status-line { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.order-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-sm) var(--space-lg); }
.order-meta .k { font-size: 0.75rem; text-transform: uppercase; color: var(--outline); }
.order-meta .v { font-family: var(--font-code); font-size: 0.8125rem; margin-top: 2px; }

.delivery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-md); }
.delivery-card {
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  display: flex; flex-direction: column; gap: var(--space-sm);
}
.delivery-card .kind { font-size: 0.75rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--primary); }
.delivery-card .content {
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  padding: var(--space-sm);
  font-family: var(--font-code); font-size: 0.8125rem;
  white-space: pre-wrap; word-break: break-all;
  max-height: 120px; overflow: auto;
}

/* ===== Пустые состояния / скелетоны ===== */
.empty { padding: var(--space-xl) var(--space-md); text-align: center; color: var(--outline); display: flex; flex-direction: column; align-items: center; gap: var(--space-sm); }
.empty svg { width: 32px; height: 32px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-container); border-radius: var(--radius); }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--on-surface) 6%, transparent), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--outline-variant); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Тосты ===== */
#toasts { position: fixed; bottom: var(--space-lg); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: var(--space-sm); max-width: min(560px, 92vw); }
.toast {
  display: flex; align-items: center; gap: var(--space-sm);
  background: var(--surface-container-high);
  border: 1px solid #2b3140;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.8125rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms ease-out;
}
.toast.error { border-left-color: var(--error); }
.toast.success { border-left-color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Модалка ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 6, 10, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: var(--space-lg);
  animation: fade-in 150ms ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal {
  width: 100%; max-width: 480px;
  background: var(--surface-container);
  border: 1px solid #2b3140;
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-md);
  max-height: 86dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: rise-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
/* Широкая модалка с таблицей результата прогона */
.modal:has(table.data) { max-width: min(1100px, 94vw); }

/* ===== Пагинация ===== */
.pager { display: flex; align-items: center; gap: var(--space-sm); justify-content: flex-end; padding: var(--space-sm) var(--space-md); }

/* ===== Футер страницы ===== */
.page-foot { display: flex; justify-content: space-between; gap: var(--space-md); color: var(--outline); font-family: var(--font-code); font-size: 0.75rem; padding: 0 var(--space-xs); flex-wrap: wrap; }

/* ---------- Админ-панель: мониторинг, алерты, бэкапы ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--space-sm); }
.stat-card {
  background: var(--surface-container-low, var(--surface));
  border: 1px solid var(--outline-variant); border-radius: var(--radius-md, 6px);
  padding: var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.stat-card .mono { font-family: var(--font-code); }
.alert-row {
  display: flex; align-items: flex-start; gap: var(--space-sm);
  padding: var(--space-sm) 0; border-bottom: 1px solid var(--outline-variant);
}
.alert-row:last-child { border-bottom: none; }
.alert-row.acked { opacity: 0.6; }
.alert-row .dot { margin-top: 6px; flex-shrink: 0; }

/* Переключатель языка интерфейса (EN/RU). */
.lang-switch {
  display: inline-flex; align-items: center;
  gap: 6px;
  letter-spacing: 0.04em;
  color: var(--on-surface-variant);
}
.lang-switch:hover { color: var(--on-surface); }
.lang-switch svg { display: block; }
.lang-code { font-family: var(--font-code); font-size: 11px; font-weight: 600; }

/* ===== Адаптив ===== */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; height: 100dvh;
    transform: translateX(-100%); transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
    padding-top: 64px;
  }
  .side.open { transform: translateX(0); }
  .topbar { z-index: 50; }
  .burger { display: grid; }
  .page { padding: var(--space-md); }
  .topbar { padding: var(--space-sm) var(--space-md); }
  .order-item { grid-template-columns: 1fr auto; }
  .oi-id { align-self: start; }
  .oi-main { grid-column: 1 / -1; grid-row: 2; }
  .oi-amount { grid-column: 1; text-align: left; }
  .oi-status { grid-row: 1; grid-column: 2; justify-self: end; align-self: start; }
  .steps { flex-direction: column; }
  #app > .topbar { position: static; }
  #app > .topbar ~ main { padding-top: var(--space-md); }
}

/* r1-100: статьи мануалов — код-блоки и типографика тела */
.manual-body h2 { margin: var(--space-md) 0 var(--space-sm); }
.manual-body h3, .manual-body h4 { margin: var(--space-sm) 0 var(--space-xs); }
.manual-body p { margin: var(--space-sm) 0; }
.manual-body ul, .manual-body ol { margin: var(--space-sm) 0 var(--space-sm) var(--space-lg); }
.manual-code {
  background: var(--surface-variant, rgba(127,127,127,.08));
  border: 1px solid var(--outline-var, rgba(127,127,127,.25));
  border-radius: var(--radius-sm, 6px);
  padding: var(--space-sm) var(--space-md);
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.8125rem;
  line-height: 1.4;
  margin: var(--space-sm) 0;
}
.manual-body code { font-family: var(--font-code); font-size: 0.875em; background: rgba(127,127,127,.12); border-radius: 4px; padding: 0 .25em; }
.manual-body .manual-code code { background: none; padding: 0; }
