/* ===== Каталог — «Графит и кобальт» ===== */
@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #F2F3F6;
  --surface: #FFFFFF;
  --soft: #F7F8FA;
  --soft-2: #EFF1F5;
  --line: #EBEDF1;
  --border: #E2E5EB;
  --border-input: #DADDE4;
  --text: #0F1115;
  --text-2: #363B47;
  --muted: #5B6170;
  --faint: #8A90A0;

  --sidebar: #14161B;
  --sidebar-active: #252933;
  --sidebar-text: #A3A9B6;
  --sidebar-line: #262A33;

  --accent: #3A63E8;
  --accent-hover: #2F55D4;
  --accent-strong: #2445B8;
  --accent-tint: #E7EDFD;
  --accent-border: #C9D6FA;

  --amber: #F0A52E;
  --amber-soft: #F8D38D;
  --teal: #12A594;
  --teal-soft: #8FDACF;
  --danger: #C4321F;
  --danger-tint: #FDECEA;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 17, 21, 0.06);
  --shadow-md: 0 8px 28px rgba(15, 17, 21, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Onest, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.xs { width: 14px; height: 14px; stroke-width: 2; }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  background: var(--sidebar);
  padding: 28px 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 28px; color: #fff; }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
}
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 12px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; color: var(--sidebar-text);
  transition: background .15s, color .15s;
}
.nav-link:hover { background: #1C1F26; color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; box-shadow: inset 2px 0 0 #6E8EFF; }
.sidebar-spacer { flex-grow: 1; }
.sidebar-sub { height: 40px; font-size: 13px; color: #8A91A0; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; margin-top: 8px; border-top: 1px solid var(--sidebar-line);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #2C313C; color: #C9CEDA;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
}
.sidebar-user .name { flex-grow: 1; font-size: 13px; font-weight: 600; color: #E6E8EE; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .btn-icon { background: transparent; border: 0; color: #8A91A0; }
.sidebar-user .btn-icon:hover { background: #1C1F26; color: #fff; }

.content {
  flex-grow: 1; min-width: 0;
  padding: 36px 48px 48px;
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1480px;
}

/* ---------- Заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head .titles { flex-grow: 1; min-width: 240px; }
.page-title { font-size: 34px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.1; }
.page-sub { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); align-self: flex-start; }
.back-link:hover { color: var(--text); }
.meta-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.meta-line strong { color: var(--text-2); font-weight: 600; }

/* ---------- Кнопки ---------- */
button { font-family: inherit; }
.btn {
  height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px Onest, sans-serif; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-input); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: #C3C8D2; background: var(--soft); }
.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #262A33; }
.btn-ghost { background: transparent; color: var(--muted); height: 36px; padding: 0 10px; }
.btn-ghost:hover { color: var(--text); background: var(--soft-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); height: 36px; padding: 0 10px; }
.btn-danger-ghost:hover { background: var(--danger-tint); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: var(--radius);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-icon:hover { background: var(--soft); }
.btn-icon.plain { border: 0; background: transparent; color: var(--faint); }
.btn-icon.plain:hover { background: var(--soft-2); color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Карточки и статистика ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-pad { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-title { font-size: 15px; font-weight: 700; flex-grow: 1; }
.card-note { font-size: 12px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.6px; }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-value.pos { color: var(--accent-strong); }
.stat-value.neg { color: var(--danger); }
.stat-foot { font-size: 13px; color: var(--text-2); }

/* ---------- Панель фильтров ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.filterbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search {
  flex-grow: 1; max-width: 360px; min-width: 220px; height: 40px;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px solid var(--border-input); border-radius: var(--radius); background: var(--soft); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); background: #fff; }
.search input { border: 0; outline: none; background: transparent; font: 500 14px Onest, sans-serif; color: var(--text); flex-grow: 1; min-width: 0; }
.search input::placeholder { color: var(--faint); }
.segmented { display: flex; padding: 3px; background: var(--soft-2); border-radius: var(--radius); gap: 2px; }
.segmented button {
  height: 34px; padding: 0 14px; border: 0; border-radius: 6px;
  font: 600 13px Onest, sans-serif; background: transparent; color: var(--muted); cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(15,17,21,.12); }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  height: 34px; padding: 0 8px 0 12px; border-radius: 17px;
  border: 1px solid var(--accent-border); background: #E9EEFD; color: var(--accent-strong);
  font: 600 13px Onest, sans-serif; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip:hover { background: var(--accent-tint); border-color: var(--accent); }
.chip-add {
  height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1px dashed #C3C8D2; background: transparent; color: var(--text-2);
  font: 600 13px Onest, sans-serif; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip-add:hover { border-color: var(--accent); color: var(--accent); }
.flex-spacer { flex-grow: 1; }

/* Поповер добавления фильтра */
.popover-wrap { position: relative; }
.popover {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  width: 300px; padding: 16px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------- Таблица ---------- */
.table-scroll { overflow: auto; max-height: calc(100vh - 380px); min-height: 240px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  background: var(--soft); border-bottom: 1px solid var(--line);
  padding: 10px 16px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px;
}
table.data td { padding: 10px 16px; border-bottom: 1px solid var(--soft-2); vertical-align: middle; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: #F9FAFC; }
table.data .num { text-align: right; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
.cell-main { display: flex; align-items: center; gap: 14px; min-width: 260px; }
.cell-stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cell-title { font-weight: 600; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cell-strong { font-weight: 700; }
.cell-pos { font-size: 12px; font-weight: 600; color: var(--accent-strong); }
.cell-neg { font-size: 12px; font-weight: 600; color: var(--danger); }
.thumb {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--radius);
  background: #4B5568; color: #fff; object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.thumb.sm { width: 36px; height: 36px; font-size: 13px; }
.table-foot { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 4px; border-radius: 2px; display: inline-block; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text); }

/* Полоска состава себестоимости */
.costbar { display: flex; height: 4px; width: 120px; border-radius: 2px; overflow: hidden; background: var(--line); gap: 1px; }
.costbar.lg { height: 10px; width: 100%; border-radius: 5px; gap: 2px; }
.seg-buy { background: var(--accent); }
.seg-log { background: var(--amber); }
.seg-store { background: var(--amber-soft); }
.seg-rest { background: var(--teal); }
.seg-cult { background: var(--teal-soft); }
.seg-other { background: #B7BDC9; }

/* ---------- Статусы ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-stock { background: var(--accent-tint); color: var(--accent-strong); }
.status-sold { background: #E9EBEF; color: #3B404C; }
.status-way { background: #FBEBD3; color: #8A5A14; }
.status-wait { background: #E9EBEF; color: #4A505D; }
.status-done { background: var(--accent-tint); color: var(--accent-strong); }

/* ---------- Поля форм ---------- */
.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(auto-fit, minmax(170px, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
.field .req { color: var(--danger); }
.input, .field input, .field select, .field textarea {
  height: 44px; width: 100%; padding: 0 12px;
  border: 1px solid var(--border-input); border-radius: var(--radius);
  background: #fff; color: var(--text);
  font: 500 14px Onest, sans-serif;
  transition: border-color .15s, box-shadow .15s;
}
.field select { padding: 0 10px; }
.field textarea { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58, 99, 232, .15); }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input.money { font-weight: 600; }
.readout {
  height: 44px; padding: 0 12px; border-radius: var(--radius); background: var(--soft-2);
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden;
}
.readout.light { font-size: 14px; font-weight: 600; }
.readout .muted { font-weight: 500; color: var(--muted); }

.scale { display: flex; gap: 4px; height: 44px; align-items: center; }
.scale button {
  flex: 1 1 0; height: 32px; padding: 0; border: 0; border-radius: 6px;
  background: var(--soft-2); color: var(--text-2);
  font: 600 12px Onest, sans-serif; cursor: pointer;
}
.scale button.filled { background: #D5DFFB; }
.scale button.on { background: var(--accent); color: #fff; }
.scale button:hover:not(.on) { background: var(--accent-border); }

.error { color: var(--danger); font-size: 13px; font-weight: 500; }
.error:empty { display: none; }

/* ---------- Карточка товара ---------- */
.item-layout { display: flex; gap: 24px; align-items: flex-start; }
.item-side { width: 400px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.item-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.photo-main {
  height: 400px; border-radius: var(--radius-lg); background: var(--soft-2);
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px;
  color: var(--faint); font-size: 14px; font-weight: 600;
}
.photo-main img { width: 100%; height: 100%; object-fit: contain; padding: 12px; box-sizing: border-box; }
.photo-badge {
  position: absolute; left: 14px; top: 14px; height: 26px; padding: 0 10px; border-radius: 13px;
  background: rgba(15,17,21,.6); color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.photo-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.photo-tile { height: 76px; border-radius: var(--radius); background: var(--soft-2); position: relative; overflow: hidden; border: 0; padding: 0; cursor: pointer; }
.photo-tile img { width: 100%; height: 100%; object-fit: contain; padding: 4px; box-sizing: border-box; display: block; }
.photo-tile.main { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-tile .tile-actions { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 4px; opacity: 0; transition: opacity .15s; }
.photo-tile:hover .tile-actions, .photo-tile:focus-within .tile-actions { opacity: 1; }
.tile-actions button { width: 26px; height: 26px; border: 0; border-radius: 6px; background: rgba(15,17,21,.7); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.tile-actions button:hover { background: rgba(15,17,21,.9); }
.photo-add {
  height: 76px; border-radius: var(--radius); border: 1.5px dashed #C3C8D2; background: #fff; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font: 600 11px Onest, sans-serif; cursor: pointer;
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.photo-slot { height: 76px; border-radius: var(--radius); background: #E9EBEF; opacity: .5; }

.cost-total { font-size: 36px; font-weight: 800; letter-spacing: -1px; }
.cost-list { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.cost-row { display: flex; align-items: center; gap: 10px; }
.cost-row .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cost-row .label { flex-grow: 1; }
.cost-row .val { font-weight: 600; }
.cost-row.zero { color: var(--faint); }
.cost-row.zero .val { font-weight: 500; }

.sale-card { background: #F3F6FE; border: 1px solid var(--accent-border); border-radius: var(--radius-lg); }
.sale-card .field { color: var(--text-2); }
.sale-card .field input, .sale-card .field select { border-color: var(--accent-border); }
.sale-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sale-foot .margin { flex-grow: 1; font-size: 14px; color: var(--text-2); }
.sale-foot .margin b.pos { color: var(--accent-strong); }
.sale-foot .margin b.neg { color: var(--danger); }
.sold-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* ---------- Доставки / хранение ---------- */
.split { display: flex; gap: 24px; align-items: flex-start; }
.party-list { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.party {
  text-align: left; width: 100%; padding: 16px 18px; border-radius: 10px;
  background: #fff; border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  font-family: inherit; color: var(--text); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.party:hover { border-color: #C3C8D2; }
.party[aria-pressed="true"] { border: 1.5px solid var(--accent); box-shadow: 0 4px 14px rgba(58,99,232,.16); }
.party-top { display: flex; align-items: center; gap: 8px; width: 100%; }
.party-num { font-size: 12px; font-weight: 700; color: var(--muted); }
.party-route { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; flex-wrap: wrap; }
.party-route svg { color: var(--faint); }
.party-foot { display: flex; gap: 16px; font-size: 13px; color: var(--muted); width: 100%; }
.party-foot b { color: var(--text); }
.detail { flex-grow: 1; min-width: 0; padding: 28px; display: flex; flex-direction: column; gap: 24px; }
.detail-title { font-size: 28px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.1; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fact { padding: 14px 16px; border-radius: 10px; background: var(--soft); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.fact .v { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact .v.big { font-size: 18px; font-weight: 700; }
.fact .s { font-size: 12px; color: var(--muted); }
.share { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.share-track { flex-grow: 1; height: 8px; border-radius: 4px; background: var(--soft-2); overflow: hidden; }
.share-fill { height: 100%; background: var(--amber); border-radius: 4px; }
.share-pct { width: 40px; text-align: right; font-size: 13px; color: var(--text-2); }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(460px, 90vw); z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  max-height: 320px; overflow: auto; padding: 6px;
}
.search-result { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); }
.search-result:hover { background: var(--soft); }
.search-result .grow { flex-grow: 1; min-width: 0; }

/* ---------- Справочники ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--soft-2); border-radius: 10px; flex-wrap: wrap; align-self: flex-start; }
.tabs button { height: 36px; padding: 0 14px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); font: 600 13px Onest, sans-serif; cursor: pointer; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.add-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-row .field { flex: 1 1 200px; }

/* ---------- Модальное окно ---------- */
dialog.modal {
  width: min(760px, calc(100vw - 32px)); padding: 0; border: 0;
  border-radius: 16px; box-shadow: var(--shadow-md); color: var(--text);
}
dialog.modal.modal-sm { width: min(440px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(15, 17, 21, .45); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 22px 24px 0; }
.modal-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; flex-grow: 1; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-section { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; border-top: 1px solid var(--line); }

/* ---------- Уведомления ---------- */
.toast-host { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px;
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Вход ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--sidebar); }
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-box .brand { padding: 0; color: var(--text); }
.login-box h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.login-box .btn { width: 100%; }

/* ---------- Адаптив ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-layout, .split { flex-direction: column; }
  .item-side, .party-list { width: 100%; position: static; }
  .facts, .sold-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
  .brand { padding: 0 12px 0 0; }
  .sidebar-spacer, .sidebar-sub { display: none; }
  .sidebar-user { border: 0; margin: 0; padding: 0 0 0 8px; }
  .content { padding: 24px 16px 40px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .stats, .grid-2, .grid-3, .grid-4, .facts, .sold-summary { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: auto; }
}
.btn-icon.plain.edit:hover { background: var(--accent-tint); color: var(--accent); }
.field input.invalid, .input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(196, 50, 31, .12); }
.suggest { border: 1px solid var(--accent-border); background: #F3F6FE; border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.suggest-head { display: flex; align-items: center; gap: 10px; padding: 0 4px; flex-wrap: wrap; }
.suggest-title { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--accent-strong); }
.suggest-list { display: flex; flex-direction: column; gap: 2px; background: #fff; border-radius: var(--radius); padding: 4px; }

/* ---------- Большое фото и просмотр на весь экран ---------- */
.photo-open { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.photo-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.photo-zoom {
  position: absolute; right: 14px; bottom: 14px; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(15,17,21,.55); color: #fff; display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
.photo-main:hover .photo-zoom, .photo-open:focus-visible ~ .photo-zoom { opacity: 1; }
.photo-tile.current:not(.main) { outline: 2px solid #9FB4F5; outline-offset: 2px; }

dialog.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(10, 11, 14, .96); color: #fff;
}
dialog.lightbox::backdrop { background: rgba(10, 11, 14, .96); }
.lb-wrap { display: flex; flex-direction: column; height: 100%; }
.lb-top { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }
.lb-counter { font-size: 14px; font-weight: 600; color: #C9CEDA; font-variant-numeric: tabular-nums; }
.lb-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; background: rgba(255,255,255,.12); font-size: 12px; font-weight: 600; }
.lb-close, .lb-nav {
  border: 0; background: rgba(255,255,255,.1); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.lb-close { width: 44px; height: 44px; border-radius: 50%; }
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 0 96px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; user-select: none; -webkit-user-drag: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 56px; height: 56px; border-radius: 50%; }
.lb-nav svg.i { width: 26px; height: 26px; }
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
.lb-thumbs { display: flex; gap: 8px; justify-content: center; padding: 16px 20px 24px; flex-wrap: wrap; }
.lb-thumbs button { width: 68px; height: 68px; padding: 0; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: none; opacity: .5; cursor: pointer; transition: opacity .15s, border-color .15s; }
.lb-thumbs button:hover { opacity: .85; }
.lb-thumbs button[aria-current="true"] { border-color: #fff; opacity: 1; }
.lb-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 700px) {
  .lb-stage { padding: 0 8px; }
  .lb-nav { width: 44px; height: 44px; background: rgba(15,17,21,.55); }
  .lb-prev { left: 12px; } .lb-next { right: 12px; }
  .lb-thumbs button { width: 52px; height: 52px; }
}

/* ---------- Фильтры по столбцам и выбор столбцов ---------- */
.popover-wide { width: 340px; }
.popover-right { left: auto; right: 0; }
.pf-inputs { display: flex; flex-direction: column; gap: 10px; }
.pf-inputs .input { height: 40px; }
.chip-split { padding: 0; gap: 0; cursor: default; overflow: hidden; }
.chip-split button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; height: 100%; display: inline-flex; align-items: center; }
.chip-edit { padding: 0 6px 0 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { padding: 0 10px 0 4px; }
.chip-split button:hover { background: rgba(58, 99, 232, .1); }

.columns-popover { width: 560px; max-width: calc(100vw - 32px); max-height: 70vh; overflow: auto; }
.columns-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.columns-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.columns-group { display: flex; flex-direction: column; gap: 6px; }
.columns-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.th-inner { display: inline-flex; align-items: center; gap: 4px; }
table.data th.num .th-inner { flex-direction: row-reverse; }
.th-filter {
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: transparent;
  color: var(--faint); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: .55; transition: opacity .15s, background .15s, color .15s;
}
table.data th:hover .th-filter, .th-filter:focus-visible { opacity: 1; }
.th-filter:hover { background: var(--soft-2); color: var(--text); }
.th-filter.active { opacity: 1; color: #fff; background: var(--accent); }
.th-sort {
  width: 18px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: transparent;
  color: var(--faint); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.th-sort .up, .th-sort .down { opacity: .55; }
table.data th:hover .th-sort .up, table.data th:hover .th-sort .down { opacity: 1; }
.th-sort.asc .up, .th-sort.desc .down { opacity: 1; stroke: var(--accent); stroke-width: 2.6; }
.th-sort.asc .down, .th-sort.desc .up { opacity: .25; }
table.data th.sorted { color: var(--text); }
table.data th.sortable { cursor: pointer; user-select: none; }
.cell-desc { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
table.data.wide td { white-space: nowrap; }
table.data.wide td, table.data.wide th { padding-left: 12px; padding-right: 12px; }
.filterbar .chips:not(:empty) { order: 10; flex-basis: 100%; }

/* ---------- Боковое меню: закрепление и сворачивание ---------- */
.brand-row { display: flex; align-items: center; gap: 4px; padding: 0 0 28px; }
.brand-row .brand { padding: 0 8px; flex-grow: 1; min-width: 0; }
.sidebar-pin {
  width: 32px; height: 32px; flex-shrink: 0; padding: 0; border: 0; border-radius: var(--radius);
  background: transparent; color: #8A91A0; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sidebar-pin:hover { background: #1C1F26; color: #fff; }
.sidebar-sub .fade { overflow: hidden; text-overflow: ellipsis; }

@media (min-width: 861px) {
  html.sidebar-unpinned .app { padding-left: 72px; }
  html.sidebar-unpinned .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    width: 72px; padding: 28px 12px 20px; overflow: hidden;
    transition: width .2s ease, box-shadow .2s ease;
  }
  html.sidebar-unpinned .sidebar:hover,
  html.sidebar-unpinned .sidebar:focus-within {
    width: 240px; box-shadow: 12px 0 40px rgba(0, 0, 0, .28);
  }
  /* отступы одинаковые в свёрнутом и раскрытом виде — иконки не прыгают */
  html.sidebar-unpinned .brand-row .brand { padding: 0 8px; }
  html.sidebar-unpinned .nav-link { padding: 0 15px; white-space: nowrap; }
  html.sidebar-unpinned .sidebar-user { padding: 12px 8px; white-space: nowrap; }
  html.sidebar-unpinned .brand { white-space: nowrap; }
  html.sidebar-unpinned .sidebar .fade { opacity: 0; transition: opacity .12s ease; }
  html.sidebar-unpinned .sidebar:hover .fade,
  html.sidebar-unpinned .sidebar:focus-within .fade { opacity: 1; transition-delay: .08s; }
}
@media (max-width: 860px) {
  .brand-row { padding: 0 12px 0 0; }
  .sidebar-pin { display: none; }
}
.brand-mark, .avatar { flex-shrink: 0; }
@media (min-width: 861px) {
  html.sidebar-unpinned .sidebar:not(:hover):not(:focus-within) .sidebar-pin,
  html.sidebar-unpinned .sidebar:not(:hover):not(:focus-within) .sidebar-user .btn-icon { display: none; }
}
.photo-main:has(img) { background: #F7F8FA; border: 1px solid var(--border); }
.photo-tile:has(img) { background: #F7F8FA; box-shadow: inset 0 0 0 1px var(--border); }

/* ---------- Перестановка столбцов ---------- */
table.data th[draggable="true"] { cursor: grab; user-select: none; }
table.data th[draggable="true"]:active { cursor: grabbing; }
table.data th.dragging { opacity: .45; }
table.data th.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
table.data th.drop-after { box-shadow: inset -3px 0 0 var(--accent); }

/* ---------- Пользователь в меню ---------- */
.sidebar-user a.name { display: flex; flex-direction: column; gap: 1px; min-width: 0; text-decoration: none; }
.sidebar-user .name-login { color: #E6E8EE; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .name-role { color: #8A91A0; font-size: 11px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user a.name:hover .name-role { color: #C9CEDA; }
.status-off { background: #FDECEA; color: var(--danger); }
.status-warn { background: #FBEBD3; color: #8A5A14; }
.status-admin { background: #ECE8FB; color: #4B3BA8; }

/* Подсветка только что добавленного столбца */
table.data th.col-flash, table.data td.col-flash { background: var(--accent-tint) !important; transition: background .6s; }

/* ---------- Карточка товара: доп. расходы, блокировка, путь товара ---------- */
.extra-costs { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.extra-head { display: flex; align-items: baseline; gap: 8px; }
.extra-title { font-size: 12px; font-weight: 600; color: var(--muted); flex-grow: 1; }
.extra-total { font-size: 13px; color: var(--text-2); }
.extra-total b { font-size: 15px; color: var(--text); }
.extra-lines { display: flex; flex-direction: column; gap: 8px; }
.extra-line { display: grid; grid-template-columns: minmax(0, 1fr) 160px 32px; gap: 8px; align-items: center; }
.extra-line .input { height: 40px; }
.extra-add { align-self: flex-start; color: var(--accent); }
.extra-add:hover { background: var(--accent-tint); color: var(--accent); }
.cost-sub { display: flex; flex-direction: column; gap: 4px; margin: -4px 0 2px 20px; padding-left: 10px; border-left: 2px solid var(--line); }
.cost-sub-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }

.lock-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-lg); background: #E9EBEF; color: #3B404C; font-size: 14px; flex-wrap: wrap; }
.lock-banner .lock-text { flex: 1 1 320px; }
.lock-banner.unlocked { background: #FBEBD3; color: #8A5A14; }
.item-main input:disabled, .item-main select:disabled, .item-main textarea:disabled { background: var(--soft); color: var(--text-2); cursor: not-allowed; opacity: 1; -webkit-text-fill-color: var(--text-2); }
.item-main .scale button:disabled { cursor: not-allowed; }

.journey { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; position: relative; }
.journey li { position: relative; }
.journey li:not(:last-child)::before { content: ''; position: absolute; left: 19px; top: 44px; bottom: -6px; width: 2px; background: var(--line); }
.j-item { display: flex; align-items: flex-start; gap: 14px; padding: 10px 8px; border-radius: 10px; color: inherit; }
a.j-item:hover { background: var(--soft); }
.j-icon { width: 24px; height: 24px; padding: 6px; box-sizing: content-box; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.j-buy { background: var(--accent-tint); color: var(--accent-strong); }
.j-truck { background: #FBEBD3; color: #8A5A14; }
.j-storage { background: #FDF1D8; color: #9A6B12; }
.j-sale { background: #E9EBEF; color: #3B404C; }
.j-body { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; row-gap: 2px; align-items: start; padding-top: 2px; }
.j-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.j-meta { font-size: 12px; color: var(--muted); grid-column: 1; }
.j-right { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.j-cost { font-size: 14px; font-weight: 700; }
.j-sub { font-size: 11px; color: var(--muted); }
.j-arrow { color: var(--faint); margin-top: 12px; flex-shrink: 0; }
.j-empty { margin: 4px 0 0 52px; font-size: 13px; color: var(--muted); }
.j-empty a { color: var(--accent); font-weight: 600; }
@media (max-width: 560px) { .extra-line { grid-template-columns: minmax(0, 1fr) 110px 32px; } .j-body { grid-template-columns: 1fr; } .j-right { grid-column: 1; grid-row: auto; align-items: flex-start; text-align: left; } }

/* Поиск по доставкам и хранению */
.party-col { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.party-col .party-list { width: 100%; }
.party-search { max-width: none; min-width: 0; background: #fff; }
.party-total {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 18px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
}
.party-total-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.party-total-sum { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.party-total-sub { font-size: 13px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pager:empty { display: none; }
.pager-nums { display: flex; align-items: center; gap: 4px; }
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font: 600 13px Onest, sans-serif; cursor: pointer;
}
.pager-btn:hover:not(:disabled) { border-color: #C3C8D2; }
.pager-btn[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-gap { padding: 0 2px; color: var(--faint); }
.pager-info { font-size: 13px; color: var(--muted); }
@media (max-width: 1180px) { .party-col { width: 100%; } }

/* ---------- Выпадающий список (замена системного <select>) ---------- */
select.dd-native { display: none !important; }
.dd { position: relative; display: inline-block; max-width: 100%; vertical-align: middle; }
.field .dd, .dd:has(> .dd-btn.input) { display: block; width: 100%; }
.dd-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--border-input); border-radius: var(--radius); background: #fff;
  color: var(--text); font: 500 14px Onest, sans-serif; text-align: left; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.dd-btn:hover:not(:disabled) { border-color: #C3C8D2; }
.dd-btn:focus-visible, .dd.open .dd-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58, 99, 232, .15); }
.dd-btn.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(196, 50, 31, .12); }
.dd-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn.dd-placeholder .dd-text { color: var(--faint); }
.dd-chev { flex: none; color: var(--muted); transition: transform .15s; }
.dd.open .dd-chev { transform: rotate(180deg); }
.dd-btn:disabled { background: var(--soft); color: var(--text-2); cursor: not-allowed; }
.dd-btn:disabled .dd-chev { opacity: .4; }
.sale-card .field .dd-btn { border-color: var(--accent-border); }

.dd-list {
  position: fixed; z-index: 1000; max-width: min(420px, calc(100vw - 16px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font: 500 14px Onest, sans-serif; color: var(--text); text-transform: none; letter-spacing: 0;
}
.dd-scroll { overflow-y: auto; padding: 6px; flex: 1 1 auto; }
.dd-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--faint); flex: none; }
.dd-search input, .dd-search input:focus { flex: 1; width: auto; min-width: 0; height: 40px; padding: 0; border: 0; outline: none; box-shadow: none; background: transparent; font: 500 14px Onest, sans-serif; color: var(--text); }
.dd-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.dd-opt {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 7px 10px;
  border-radius: 6px; cursor: pointer; line-height: 1.35;
}
.dd-opt-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.dd-opt.active { background: var(--soft-2); }
.dd-opt.sel { color: var(--accent-strong); font-weight: 600; }
.dd-opt.sel .i { color: var(--accent); flex: none; }
.dd-opt.dd-empty { color: var(--faint); }
.dd-opt[hidden], .dd-group[hidden] { display: none; }
.dd-none { padding: 10px; color: var(--faint); font-size: 13px; }
.dd-add { flex: none; margin: 0; border-radius: 0; border-top: 1px solid var(--line); padding: 10px 16px; color: var(--accent); font-weight: 600; }
.dd-add.active { background: var(--accent-tint); }
.dd-add .i { flex: none; }
