/* Тема CRM поставок ЛифтПрома: форма как в CRM ASAP (Manrope, карточки 12/16 px, мягкие тени), цвета ЛифтПрома
   (синий #0F86E6, кнопки #0B6CC0 под белый текст), светлая и тёмная схемы на токенах. Подключается после styles.css
   и только переопределяет внешний вид — разметка, id и логика app.js не меняются. Меню на телефоне и переключатель темы — ui.js. */
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("brand/fonts/manrope-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("brand/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("brand/fonts/manrope-rub.woff2") format("woff2"); unicode-range: U+20BD; }

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --field: #ffffff;
  --hover: #f6f8fa;
  --ink: #111418;
  --ink-2: #3b434b;
  --muted: #69727c;
  --line: #e2e6ea;
  --line-soft: #edf0f3;
  --hover-line: #d2d9e0;
  --fill: #f1f3f6;
  --fill-2: #e7ebef;
  --seg-bg: #e9ecf0;
  --seg-active: #ffffff;
  --shade: rgba(17, 20, 24, .32);
  --blue: #0b6cc0;
  --green: #1a7a48;
  --amber: #8a5300;
  --red: #b42318;
  --soft-blue: #e8f3fd;
  --soft-green: #eaf7ef;
  --soft-amber: #fff6e3;
  --soft-red: #fef3f2;
  --green-line: #bfe3cc;
  --amber-line: #f1dfb6;
  --red-line: #f1c6c0;
  --danger-hover: #fde2df;
  --overdue: #fffafa;
  --brand: #0b6cc0;
  --brand-hover: #0858a8;
  --brand-ink: #ffffff;
  --accent: #0f86e6;
  --brand-text: #0b6cc0;
  --brand-soft: #e8f3fd;
  --brand-line: #b9dcf8;
  --r: 12px;
  --r-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(17, 20, 24, .05);
  --shadow-hover: 0 1px 2px rgba(17, 20, 24, .05), 0 10px 24px -14px rgba(17, 20, 24, .28);
  --shadow-pop: 0 22px 44px -20px rgba(17, 20, 24, .32), 0 2px 6px rgba(17, 20, 24, .06);
  --shadow-modal: 0 28px 64px -24px rgba(17, 20, 24, .45), 0 0 0 1px rgba(17, 20, 24, .05);
  --ring: 0 0 0 3px rgba(15, 134, 230, .24);
}

/* тёмная тема: data-theme ставит скрипт в <head> до CSS (выбор из localStorage, иначе системная) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1116;
  --panel: #151a21;
  --panel-2: #1a2029;
  --field: #10151b;
  --hover: #1c232c;
  --ink: #e6ebf0;
  --ink-2: #c1c9d2;
  --muted: #8d97a3;
  --line: #29313a;
  --line-soft: #20272f;
  --hover-line: #3a4550;
  --fill: #1f262f;
  --fill-2: #2a323c;
  --seg-bg: #10151b;
  --seg-active: #262e38;
  --shade: rgba(0, 0, 0, .58);
  --blue: #6cbcff;
  --green: #5ccf8c;
  --amber: #f0bd5e;
  --red: #ff8a80;
  --soft-blue: rgba(42, 163, 255, .14);
  --soft-green: rgba(63, 185, 110, .14);
  --soft-amber: rgba(240, 180, 60, .13);
  --soft-red: rgba(255, 100, 90, .13);
  --green-line: rgba(63, 185, 110, .34);
  --amber-line: rgba(240, 180, 60, .32);
  --red-line: rgba(255, 100, 90, .34);
  --danger-hover: rgba(255, 100, 90, .22);
  --overdue: rgba(255, 100, 90, .06);
  --brand: #0b6cc0;
  --brand-hover: #0d74cc;
  --brand-ink: #ffffff;
  --accent: #2aa3ff;
  --brand-text: #5cb6ff;
  --brand-soft: rgba(42, 163, 255, .14);
  --brand-line: rgba(42, 163, 255, .38);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-hover: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 26px -14px rgba(0, 0, 0, .75);
  --shadow-pop: 0 22px 44px -20px rgba(0, 0, 0, .8), 0 2px 6px rgba(0, 0, 0, .4);
  --shadow-modal: 0 28px 64px -24px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .06);
  --ring: 0 0 0 3px rgba(42, 163, 255, .32);
}

body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { letter-spacing: -0.01em; }
.muted { color: var(--muted); }

/* ---------- каркас ---------- */
.app { grid-template-columns: 252px minmax(0, 1fr); }
@media (min-width: 921px) { .app { background: linear-gradient(90deg, var(--panel) 251px, var(--line) 251px, var(--line) 252px, transparent 252px); } }
.content { padding: 26px 32px 48px; min-width: 0; }

/* ---------- сайдбар ---------- */
.sidebar {
  background: var(--panel);
  color: var(--ink);
  border-right: 1px solid var(--line);
  padding: 20px 14px 18px;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { grid-template-columns: 40px 1fr; gap: 11px; padding: 0 4px; }
.brand-logo { display: block; width: 40px; height: 40px; border-radius: 11px; }
.brand h1 { font-size: 15px; font-weight: 800; }
.brand p { color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 3px; }

.nav { gap: 2px; }
.nav-btn {
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  transition: background .12s ease, color .12s ease;
}
.nav-btn:hover { background: var(--fill); color: var(--ink); }
.nav-btn.active { background: var(--brand-soft); color: var(--ink); font-weight: 800; box-shadow: inset 3px 0 0 var(--accent); }
.nav-btn:focus-visible, .settings-panel summary:focus-visible { outline: none; box-shadow: var(--ring); }

/* настройки и интеграции — свёрнуты, чтобы меню разделов было главным */
.settings-panel { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.settings-panel summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-panel summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease; }
.settings-panel[open] summary::after { transform: rotate(45deg); }
.settings-panel summary:hover, .settings-panel[open] summary { background: var(--fill); color: var(--ink); }
.sync-box { margin: 10px 0 0; padding: 0 2px; border-top: 0; gap: 8px; font-size: 12px; color: var(--muted); }
.tax-box { background: var(--fill); border: 0; border-radius: var(--r); padding: 12px; gap: 8px; }
.tax-title { color: var(--ink); font-weight: 800; font-size: 13px; }
.tax-box span { color: var(--muted); font-size: 12px; }
.tax-box input { background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; height: 36px; padding: 0 10px; }
.google-sync-actions { gap: 6px; }
#syncInfo, #googleSyncInfo, #yandexSyncInfo, #telegramNotifyInfo, #integrationHealthInfo { color: var(--muted); font-size: 12px; }
.integration-summary.warning { color: var(--amber) !important; font-weight: 700; }
.integration-summary.error { color: var(--red) !important; font-weight: 700; }
.integration-summary.ok { color: var(--green) !important; }

/* ---------- кнопки ---------- */
.primary-btn, .ghost-btn, .danger-btn, .ghost-dark-btn, .secondary-link {
  border-radius: 10px;
  padding: 9px 14px;
  min-height: 40px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  transition: background .12s ease, box-shadow .12s ease, color .12s ease;
}
.primary-btn { background: var(--brand); color: var(--brand-ink); }
.primary-btn:hover { background: var(--brand-hover); }
.ghost-btn, .ghost-dark-btn { background: var(--fill); color: var(--ink); border: 0; }
.ghost-btn:hover, .ghost-dark-btn:hover { background: var(--fill-2); }
.secondary-link { display: inline-flex; align-items: center; justify-content: center; background: var(--panel); color: var(--brand-text); border: 1px solid var(--line); }
.secondary-link:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.danger-btn { background: var(--soft-red); color: var(--red); }
.danger-btn:hover { background: var(--danger-hover); }
.sync-box .primary-btn, .sync-box .ghost-dark-btn, .sync-box .secondary-link { min-height: 36px; font-size: 13px; padding: 8px 10px; }
.primary-btn:focus-visible, .ghost-btn:focus-visible, .danger-btn:focus-visible, .ghost-dark-btn:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn { background: var(--fill); color: var(--ink); border-radius: 10px; width: 38px; height: 38px; font-size: 22px; }
.icon-btn:hover { background: var(--fill-2); }

/* ---------- шапка раздела ---------- */
.topbar { align-items: center; gap: 16px; margin-bottom: 18px; }
.topbar h2 { font-size: 28px; font-weight: 800; line-height: 1.15; margin: 0; }
.topbar p { color: var(--muted); font-size: 13px; margin: 5px 0 0; }
.topbar-actions { gap: 10px; align-items: center; }
.topbar-actions .primary-btn, .topbar-actions .ghost-btn { white-space: nowrap; }
.current-user { color: var(--muted); font-size: 13px; font-weight: 600; }
.search input {
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: 10px;
  height: 40px;
  padding: 0 14px;
  min-width: 220px;
}
.current-user { white-space: nowrap; }
@media (min-width: 921px) { .search { min-width: 262px; } }
.search input:focus { background: var(--field); border-color: var(--brand-line); box-shadow: var(--ring); outline: none; }
.nav-toggle, .nav-shade { display: none; }

/* ---------- поля ---------- */
.filters select, .field input, .field select, .field textarea, .inbox-search, .inbox-controls select,
.form-grid input, .form-grid select, .form-grid textarea, .auth-form input, .drawer input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.drawer select, .drawer textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  min-height: 40px;
}
.inbox-controls select { padding: 0 10px; }
.filters select:focus, .field input:focus, .field select:focus, .field textarea:focus, .inbox-search:focus, .inbox-controls select:focus,
.auth-form input:focus, .drawer input:focus, .drawer select:focus, .drawer textarea:focus {
  outline: none;
  border-color: var(--brand-line);
  box-shadow: var(--ring);
}
.field label, .form-grid label > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.filters { gap: 10px; margin: 16px 0 12px; }

/* ---------- метрики ---------- */
.metrics { gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (min-width: 1240px) { .metrics { grid-template-columns: minmax(96px, .6fr) minmax(96px, .6fr) repeat(5, minmax(0, 1fr)); } }
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  min-height: 0;
}
.metric span { color: var(--muted); font-size: 12px; font-weight: 600; }
.metric strong { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric.tax { background: var(--soft-amber); border-color: var(--amber-line); }
.metric.net { background: var(--soft-green); border-color: var(--green-line); }

/* ---------- таблица позиций ---------- */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.data-table th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table { min-width: 940px; }
.data-table td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table th { padding-left: 12px; padding-right: 12px; }
.data-table td:nth-child(2) { min-width: 150px; }
.data-table td.name-cell { min-width: 220px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { cursor: pointer; transition: background .1s ease; }
.data-table tr:hover { background: transparent; }
.data-table tbody tr:hover td { background: var(--hover); }
.id-cell { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.name-cell strong { font-weight: 700; }
.money-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.date-cell { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- статусы ---------- */
.pill, .message-status {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  white-space: nowrap;
  border: 0;
}
.pill.default { background: var(--fill); color: var(--ink-2); }
.pill.green, .pill.ok { background: var(--soft-green); color: var(--green); }
.pill.blue { background: var(--soft-blue); color: var(--blue); }
.pill.amber { background: var(--soft-amber); color: var(--amber); }
.pill.red, .pill.critical { background: var(--soft-red); color: var(--red); }

/* ---------- сегменты-фильтры (входящие, задачи, контроль поставок) ---------- */
.segmented-control {
  background: var(--seg-bg);
  border: 0;
  border-radius: var(--r);
  padding: 4px;
  gap: 2px;
  display: inline-flex;
  flex-wrap: wrap;
}
.segment {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: 9px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.segment:hover { color: var(--ink); }
.segment.active { background: var(--seg-active); color: var(--ink); box-shadow: var(--shadow-xs); }
.segment span { color: var(--muted); background: var(--fill-2); font-weight: 700; margin-left: 4px; }
.segment.active span { background: var(--fill); }
.inbox-toolbar { gap: 12px; margin-bottom: 14px; }

/* ---------- списки-карточки ---------- */
.task-row, .logistics-control-row, .preliminary-row, .file-archive-row, .document-list-row, .confirmation-card, .message,
.integration-health-item, .request-summary > *, .confirmation-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
}
.task-row, .logistics-control-row, .preliminary-row, .file-archive-row, .document-list-row { transition: box-shadow .12s ease, border-color .12s ease; }
.task-row:hover, .logistics-control-row:hover, .preliminary-row:hover, .file-archive-row:hover, .document-list-row:hover { box-shadow: var(--shadow-hover); border-color: var(--hover-line); }
.task-row { border-left-width: 3px; }
.task-list, .logistics-control-list, .preliminary-list, .file-archive-list, .inbox-list, .confirmation-list { gap: 10px; }
.confirmation-area { padding: 16px; margin-bottom: 16px; }
.section-head h3 { font-size: 16px; font-weight: 800; }
.section-head p { color: var(--muted); }
.empty-note { color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; }

/* ---------- очередь предварительных запросов (тулбар массовых действий) ---------- */
.message-status.preliminary { background: var(--brand-soft); color: var(--brand-text); }
.queue-toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  padding: 10px 12px;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.queue-toolbar select, .queue-toolbar input[type=datetime-local] {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
}
.queue-toolbar select:focus, .queue-toolbar input:focus { outline: none; border-color: var(--brand-line); box-shadow: var(--ring); }
.queue-toolbar label { font-weight: 600; cursor: pointer; }
#queueCount { color: var(--muted); font-weight: 600; }
.queue-toolbar button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  cursor: pointer;
}
.queue-toolbar button:hover { background: var(--brand-hover); }
.queue-select, .queue-toolbar input[type=checkbox], .check-field input[type=checkbox], .drawer input[type=checkbox] { accent-color: var(--accent); }
.queue-entry { gap: 10px; }

/* ---------- карточка позиции ---------- */
.shade { background: var(--shade); backdrop-filter: blur(2px); }
.drawer {
  width: min(760px, 100vw);
  background: var(--panel);
  color: var(--ink);
  border-left: 0;
  box-shadow: var(--shadow-modal);
  border-radius: 18px 0 0 18px;
  overflow: hidden;
}
.drawer-head { padding: 20px 24px 16px; background: var(--panel); border-color: var(--line); }
.drawer h3 { font-size: 22px; font-weight: 800; line-height: 1.2; }
#drawerId { font-size: 12px; font-weight: 700; color: var(--muted); }
.drawer-body { background: var(--panel-2); padding: 18px 24px 28px; }
.detail, .workflow-panel, .warehouse-panel, .item-files-panel, .pricing-assistant, .backup-panel, .email-send-panel, .linked-messages, .events {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.warehouse-panel, .events, .linked-messages { padding: 14px; }
.drawer-body > * + * { margin-top: 12px; }
.detail span { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail strong { font-weight: 800; }
.warehouse-action, .warehouse-actions button { border-radius: 10px; }
.event { border-color: var(--line-soft); }

/* ---------- вход ---------- */
.auth-screen { background: var(--bg); }
.auth-panel { background: var(--panel); border-radius: 20px; padding: 32px; box-shadow: var(--shadow-pop); border-color: var(--line); }
.auth-panel h2 { font-size: 24px; font-weight: 800; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.auth-brand .brand-logo { width: 48px; height: 48px; border-radius: 13px; }
.auth-form label > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.auth-form input { height: 44px; padding: 0 14px; }
.auth-form .primary-btn { min-height: 44px; }

/* ---------- поверхности из styles.css с зашитыми цветами — на токены (нужно тёмной теме) ---------- */
.item-files-panel, .task-row, .file-archive-row, .confirmation-card, .message, .preliminary-row, .request-summary > div { background: var(--panel); color: var(--ink); }
.setup-note, .item-file-row, .logistics-control, .document-lines, .automation-check, .linked-message, .empty-note { background: var(--panel-2); }
.file-upload-row select, .file-upload-row input { background: var(--field); color: var(--ink); border-color: var(--line); }
.preliminary-row:hover { background: var(--panel); }
.preliminary-row.overdue { background: var(--overdue); }
.request-summary .attention { border-color: var(--red-line); background: var(--soft-red); }
.automation-check.green { border-left-color: var(--green); }
.automation-check.amber { border-left-color: var(--amber); }
.conversation-message { border-left-color: var(--hover-line); background: var(--panel-2); }
.conversation-message.outbound { border-left-color: var(--accent); background: var(--brand-soft); }
.logistics-progress i { background: linear-gradient(90deg, var(--accent) var(--progress), var(--fill-2) var(--progress)); }
.logistics-ok, .profit-good, .integration-health-item.ok .integration-health-head span { color: var(--green); }
.workflow-warning, .integration-health-item.warning .integration-health-head span { color: var(--amber); }
.integration-health-item.error .integration-health-head span { color: var(--red); }
.message-status.new { background: var(--soft-amber); color: var(--amber); }
.message-status.attached { background: var(--soft-green); color: var(--green); }
.message-status.ignored { background: var(--fill); color: var(--muted); }
.message-status.suggestion { background: var(--brand-soft); color: var(--brand-text); }
.control-priority { color: var(--brand-text); }
.warehouse-label img { background: #fff; padding: 4px; border-radius: 8px; }
a { color: var(--brand-text); }
.secondary-link, .primary-btn, .ghost-btn, .danger-btn { text-decoration: none; }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: #6f7a86; }

/* ---------- переключатель темы: в шапке и в мобильном меню ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
  transition: background .12s ease, color .12s ease;
}
.theme-toggle:hover { background: var(--fill); color: var(--ink); }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
.theme-toggle svg { width: 18px; height: 18px; flex: none; }
.theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
.theme-toggle.side { display: none; width: 100%; height: auto; min-height: 40px; justify-content: flex-start; padding: 9px 12px; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); }
.theme-toggle.side:hover { background: var(--fill); color: var(--ink); }
.theme-toggle .t-light, :root[data-theme="dark"] .theme-toggle .t-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .t-light { display: inline; }
@media (max-width: 920px) {
  .theme-toggle { width: 44px; height: 44px; }
  .theme-toggle.side { display: inline-flex; width: 100%; height: auto; min-height: 44px; }
}
@media (max-width: 720px) { .topbar-actions .theme-toggle { display: none; } }

/* ---------- планшет и телефон ---------- */
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: 100dvh;
    z-index: 40;
    transform: translateX(-104%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-modal);
  }
  body.nav-open .sidebar { transform: none; }
  .nav { grid-template-columns: 1fr; }
  .nav-shade {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: var(--shade);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open .nav-shade { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .content { padding: 14px 16px 40px; }
  .topbar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
  .topbar-title { flex: 1 1 0; min-width: 0; }
  .topbar h2 { font-size: 24px; }
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    cursor: pointer;
    flex: none;
  }
  .nav-toggle span { display: block; height: 2px; border-radius: 2px; background: var(--ink); }
  .topbar-actions { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .current-user { flex: 1 1 auto; }
  .search { order: 5; flex: 1 1 100%; min-width: 0; }
  .search input { min-width: 0; width: 100%; height: 44px; }
  .primary-btn, .ghost-btn, .danger-btn, .ghost-dark-btn { min-height: 44px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 12px 13px; border-radius: 14px; }
  .metric strong { font-size: 16px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters select { width: 100%; min-height: 44px; }
  .drawer { width: 100vw; border-radius: 0; }
  .drawer-head { padding: 16px; }
  .drawer-body { padding: 14px 16px 28px; }
  .segmented-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .segment { border-bottom: 0; text-align: center; }
}

/* позиции на телефоне — карточки вместо таблицы (порядок колонок задан app.js: ID, объект, наименование, статус, деньги ×4, Москва) */
@media (max-width: 720px) {
  .queue-entry { align-items: flex-start; gap: 8px; }
  .queue-entry > .queue-select { margin-top: 18px; }
  .queue-toolbar > * { flex: 1 1 auto; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .data-table, .data-table tbody, .data-table td { display: block; width: 100%; min-width: 0; }
  .data-table thead { display: none; }
  .data-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-xs);
  }
  .data-table tbody tr:hover td { background: transparent; }
  .data-table td { padding: 0; border: 0; min-width: 0; }
  .data-table td:only-child { grid-column: 1 / -1; text-align: center; padding: 8px 0; }
  .data-table td:nth-child(1) { order: 1; align-self: center; }
  .data-table td:nth-child(4) { order: 2; justify-self: end; align-self: center; }
  .data-table td:nth-child(3) { order: 3; grid-column: 1 / -1; font-size: 15px; }
  .data-table td:nth-child(2) { order: 4; grid-column: 1 / -1; color: var(--muted); font-size: 13px; margin-top: -4px; }
  .data-table td:nth-child(5) { order: 5; }
  .data-table td:nth-child(6) { order: 6; }
  .data-table td:nth-child(7) { order: 7; }
  .data-table td:nth-child(8) { order: 8; }
  .data-table td:nth-child(9) { order: 9; grid-column: 1 / -1; }
  .data-table td:nth-child(9):empty { display: none; }
  .data-table td.money-cell { background: var(--fill); border-radius: 10px; padding: 7px 10px; font-weight: 700; }
  .data-table td.money-cell::before { display: block; color: var(--muted); font-size: 11px; font-weight: 600; margin-bottom: 1px; }
  .data-table td:nth-child(5)::before { content: "Себестоимость"; }
  .data-table td:nth-child(6)::before { content: "Оплатили"; }
  .data-table td:nth-child(7)::before { content: "Валовая прибыль"; }
  .data-table td:nth-child(8)::before { content: "Чистая прибыль"; }
  .data-table td:nth-child(9)::before { content: "Москва: "; }
}
