:root {
  --bg: #f6f6f4;
  --card: #fff;
  --line: #e3e2dd;
  --ink: #1f1f1d;
  --muted: #6f6e69;
  --accent: #1f5fa8;
  --below: #a32d2d;
  --below-bg: #fcebeb;
  --above: #854f0b;
  --above-bg: #faeeda;
  --inside: #0f6e56;
  --inside-bg: #e6f4ef;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

.shell { display: flex; align-items: stretch; min-height: 100vh; }

.side {
  width: 210px; flex: 0 0 210px; background: var(--card);
  border-right: 1px solid var(--line); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand {
  font-weight: 600; letter-spacing: .2px; color: var(--ink);
  padding: 2px 8px 14px; font-size: 16px;
}
.side .brand:hover { text-decoration: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side nav a {
  color: var(--ink); padding: 7px 10px; border-radius: 8px; font-size: 14px;
}
.side nav a:hover { background: #f0efec; text-decoration: none; }
.side nav a.on { background: #e6f1fb; color: var(--accent); font-weight: 500; }
.side .group {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; padding: 14px 10px 4px;
}
.side .who {
  margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid var(--line);
  font-size: 13px;
}
.side .who .name { font-weight: 500; }

main { flex: 1; min-width: 0; padding: 18px 22px 60px; max-width: 1500px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side {
    width: auto; flex: none; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .group { display: none; }
  .side .who { margin-top: 8px; }
}
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
input[type=text], input[type=number], input[type=password], select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink);
}
input[type=text]:focus, select:focus { outline: 2px solid #cfe0f3; border-color: var(--accent); }
button {
  font: inherit; padding: 7px 14px; border: 1px solid var(--line); background: var(--card);
  border-radius: 8px; cursor: pointer;
}
button:hover { background: #f0efec; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #17518f; }
button.link { border: none; background: none; color: var(--muted); padding: 2px 4px; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 12px; font-weight: 600; color: var(--muted);
  position: sticky; top: 0; z-index: 2; background: var(--card);
  box-shadow: inset 0 -1px 0 var(--line);
}
tbody tr:hover { background: #fafaf8; }
/* clip, а не hidden: hidden делает контейнер прокручиваемым и ломает липкую шапку */
.wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: clip; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
  border-radius: 7px; font-size: 13px; white-space: nowrap; margin: 0 4px 4px 0;
}
.chip.below { background: var(--below-bg); color: var(--below); }
.chip.above { background: var(--above-bg); color: var(--above); }
.chip.inside { background: var(--inside-bg); color: var(--inside); }
.chip.unknown { background: #f0efec; color: var(--muted); }
.chip small { opacity: .75; font-size: 11px; }

.titled { display: flex; gap: 10px; align-items: flex-start; }
.thumb {
  width: 38px; height: 38px; object-fit: contain; flex: 0 0 38px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
.hero {
  float: right; width: 120px; height: 120px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-left: 16px;
}

th.partner { background: #faf6ef; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.name { font-weight: 500; }
.corridor { color: var(--muted); font-size: 12px; white-space: nowrap; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: #f0efec; color: var(--muted); font-size: 12px;
}
.pill.on { background: #e6f1fb; color: var(--accent); }

.login { max-width: 320px; margin: 12vh auto; }
.login .panel { padding: 22px; }
.login input { width: 100%; margin-bottom: 10px; }
.error { color: var(--below); font-size: 13px; margin-bottom: 10px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.stat { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 8px; }
.stat b { font-size: 20px; font-weight: 600; display: block; }
.stat span { color: var(--muted); font-size: 12px; }

/* динамика цен на странице товара: график слева, легенда справа (на узком экране — под ним) */
.chart-box { display: flex; gap: 16px; align-items: flex-start; }
.chart-box svg { flex: 1 1 auto; min-width: 0; }
.chart-legend { list-style: none; margin: 0; padding: 0; font-size: 12px; min-width: 190px; }
.chart-legend li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.chart-legend b { margin-left: auto; font-weight: 600; }
.chart-legend .swatch { width: 12px; height: 3px; border-radius: 2px; flex: none; }
@media (max-width: 720px) { .chart-box { flex-direction: column; } .chart-legend { min-width: 0; width: 100%; } }
