:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #0ea5e9;
  --brand-ink: #0369a1;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-ink); text-decoration: none; }
button { font-family: inherit; }

.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar .logo { font-weight: 800; letter-spacing: -0.02em; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.topbar .logo .mark { color: var(--brand); }
.topbar nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.topbar nav a {
  color: #cbd5e1; padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topbar .badge-count {
  background: var(--brand); color: #fff; border-radius: 999px; font-size: 12px;
  min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; font-weight: 700;
}
.topbar .user {
  margin-left: 6px; display: flex; align-items: center; gap: 10px; color: #cbd5e1; font-size: 13px;
}
.topbar .user button {
  background: transparent; border: 1px solid rgba(255,255,255,0.2); color: #e2e8f0;
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px;
}
.topbar .user button:hover { background: rgba(255,255,255,0.1); }

.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 64px; }
.container-wide { max-width: min(1760px, 97vw); margin: 0 auto; padding: 20px 18px 64px; }

/* ---------- Search ---------- */
.searchbar { display: flex; flex-direction: column; gap: 12px; }
.searchbar .row { display: flex; gap: 8px; }
.searchbar input[type='text'] {
  flex: 1; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 14px 16px; font-size: 16px; color: var(--ink);
  box-shadow: var(--shadow);
}
.searchbar input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn {
  border: none; border-radius: 12px; padding: 0 20px; font-weight: 700; font-size: 15px;
  background: var(--brand); color: #fff; cursor: pointer; min-height: 50px;
}
.btn:hover { background: #0284c7; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

.modes { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--brand-ink); color: #fff; border-color: var(--brand-ink); }
/* Главное меню поиска (#2): крупнее обычных чипов — это основной переключатель режима. */
.primary-modes { gap: 8px; margin-top: 2px; }
.primary-modes .chip { font-size: 14px; padding: 9px 18px; }
/* Подпись типа на карточке (#4): Вал / Колесо / Картридж / Турбокомпрессор. */
.type-badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 7px;
  background: #eef2ff; color: #3730a3; border: 1px solid #e0e7ff; white-space: nowrap; }
.type-badge.turbo { background: #ecfeff; color: #155e75; border-color: #cffafe; }

.hint { color: var(--muted); font-size: 13px; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.recent .tag {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--ink-soft);
}

/* ---------- Sections / cards ---------- */
.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  font-weight: 700; margin: 26px 0 10px;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card .head { display: flex; align-items: flex-start; gap: 12px; }
.card .head .title { font-weight: 700; font-size: 16px; }
.card .head .sub { color: var(--ink-soft); font-size: 13px; }
.card .thumb {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #f1f5f9;
  border: 1px solid var(--line); flex: none;
}
.source-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  background: #f1f5f9; color: var(--ink-soft); border-radius: 6px; padding: 2px 7px; border: 1px solid var(--line);
}
.spacer { flex: 1; }

.kv { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kv .pill {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px;
  font-size: 12.5px; color: var(--ink-soft);
}
.kv .pill b { color: var(--ink); font-weight: 700; }

.crosses { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.crosses .num {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px;
  background: #eff6ff; color: var(--brand-ink); border: 1px solid #dbeafe; border-radius: 7px; padding: 3px 8px;
}
.note { margin-top: 10px; color: var(--warn); font-size: 12.5px; }

.card-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Confidence badge ---------- */
.conf { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 700; }
.conf .dot { width: 8px; height: 8px; border-radius: 50%; }
.conf.high { background: var(--ok-bg); color: #166534; }
.conf.high .dot { background: var(--ok); }
.conf.medium { background: var(--warn-bg); color: #92400e; }
.conf.medium .dot { background: var(--warn); }
.conf.low, .conf.manual { background: var(--bad-bg); color: #991b1b; }
.conf.low .dot, .conf.manual .dot { background: var(--bad); }

/* ---------- Turbine composition ---------- */
.turbine-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.turbine-head .model { font-weight: 800; font-size: 17px; }
.comp-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line);
}
.comp-row:first-of-type { border-top: none; }
.comp-row .slot { font-weight: 700; min-width: 120px; }
.comp-row .art { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--ink); }

/* ---------- Forms / auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; border: 1px solid var(--line); }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.auth-card .brandmark { color: var(--brand); }
.auth-card p.lead { color: var(--ink-soft); margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px;
}
.field input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.auth-card .btn { width: 100%; }
.switch { text-align: center; margin-top: 16px; color: var(--ink-soft); font-size: 14px; }
.switch button { background: none; border: none; color: var(--brand-ink); font-weight: 700; cursor: pointer; }
.error-box { background: var(--bad-bg); color: #991b1b; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }

/* ---------- Empty / states ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 50;
}

/* dimensions */
.meas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meas-grid .field { margin: 0; }

/* ---------- Part card v2 (Voltag-like, rich) ---------- */
.pcard { display: flex; gap: 14px; }
.pcard .media { flex: none; width: 120px; }
.pcard .photo {
  width: 120px; height: 120px; border-radius: 12px; object-fit: cover; cursor: zoom-in;
  background: #f1f5f9; border: 1px solid var(--line); display: block;
}
.pcard .photo.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 30px; cursor: default; }
.pcard .thumbs { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.pcard .thumbs img {
  width: 26px; height: 26px; border-radius: 6px; object-fit: cover; cursor: zoom-in;
  border: 1px solid var(--line);
}
.pcard .thumbs .more { width: 26px; height: 26px; border-radius: 6px; background: #f1f5f9;
  display: grid; place-items: center; font-size: 11px; color: var(--ink-soft); border: 1px solid var(--line); }
.pcard .body { flex: 1; min-width: 0; }
.pcard .titleline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pcard .art { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.pcard .type { color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }

.dimtable { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.dimtable .d { display: flex; justify-content: space-between; gap: 8px; font-size: 13px;
  border-bottom: 1px dashed var(--line); padding: 2px 0; }
.dimtable .d .l { color: var(--ink-soft); }
.dimtable .d .v { font-weight: 700; white-space: nowrap; }
.dimtable .d.crit .v { color: var(--brand-ink); }

.brandcross { margin-top: 10px; }
.brandcross .grp { margin-bottom: 5px; }
.brandcross .bn { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; margin-right: 6px; }

.availability { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--ok-bg); color: #166534; border-radius: 8px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.availability.muted { background: #f1f5f9; color: var(--ink-soft); }

.branch { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.branch .bbtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--brand-ink);
  border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.branch .bbtn:hover { background: #f0f9ff; border-color: #bae6fd; }
.branch .bbtn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.branch .bbtn.primary:hover { background: #0284c7; }
.branch .bbtn.added { background: var(--ok-bg); color: #166534; border-color: #bbf7d0; }

.queried-tag { background: var(--warn-bg); color: #92400e; border-radius: 6px; padding: 1px 7px;
  font-size: 11px; font-weight: 700; }

/* breadcrumb / back */
.crumbs { display: flex; align-items: center; gap: 8px; margin: 18px 0 6px; flex-wrap: wrap; }
.crumbs .back { background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--ink); }
.crumbs .back:hover { background: #f8fafc; }
.crumbs .ctx { color: var(--ink-soft); font-size: 14px; }
.crumbs .ctx b { color: var(--ink); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(2,6,23,0.88); z-index: 100;
  display: grid; place-items: center; padding: 24px; }
.lightbox img { max-width: 96vw; max-height: 86vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.lightbox .lb-close { position: fixed; top: 16px; right: 20px; color: #fff; font-size: 30px; cursor: pointer; line-height: 1; }
.lightbox .lb-nav { position: fixed; top: 50%; transform: translateY(-50%); color: #fff; font-size: 44px;
  cursor: pointer; user-select: none; padding: 12px; opacity: 0.8; }
.lightbox .lb-nav:hover { opacity: 1; }
.lightbox .lb-prev { left: 8px; } .lightbox .lb-next { right: 8px; }
.lightbox .lb-count { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: #cbd5e1; font-size: 14px; }

/* diagram */
.diagram-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.diagram-box h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.diagram-box ul { margin: 0; padding-left: 18px; }
.diagram-box li { font-size: 13.5px; margin-bottom: 4px; color: var(--ink-soft); }
.diagram-box li b { color: var(--ink); }
.diagram-box img { max-width: 100%; border-radius: 8px; margin-top: 10px; border: 1px solid var(--line); }

.measline { font-size: 12px; color: var(--muted); margin-top: 3px; }

.dim-instruction { background: #eff6ff; border: 1px solid #dbeafe; color: #0c4a6e; border-radius: 10px;
  padding: 10px 12px; font-size: 13px; margin: 4px 0 12px; }

/* clickable logo */
.topbar .logo { cursor: pointer; }
.topbar .logo:hover { opacity: 0.9; }

/* turbine summary card (part→turbines) */
.summary-card { cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; }
.summary-card:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(14,165,233,0.15); }
.summary-card .apply { margin-top: 8px; color: var(--ink-soft); font-size: 13.5px; }
.summary-card .apply b { color: var(--ink); }
.summary-card .open-hint { margin-top: 10px; color: var(--brand-ink); font-weight: 700; font-size: 13px; }
.summary-card.static { cursor: default; }
.summary-card.static:hover { border-color: var(--line); box-shadow: var(--shadow); }

.cat-badge { font-size: 11px; font-weight: 800; border-radius: 6px; padding: 2px 8px; text-transform: uppercase; letter-spacing: 0.02em; }
.cat-truck { background: #fef3c7; color: #92400e; }
.cat-special { background: #dcfce7; color: #166534; }
.cat-bus { background: #e0e7ff; color: #3730a3; }
.cat-van { background: #f1f5f9; color: var(--ink-soft); }
.cat-passenger { background: #eff6ff; color: var(--brand-ink); }
.cat-unknown { background: #f1f5f9; color: var(--muted); }

.appl-list { margin-top: 10px; display: flex; flex-direction: column; gap: 3px; }
.appl-row { font-size: 13.5px; color: var(--ink-soft); }
.appl-row b { color: var(--ink); }
.appl-row .eng { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--brand-ink); font-size: 12.5px; }
.chip.cat { font-size: 12.5px; }

/* group modal */
.modal { position: fixed; inset: 0; background: rgba(2,6,23,0.5); z-index: 90; display: grid; place-items: center; padding: 18px; }
.modal-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 22px; width: 100%; max-width: 440px; }
.modal-card h3 { margin: 0 0 4px; font-size: 18px; }
.modal-card .msub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 16px; }
.modal-card .label2 { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 14px 0 8px; }
.group-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.group-chips .gc { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 12px; font-size: 13.5px; cursor: pointer; font-weight: 600; }
.group-chips .gc:hover { background: #f0f9ff; border-color: #bae6fd; }
.group-chips .gc.none { color: var(--ink-soft); }
.newgroup { display: flex; gap: 8px; margin-top: 10px; }
.newgroup input { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 14px; }
.modal-card .close-row { margin-top: 18px; text-align: right; }

/* worklist groups */
.wl-search { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.wl-group { margin-bottom: 8px; }
.wl-group .gh { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; }
.wl-group .gh .gname { font-weight: 800; font-size: 16px; }
.wl-group .gh .gcount { background: #f1f5f9; color: var(--ink-soft); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.wl-item-head { display: flex; align-items: center; gap: 10px; }
.wl-group .gh { cursor: pointer; user-select: none; }
.wl-group .gh:hover { color: var(--brand-ink); }
.wl-group .gh .caret { color: var(--muted); font-size: 13px; width: 14px; }

/* free-text dimensions */
.freetext { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; background: #f8fafc; }
.freetext summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--brand-ink); padding: 6px 0; }
.freetext textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace; margin: 8px 0; resize: vertical; }

/* per-param tolerance */
.meas-row { display: flex; gap: 8px; align-items: center; }
.meas-row > input { min-width: 0; }                       /* value field: never forces overflow */
.meas-row > input:first-child { flex: 1 1 auto; }         /* value field stays dominant */
/* tolerance: fixed narrow, optional, visually distinct.
   Selector kept at (0,2,0) so it beats .field input (0,1,1) and the width isn't clobbered. */
.meas-row .tol-input {
  flex: 0 0 88px; width: 88px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 8px; font-size: 13px; text-align: center;
  color: var(--warn); background: var(--warn-bg);
}
.meas-row .tol-input::placeholder { color: var(--warn); opacity: 0.7; }
.meas-row .tol-input:focus { outline: 2px solid var(--warn); border-color: transparent; background: var(--surface); }

@media (max-width: 560px) {
  .topbar nav a span.label { display: none; }
  .meas-grid { grid-template-columns: 1fr; }
  .comp-row .slot { min-width: 90px; }
  .pcard { flex-direction: column; }
  .pcard .media { width: 100%; }
  .pcard .photo { width: 100%; height: 200px; }
  .dimtable { grid-template-columns: 1fr; }
}

/* ===== Подбор Экспертом (фаза 17) ===== */
.ex-wrap { max-width: 860px; margin: 0 auto; }
.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ex-head h2 { margin: 4px 0; }
.ex-balance { font-size: 14px; }
.ex-balance b { font-size: 16px; }
.ex-guide { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px; padding: 12px 14px; margin: 12px 0; font-size: 13.5px; }
.ex-guide-title { font-weight: 600; margin-bottom: 6px; }
.ex-guide ol { margin: 0; padding-left: 20px; }
.ex-guide li { margin: 3px 0; }
.ex-form { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; margin-bottom: 18px; }
.ex-form label { font-size: 13px; font-weight: 600; color: #475569; margin-top: 4px; }
.ex-form textarea, .ex-reply input, .ex-block textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; box-sizing: border-box; }
.ex-files { font-size: 12.5px; color: #0369a1; }
.ex-submit-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.ex-mine-title { margin: 8px 0; font-size: 15px; }
.ex-list { display: flex; flex-direction: column; gap: 8px; }
.ex-card { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.ex-card:hover { border-color: #94a3b8; background: #f8fafc; }
.ex-card-title { font-weight: 600; }
.ex-card-status { font-size: 13px; color: #475569; white-space: nowrap; }
.ex-detail { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; margin-top: 8px; }
.ex-detail-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ex-chat { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 12px; font-size: 14px; }
.bubble .bubble-who { font-size: 11px; opacity: .7; margin-bottom: 2px; }
.bubble.you { align-self: flex-end; background: #dbeafe; }
.bubble.expert { align-self: flex-start; background: #f1f5f9; }
.bubble.client { align-self: flex-start; background: #ecfccb; }
.bubble.ai { align-self: flex-start; background: #f1f5f9; }
.bubble.system { align-self: center; background: #fef3c7; font-size: 12.5px; }
.ex-reply { display: flex; gap: 8px; margin-top: 8px; }
.ex-reply input { flex: 1; }
.ex-result { border-top: 2px solid #dcfce7; margin-top: 12px; padding-top: 10px; }
.ex-result-title { font-weight: 700; color: #15803d; }
.ex-result-sum { margin: 6px 0; }
.ex-cand { border-left: 3px solid #cbd5e1; padding: 4px 0 4px 10px; margin: 6px 0; }
.conf { font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.conf.high { background: #dcfce7; color: #15803d; }
.conf.medium { background: #fef9c3; color: #a16207; }
.conf.low { background: #fee2e2; color: #b91c1c; }
.ex-working { color: #0369a1; font-size: 13px; padding: 6px 0; }
.ex-tabs { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.ex-block { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.ex-block-t { font-weight: 600; font-size: 13px; color: #475569; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ex-atts a { display: inline-block; margin-right: 10px; font-size: 13px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }
.hist-list { display: flex; flex-direction: column; gap: 2px; }
.hist-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid #f1f5f9; }
.hist-row .tag { cursor: pointer; }
.hist-mode { font-size: 12px; color: #64748b; background: #f1f5f9; border-radius: 6px; padding: 1px 8px; }
.hist-time { margin-left: auto; font-size: 12px; white-space: nowrap; }

/* ---------- Поставщики (фаза 19) ---------- */
.sup-list { display: flex; flex-direction: column; gap: 12px; }
.sup-card { padding: 14px 16px; }
.sup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sup-name { font-weight: 600; font-size: 16px; color: inherit; text-decoration: none; }
.sup-badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; }
.sup-badge.ok { background: #dcfce7; color: #166534; }
.sup-badge.err { background: #fef2f2; color: #b91c1c; }
.sup-badge.off { background: #f1f5f9; color: #64748b; }
.sup-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sup-form input { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; min-width: 190px; font-size: 14px; }
.sup-info { margin-bottom: 10px; font-size: 14px; }
.sup-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.sup-actions .sw { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.supoffers { margin: 8px 0 2px; }
.sup-btn { background: #eff6ff !important; border-color: #bfdbfe !important; color: #0369a1 !important; }
.sup-loading, .sup-empty, .sup-err { font-size: 13px; color: #64748b; padding: 4px 0; }
.sup-err { color: #b91c1c; }
.sup-sumline { font-size: 13px; margin-bottom: 6px; }
.sup-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 2px; }
.sup-table th { text-align: left; font-weight: 500; color: #64748b; padding: 4px 8px; border-bottom: 1px solid #e5e7eb; }
.sup-table td { padding: 5px 8px; border-bottom: 1px solid #f1f5f9; }
.sup-table tr.best td { background: #f0fdf4; }
.sup-table td.price { font-weight: 600; white-space: nowrap; }
.sup-table td.has { color: #166534; }
.sup-table td.muted { color: #94a3b8; }
.sup-anh { font-size: 12px; color: #64748b; margin: 8px 0 2px; }
.sup-sech { font-size: 12px; font-weight: 600; color: #475569; margin: 10px 0 2px; }
.sup-table td.sup-src { color: #4338ca; white-space: nowrap; font-size: 12px; }
.sup-tablewrap { overflow-x: auto; }
.sup-table td.sup-art { white-space: nowrap; font-weight: 500; }
.sup-table td.sup-name { white-space: nowrap; font-weight: 600; color: #0f172a; }
.sup-table td.sup-desc { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; }
.sup-table td.sup-wh { max-width: 220px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; color: #334155; vertical-align: top; }
.sup-table td.sup-dl, .sup-table td.sup-prob { white-space: nowrap; color: #64748b; font-size: 12px; }
/* Единая лента заказов (фаза 2) */
.ord-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.ord-head h2 { margin: 0; }
.ord-table td.ord-date { white-space: nowrap; font-size: 12px; color: #64748b; }
.ord-status { padding: 2px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; color: #1e293b; }
.ord-table td.ord-cmt { max-width: 170px; font-size: 12px; color: #475569; white-space: normal; }
/* Корзина (фаза 2b) */
.cart-add-btn { border: 1px solid #bfdbfe; background: #eff6ff; color: #0369a1; border-radius: 7px; width: 26px; height: 26px; cursor: pointer; font-size: 15px; line-height: 1; }
.cart-add-btn:hover { background: #dbeafe; }
.cart-group { padding: 12px 14px; margin-bottom: 12px; }
.cart-gh { font-size: 14px; margin-bottom: 8px; }
.cart-qty { width: 60px; padding: 4px 6px; border: 1px solid #d1d5db; border-radius: 6px; }
.cart-cmt { width: 100%; min-width: 140px; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 6px; }
.cart-checkout { padding: 14px 16px; }
.cart-grand { font-size: 16px; margin-bottom: 10px; }
.co-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.co-row input, .co-row select { padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }
.co-row input#coComment { flex: 1; min-width: 200px; }
.ord-table td.ord-act { white-space: nowrap; font-size: 12px; }
.ord-req { padding: 2px 8px; border-radius: 6px; background: #fef9c3; color: #854d0e; font-size: 12px; }
.ord-req.err { background: #fef2f2; color: #b91c1c; }
#tp-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.28); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 3000; }
#tp-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cart-add-btn.added { background: #22c55e; border-color: #16a34a; color: #fff; }
.cart-unsel { opacity: 0.5; }
.cart-sel, .cart-selall { width: 16px; height: 16px; cursor: pointer; }
.proc-form { display: flex; gap: 8px; max-width: 640px; }
.proc-form input { flex: 1; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 15px; }
.link-btn { background: none; border: none; color: #0369a1; cursor: pointer; font-size: 12px; padding: 2px 4px; text-decoration: underline; }

/* Фильтры ленты заказов (фаза 19, доработка) */
.ord-filters { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 6px 2px 10px; }
.ordf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 14px; }
.ordf-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ordf-grid input, .ordf-grid select { font: inherit; font-size: 13px; text-transform: none; font-weight: 400; color: var(--ink); padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.ordf-dates { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.ordf-dates input { flex: 1; min-width: 0; }
.ordf-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.ordf-badge { font-size: 12px; color: var(--brand-ink); background: #e0f2fe; padding: 3px 8px; border-radius: 6px; font-weight: 700; }

/* Кнопки в шапке раздела «Заказы» (Excel + Обновить) */
.ord-head-btns { display: inline-flex; gap: 8px; }

/* Пер-поставщик опции оформления в корзине (доставка/адрес/оплата/дата/контакт) */
.co-supplier { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 10px; }
.co-sup-h { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.co-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.co-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.co-row input, .co-row select { font: inherit; font-size: 13px; font-weight: 400; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.co-row label.co-cmt { flex: 1; min-width: 160px; }
.co-row label.co-cmt input { width: 100%; }

/* Кликабельная сортировка заголовков таблицы офферов (проценка + карточки) */
.sup-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sup-table th.sortable:hover { color: var(--ink); text-decoration: underline; }
.sup-table th.sortable.active { color: var(--brand-ink); font-weight: 700; }

/* Аналитика активности (владелец) */
.an-cards { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 16px; }
.an-card { flex: 1; min-width: 130px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.an-card-v { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.an-card-l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-top: 2px; }
.an-table td.an-name { font-weight: 700; white-space: nowrap; }
.an-table td.an-num { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.an-table th { white-space: nowrap; }
