:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --line: #e4e6eb; --line-strong: #d3d6dd;
  --text: #15171c; --text-2: #4b5160; --muted: #7b8191;
  --accent: #2a78d6; --accent-soft: #e8f1fc; --accent-text: #ffffff;
  --good: #0f7b46; --good-soft: #e6f4ec; --bad: #c4302b; --bad-soft: #fbeaea; --warn: #a66200; --warn-soft: #fdf3e2;
  --series-1: #2a78d6; --series-3: #1baf7a;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111214; --surface: #1a1b1e; --surface-2: #202125; --line: #2b2d32; --line-strong: #3a3d44;
    --text: #eceef2; --text-2: #b6bac4; --muted: #8a8f9b;
    --accent: #4c95ec; --accent-soft: #1d2b3d; --accent-text: #0b0d10;
    --good: #4cc38a; --good-soft: #15291f; --bad: #f07470; --bad-soft: #321b1b; --warn: #f0b04a; --warn-soft: #2f2615;
    --series-1: #3987e5; --series-3: #199e70;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --surface: #1a1b1e; --surface-2: #202125; --line: #2b2d32; --line-strong: #3a3d44;
  --text: #eceef2; --text-2: #b6bac4; --muted: #8a8f9b;
  --accent: #4c95ec; --accent-soft: #1d2b3d; --accent-text: #0b0d10;
  --good: #4cc38a; --good-soft: #15291f; --bad: #f07470; --bad-soft: #321b1b; --warn: #f0b04a; --warn-soft: #2f2615;
  --series-1: #3987e5; --series-3: #199e70;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.num, td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); } .pos { color: var(--good); }

/* Каркас */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; display: flex; gap: 8px; align-items: center; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 13px; }
.side a.item { color: var(--text-2); padding: 8px 10px; border-radius: 8px; display: block; }
.side a.item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side a.item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.side .spacer { flex: 1; }
.side .who { padding: 10px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 8px; }
main { padding: 22px 28px 40px; min-width: 0; max-width: 1400px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.top .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sync-note { font-size: 12px; color: var(--muted); }

/* Карточки и плитки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.stack { display: grid; gap: 16px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Таблицы */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); }
.thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: block; }
.thumb.sm { width: 30px; height: 30px; }
.prod { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.prod .t { line-height: 1.3; }
.prod .t small { color: var(--muted); display: block; }
.items-mini { display: grid; gap: 6px; }

/* Значки */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Формы и кнопки */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: default; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 220px; flex: 1; max-width: 360px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg a { padding: 6px 11px; color: var(--text-2); border-right: 1px solid var(--line); font-size: 13px; }
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--surface-2); text-decoration: none; }
.seg a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.period { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.period form { display: flex; gap: 6px; align-items: center; }
.period input[type=date] { padding: 5px 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.form-grid label, .field { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--accent-soft); color: var(--text); }
.alert.bad { background: var(--bad-soft); } .alert.good { background: var(--good-soft); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.cost-input { width: 110px; text-align: right; }
.cost-src { font-size: 11px; color: var(--muted); display: block; text-align: right; }
pre.report { white-space: pre-wrap; font: inherit; margin: 0; }
details summary { cursor: pointer; color: var(--accent); }
.chart-box { position: relative; height: 240px; }
.bar-inline { height: 6px; border-radius: 3px; background: var(--series-1); min-width: 2px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.cell-zero { color: var(--line-strong); }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 26px; }
.login form { display: grid; gap: 12px; }

/* Телефон */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; gap: 4px; }
  .side .group, .side .spacer, .side .who { display: none; }
  .brand { padding: 4px 8px 4px 0; white-space: nowrap; }
  .side a.item { white-space: nowrap; }
  main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .tile .value { font-size: 19px; }
  .filters input[type=search] { min-width: 0; max-width: none; width: 100%; }
}

/* Окно поверх страницы */
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(15, 18, 24, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dlg h2 { margin-top: 4px; }
table.matrix th { position: sticky; top: 0; z-index: 1; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
table.matrix td:first-child, table.matrix th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 2; }
@media (max-width: 860px) { .dlg { padding: 14px; width: calc(100vw - 16px); max-height: calc(100vh - 16px); } }

/* Окно остатков: раскрывающиеся продажи по дням под складом */
.wh-table .chev { display: inline-block; width: 16px; color: var(--muted); transition: transform .15s; }
.wh-row.can-open { cursor: pointer; }
.wh-row.can-open:hover td { background: var(--surface-2); }
.wh-row.can-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wh-row[aria-expanded="true"] td { background: var(--accent-soft); border-bottom-color: transparent; }
.wh-row[aria-expanded="true"] .chev { transform: rotate(90deg); color: var(--accent); }
.wh-days > td { padding: 4px 10px 14px; background: var(--accent-soft); }
.wh-days:hover td { background: var(--accent-soft) !important; }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.day .dd { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day .vv { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--line-strong); }
.day.has { border-color: var(--accent); }
.day.has .vv { color: var(--text); }

/* Иконка «Копировать»: два листа; после копирования — галочка */
.copy-btn { width: 24px; height: 24px; margin-left: 4px; padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  vertical-align: middle; background-color: var(--muted); opacity: .7;
  -webkit-mask: var(--icon-copy) center / 16px no-repeat; mask: var(--icon-copy) center / 16px no-repeat; }
.copy-btn:hover { background-color: var(--accent); opacity: 1; }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-btn.copied { background-color: var(--good); opacity: 1;
  -webkit-mask-image: var(--icon-check); mask-image: var(--icon-check); }
.copy-btn.failed { background-color: var(--bad); opacity: 1; }
:root {
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* Почта */
.mail-state { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.mail-list { display: flex; flex-direction: column; }
.mail-row { display: grid; grid-template-columns: minmax(160px, 220px) 1fr auto; gap: 14px; align-items: center;
  padding: 11px 18px; border-bottom: 1px solid var(--line); color: var(--text); }
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: var(--surface-2); text-decoration: none; }
.mail-from { min-width: 0; display: flex; flex-direction: column; }
.mail-from b, .mail-from small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-main { min-width: 0; }
.mail-subj, .mail-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-prev { font-size: 13px; }
.mail-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.mail-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mail-att { margin-bottom: 12px; }
.mail-body { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; padding: 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); max-height: 70vh; overflow: auto; }
.mail-grid { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 860px) {
  .mail-row { grid-template-columns: 1fr; gap: 4px; }
  .mail-meta { flex-direction: row; align-items: center; justify-content: flex-start; flex-wrap: wrap; }
  .mail-grid { grid-template-columns: 1fr; }
}

/* Цены и бренды */
.brand-select { max-width: 140px; padding: 4px 6px; font-size: 13px; }
.price-panel summary { cursor: pointer; list-style: revert; }
.price-panel[open] summary { margin-bottom: 12px; }
.price-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.price-form .field { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.seg label { padding: 6px 11px; border-right: 1px solid var(--line); font-size: 13px; cursor: pointer; color: var(--text-2);
  display: inline-flex; gap: 6px; align-items: center; }
.seg label:last-child { border-right: 0; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg label input { margin: 0; }
.price-table .warn-row td { background: var(--warn-soft); }
.price-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 12px; flex-wrap: wrap; }

/* Карандаш и окно цен одного товара */
.edit-btn { width: 22px; height: 22px; margin-left: 2px; padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  vertical-align: middle; background-color: var(--muted); opacity: .6;
  -webkit-mask: var(--icon-pencil) center / 15px no-repeat; mask: var(--icon-pencil) center / 15px no-repeat; }
.edit-btn:hover { background-color: var(--accent); opacity: 1; }
.edit-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:root { --icon-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/svg%3E"); }
.item-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 16px; }
.fld { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.fld input { font-size: 16px; padding: 10px 12px; }
.fld input[disabled] { opacity: .6; }
.fld small { color: var(--muted); font-size: 12px; }
.item-calc, .item-msg { grid-column: 1 / -1; font-size: 13px; min-height: 0; }
.warn-box { background: var(--warn-soft); color: var(--text); padding: 10px 12px; border-radius: 8px; }
#price-dlg:has(.item-form) { width: min(640px, calc(100vw - 32px)); }
@media (max-width: 860px) { .item-form { grid-template-columns: 1fr; } }

/* Кнопки-иконки: рисунок внутри кнопки (заменяет прежние маски) */
.icon-btn { -webkit-mask: none; mask: none; background: transparent; opacity: 1; border: 0; padding: 3px; margin-left: 4px;
  width: auto; height: auto; border-radius: 6px; color: var(--muted); cursor: pointer; vertical-align: middle;
  display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn .ic-done { display: none; }
.icon-btn.copied { color: var(--good); background: var(--good-soft); }
.icon-btn.copied .ic-main { display: none; }
.icon-btn.copied .ic-done { display: inline; }
.icon-btn.failed { color: var(--bad); }

/* Окно цен: поля в ровной сетке, подсказки не сдвигают поля, кнопки в одной строке */
.item-form { align-items: start; }
.fld { align-content: start; grid-template-rows: auto auto auto; }
.fld input { height: 44px; box-sizing: border-box; }
.fld small { min-height: 16px; }
.item-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.item-foot > .muted { font-size: 12px; flex: 1 1 260px; }
.item-buttons { display: flex; gap: 10px; flex-shrink: 0; margin-left: auto; }
.item-calc:empty, .item-msg:empty { display: none; }

/* Товары: артикул под названием, расходы Ozon */
.prod .t small.art { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.prod .t small.art .icon-btn { margin-left: 2px; padding: 2px; }
.fee { white-space: nowrap; cursor: help; }
.fee-sub { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.prod .t small.art { display: flex; margin-top: 2px; }
.fee-line { white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1.5; cursor: help; }
.fee-lbl { display: inline-block; width: 32px; text-align: left; color: var(--muted); font-size: 12px; }
.warn-txt { color: var(--warn); }
.link-chk { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.link-chk input { width: auto; height: auto; margin: 0; }

/* ===== Горизонтальное меню (вместо боковой панели) ===== */
.layout { display: block; min-height: 100vh; }
.side { display: none; }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.topbar .brand { padding: 0; display: flex; gap: 8px; align-items: center; color: var(--text); font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.topbar .brand:hover { text-decoration: none; }
.topnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.topnav::-webkit-scrollbar { display: none; }
.topbar .item { color: var(--text-2); padding: 7px 11px; border-radius: 8px; white-space: nowrap; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.topbar .item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar .item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topright { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.caret { font-size: 10px; color: var(--muted); }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; display: grid; gap: 2px; z-index: 60; }
.menu-pop a { padding: 8px 10px; border-radius: 7px; color: var(--text); }
.menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop a.on { color: var(--accent); font-weight: 600; }
main { max-width: none; padding: 20px 24px 40px; }
@media (max-width: 1100px) { .who-name, .brand-name { display: none; } }
@media (max-width: 860px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar .item { padding: 6px 9px; }
  main { padding: 14px; }
}
@media (max-width: 860px) { .filters input[type=search] { flex: 1 1 100%; } }

/* Остатки в «Товарах»: FBO только просмотр, FBS можно поменять */
.stock-cell { white-space: nowrap; }
.stock-line { font-variant-numeric: tabular-nums; line-height: 1.7; }
.fbs-input { width: 64px; text-align: right; padding: 2px 6px; margin-left: 4px; }
.fbs-input.changed { border-color: var(--warn, #d08a00); }
.stock-msg { display: block; font-size: 12px; color: var(--muted); white-space: normal; max-width: 160px; margin-left: auto; }
.stock-msg.bad { color: var(--bad); }

/* ===== Телефон: меню-кнопка, таблицы карточками, формы в столбик ===== */
.nav-toggle, .nav-current { display: none; }
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-left: -4px;
    border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; flex-shrink: 0; }
  .nav-toggle:hover, .topbar.open .nav-toggle { background: var(--surface-2); }
  .nav-current { display: block; flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topnav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; gap: 2px; padding: 8px;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0,0,0,.12);
    max-height: calc(100dvh - 52px); overflow-y: auto; }
  .topbar.open .topnav { display: flex; }
  .topnav .item { padding: 11px 12px; font-size: 15px; }
  .top { margin-bottom: 12px; }
  .top h1 { font-size: 20px; }
  .sync-note { flex-basis: 100%; order: 2; }
  .menu-pop { right: -4px; }
}
@media (max-width: 640px) {
  .period { gap: 8px; }
  .period .seg { width: 100%; }
  .period .seg a { flex: 1 0 auto; text-align: center; }
  .period form { width: 100%; }
  .period form input[type=date] { flex: 1; min-width: 0; }
  .filters > * { flex: 1 1 auto; }
  .filters input[type=search] { flex-basis: 100%; }
  .seg { width: 100%; }
  .seg a { flex: 1 0 auto; text-align: center; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile .value { font-size: 17px; }
  .card { padding: 12px 14px; }
  .chart-box { height: 200px; }
  .dlg, #price-dlg:has(.item-form) { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: 12px; }
  .price-form { flex-direction: column; align-items: stretch; }

  /* таблица → карточки: заголовок колонки подписан слева у каждого значения */
  .table-wrap.m-cards-wrap { margin: 0; padding: 0; overflow: visible; }
  table.m-cards thead { display: none; }
  table.m-cards, table.m-cards tbody, table.m-cards tfoot, table.m-cards tr { display: block; width: 100%; }
  table.m-cards tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.m-cards tr:last-child { border-bottom: 0; }
  table.m-cards td { display: block; border: 0; padding: 4px 0; text-align: right; white-space: normal; min-height: 22px; }
  table.m-cards td::after { content: ""; display: block; clear: both; }
  table.m-cards td::before { content: attr(data-label); float: left; color: var(--muted); font-size: 12px; text-align: left;
    max-width: 45%; padding: 2px 12px 0 0; white-space: normal; }
  table.m-cards td.m-head { display: block; text-align: left; padding: 0 0 6px; font-weight: 500; }
  table.m-cards td.m-head::before, table.m-cards td[data-label=""]::before { content: none; }
  table.m-cards td:empty { display: none; }
  table.m-cards td[colspan] { display: block; text-align: center; }
  table.m-cards tbody tr:hover td { background: none; }
  table.m-cards tfoot td { border-top: 0; }
  table.m-cards tfoot tr { border-top: 1px solid var(--line-strong); }
  table.m-cards .prod { min-width: 0; }
  table.m-cards .stock-msg { margin-left: auto; }
  table.m-cards .stock-line { display: inline-block; margin-left: 10px; }
  table.m-cards .fee-line, table.m-cards .fee { display: block; }
  table.m-cards .cost-src { text-align: right; }
}
