/* ==========================================================================
   ALUBEST Forge — дизайн-система веб-панели (2026-10-02)
   Токены → оболочка → компоненты → совместимость со старыми шаблонами.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-muted: #667085;

  --accent: #2f6fed;
  --accent-hover: #1f5bd6;
  --accent-soft: #eaf1ff;
  --accent-fg: #1849a9;
  --on-accent: #ffffff;

  --ember: #ff6a1a;
  --ember-2: #ffb020;

  --success: #12b76a; --success-fg: #067647; --success-bg: #ecfdf3;
  --warning: #f79009; --warning-fg: #b54708; --warning-bg: #fffaeb;
  --danger:  #f04438; --danger-fg:  #b42318; --danger-bg:  #fef3f2;
  --info:    #2e90fa; --info-fg:    #175cd3; --info-bg:    #eff8ff;
  --neutral-bg: #f2f4f7; --neutral-fg: #344054;

  --side-bg: #0b1020;
  --side-bg-2: #121a2e;
  --side-text: #c2cad8;
  --side-muted: #6b7a93;
  --side-active: #ffffff;
  --side-border: rgba(255,255,255,.07);

  /* Графики — палитра проверена валидатором dataviz (light) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4;
  --status-good: #0ca30c; --status-warning: #fab219; --status-critical: #d03b3b;
  --grid: #e1e0d9;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 20px 40px -12px rgba(16,24,40,.25);
  --ring: 0 0 0 4px rgba(47,111,237,.18);

  --sidebar-w: 264px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0a0d14; --surface: #111622; --surface-2: #151b28; --surface-3: #1c2433;
    --border: #232c3c; --border-strong: #334055;
    --text: #eef2f7; --text-2: #b4bfcd; --text-muted: #8591a5;
    --accent: #5b8cff; --accent-hover: #7aa2ff; --accent-soft: rgba(91,140,255,.14); --accent-fg: #a9c1ff; --on-accent: #0a0d14;
    --success-fg: #47cd89; --success-bg: rgba(18,183,106,.14);
    --warning-fg: #fdb022; --warning-bg: rgba(247,144,9,.14);
    --danger-fg: #f97066;  --danger-bg: rgba(240,68,56,.15);
    --info-fg: #53b1fd;    --info-bg: rgba(46,144,250,.14);
    --neutral-bg: #1c2433; --neutral-fg: #cbd5e1;
    --side-bg: #070a11; --side-bg-2: #0e1420;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --grid: #2c2c2a;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
    --ring: 0 0 0 4px rgba(91,140,255,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d14; --surface: #111622; --surface-2: #151b28; --surface-3: #1c2433;
  --border: #232c3c; --border-strong: #334055;
  --text: #eef2f7; --text-2: #b4bfcd; --text-muted: #8591a5;
  --accent: #5b8cff; --accent-hover: #7aa2ff; --accent-soft: rgba(91,140,255,.14); --accent-fg: #a9c1ff; --on-accent: #0a0d14;
  --success-fg: #47cd89; --success-bg: rgba(18,183,106,.14);
  --warning-fg: #fdb022; --warning-bg: rgba(247,144,9,.14);
  --danger-fg: #f97066;  --danger-bg: rgba(240,68,56,.15);
  --info-fg: #53b1fd;    --info-bg: rgba(46,144,250,.14);
  --neutral-bg: #1c2433; --neutral-fg: #cbd5e1;
  --side-bg: #070a11; --side-bg-2: #0e1420;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --grid: #2c2c2a;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
  --ring: 0 0 0 4px rgba(91,140,255,.25);
}

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 620; letter-spacing: -.01em; margin: 28px 0 12px; }
h3 { font-size: 14px; font-weight: 620; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num, .tabular, td, th { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
i[data-lucide], svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }

/* ---------- Оболочка ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--side-bg); color: var(--side-text);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--side-border); z-index: 60;
  transition: transform .28s var(--ease), width .2s var(--ease);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; color: #fff; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: radial-gradient(120% 120% at 0% 0%, #e9edf5 0%, #9aa6ba 45%, #4a5568 100%);
  color: #0b1020; font-weight: 800; font-size: 13px; letter-spacing: -.02em; position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 4px 14px rgba(0,0,0,.4);
}
.brand .logo::after {
  content: ""; position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--ember-2), var(--ember)); box-shadow: 0 0 12px var(--ember);
  border: 2px solid var(--side-bg);
}
.brand b { display: block; font-size: 15px; letter-spacing: .06em; }
.brand span { display: block; font-size: 11px; color: var(--side-muted); letter-spacing: .02em; }

.search-trigger {
  margin: 4px 14px 10px; display: flex; align-items: center; gap: 10px; width: calc(100% - 28px);
  background: var(--side-bg-2); border: 1px solid var(--side-border); color: var(--side-muted);
  padding: 9px 12px; border-radius: 10px; font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.search-trigger:hover { color: var(--side-text); border-color: rgba(255,255,255,.14); background: var(--side-bg-2); }
.search-trigger kbd { margin-left: auto; font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--side-border); border-radius: 5px; padding: 1px 6px; }

.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; scrollbar-color: #253047 transparent; }
.side-section { margin-top: 14px; }
.side-section > .side-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted);
  padding: 6px 10px; font-weight: 600;
}
.side-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--side-text);
  font-size: 13.5px; font-weight: 500; position: relative; transition: background .15s, color .15s;
}
.side-link svg { opacity: .7; width: 17px; height: 17px; }
.side-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.side-link.active { background: linear-gradient(90deg, rgba(91,140,255,.22), rgba(91,140,255,.06)); color: var(--side-active); }
.side-link.active svg { opacity: 1; color: #8fb0ff; }
.side-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #6f9bff; }
.side-link .count {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px;
  min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px;
}
.sidebar-foot { border-top: 1px solid var(--side-border); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, #5b8cff, #8b5cf6); color: #fff; flex-shrink: 0;
}
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { display: block; color: var(--side-muted); font-size: 11.5px; }
.sidebar-foot a { color: var(--side-muted); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; }
.sidebar-foot a:hover { background: rgba(255,255,255,.06); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; min-width: 0; }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { opacity: .5; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-search { position: relative; }
.top-search input {
  width: 300px; padding: 8px 12px 8px 36px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  font-size: 13px;
}
.top-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; pointer-events: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; position: relative;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); cursor: pointer; padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn .dot {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--bg); animation: pulse 2.2s infinite;
}
.content { padding: 28px; width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }
.only-mobile { display: none !important; }
.scrim { display: none; }
.bottom-nav { display: none; }

body.sidebar-collapsed .sidebar { width: 76px; }
body.sidebar-collapsed .sidebar .brand div:not(.logo),
body.sidebar-collapsed .sidebar .side-title,
body.sidebar-collapsed .sidebar .side-link span,
body.sidebar-collapsed .sidebar .search-trigger span,
body.sidebar-collapsed .sidebar .search-trigger kbd,
body.sidebar-collapsed .sidebar .who { display: none; }
body.sidebar-collapsed .side-link { justify-content: center; }
body.sidebar-collapsed .side-link .count { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 9.5px; }
body.sidebar-collapsed .search-trigger { justify-content: center; }
body.sidebar-collapsed .sidebar-foot { flex-direction: column; }

/* ---------- Заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin: 0; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }

/* ---------- Сетки и утилиты ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.w-full { width: 100%; }
.text-success { color: var(--success-fg); } .text-warning { color: var(--warning-fg); }
.text-danger { color: var(--danger-fg); } .text-info { color: var(--info-fg); }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-head .hint { color: var(--text-muted); font-size: 12.5px; }
.card.flush .card-head { padding: 16px 20px 0; }
.card-foot { border-top: 1px solid var(--border); padding: 12px 20px; background: var(--surface-2); }
.card.interactive { transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
a.card { color: inherit; display: block; }

/* Совместимость: старые .cards/.card .num/.label */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.cards .card { padding: 16px 18px; }
.card .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ---------- KPI ---------- */
.kpi { position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 12.5px; font-weight: 550; }
.kpi .kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); }
.kpi .kpi-icon.warn { background: var(--warning-bg); color: var(--warning-fg); }
.kpi .kpi-icon.danger { background: var(--danger-bg); color: var(--danger-fg); }
.kpi .kpi-icon.ok { background: var(--success-bg); color: var(--success-fg); }
.kpi .kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 10px; line-height: 1.1; }
.kpi .kpi-value small { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-left: 4px; letter-spacing: 0; }
.kpi .kpi-foot { margin-top: 8px; font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; padding: 1px 7px; border-radius: 99px; font-size: 12px; }
.delta.up { color: var(--success-fg); background: var(--success-bg); }
.delta.down { color: var(--danger-fg); background: var(--danger-bg); }
.delta.flat { color: var(--neutral-fg); background: var(--neutral-bg); }

/* ---------- Бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.no-dot::before { display: none; }
.badge-success, .badge-confirmed, .badge-resolved, .badge-closed, .badge-arrived, .badge-done, .badge-approved { background: var(--success-bg); color: var(--success-fg); }
.badge-warning, .badge-created, .badge-open, .badge-medium, .badge-forming, .badge-lotting { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger, .badge-high, .badge-discrepancy, .badge-rejected, .badge-qc_failed, .badge-pour_rejected { background: var(--danger-bg); color: var(--danger-fg); }
.badge-info, .badge-agreed, .badge-investigating, .badge-shipped, .badge-active, .badge-in_transit, .badge-in_lab { background: var(--info-bg); color: var(--info-fg); }
.badge-low, .badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge-live::before { animation: pulse 1.6s infinite; }

/* ---------- Кнопки ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 10px 16px; min-height: 38px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(16,24,40,.08), inset 0 1px 0 rgba(255,255,255,.12);
  transition: background .15s, transform .08s, box-shadow .15s, opacity .15s;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-hover); color: var(--on-accent); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-secondary, button.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover, button.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost, button.btn-ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover, button.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-success, button.btn-success { background: var(--success); color: #fff; }
.btn-success:hover, button.btn-success:hover { background: #0e9f5b; color: #fff; }
.btn-danger, button.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover, button.btn-danger:hover { background: #d92d20; color: #fff; }
.btn-warning, button.btn-warning { background: var(--warning); color: #fff; }
.btn-sm, button.btn-sm { padding: 7px 11px; min-height: 32px; font-size: 12.5px; border-radius: 8px; }
.btn-lg, button.btn-lg { padding: 13px 20px; min-height: 46px; font-size: 15px; border-radius: 12px; }
button.is-loading { position: relative; color: transparent !important; pointer-events: none; }
button.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .7s linear infinite;
}
form.inline { display: inline-flex; }

/* ---------- Формы ---------- */
:where(input:not([type=checkbox], [type=radio], [type=file], [type=hidden])), :where(select), :where(textarea) {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; min-height: 40px;
  transition: border-color .15s, box-shadow .15s; max-width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[type=file] { font: inherit; font-size: 13px; color: var(--text-2); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 12.5px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); border-radius: 8px; padding: 7px 12px; margin-right: 10px; cursor: pointer;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 17px; height: 17px; vertical-align: middle; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
label { font-size: 13px; font-weight: 550; color: var(--text-2); }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea { display: block; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > .lbl { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field .err { font-size: 12px; color: var(--danger-fg); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; align-items: end; }
.input-suffix { position: relative; }
.input-suffix input { width: 100%; padding-right: 44px; }
.input-suffix > em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.input-xl input { font-size: 22px; font-weight: 650; min-height: 56px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* Старые шаблоны: формы в стиле "flex + inline style" — приводим к карточке */
form[style*="display:flex"], form[style*="display: flex"] { align-items: flex-end !important; }

/* ---------- Таблицы ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  font-size: 13.5px;
}
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  background: var(--surface-2); color: var(--text-muted); font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr, table tr { transition: background .12s; }
table tr:hover td { background: var(--surface-2); }
td a { font-weight: 550; }
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
.table-wrap > table { min-width: 100%; }
.card > .table-wrap > table, .card > table { border: none; box-shadow: none; border-radius: 0; }
td.actions, td:last-child form.inline { white-space: nowrap; }
td form.inline + form.inline { margin-left: 6px; }

/* ---------- Пустые состояния и callout ---------- */
.empty {
  color: var(--text-muted); padding: 36px 20px; text-align: center; background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); font-size: 14px;
}
.empty svg { width: 32px; height: 32px; display: block; margin: 0 auto 10px; opacity: .55; }
.callout {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--info-bg); color: var(--info-fg); border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  font-size: 13.5px; margin-bottom: 16px;
}
.callout svg { margin-top: 1px; }
.callout b { color: inherit; }
.callout .callout-body { flex: 1; color: var(--text); }
.callout .callout-body p:last-child { margin: 0; }
.callout.warning { background: var(--warning-bg); color: var(--warning-fg); }
.callout.danger { background: var(--danger-bg); color: var(--danger-fg); }
.callout.success { background: var(--success-bg); color: var(--success-fg); }

/* ---------- Прогресс ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s var(--ease); }
.progress.ok > span { background: var(--success); }
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }
.ring {
  --p: 0; --c: var(--accent); width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; flex-shrink: 0;
  transition: --p .6s;
}
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.ring > * { position: relative; text-align: center; line-height: 1.1; }
.ring b { display: block; font-size: 17px; font-weight: 700; }
.ring span { font-size: 10.5px; color: var(--text-muted); }

/* ---------- Конвейер (pipeline) ---------- */
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 0; position: relative; }
.pipe-stage { position: relative; padding: 16px 14px; display: block; color: inherit; border-radius: 12px; transition: background .15s; }
.pipe-stage:hover { background: var(--surface-2); color: inherit; }
.pipe-stage + .pipe-stage::before {
  content: ""; position: absolute; left: -7px; top: 34px; width: 14px; height: 14px; border-top: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong); transform: rotate(45deg); opacity: .7;
}
.pipe-stage .pi { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); margin-bottom: 10px; }
.pipe-stage.hot .pi { background: linear-gradient(135deg, var(--ember-2), var(--ember)); color: #fff; box-shadow: 0 6px 16px -6px var(--ember); }
.pipe-stage .pv { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.pipe-stage .pv small { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-left: 3px; }
.pipe-stage .pl { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Лента действий ---------- */
.actions-feed { display: flex; flex-direction: column; }
.action-item {
  display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 14px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--border); color: inherit; transition: background .15s;
}
.action-item:first-child { border-top: none; }
.action-item:hover { background: var(--surface-2); color: inherit; }
.action-item .ai-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.action-item.critical .ai-icon { background: var(--danger-bg); color: var(--danger-fg); }
.action-item.warning .ai-icon { background: var(--warning-bg); color: var(--warning-fg); }
.action-item.info .ai-icon { background: var(--info-bg); color: var(--info-fg); }
.action-item.success .ai-icon { background: var(--success-bg); color: var(--success-fg); }
.action-item.critical { box-shadow: inset 3px 0 0 var(--danger); }
.action-item .ai-title { font-weight: 620; font-size: 14px; }
.action-item .ai-detail { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.action-item .ai-cta { font-size: 12.5px; font-weight: 650; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.all-clear { padding: 40px 20px; text-align: center; }
.all-clear .ac-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--success-bg); color: var(--success-fg); }

/* ---------- Лестница эскалации ---------- */
.ladder { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.rung { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.rung.passed { background: var(--accent-soft); color: var(--accent-fg); }
.rung.current { background: var(--accent); color: var(--on-accent); }
.ladder .arrow { color: var(--text-muted); font-size: 11px; opacity: .6; }

/* ---------- Инциденты ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { font-size: 11.5px; opacity: .7; }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-fg); }
.incident {
  display: grid; grid-template-columns: 6px minmax(0,1fr); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); scroll-margin-top: 80px;
}
.incident + .incident { margin-top: 12px; }
.incident .sev-bar { background: var(--neutral-fg); }
.incident.sev-high .sev-bar { background: var(--danger); }
.incident.sev-medium .sev-bar { background: var(--warning); }
.incident.sev-low .sev-bar { background: var(--success); }
.incident.is-resolved { opacity: .72; }
.incident:target { box-shadow: var(--ring), var(--shadow-lg); }
.incident .inc-body { padding: 16px 20px; }
.incident .inc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.incident .inc-title { font-weight: 650; font-size: 15px; }
.incident .inc-meta { color: var(--text-muted); font-size: 12.5px; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.incident .inc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.incident .inc-meta svg { width: 14px; height: 14px; }
.incident .inc-desc { margin: 12px 0; color: var(--text); font-size: 14px; white-space: pre-line; }
.incident .inc-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px dashed var(--border); }

/* ---------- Садки / таймер ---------- */
.load-card { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 18px; align-items: center; }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.step { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--surface-3); color: var(--text-muted); }
.step.done { background: var(--success-bg); color: var(--success-fg); }
.step.now { background: var(--warning-bg); color: var(--warning-fg); }
.step.now::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.select-card {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.select-card:hover { border-color: var(--border-strong); }
.select-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.select-card.blocked { cursor: default; background: var(--surface-2); border-style: dashed; }
.select-card + .select-card { margin-top: 8px; }
.sticky-bar {
  position: sticky; bottom: 16px; z-index: 30; margin-top: 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
}

/* ---------- Живой расчёт веса ---------- */
.calc { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.calc > div { padding: 14px 16px; background: var(--surface-2); }
.calc > div + div { border-left: 1px solid var(--border); }
.calc .cl { font-size: 12px; color: var(--text-muted); font-weight: 550; }
.calc .cv { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.calc .cv.big { color: var(--accent-fg); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: start; padding: 14px 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in .35s var(--ease) both; font-size: 13.5px;
}
.toast .t-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.toast.success .t-icon { background: var(--success-bg); color: var(--success-fg); }
.toast.error .t-icon { background: var(--danger-bg); color: var(--danger-fg); }
.toast.warning .t-icon { background: var(--warning-bg); color: var(--warning-fg); }
.toast.info .t-icon { background: var(--info-bg); color: var(--info-fg); }
.toast b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.toast .t-close { background: none; border: none; box-shadow: none; color: var(--text-muted); padding: 2px; min-height: 0; }
.toast .t-close:hover { background: var(--surface-3); color: var(--text); }
.toast.leaving { animation: toast-out .25s ease-in both; }

/* ---------- Модальные окна / палитра ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 150; background: rgba(8,11,18,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; animation: fade-in .15s both;
}
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop-in .22s var(--ease) both; overflow: hidden; }
.modal .m-body { padding: 22px 22px 8px; }
.modal .m-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--warning-bg); color: var(--warning-fg); margin-bottom: 14px; }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { color: var(--text-2); }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }
.palette { max-width: 620px; }
.palette .p-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette .p-input input { border: none !important; box-shadow: none !important; padding: 4px 0 !important; font-size: 16px !important; flex: 1; background: transparent !important; min-height: 0 !important; }
.palette .p-list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.palette .p-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); cursor: pointer; }
.palette .p-item small { margin-left: auto; color: var(--text-muted); font-size: 11.5px; }
.palette .p-item.sel { background: var(--accent-soft); color: var(--accent-fg); }
.palette .p-hint { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.palette kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 5px; background: var(--surface-2); }

/* ---------- Графики ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.balance-bar { display: flex; height: 18px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.balance-bar > span { display: block; height: 100%; min-width: 3px; transition: flex-grow .6s var(--ease); }
.balance-bar > span:first-child { border-radius: 6px 0 0 6px; }
.balance-bar > span:last-child { border-radius: 0 6px 6px 0; }
.balance-rows { display: grid; gap: 8px; margin-top: 14px; }
.balance-rows .br { display: grid; grid-template-columns: 14px minmax(0,1fr) auto auto; gap: 10px; align-items: center; font-size: 13px; }
.balance-rows .br i { width: 10px; height: 10px; border-radius: 3px; }
.balance-rows .br .v { font-weight: 650; }
.balance-rows .br .p { color: var(--text-muted); width: 52px; text-align: right; }

/* ---------- Ошибки / вход ---------- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-size: 80px; font-weight: 800; letter-spacing: -.05em; line-height: 1; background: linear-gradient(135deg, var(--text), var(--text-muted)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-page .err-icon { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px; display: grid; place-items: center; background: var(--warning-bg); color: var(--warning-fg); }
.error-page .err-icon svg { width: 30px; height: 30px; }

/* ---------- Анимации ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.content > * { animation: rise .45s var(--ease) both; }
.content > *:nth-child(2) { animation-delay: .04s; } .content > *:nth-child(3) { animation-delay: .08s; }
.content > *:nth-child(4) { animation-delay: .12s; } .content > *:nth-child(5) { animation-delay: .16s; }
.content > *:nth-child(n+6) { animation-delay: .2s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Адаптив ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pipeline { grid-template-columns: repeat(4, minmax(0,1fr)); row-gap: 8px; }
  .pipe-stage:nth-child(5)::before { display: none; }
  .top-search input { width: 220px; }
}
@media (max-width: 1024px) {
  .grid-main, .grid-3 { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); width: var(--sidebar-w) !important; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(8,11,18,.5); animation: fade-in .2s both; }
  body.sidebar-collapsed .sidebar .brand div:not(.logo), body.sidebar-collapsed .sidebar .side-title,
  body.sidebar-collapsed .sidebar .side-link span, body.sidebar-collapsed .sidebar .who { display: revert; }
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 96px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-muted);
    background: none; border: none; box-shadow: none; padding: 6px 0; min-height: 0; position: relative;
  }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .dot { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 9.5px; display: grid; place-items: center; padding: 0 4px; }
  .toast-stack { bottom: 84px; right: 16px; left: 16px; max-width: none; }
}
@media (max-width: 720px) {
  h1 { font-size: 21px; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0,1fr); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 10px !important; }
  .kpi .kpi-value { font-size: 24px; }
  .top-search { display: none; }
  .pipeline { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pipe-stage::before { display: none !important; }
  .calc { grid-template-columns: minmax(0,1fr); }
  .calc > div + div { border-left: none; border-top: 1px solid var(--border); }
  .card { padding: 16px; border-radius: 14px; }
  .action-item { grid-template-columns: 36px minmax(0,1fr); padding: 14px 16px; }
  .action-item .ai-cta { grid-column: 2; }
  :where(input:not([type=checkbox], [type=radio], [type=file])), :where(select), :where(textarea) { font-size: 16px; min-height: 44px; } /* без автозума iOS */
  button, .btn { min-height: 44px; }

  /* Таблицы → карточки */
  table.rt { border: none; background: transparent; box-shadow: none; }
  table.rt thead, table.rt tr.rt-head { display: none; }
  table.rt tr { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
  table.rt td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); text-align: right; }
  table.rt td:last-child { border-bottom: none; }
  table.rt td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 550; text-align: left; flex-shrink: 0; max-width: 45%; }
  table.rt td[data-label=""]::before { display: none; }
  table.rt td:empty { display: none; }
  table.rt tr:hover td { background: transparent; }
  .table-wrap { overflow: visible; }
}

/* ---------- Печать ---------- */
@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --text: #000; --border: #ccc; }
  .sidebar, .topbar, .bottom-nav, .toast-stack, .page-head .actions, button { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card, table { box-shadow: none; }
}

/* Сверка образца и PDF спектрометра (2026-10-15, _spectro.html + spectro.js) */
.spectro-panel { display: flex; flex-direction: column; gap: 8px; flex-basis: 100%; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.spectro-code { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spectro-code img { background: #fff; padding: 2px; border-radius: 4px; }
.spectro-hint { font-size: 12px; color: var(--text-muted); }
.spectro-number { font-family: ui-monospace, Consolas, monospace; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.spectro-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.spectro-field input[type=text] { max-width: 360px; font-family: ui-monospace, Consolas, monospace; }
.spectro-status { font-size: 13px; padding: 8px 10px; border-radius: 6px; }
.spectro-ok { background: var(--success-bg); color: var(--success-fg); }
.spectro-bad { background: var(--danger-bg); color: var(--danger-fg); }
.spectro-info { background: var(--info-bg); color: var(--info-fg); }
input.spectro-filled { background: var(--success-bg); color: var(--success-fg); }

/* ---------- Заявка дилера (2026-10-16, sales_order_form.html + order_form.js) ----------
   Для людей, которым трудно с компьютером: крупные цели нажатия (≥44px),
   один выбор за раз (система → цвет → пачки), итог всегда перед глазами. */
.of-top { margin-bottom: 20px; }
.of-dealer { display: flex; gap: 14px; align-items: center; }
.of-dealer-icon, .of-drop > svg { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); padding: 10px; }
.of-dealer-name { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 2px 0; }
.of-upload { padding: 0; }
.of-drop { display: flex; gap: 14px; align-items: center; padding: 18px 20px; cursor: pointer; border: 2px dashed var(--border-strong); border-radius: inherit; height: 100%; transition: border-color .15s, background .15s; }
.of-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.of-drop > svg { background: var(--success-bg); color: var(--success-fg); }
.of-step { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; margin: 18px 0 10px; }
.of-layout > div > .of-step:first-child { margin-top: 0; }
.of-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); font-size: 14px; flex: none; }
.of-systems, .of-colors { display: flex; gap: 8px; flex-wrap: wrap; }
button.of-sys, button.of-color {
  min-height: 52px; padding: 12px 18px; font-size: 16px; font-weight: 650; border-radius: 14px;
  background: var(--surface); color: var(--text); border: 2px solid var(--border); box-shadow: var(--shadow-sm); gap: 10px;
}
button.of-sys:hover, button.of-color:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
button.of-sys.active, button.of-color.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-fg); box-shadow: 0 0 0 1px var(--accent) inset; }
button.of-color { min-height: 46px; font-size: 15px; padding: 10px 14px; }
.of-swatch { width: 24px; height: 24px; border-radius: 7px; border: 1px solid rgba(0,0,0,.18); flex: none; }
.of-badge { font-style: normal; font-size: 12px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--success); color: #fff; display: inline-grid; place-items: center; }
.of-badge:empty { display: none; }
.of-items { display: flex; flex-direction: column; gap: 8px; }
.of-item {
  display: grid; grid-template-columns: minmax(0,1.3fr) auto minmax(110px,.7fr); gap: 14px; align-items: center;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; transition: border-color .15s, background .15s;
}
.of-item.filled { border-color: var(--success); background: var(--success-bg); }
.of-item-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.of-item-name b { font-size: 16px; }
.of-qty { display: flex; align-items: center; gap: 6px; }
.of-qty button { width: 48px; height: 48px; min-height: 48px; padding: 0; font-size: 26px; font-weight: 600; border-radius: 12px; }
.of-qty .of-minus { background: var(--surface-3); color: var(--text); box-shadow: none; }
.of-qty .of-minus:hover { background: var(--border-strong); color: var(--text); }
.of-qty input { width: 76px; height: 48px; text-align: center; font-size: 20px; font-weight: 700; border-radius: 12px; font-variant-numeric: tabular-nums; }
.of-unit { font-size: 13px; color: var(--text-muted); width: 34px; }
.of-result { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.of-result b { font-size: 16px; }
button.of-toggle { background: none; border: none; box-shadow: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
button.of-toggle:hover { background: none; color: var(--accent-hover); }
.of-summary-col { position: relative; }
.of-summary { position: sticky; top: calc(var(--topbar-h) + 16px); }
.of-sum-list { max-height: 46vh; overflow-y: auto; margin: 0 -6px; }
.of-sum-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px dashed var(--border); cursor: default; }
.of-sum-row > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.of-sum-q { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.of-sum-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.of-sum-total div { display: flex; flex-direction: column; }
.of-sum-total b { font-size: 18px; }
.of-bar .of-bar-info { display: flex; flex-direction: column; }
.of-bar .of-bar-info b { font-size: 16px; }
@media (max-width: 1024px) {
  .of-summary { position: static; }
  .of-bar { bottom: 76px; }
}
@media (max-width: 720px) {
  .of-item { grid-template-columns: auto minmax(0,1fr); gap: 10px 12px; }
  .of-item-name { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .of-result { align-items: flex-end; }
  .of-qty button { width: 52px; height: 52px; }
  .of-bar { flex-wrap: nowrap; padding: 10px 12px; gap: 10px; }
  .of-bar .of-bar-info { min-width: 0; flex: 1; }
  .of-bar .of-bar-info b { font-size: 14px; }
  .of-bar .of-bar-info .small { display: none; }
  .of-bar .row { flex-wrap: nowrap; margin-left: 0 !important; }
  .of-bar #of-draft { display: none; }
  .of-bar #of-send { padding: 12px 14px; }
}

/* ---------- Склад ГП, план, этапы ---------- */
.cell-codes { display: flex; gap: 4px; flex-wrap: wrap; }
.cell-code { font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
a.cell-code:hover { background: var(--accent-soft); color: var(--accent-fg); }
.mono { font-family: var(--mono); }
.heat { border-collapse: separate; border-spacing: 3px; }
.heat td, .heat th { padding: 6px 4px; border: none; text-align: center; font-size: 11.5px; min-width: 44px; }
.heat td.lbl, .heat th.lbl { text-align: left; white-space: nowrap; font-size: 12.5px; min-width: 160px; }
.heat td.c { border-radius: 6px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.heat td.c.l1 { background: var(--success-bg); color: var(--success-fg); }
.heat td.c.l2 { background: var(--warning-bg); color: var(--warning-fg); }
.heat td.c.l3 { background: var(--danger-bg); color: var(--danger-fg); font-weight: 700; }
.heat td.c.off { background: transparent; color: var(--text-muted); opacity: .5; }
.heat tr:hover td { background: inherit; }
.spans { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.loc { font-family: var(--mono); font-size: 11px; padding: 6px 4px; text-align: center; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.loc.used { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, 70mm); gap: 4mm; }
.loc-label { width: 70mm; height: 40mm; border: 1px solid #000; border-radius: 3mm; display: flex; align-items: center; gap: 3mm; padding: 3mm; background: #fff; color: #000; break-inside: avoid; }
.loc-label img { width: 32mm; height: 32mm; }
.loc-label b { font-family: var(--mono); font-size: 7mm; letter-spacing: .3mm; display: block; }
.timeline { display: flex; gap: 0; flex-wrap: wrap; }
.tl-step { flex: 1; min-width: 130px; padding: 10px 12px; border-top: 4px solid var(--border); }
.tl-step.done { border-color: var(--success); }
.tl-step.now { border-color: var(--warning); }
.tl-step.late { border-color: var(--danger); }
.tl-step b { display: block; font-size: 13px; }

/* ---------- Склад ГП: шахматка «профиль × цвет» ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); }
.seg a, .seg button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--text-2); background: transparent; border: none; box-shadow: none; min-height: 0; cursor: pointer; }
.seg a svg, .seg button svg { width: 15px; height: 15px; }
.seg .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.mx-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.mx-sys-tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; }
.mx-sys-tabs .chip { cursor: pointer; }
#mx-q { flex: 1 1 220px; max-width: 360px; }
.mx-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.mx-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 16px 10px; font-size: 12px; color: var(--text-2); }
.mx-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mx-legend small { font-size: .8em; color: var(--text-muted); }
.lg { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); position: relative; display: inline-block; }
.lg.h3 { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.mx-sys { padding: 0 16px 16px; }
.mx-title { margin: 8px 0; font-size: 14px; }
.mx-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid var(--border); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table.mx { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; border: none; box-shadow: none; border-radius: 0; font-variant-numeric: tabular-nums; }
.mx th, .mx td { padding: 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--surface); }
.mx thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); padding: 8px 6px; vertical-align: bottom; }
.mx tfoot th, .mx tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--surface-2); font-weight: 700; }
.mx .mx-rh { position: sticky; left: 0; z-index: 1; text-align: left; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--text);
  min-width: 150px; max-width: 220px; white-space: normal; line-height: 1.25; box-shadow: 1px 0 0 var(--border-strong); }
.mx th { text-transform: none; letter-spacing: 0; }
.mx thead .mx-rh, .mx tfoot .mx-rh { z-index: 3; }
.mx-ch { min-width: 76px; text-align: center; }
.mx-ch .of-swatch { width: 18px; height: 18px; border-radius: 5px; display: block; margin: 0 auto 4px; }
.mx td.mx-c, .mx td.mx-na, .mx td.mx-tot { text-align: center; padding: 8px 6px; font-size: 15px; font-weight: 600; min-width: 76px; position: relative; }
.mx td.mx-c { cursor: pointer; }
.mx td.mx-c:hover, .mx td.mx-c:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }
.mx td.mx-na { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface) 4px 8px); }
.mx td.mx-tot, .mx th.mx-tot { background: var(--surface-2); font-weight: 700; }
.mx tr:hover th.mx-rh, .mx tr:hover td.mx-c:not([class*=" h"]) { background: var(--surface-2); }
.mx td.h1 { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.mx td.h2 { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); }
.mx td.h3 { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); }
.mx td.h4 { background: color-mix(in srgb, var(--accent) 40%, var(--surface)); }
.mx-c small, .mx-tot small { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-left: 1px; }
.mx-0 { color: var(--text-muted); opacity: .5; font-weight: 400; }
.mx-c.debt::after, .lg.debt::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 9px 9px 0; border-color: transparent var(--danger) transparent transparent; }
.mx-c.held, .lg.held { box-shadow: inset 0 0 0 2px var(--warning); }
.mx-c.prod::before, .lg.prod::before { content: ""; position: absolute; top: 4px; left: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--info); }
.mx .u-pc, .mx .u-kg, .mx-unit-pc .u-pk-only, .mx-unit-kg .u-pk-only { display: none; }
.mx-unit-pc .mx .u-pk, .mx-unit-kg .mx .u-pk { display: none; }
.mx-unit-pc .mx .u-pc, .mx-unit-kg .mx .u-kg { display: inline; }
.mx-hide-empty .mx tr.z, .mx-hide-empty .mx .zc { display: none; }
.mx-dlg { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.mx-dlg::backdrop { background: rgba(10,13,20,.45); }
.mx-dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 0 0 12px; }
.mx-dlg-head h3 { margin: 0; font-size: 17px; }
.mx-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 14px; }
.mx-stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px; color: var(--text-muted); }
.mx-stats b { display: block; font-size: 17px; color: var(--text); }
.mx-stats .bad b { color: var(--danger-fg); }
.mx-stats .ok b { color: var(--success-fg); }
.mx-dlg-sub { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.mx-dlg .cell-code { font-size: 13px; padding: 5px 9px; }
.mx-dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
@media (max-width: 640px) {
  .mx .mx-rh { min-width: 120px; max-width: 140px; font-size: 12px; padding: 6px 8px; }
  .mx td.mx-c, .mx td.mx-na, .mx td.mx-tot, .mx-ch { min-width: 62px; font-size: 14px; }
  .mx-sys { padding: 0 8px 12px; }
  .mx-sys-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .mx-sys-tabs .chip { flex: none; }
  .mx-bar { gap: 8px; }
  .mx-legend { font-size: 11px; gap: 4px 10px; }
}
@media print {
  .mx-bar, .mx-legend .muted, .mx-dlg { display: none !important; }
  .mx-wrap { max-height: none; overflow: visible; }
  .mx th, .mx td { position: static !important; }
}
