:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #14181f;
  --muted: #5a6472;
  --line: #dde1e7;
  --accent: #1f4fd8;
  --accent-soft: #eaf0ff;
  --accent-ink: #ffffff;
  --ok: #0f7a4a;
  --ok-soft: #e8f6ee;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --warn: #8a5a00;
  --warn-soft: #fff6e0;
  --radius: 10px;
  --row-hover: #fafbfc;
  --field-bg: #ffffff;
  --shadow: none;
  color-scheme: light;
}

/* ── тёмная тема ───────────────────────────────────── */

:root[data-theme="dark"] {
  --bg: #12151b;
  --panel: #1a1e26;
  --ink: #e8ecf3;
  --muted: #9aa4b4;
  --line: #2c333f;
  --accent: #7ea2ff;
  --accent-soft: #23304d;
  --accent-ink: #10131a;
  --ok: #6fd39b;
  --ok-soft: #17352a;
  --bad: #ff8d85;
  --bad-soft: #3a1f1e;
  --warn: #e3b667;
  --warn-soft: #362a14;
  --row-hover: #212733;
  --field-bg: #151922;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --panel: #1a1e26;
    --ink: #e8ecf3;
    --muted: #9aa4b4;
    --line: #2c333f;
    --accent: #7ea2ff;
    --accent-soft: #23304d;
    --accent-ink: #10131a;
    --ok: #6fd39b;
    --ok-soft: #17352a;
    --bad: #ff8d85;
    --bad-soft: #3a1f1e;
    --warn: #e3b667;
    --warn-soft: #362a14;
    --row-hover: #212733;
    --field-bg: #151922;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1180px, 100% - 32px); margin: 0 auto; }

/* ── шапка ─────────────────────────────────────────── */

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.2px;
}
.brand-dot { color: var(--accent); padding: 0 2px; }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 2px;
}
.nav a.is-active { color: var(--ink); font-weight: 600; }
.nav .quiet { font-size: 13px; display: inline-flex; align-items: center; min-height: 28px; }
.who {
  font-size: 13px;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

.main { padding: 24px 0 48px; }
.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 32px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  margin-top: 24px;
}
.quiet { color: var(--muted); }

/* ── панели ────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel h1, .panel h2, .panel h3 { margin: 0 0 12px; letter-spacing: -0.2px; }
.panel h1 { font-size: 22px; }
.panel h2 { font-size: 18px; }
.panel h3 { font-size: 15px; }
.panel > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -0.4px; margin-top: 2px; }
.stat .v.sm { font-size: 18px; }
.stat .s { color: var(--muted); font-size: 12px; }

/* ── формы ─────────────────────────────────────────── */

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="search"], input[type="number"], input[type="password"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  font: inherit;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink, #fff);
  padding: 9px 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-ghost { background: var(--field-bg); color: var(--ink); border-color: var(--line); }
.btn-small { padding: 5px 10px; font-size: 13px; font-weight: 500; }
.btn-link {
  background: none; border: none; color: var(--accent);
  padding: 4px 2px; min-height: 28px; font: inherit; cursor: pointer;
  text-decoration: underline;
}
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { margin-bottom: 0; }

.flash {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-bad { background: var(--bad-soft); color: var(--bad); }

/* ── таблицы ───────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ── метки ─────────────────────────────────────────── */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }

/* ── выбор магазинов ───────────────────────────────── */

.picker { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.picker-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1.6fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.picker-row:last-child { border-bottom: none; }
.picker-row.is-chosen { background: var(--accent-soft); }
.picker-row input[type="checkbox"] { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.picker-row .area { color: var(--muted); font-size: 12px; }

.bar {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.counter { font-variant-numeric: tabular-nums; font-weight: 600; }
.counter.over { color: var(--bad); }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pager .current { font-weight: 600; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

.muted-sm { color: var(--muted); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .picker-row { grid-template-columns: 30px minmax(0, 1fr); }
  .picker-row .area, .picker-row .status { display: none; }
  .table-wrap { margin: 0; padding: 0; }
}

/* ── фильтры и чекбоксы ─────────────────────────────── */

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  font-size: 13px;
  color: var(--muted);
}
.check input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
}
details > summary {
  padding: 8px 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  list-style-position: inside;
}
.form-hint { margin: 8px 0 0; }

/* ── чекбоксы в таблицах админки ───────────────────── */

table input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0 4px 0 0;
  vertical-align: middle;
  accent-color: var(--accent);
}
label.muted-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
}
.lead { max-width: 66ch; }
/* ── переключатель темы ────────────────────────────── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field-bg);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
  :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
}
:root[data-theme="light"] .theme-icon-dark { display: inline; }
:root[data-theme="light"] .theme-icon-light { display: none; }
/* ── длинные названия в выборе магазинов ───────────── */

.picker-row > span { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .stores-table { min-width: 560px; }
  .stores-table td { white-space: nowrap; }
}
/* ── выбранные магазины (чипы) ─────────────────────── */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13px;
  max-width: 100%;
}
.chip a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
}
.chip a:hover { background: var(--panel); }
/* ── только для телефона ───────────────────────────── */

.only-mobile { display: none; }

@media (max-width: 760px) {
  .only-mobile { display: block; }
}
/* ── «Отправки»: карточки на телефоне, таблица на компьютере ── */

.only-desktop { display: block; }

@media (max-width: 760px) {
  .only-desktop { display: none; }
  .feed-cards { display: flex; flex-direction: column; gap: 8px; }
}



.feed-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px 12px;
}

.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.feed-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-store {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.feed-items { list-style: none; margin: 0; padding: 0; }
.feed-item { padding: 6px 0; border-top: 1px solid var(--line); }
.feed-item:first-child { border-top: 0; padding-top: 0; }

.feed-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.feed-title { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.feed-qty { font-weight: 700; font-size: 14px; white-space: nowrap; }
.feed-meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.feed-series { text-align: right; }
.feed-eta { color: var(--muted); font-size: 12px; margin-top: 1px; }

.feed-address {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
/* ── миниатюры картинок в материалах ───────────────── */

.thumb {
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 4px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { color: var(--muted); font-size: 12px; }

.materials-table td { vertical-align: top; }
.materials-table input[type="file"] { max-width: 180px; font-size: 12px; min-height: 28px; }