:root {
  --brand: #e8562f;
  --brand-dark: #cf461f;
  --brand-soft: #fdece3;
  --text: #2b241d;
  --text-secondary: #6b6058;
  --muted: #94897d;
  --border: #eee2d4;
  --bg: #fbf5ec;
  --surface: #fffdf9;
  --blue: #2a78d6;
  --blue-soft: #eaf1fc;
  --good: #1f9254;
  --good-soft: #e6f5ec;
  --warning: #d98a12;
  --warning-soft: #fdf1de;
  --serious: #ec835a;
  --serious-soft: #fdece4;
  --critical: #d0503b;
  --critical-soft: #fbe9e3;
  --info-soft: #eaf1fc;
  --violet: #7a5ac9;
  --violet-soft: #f1ecfb;
  --aqua: #1a9a72;
  --aqua-soft: #e5f5ee;
  --yellow: #b5790a;
  --yellow-soft: #fbf1de;
  --magenta: #c65c85;
  --magenta-soft: #fbebf1;
  --sidebar-w: 240px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(120, 90, 60, 0.05), 0 4px 14px rgba(120, 90, 60, 0.06);
  --shadow-pop: 0 8px 24px rgba(120, 90, 60, 0.12);
}

/* палитра для аватаров/акцентов, назначается по остатку от id — чтобы у
   одного и того же клиента цвет был стабильным между перезагрузками */
.avatar-0 { background: var(--blue-soft); color: var(--blue); }
.avatar-1 { background: var(--aqua-soft); color: var(--aqua); }
.avatar-2 { background: var(--violet-soft); color: var(--violet); }
.avatar-3 { background: var(--magenta-soft); color: var(--magenta); }
.avatar-4 { background: var(--yellow-soft); color: var(--yellow); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: proportional-nums;
}

/* ---- shell / sidebar ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 28px; }
.brand-text { font-weight: 700; font-size: 15.5px; }

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.side-nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.side-nav a.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(232, 86, 47, 0.3); }
.side-nav a svg { flex-shrink: 0; }

.logout-form { margin-top: auto; }
.logout-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.logout-btn:hover { background: var(--bg); }

.content-area { flex: 1; min-width: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 34px 38px; }

/* ---- headings / layout ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
.subtle { color: var(--muted); font-size: 13px; }

.tab-bar { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab-bar a {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: background 0.15s ease;
}
.tab-bar a:hover { color: var(--text); background: var(--brand-soft); }
.tab-bar a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- buttons ---- */
.btn {
  background: var(--brand);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-block;
  box-shadow: 0 2px 8px rgba(232, 86, 47, 0.28);
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(232, 86, 47, 0.35); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--brand-soft); transform: none; box-shadow: none; }
.btn-small { padding: 9px 15px; font-size: 13px; }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; text-decoration: none; display: inline-block; }
.btn-icon:hover { color: var(--critical); }
.confirm-armed {
  color: var(--critical) !important;
  font-weight: 700;
}
.btn-icon.confirm-armed {
  font-size: 11px;
  background: var(--critical-soft) !important;
  padding: 4px 8px;
  border-radius: 999px;
  animation: confirm-pulse 0.9s ease-out;
}
button.confirm-armed:not(.btn-icon) {
  background: var(--critical) !important;
  color: #fff !important;
  border-color: var(--critical) !important;
}
@keyframes confirm-pulse {
  0% { box-shadow: 0 0 0 0 rgba(208, 80, 59, 0.5); }
  100% { box-shadow: 0 0 0 8px rgba(208, 80, 59, 0); }
}
.row-actions { display: flex; gap: 10px; align-items: center; }
.item-name-cell { display: flex; gap: 10px; align-items: center; }
.url-fetch-row { display: flex; gap: 8px; }
.url-fetch-row input { flex: 1; min-width: 0; }
.btn-fetch {
  flex-shrink: 0;
  background: var(--info-soft); color: var(--blue);
  border: none; border-radius: var(--radius-sm); padding: 0 12px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-fetch:hover { background: #dcebfb; }
.btn-fetch:disabled { opacity: 0.7; cursor: default; }
.item-thumb { width: 34px; height: 34px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.file-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.file-field input[type="file"] { font-size: 12.5px; }
.file-field .item-thumb { width: 60px; height: 60px; margin-bottom: 4px; }

.item-thumb[data-lightbox] { cursor: zoom-in; }
.lightbox-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 14, 8, 0.72);
  align-items: center; justify-content: center;
  padding: 40px; cursor: zoom-out;
}
.lightbox-overlay.is-open { display: flex; }
.lightbox-overlay img {
  max-width: 420px; max-height: 420px; width: auto; height: auto;
  object-fit: contain; background: #fff;
  border-radius: var(--radius-md); box-shadow: var(--shadow-pop);
}

.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- tables (used where a real dense grid still helps) ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-card);
}
.table th, .table td { padding: 13px 16px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--brand-soft); }
.table a { color: var(--text); text-decoration: none; font-weight: 600; }
.table a:hover { color: var(--brand); }

/* ---- status chips (fixed semantic palette — never themed) ---- */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-collecting { background: var(--info-soft); color: var(--blue); }
.status-in_transit { background: var(--warning-soft); color: #9a6b00; }
.status-delivered { background: var(--good-soft); color: var(--good); }

.type-badge { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.type-personal { background: var(--violet-soft); color: var(--violet); }
.type-individual { background: var(--blue-soft); color: var(--blue); }
.type-group { background: var(--aqua-soft); color: var(--aqua); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.name-with-avatar { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.name-with-avatar:hover .entity-card-title { color: var(--brand); }

/* ---- empty state ---- */
.empty {
  padding: 56px 32px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
}

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 15px; max-width: 480px; }
.form-wide { max-width: 760px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.form input, .form select, .form textarea {
  font-size: 14px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; color: var(--text); background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.form textarea { min-height: 70px; resize: vertical; }

.form-columns { display: flex; gap: 32px; max-width: none; }
.form-columns .form-section { flex: 1; }
.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section h3 { margin: 0 0 4px; font-size: 14px; }

.form-inline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; max-width: none; margin-top: 16px; align-items: center; }
.form-inline-grid input, .form-inline-grid select { font-size: 13px; padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

.inline-form { display: inline-block; }
.inline-form select { font-size: 13px; padding: 7px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.inline-form-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.new-folder-form { margin-top: 0; margin-bottom: 20px; }
.new-folder-form input { min-width: 240px; }
.inline-form-row input, .inline-form-row select { font-size: 13px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ---- blocks / cards ---- */
.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 26px; margin-bottom: 22px; box-shadow: var(--shadow-card); }

.rules-block { max-width: 760px; }
.rules-intro { margin: 0 0 18px; font-size: 14px; }
.rules-list { display: flex; flex-direction: column; gap: 14px; margin: 0; padding-left: 24px; }
.rules-list li { font-size: 14px; line-height: 1.55; padding-left: 4px; }
.rules-list li::marker { color: var(--critical); font-weight: 700; }
.block h2 { font-size: 15px; margin: 0 0 14px; }
.sub-block { margin-bottom: 14px; }
.sub-block a { color: var(--text); font-weight: 600; text-decoration: none; }
.plain-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

.chip-list { list-style: none; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chip-list a { padding: 5px 14px 5px 5px; background: var(--bg); border-radius: 999px; text-decoration: none; color: var(--text); font-size: 13px; font-weight: 600; }
.chip-list .avatar { width: 22px; height: 22px; font-size: 11px; }

/* ---- KPI / totals cards ---- */
.totals-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.totals-card {
  flex: 1; min-width: 160px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 17px 21px; display: flex; flex-direction: column; gap: 5px;
  box-shadow: var(--shadow-card);
}
.totals-card span { color: var(--muted); font-size: 12.5px; }
.totals-card strong { font-size: 23px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.totals-card.accent strong { color: var(--brand); }
.totals-card.tint-blue { background: var(--blue-soft); border-color: transparent; }
.totals-card.tint-blue strong { color: var(--blue); }
.totals-card.tint-green { background: var(--good-soft); border-color: transparent; }
.totals-card.tint-green strong { color: var(--good); }

.link-box input { width: 100%; padding: 11px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--bg); }
.link-box-row { display: flex; gap: 10px; }
.link-box-row input { flex: 1; }
.link-small { font-size: 12px; color: var(--brand); text-decoration: none; }

.debt-positive { color: var(--critical); font-weight: 600; }
.debt-card { background: var(--critical-soft); border-color: transparent; }

/* ---- card grids: посылки и клиенты ---- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.entity-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.entity-card-title { font-size: 15.5px; font-weight: 700; line-height: 1.3; color: var(--text); text-decoration: none; }
a.entity-card-title:hover { color: var(--brand); }
.entity-card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.entity-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.entity-card-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.entity-card-stat span { display: block; color: var(--muted); font-size: 11.5px; }
.entity-card-stat strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.entity-card-stat.is-debt strong { color: var(--critical); }
.entity-card-stat.is-profit strong { color: var(--good); }
.entity-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.entity-card-foot select { font-size: 12.5px; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; max-width: 130px; }
.card-actions { display: flex; gap: 4px; }

/* ---- dashboard charts ---- */
.chart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-card); }
.chart-card h2 { font-size: 14px; margin: 0 0 16px; color: var(--text); }
.chart-card canvas { max-width: 100%; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

.debt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.debt-list li { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; padding: 4px 0; }
.debt-list a { color: var(--text); text-decoration: none; font-weight: 600; }
.debt-list .amount { font-variant-numeric: tabular-nums; color: var(--critical); font-weight: 600; }

/* ---- onboarding / help ---- */
.help-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(135deg, var(--brand-soft), #fff);
  border: 1px solid var(--brand-soft);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 22px;
}
.help-banner-text strong { display: block; font-size: 15px; margin-bottom: 3px; }
.help-banner-text span { color: var(--text-secondary); font-size: 13px; }
.help-banner .btn-secondary { background: #fff; }

.onboarding-block { background: linear-gradient(135deg, var(--brand-soft), #fff); border-color: var(--brand-soft); }
.onboarding-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.onboarding-header strong { font-size: 15.5px; margin-right: 8px; }
.onboarding-header a { text-decoration: none; font-weight: 600; }
.onboarding-header a:hover { color: var(--brand); }

.onboarding-progress { height: 7px; border-radius: 999px; background: #fff; overflow: hidden; margin-bottom: 18px; }
.onboarding-progress-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.3s ease; }

.onboarding-tasks { display: flex; flex-direction: column; gap: 4px; }
.onboarding-task {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.onboarding-task:last-child { border-bottom: none; }
.onboarding-check {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: #fff; color: var(--muted); border: 1.5px solid var(--border);
}
.onboarding-task.is-done .onboarding-check { background: var(--good); color: #fff; border-color: var(--good); }
.onboarding-task-body { flex: 1; min-width: 0; }
.onboarding-task-title { font-size: 14px; font-weight: 600; }
.onboarding-task.is-done .onboarding-task-title { color: var(--muted); text-decoration: line-through; }
.onboarding-task-hint { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.onboarding-task .btn { flex-shrink: 0; }

.onboarding-done { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.onboarding-done strong { display: block; font-size: 15px; margin-bottom: 3px; }

.guide-steps { display: flex; flex-direction: column; gap: 16px; }
.guide-step { display: flex; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-card); }
.guide-step-num {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.guide-step-body h3 { margin: 4px 0 6px; font-size: 15.5px; }
.guide-step-body p { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.guide-step-body code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }
.guide-faq { margin-top: 26px; }
.guide-faq h2 { font-size: 17px; margin-bottom: 14px; }

/* ---- public client page ---- */
.public-topbar { justify-content: center; display: flex; padding: 18px 32px; background: var(--surface); border-bottom: 1px solid var(--border); }
.public-main { max-width: 480px; margin: 0 auto; padding: 22px 16px 48px; }
.public-h1 { font-size: 20px; margin: 4px 0 16px; }

.public-summary {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.public-summary > div { flex: 1; padding: 13px 14px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); }
.public-summary > div:last-child { border-right: none; }
.public-summary span { color: var(--muted); font-size: 11px; }
.public-summary strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.public-summary .debt strong { color: var(--critical); }

.public-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 12px; }

.public-package { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 17px; margin-bottom: 16px; box-shadow: var(--shadow-card); }
.public-package-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.product-list { display: flex; flex-direction: column; gap: 12px; }
.product-card { display: flex; gap: 12px; align-items: center; }
.product-photo {
  width: 54px; height: 54px; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; overflow: hidden;
}
.product-photo img { width: 100%; height: 100%; object-fit: cover; }
.product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.product-name { font-size: 14px; font-weight: 600; }
.product-meta { font-size: 12px; color: var(--muted); }
.product-meta a { color: var(--brand); text-decoration: none; }
.product-price { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.item-status {
  align-self: flex-start;
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  background: var(--info-soft); color: var(--blue);
}
.item-status-delivered { background: var(--good-soft); color: var(--good); }
.item-status-in_transit { background: var(--warning-soft); color: #9a6b00; }
.item-status-problem { background: var(--critical-soft); color: var(--critical); }
.item-status-at_warehouse, .item-status-ordered { background: var(--info-soft); color: var(--blue); }

.public-package-total { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; text-align: right; }

/* ---- login page ---- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 38px 34px; width: 340px; max-width: 100%; box-shadow: var(--shadow-pop); }
.login-card .brand { padding: 0 0 22px; justify-content: center; }
.login-error { background: var(--critical-soft); color: var(--critical); font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; }

/* ---- выбор клиентов для расчёта суммы в юанях ---- */
.cny-summary {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid var(--brand-soft);
  border-radius: var(--radius-md); padding: 12px 18px; margin-bottom: 16px;
  position: sticky; top: 0; z-index: 10; font-size: 13.5px;
}
.cny-summary strong { font-size: 16px; color: var(--brand-dark); }
.cny-checkbox { display: flex; align-items: center; margin-right: 2px; }
.cny-checkbox input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); }

/* ---- сканер штрихкодов/QR ---- */
.scan-reader { max-width: 420px; margin: 0 auto 14px; border-radius: var(--radius-md); overflow: hidden; }
.scan-reader video, .scan-reader img { border-radius: var(--radius-md); }

/* ---- tables: горизонтальная прокрутка вместо переполнения на узких экранах ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-md); }
.table-scroll .table { box-shadow: none; }

/* ---- мобильная навигация: выезжающая панель вместо всегда видимого сайдбара ---- */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 60;
  }
  .mobile-menu-btn {
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    width: 38px; height: 38px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text); cursor: pointer;
  }
  .shell { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-pop);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open {
    display: block;
    position: fixed; inset: 0; background: rgba(20, 14, 8, 0.4); z-index: 90;
  }
  .content-area { width: 100%; }
  main { padding: 20px 16px; }

  .page-header { flex-wrap: wrap; }
  .header-actions { width: 100%; }
  .totals-row { gap: 10px; }
  .totals-card { min-width: 130px; }
  .form-inline-grid { grid-template-columns: 1fr; }
  .form-columns { flex-direction: column; gap: 20px; }
  .card-grid { grid-template-columns: 1fr; }

  .onboarding-task { flex-direction: column; align-items: flex-start; gap: 8px; }
  .onboarding-task .btn { margin-left: 44px; }
  .onboarding-header { flex-direction: column; align-items: flex-start; }
  .entity-card-foot { flex-wrap: wrap; }
  .link-box-row { flex-wrap: wrap; }
  .link-box-row input { flex: 1 1 100%; }
  .url-fetch-row { flex-wrap: wrap; }
  .url-fetch-row input { flex: 1 1 100%; }
}
