:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #005bff; --accent-ink: #fff; --bad: #c62828; --ok: #2e7d32; --note: #fff6dc;
  --g0: #edfaee; --g1: #ebf4ff; --g2: #f5f0fd; --g3: #e8fcf7; --we: #fafafa;
  --total: #fff9e6;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
button { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
button:hover { border-color: #b8bec8; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
form.inline { display: inline; }
.hint { color: var(--muted); font-size: 12px; }
.bad { color: var(--bad); }
.ok { color: var(--ok); }
.note { background: var(--note); padding: 8px 12px; border-radius: 6px; }

/* шапка */
.top { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--ink); }
.top nav a.on { background: var(--g1); color: var(--accent); }
.me { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); }
main { padding: 16px; }
footer { padding: 8px 16px 16px; color: var(--muted); font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 380px; margin: 40px auto; }
.narrow label { display: block; margin-bottom: 12px; }
.narrow input { display: block; width: 100%; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* РнП: панель фильтров */
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bar h1 { margin: 0 8px 0 0; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg label { padding: 6px 12px; cursor: pointer; }
.seg label.on { background: var(--accent); color: #fff; }
.seg input { display: none; }
.dt { color: var(--muted); }
.pick { position: relative; }
.pick summary { list-style: none; cursor: pointer; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pick summary::-webkit-details-marker { display: none; }
.pick-list { position: absolute; z-index: 20; top: 36px; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 220px; max-height: 360px; overflow: auto; }
.pick-list label { display: block; padding: 3px 0; white-space: nowrap; }
.pick-tools { display: flex; gap: 6px; margin-bottom: 6px; }
.pick-tools button { padding: 2px 8px; font-size: 12px; }
.refresh { margin-left: auto; }

/* график */
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 4px; margin-bottom: 12px; }
.chart-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#chart-title { font-weight: 600; }
#chart { width: 100%; height: 210px; display: block; }
#chart .bar-p { fill: #5b8def; }
#chart .bar-n { fill: #e57373; }
#chart .lbl-v { fill: var(--ink); font-weight: 600; }
#chart .lbl-c { fill: var(--muted); }
#chart .ln2 { fill: none; stroke: #f08a24; stroke-width: 2.2; }
#chart .pt2 { fill: #fff; stroke: #f08a24; stroke-width: 2; }
#chart .lbl-2 { fill: #c25e00; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.chart-tools { display: inline-flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.chart-tools .cmp { font-size: 12px; color: var(--muted); }
.chart-tools select { font-size: 12px; padding: 2px 6px; }
#chart-title .lg1::before, #chart-title .lg2::before { content: ""; display: inline-block; width: 12px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: 0; }
#chart-title .lg1::before { background: #5b8def; }
#chart-title .lg2::before { background: #f08a24; height: 3px; vertical-align: 3px; }
#chart .lbl-c.good { fill: #1e7b34; }
#chart .lbl-c.bad { fill: #b3261e; }
#chart .ax { stroke: var(--line); }
#chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; }
#chart .pt { fill: var(--accent); }
#chart text { font-size: 11px; fill: var(--muted); }

/* таблица-пивот */
.table-wrap { overflow: auto; max-height: calc(100vh - 330px); min-height: 300px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
table.pivot { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.pivot th, .pivot td { padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pivot td { text-align: right; min-width: 74px; }
.pivot thead th { position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 2px solid #cfd4dc; font-weight: 600; text-align: right; vertical-align: bottom; }
.pivot thead th small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.pivot thead th.we small { color: #b24; }
.pivot thead th.part { color: var(--muted); }
.pivot .c-off { position: sticky; left: 0; z-index: 2; background: #fff; text-align: left; min-width: 150px; max-width: 190px; vertical-align: top; }
.pivot .c-met { position: sticky; left: 150px; z-index: 2; text-align: left; font-weight: 400; min-width: 170px; border-right: 2px solid #cfd4dc; }
.pivot thead .c-off, .pivot thead .c-met { z-index: 4; text-align: left; }
.pivot tbody.blk tr:last-child > * { border-bottom: 2px solid #b8bec8; }
.pivot tbody.blk tr.main td, .pivot tbody.blk tr.main .c-met { font-weight: 600; }
.pivot tr.g0 > td, .pivot tr.g0 > .c-met { background: var(--g0); }
.pivot tr.g1 > td, .pivot tr.g1 > .c-met { background: var(--g1); }
.pivot tr.g2 > td, .pivot tr.g2 > .c-met { background: var(--g2); }
.pivot tr.g3 > td, .pivot tr.g3 > .c-met { background: var(--g3); }
.pivot tbody.total .c-off { background: var(--total); }
.pivot td.neg { color: var(--bad); }
.pivot tr { cursor: pointer; }
/* наведение и выбранная строка: мягкая подсветка всей строки, включая названия (поверх подкраски ячеек) */
.pivot tbody tr:hover > td, .pivot tbody tr:hover > th { box-shadow: inset 0 0 0 9999px rgba(0, 91, 255, .06); }
.pivot tbody tr.sel > td, .pivot tbody tr.sel > th { box-shadow: inset 0 0 0 9999px rgba(0, 91, 255, .11); }
.pivot tbody tr.sel > .c-met, .bymetric tbody tr.sel > .c-off { color: var(--accent); font-weight: 600; }
.pivot tbody tr.sel > :first-child { box-shadow: inset 3px 0 0 var(--accent), inset 0 0 0 9999px rgba(0, 91, 255, .11); }
.pivot tbody.folded tr.sub { display: none; }
.fold { border: 0; background: none; padding: 0 6px 0 0; color: var(--muted); }
.pivot tbody.folded .fold { transform: rotate(-90deg); display: inline-block; }

/* списки, формы */
table.list { border-collapse: collapse; width: 100%; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-weight: 600; color: var(--muted); font-size: 12px; }
tr.off td { color: var(--muted); }
.users input[name=name] { width: 160px; }
.users input[type=password] { width: 140px; }
.addform { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.addform h2, .addform .hint { flex-basis: 100%; margin: 0; }
.addform label { display: flex; flex-direction: column; gap: 4px; }
.chk { white-space: nowrap; margin-right: 10px; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.role-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.role-name { font-weight: 600; font-size: 16px; }
.perm td.lv { white-space: nowrap; }
.role-btns { display: flex; gap: 8px; margin-top: 10px; }

/* меню: группы видны только слева; сверху порядок — меню, поиск, пользователь */
.ngroup { display: none; }
.top nav { order: 1; }
.top .search { order: 2; }
.top .me { order: 3; }

/* меню слева (на широком экране); сворачивается до иконок — кнопка «<<» у названия */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.fold-nav { display: none; border: 0; background: none; padding: 4px; color: var(--muted); margin-left: auto; }
.fold-nav:hover { color: var(--ink); }
.top nav a, .me a, .me button.link { display: inline-flex; align-items: center; gap: 8px; }
.top nav .ico { display: none; }
.me .ico { display: none; }
@media (min-width: 701px) {
  body.side { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
  body.side .top { position: sticky; top: 0; z-index: 20; height: 100vh; overflow-y: auto; flex-direction: column;
    align-items: stretch; flex-wrap: nowrap; gap: 14px; padding: 14px 10px; border-bottom: 0; border-right: 1px solid var(--line); }
  body.side .top > * { order: 0; }
  body.side .brand { padding: 0 8px; font-size: 15px; white-space: nowrap; }
  body.side .fold-nav { display: inline-flex; }
  body.side .search input { width: 100%; }
  body.side .top nav { flex-direction: column; gap: 2px; }
  body.side .top nav a { padding: 7px 10px; }
  body.side .top nav .ico, body.side .me .ico { display: inline-block; }
  body.side .ngroup { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 10px 4px; }
  body.side .ngroup:first-child { padding-top: 0; }
  body.side .me { margin: auto 0 0; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
  body.side .me a, body.side .me button.link { color: var(--muted); }
  body.side .page { min-width: 0; }
  /* свёрнуто: только иконки, подсказка — при наведении */
  body.side.folded { grid-template-columns: 58px minmax(0, 1fr); }
  body.side.folded .top { padding: 14px 8px; align-items: center; }
  body.side.folded .brand, body.side.folded .search, body.side.folded .ngroup, body.side.folded .lbl { display: none; }
  body.side.folded .fold-nav { margin: 0; transform: rotate(180deg); }
  body.side.folded .top nav { align-items: center; }
  body.side.folded .top nav a { padding: 8px; }
  body.side.folded .top nav .ngroup + a, body.side.folded .top nav a:first-of-type { margin-top: 10px; }
  body.side.folded .me { align-items: center; padding: 10px 0 0; }
}

/* поиск в шапке */
.search input { width: 200px; }

/* сводка и карточка */
h3 { font-size: 14px; margin: 14px 0 8px; }
.seg a { padding: 6px 12px; color: var(--ink); }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.card .kpi { background: var(--bg); border: 0; }
.kpi-l { color: var(--muted); font-size: 12px; }
.kpi-v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-d, .d { font-size: 12px; color: var(--muted); }
.good { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: #9a6700; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--g0); white-space: nowrap; }
.pill.bad { background: #fdecec; color: var(--bad); }
.pill.warn { background: #fff4d6; color: #8a5a00; }
.pill.good { background: #e7f6e9; color: var(--ok); }
.signals ul { margin: 0; padding-left: 18px; columns: 2 420px; }
.signals li { margin: 3px 0; break-inside: avoid; }
.signals li.bad::marker { color: var(--bad); }
.signals li.warn::marker { color: #e0a000; }
.list-wrap { overflow-x: auto; }
table.list th.r, table.list td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.list th a { color: inherit; }
.products tbody tr { cursor: pointer; }
.products tbody tr:hover td { background: var(--g1); }
.products td { white-space: nowrap; }
.spark { width: 120px; height: 28px; display: block; }
.spark polyline, .hist polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.hist svg { width: 100%; height: 60px; display: block; background: var(--bg); border-radius: 6px; }
.neg { color: var(--bad); }
.crumbs { margin: 0 0 8px; }
.head-top { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.head-top h1 { margin: 0; }
.facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); }
.facts b { color: var(--ink); }
.summary { margin: 10px 0 0; padding: 8px 12px; background: var(--g1); border-radius: 6px; }
.anchors { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.anchors a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
section[id] { scroll-margin-top: 12px; }
table.kv td { padding: 4px 8px; }

/* отчёт */
.rep-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.rep-nav { display: flex; align-items: center; gap: 10px; }
.rep-nav h1 { margin: 0; font-size: 20px; }
.navbtn { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 16px; }
.navbtn:hover { text-decoration: none; border-color: #b8bec8; }
.navbtn.off { color: #c9ced6; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.alert.bad { background: #fdecec; color: #8c1d1d; }
.alert.warn { background: #fff4d6; color: #6b4600; }
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.hcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 10px; }
.hv { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; margin: 2px 0; }
.hrow { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.hrow .d { font-size: 13px; }
.trend { width: 100%; height: 32px; display: block; margin-top: 6px; }
.trend polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.split { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin: 6px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }
.legend b { color: var(--ink); font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.c1 { background: #9aa5b5; } .c2 { background: #f0a24a; } .c3 { background: #7c8cf0; } .c4 { background: #3aa76d; }
.c5 { background: #4fb3d9; } .c6 { background: #c3a6f2; } .c7 { background: #e57373; } .c8 { background: #d9d9d9; }
.barcell { width: 140px; }
.barcell.wide { width: 50%; }
.pbar { display: inline-block; height: 10px; background: #3aa76d; border-radius: 3px; vertical-align: middle; }
.pbar.negbar { background: var(--bad); }
.pbar.transit { background: #b9c7ff; border-radius: 0 3px 3px 0; }
.stockbars .pbar { background: var(--accent); border-radius: 3px 0 0 3px; }
.stockbars tr, .rep tbody tr { cursor: pointer; }
.stockbars tr:hover td { background: var(--g1); }

/* полоса прокрутки вбок, прижатая к низу экрана (для широких таблиц) */
.hscroll { position: fixed; bottom: 0; height: 17px; overflow-x: auto; overflow-y: hidden; z-index: 30;
  background: rgba(245, 246, 248, .95); border-top: 1px solid var(--line); display: none; }
.hscroll > div { height: 1px; }

/* РнП: компактная панель */
.rnp-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; }
.rnp-top h1 { font-size: 18px; margin: 0 4px 0 0; }
.rnp-top .filters { display: contents; }
.rnp-top .grow { flex: 1; }
.rnp-top button, .rnp-top .pick summary, .rnp-top input[type=date] { font-size: 13px; padding: 3px 8px; }
.seg.sm a, .seg.sm label { padding: 3px 9px; font-size: 13px; }
.rnp-top .dates { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.rnp-top .month-pick { font-size: 13px; padding: 3px 6px; }
.rnp-top .pick-tools .primary { margin-left: auto; }
.hidden-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.rnp-top .refresh { margin-left: 0; }
.rnp-top ~ .mtabs { margin-bottom: 8px; }
.mtabs a, .mtabs .chg-toggle { padding: 2px 8px; font-size: 12px; }

/* РнП: по метрике */
.filters { margin-bottom: 10px; }
.mtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.mtabs a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); font-size: 13px; }
.mtabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mtabs a:hover { text-decoration: none; }
.bymetric .c-off { min-width: 200px; width: 200px; max-width: 200px; border-right: 2px solid #cfd4dc;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }      /* длинные названия складов — переносом */
.chart-fold { border: 0; background: none; padding: 0 8px 0 0; font-weight: 600; color: var(--accent); cursor: pointer; }
.chart-box.folded #chart { display: none; }
.chart-box.folded { padding-bottom: 8px; }
.bymetric td { position: relative; }            /* шапка (в т.ч. «Итого», «к пред.») остаётся прилипающей */
.bymetric th.tot, .bymetric td.tot { background: #fafbfc; border-left: 1px solid var(--line); font-weight: 600; text-align: right; }
.bymetric tr.total td, .bymetric tr.total th { border-bottom: 2px solid #b8bec8; font-weight: 600; }
.bymetric tr.total .c-off { background: var(--total); }
.hp1 { background: #eaf7ee; } .hp2 { background: #c9ecd3; } .hp3 { background: #9fdcb1; }
/* цвета строк метрик по группам (кнопка «🎨 Цвета метрик»): название и ячейки без подкраски —
   цветом группы, ячейки тепловой карты сохраняют свой цвет */
body.rowcol .bymetric tr.mg0 > th { background: #dff3e4; box-shadow: inset 4px 0 0 #6cc28a; }
body.rowcol .bymetric tr.mg1 > th { background: #dcebfd; box-shadow: inset 4px 0 0 #6aa2ee; }
body.rowcol .bymetric tr.mg2 > th { background: #ebe4fb; box-shadow: inset 4px 0 0 #a58be6; }
body.rowcol .bymetric tr.mg3 > th { background: #d9f6ef; box-shadow: inset 4px 0 0 #4fc4a8; }
body.rowcol .bymetric tr.mg0 > td:not([class*="h"]) , body.noheat.rowcol .bymetric tr.mg0 > td { background: var(--g0); }
body.rowcol .bymetric tr.mg1 > td:not([class*="h"]) , body.noheat.rowcol .bymetric tr.mg1 > td { background: var(--g1); }
body.rowcol .bymetric tr.mg2 > td:not([class*="h"]) , body.noheat.rowcol .bymetric tr.mg2 > td { background: var(--g2); }
body.rowcol .bymetric tr.mg3 > td:not([class*="h"]) , body.noheat.rowcol .bymetric tr.mg3 > td { background: var(--g3); }
body.rowcol .bymetric tr.mg0 > td.tot, body.rowcol .bymetric tr.mg1 > td.tot,
body.rowcol .bymetric tr.mg2 > td.tot, body.rowcol .bymetric tr.mg3 > td.tot { filter: brightness(0.98); }

/* личный цвет метрики (настройка метрик) — вместо цвета группы */
body.rowcol .bymetric tr.mcust > th { background: color-mix(in srgb, var(--mc) 30%, white); box-shadow: inset 4px 0 0 var(--mc); }
body.rowcol .bymetric tr.mcust > td:not([class*="h"]), body.noheat.rowcol .bymetric tr.mcust > td { background: color-mix(in srgb, var(--mc) 12%, white); }
.cfg-order .mc { width: 22px; height: 18px; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: none; cursor: pointer; }

/* тепловая карта выключена (кнопка «▦ Тепловая карта») */
body.noheat .bymetric td.hp1, body.noheat .bymetric td.hp2, body.noheat .bymetric td.hp3,
body.noheat .bymetric td.hn1, body.noheat .bymetric td.hn2, body.noheat .bymetric td.hn3 { background: transparent; }
body.noheat .legend-heat .sw2 { display: none; }
.hn1 { background: #fdf0ef; } .hn2 { background: #f9d3cf; } .hn3 { background: #f2a9a1; }
.pivot td.alert, b.alert { outline: 2px solid var(--bad); outline-offset: -2px; }
.ev { color: #7c4dff; font-weight: 700; position: absolute; top: -2px; right: 2px; font-size: 14px; cursor: help; }
.legend-heat .ev { position: static; }
.sw2 { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: 0; margin: 0 4px 0 10px; }
.xp { border: 0; background: none; padding: 0 6px 0 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.xp-all { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 0 5px; margin-right: 6px;
  font-size: 13px; line-height: 18px; color: var(--muted); cursor: pointer; }
.xp-all:hover { color: var(--accent); border-color: var(--accent); }
.xp-name { cursor: pointer; color: var(--ink); font-weight: 600; }
.xp-name:hover { text-decoration: underline; }
/* названия в таблицах и списках — чёрные; синие только у выделенной строки */
table.pivot a, table.list a, .signals a { color: var(--ink); }
table.pivot a:hover, table.list a:hover, .signals a:hover { color: var(--accent); }
table.pivot tr.sel .xp-name, table.pivot tr.sel a, table.pivot tr.sel > th { color: var(--accent); }
.to-card { margin-left: 6px; color: var(--muted); font-size: 12px; }
/* раскрытый артикул: строка пустая (значения — в подстроках) и прилипает к верху, пока видны его метрики */
/* значения в строке раскрытого артикула не нужны (они в подстроках); прилипает только ячейка с
   названием — без белой полосы через всю таблицу */
.bymetric tr.blank-open.open > td { background: transparent !important; color: transparent; box-shadow: none !important; }
.bymetric tr.blank-open.open > td > * { visibility: hidden; }
.bymetric tr.sub2 > th { padding-left: 46px; }
.bymetric tr.camp-row > th .xp { margin-left: -14px; }
.bymetric tr.main.open > th.c-off { background: #f3f6fc; }
/* название раскрытого артикула в шапке, пока прокручиваются его метрики */
.cur-off { display: block; font-size: 11px; font-weight: 600; color: var(--accent); line-height: 1.2; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.cur-off:empty { display: none; }
.bymetric tr.sub > th { font-weight: 400; color: var(--ink); padding-left: 26px; font-size: 13px; }   /* названия параметров — чёрные */
.bymetric tr.sub > td { font-size: 13px; }
.bymetric tr.sub:last-of-type > * { border-bottom: 1px solid var(--line); }

.cfg .cfg-list { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 90px); overflow-x: hidden; z-index: 40; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.cfg .cfg-list label { white-space: normal; }
.cfg-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 20px; }
.cfg-h { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.cfg-order { list-style: none; margin: 0; padding: 0; counter-reset: n; }
.cfg-order li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 4px; background: #fff; cursor: grab; }
.cfg-order li.drag { opacity: .5; border-style: dashed; }
.cfg-order li::before { counter-increment: n; content: counter(n); color: var(--muted); font-size: 11px; min-width: 16px; }
.cfg-order .grip { color: #b8bec8; letter-spacing: -2px; }
.cfg-order .nm { flex: 1; white-space: normal; }
.cfg-order button { border: 0; background: none; padding: 0 3px; color: var(--muted); font-size: 11px; cursor: pointer; }
.cfg-order button:hover { color: var(--ink); }
.cfg-order .rm:hover { color: var(--bad); }
.cfg-cat { columns: 2 200px; column-gap: 16px; }
.cfg-cat .cfg-h { column-span: all; }
.cfg fieldset { border: 0; padding: 0; margin: 0 0 10px; break-inside: avoid; }
.cfg legend { font-weight: 600; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.cfg-btns { display: flex; gap: 8px; margin-top: 10px; position: sticky; bottom: -8px; background: #fff; padding: 8px 0; }
@media (max-width: 700px) { .cfg-cols { grid-template-columns: 1fr; } }

.bymetric td small.chg { display: block; font-size: 10.5px; line-height: 1.1; font-weight: 400; color: var(--muted); white-space: nowrap; }   /* изменение — под числом */
.bymetric td small.chg.good { color: #1e7b34; }
.bymetric td small.chg.bad { color: #b3261e; }
.chg-toggle { padding: 5px 10px; border: 1px dashed #b8bec8; border-radius: 14px; background: #fff; font-size: 13px; color: var(--muted); }
.chg-toggle.on { border-style: solid; border-color: var(--accent); color: var(--accent); }

.bymetric .camp { color: var(--ink); }
.bymetric .camp-tags { display: block; font-size: 11px; color: var(--muted); }
.bymetric tr.sub > th { max-width: 260px; white-space: normal; }

/* РнП: почему изменилась прибыль */
.why-head { font-size: 15px; margin: 0 0 10px; }
.whyf td { padding: 5px 8px; }
.wbar { width: 260px; white-space: nowrap; }
.wbar .half { display: inline-block; width: 50%; vertical-align: middle; }
.wbar .neg-side { text-align: right; border-right: 1px solid #b8bec8; }
.wbar .pbar { height: 12px; }
.whyt td { white-space: nowrap; }

/* телефон: панель в столбик, колонка «Метрика» уже */
@media (max-width: 700px) {
  main { padding: 10px; }
  .me { margin-left: 0; }
  .refresh { margin-left: 0; }
  .pivot .c-off { min-width: 96px; max-width: 110px; white-space: normal; }
  .pivot .c-met { left: 96px; min-width: 120px; white-space: normal; }
  .table-wrap { max-height: none; }
  .roles { grid-template-columns: 1fr; }
  .top { gap: 8px; padding: 8px 10px; }
  .top nav { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; order: 3; flex-basis: 100%; }
  .top nav a { white-space: nowrap; padding: 6px 8px; }
  .me { font-size: 12px; gap: 8px; margin-left: auto; }
  .search input { width: 100%; }
  .search { flex-basis: 100%; order: 4; }
  .kpi-v { font-size: 18px; }
  .sm-hide { display: none; }
  .hero { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hcard { padding: 10px 12px 8px; }
  .hv { font-size: 22px; }
  .rep-nav h1 { font-size: 16px; }
  .barcell.wide { width: 35%; }
  .wbar { width: 110px; }
  .bymetric .c-off { min-width: 110px; }
}

/* ---------- ОПиУ ---------- */
.opiu .c-off { min-width: 270px; width: 270px; max-width: 270px; white-space: normal; }
.opiu th.c-off .xp-name { cursor: default; }
.opiu tr[data-node] > th.c-off .xp-name { cursor: pointer; }
.opiu tr.lv0 > th.c-off { padding-left: 8px; }
.opiu tr.lv1 > th.c-off { padding-left: 26px; font-weight: 400; }
.opiu tr.lv2 > th.c-off { padding-left: 44px; font-weight: 400; font-size: 13px; }
.opiu tr.lv3 > th.c-off { padding-left: 62px; font-weight: 400; font-size: 13px; color: #333; }
.opiu tr.lv2 > td, .opiu tr.lv3 > td { font-size: 13px; }
.opiu tr.lv0:not([data-node]) > th.c-off { padding-left: 30px; }
.opiu tr.lv1:not([data-node]) > th.c-off { padding-left: 48px; }
.opiu tr.lv2:not([data-node]) > th.c-off { padding-left: 66px; }
.opiu tr.lv3:not([data-node]) > th.c-off { padding-left: 84px; }
.opiu tr.op-head > th, .opiu tr.op-head > td { font-weight: 700; }
.opiu tr.op-head > th.c-off { background: #eaf3ff; }
.opiu tr.op-res > th.c-off { background: #e9f8ec; }
.opiu tr.op-res > td:not([class*="h"]) { background: #f4fbf5; }
.opiu tr.op-ref > th.c-off { font-style: italic; font-weight: 400; color: #444; background: #f5f5f5; }
.opiu tr.op-warn > th.c-off { background: #fde0e0; }
.opiu tr.op-head > *, .opiu tr.op-ref > * { border-top: 1px solid #d5dae2; }
.opiu th.per, .opiu td.per { border-left: 2px solid #9aa3ae; }
.opiu td.per:not([class*="h"]) { background: #fff8e1; }
.opiu thead th.per { background: #fff3cf; }
.opiu td.part { color: #666; }
.opiu .xp-name { font-weight: inherit; }
.opiu tr > th.c-off { font-weight: 400; }
.opiu tr.op-head > th.c-off { font-weight: 700; }
.opiu td small.op-sub { display: block; font-size: 10.5px; line-height: 1.1; font-weight: 400; white-space: nowrap; }
.opiu td small.op-sub .pct { color: #8a8f98; }
.opiu td small.op-sub .chg { margin-left: 5px; color: var(--muted); }
.opiu td small.op-sub .chg.good { color: #1e7b34; }
.opiu td small.op-sub .chg.bad { color: #b3261e; }
.legend-heat .part-mark { color: var(--muted); }
@media (max-width: 700px) { .opiu .c-off { min-width: 150px; width: 150px; max-width: 150px; } }

/* ---------- Себестоимость (ввод) ---------- */
.costs-wrap { max-height: calc(100vh - 290px); }
.costs th.c-off { min-width: 170px; text-align: left; }
.costs .sku { font-size: 12px; color: var(--muted); white-space: nowrap; }
.costs td { padding: 2px 3px; }
.costs th.cur, .costs td.cur { background: #eef5ff; }
.costs th.fut small { color: var(--muted); }
.costs input.ci { width: 84px; text-align: right; border: 1px solid transparent; border-radius: 4px; padding: 4px 5px;
  font: inherit; font-variant-numeric: tabular-nums; background: transparent; }
.costs input.ci:hover { border-color: #cfd4dc; }
.costs input.ci:focus { border-color: var(--accent); background: #fff; outline: none; }
.costs input.ci::placeholder { color: #a0a6ae; font-style: italic; }
.costs input.ci.chg { background: #fff6d6; border-color: #e3c25a; }
.costs input.ci.bad, input.bad { background: #fde0e0; border-color: #d33; }
.costs .inh { color: #a0a6ae; font-style: italic; }
.add-cost { margin-top: 12px; }
.add-cost .row-inputs { display: flex; flex-wrap: wrap; gap: 10px; }
.add-cost label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.add-cost input { width: 170px; }
.save-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 10px 12px; margin-top: 10px; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 10px rgba(0,0,0,.04); z-index: 6; }
.save-bar #chg-count.bad { color: #b3261e; font-weight: 600; }
.save-bar button:disabled { opacity: .45; cursor: default; }

/* ---------- Расходы (ввод) ---------- */
.expenses td.x, .expenses th.x { width: 26px; padding: 0 2px; }
.expenses .rm-row { border: 0; background: none; color: #b0b6be; cursor: pointer; font-size: 13px; padding: 4px; }
.expenses .rm-row:hover { color: #b3261e; }
.expenses td.sec select { font: inherit; font-size: 12px; border: 1px solid transparent; background: transparent; padding: 3px; max-width: 170px; }
.expenses td.sec select:hover, .expenses td.sec select:focus { border-color: #cfd4dc; }
.expenses td.name input, .expenses td.off input { font: inherit; border: 1px solid transparent; border-radius: 4px; padding: 4px 5px; background: transparent; }
.expenses td.name input { width: 220px; }
.expenses td.off input { width: 150px; font-size: 12px; }
.expenses td.name input:hover, .expenses td.off input:hover { border-color: #cfd4dc; }
.expenses td.name input:focus, .expenses td.off input:focus { border-color: var(--accent); background: #fff; outline: none; }
.expenses input.chg, .expenses select.chg { background: #fff6d6 !important; border-color: #e3c25a !important; }
.expenses td.name, .expenses td.off, .expenses td.sec { text-align: left; }
.expenses tfoot tr.tot th { text-align: left; font-weight: 600; font-size: 12px; }
.expenses tfoot tr.tot td { text-align: right; font-weight: 600; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.expenses tfoot tr.tot > * { border-top: 2px solid #cfd4dc; background: #fafbfc; }

.expenses td.op, .expenses th.op { font-size: 11px; white-space: nowrap; text-align: left; }
.op-yes { color: #1e7b34; font-weight: 600; }
.op-no { color: #8a8f98; }
.expenses tr.in td.name input, .expenses tr.in td.name { color: #1e6b34; }
.expenses tr.in > td:first-child { box-shadow: inset 3px 0 0 #6cc28a; }
.expenses tfoot tr.all-tot > * { background: #eef1f5; }
.sec-help { margin-bottom: 10px; }
.sec-help summary { cursor: pointer; font-weight: 600; }
.sec-help .list td { vertical-align: top; }

/* ---------- Склад и Настройки поставок/закупок (ввод) ---------- */
.sklad-sec, .grid-edit > .card { margin-bottom: 12px; }
.sklad-wrap, .cfg-wrap { max-height: none; }
.sklad td.x, .sklad th.x { width: 26px; padding: 0 2px; }
.grid-edit .rm-row { border: 0; background: none; color: #b0b6be; cursor: pointer; font-size: 13px; padding: 4px; }
.grid-edit .rm-row:hover { color: #b3261e; }
.sklad input.ci { width: 64px; }
.sklad td.ref, .sklad th.ref { color: var(--muted); font-size: 12px; white-space: nowrap; padding: 2px 8px; }
.sklad td.ref { text-align: right; }
.sklad tr[data-new] th.c-off { color: var(--accent); }
.sklad th.day, .sklad th.day-add { position: relative; white-space: nowrap; padding: 4px 6px; }
.sklad .day-btn { border: 1px solid transparent; background: none; font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px;
  border-radius: 4px; color: var(--ink); line-height: 1.15; }
.sklad .day-btn small { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; }
.sklad .day-btn:hover { border-color: #cfd4dc; background: #fff; color: var(--accent); }
.sklad th.day.chg .day-btn { background: #fff6d6; border-color: #e3c25a; }
.sklad .day-rm { display: none; position: absolute; top: 1px; right: 0; border: 0; background: none; color: #b0b6be;
  cursor: pointer; font-size: 11px; padding: 2px 3px; }
.sklad th.day.empty .day-rm { display: block; }
.sklad .day-rm:hover { color: #b3261e; }
.sklad .day-pick { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.sklad .day-add-btn { border: 1px dashed #b8bec8; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--accent); white-space: nowrap; }
.sklad .day-add-btn:hover { border-style: solid; border-color: var(--accent); }
.sklad-add { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; margin-top: 8px; }
.sklad-add label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.sklad-add .add-off { width: 180px; }
.plancfg input.ci { width: 70px; }
.plancfg select { font: inherit; border: 1px solid transparent; border-radius: 4px; padding: 3px; background: transparent; }
.plancfg select:hover, .plancfg select:focus { border-color: #cfd4dc; }
.grid-edit select.chg { background: #fff6d6; border-color: #e3c25a; }
.plancfg tr.off th.c-off { color: var(--muted); }
.plancfg tr.def > * { background: #f2f8f3; font-weight: 600; }
.cfg-params { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 6px 0 10px; }
.cfg-params label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.cfg-params input.ci { width: 60px; text-align: right; border: 1px solid #cfd4dc; border-radius: 4px; padding: 4px 5px; font: inherit; }
.cfg-params input.ci.chg { background: #fff6d6; border-color: #e3c25a; }
.cfg-params .hint { flex-basis: 100%; margin: 0; font-size: 11.5px; }

/* меню «Склад» с подменю: всплывающее окно справа при наведении */
.nsub-head .caret { margin-left: auto; font-size: 10px; color: var(--muted); }
.nsub-head .nsub-cur { margin-left: 6px; font-size: 11px; color: var(--muted); }
.nsub-head.on .nsub-cur { color: var(--accent); }
.nsub.fly .nsub-head { background: #f1f3f6; }
.nsub-items { display: none; flex-direction: column; gap: 2px; }
.nsub-items a { font-size: 13px; border-radius: 6px; color: var(--ink); }
.nsub-items a.on { background: var(--g1); color: var(--accent); }
.nsub-items a:hover { background: #f1f3f6; }
.nsub.fly .nsub-items { display: flex; position: fixed; z-index: 60; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); padding: 6px; min-width: 170px; }
.nsub.fly .nsub-items a { padding: 6px 12px !important; }
.nsub.fly .nsub-items::before { content: "Склад"; font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; padding: 2px 12px 4px; }
@media (min-width: 701px) {
  body.side .nsub-head { display: flex !important; }
}
@media (max-width: 700px) {                    /* меню сверху строкой: подпункты — обычными пунктами */
  .nsub, .nsub-items { display: contents; }
  .nsub-head { display: none !important; }
  .nsub-items a { padding: 6px 8px !important; white-space: nowrap; }
}

/* ---------- Склад Расчёт ---------- */
.sklad-calc th, .sklad-calc td { text-align: right; font-variant-numeric: tabular-nums; }
.sklad-calc thead th { white-space: normal; min-width: 84px; max-width: 120px; font-size: 12px; vertical-align: bottom; cursor: help; }
.sklad-calc th.c-off { text-align: left; min-width: 190px; white-space: nowrap; }
.sklad-calc td.txt { text-align: left; white-space: nowrap; font-size: 12px; color: var(--muted); }
.sklad-calc td.calc, .sklad-calc th.calc { background: #eaf6ec; font-weight: 700; }
.sklad-calc td.neg, .sklad-calc td.bad { color: #b3261e; font-weight: 700; }
.sklad-calc tfoot tr.tot > * { font-weight: 700; background: #eaf6ec; border-top: 2px solid #cfd4dc; }
.sklad-calc .sk-xp { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 6px 0 0; font-size: 12px; }
.sklad-calc tbody.sk-row.open .sk-xp { color: var(--accent); }
.sklad-calc tr.sk-mv > td { text-align: left; background: #fafbfc; padding: 4px 8px 10px 26px; }
.sk-moves { font-size: 12px; width: auto; }
.sk-moves th, .sk-moves td { text-align: left; padding: 3px 10px; white-space: nowrap; }
.sk-moves .num { text-align: right; }
.sk-moves tr.before td { color: #9aa1aa; }
.sk-moves tr.off td { opacity: .55; }
.sk-moves .muted { color: var(--muted); font-size: 11px; }

/* ---------- Поставки ---------- */
.supply-wrap { max-height: 70vh; }
.supply th, .supply td { text-align: right; font-variant-numeric: tabular-nums; }
.supply thead th { white-space: normal; min-width: 62px; max-width: 110px; font-size: 12px; vertical-align: bottom; cursor: help; }
.supply th.c-off { text-align: left; min-width: 230px; white-space: nowrap; }
.supply td.st, .supply th.st { text-align: left; white-space: nowrap; }
.supply td.st-red { color: #b3261e; font-weight: 600; }
.supply td.st-yel { color: #8a6100; }
.supply td.st-grn { color: #1e7b34; }
.supply td.st-none, .supply td.st-off { color: var(--muted); }
.supply td.ord, .supply th.ord { background: #fff6d6; }
.supply td.ord { font-weight: 700 !important; }                       /* «Поставить» — жирным во всех строках */
.supply td.neg { color: #b3261e; }
.supply tr.cl > * { font-weight: 600; border-top: 1px solid #dfe3e8; }
.supply tr.cl td:not(.ord):not(.st) { font-weight: 500; }
.supply tr.of th.c-off { padding-left: 30px; font-weight: 400; }
.supply tr.of > * { background: #fbfcfd; font-size: 12.5px; }
.supply tr.of td.ord { background: #fffaea; }
.supply tbody.off tr.cl > * { color: var(--muted); }
.supply .sp-xp { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 6px 0 0; font-size: 12px; }
.supply tbody.open .sp-xp { color: var(--accent); }
.supply tbody.open tr.cl > *:not(.ord) { background: #ebf5ff; }      /* раскрытый кластер — светло-синий, как в таблице */
.supply tbody.open tr.cl > * { border-top: 2px solid #8a94a3; }
.sp-meta { font-size: 12px; color: var(--muted); }
/* подсказка data-tip: своё окошко (системная подсказка title появляется с задержкой или не появляется) */
.th-tip { position: fixed; z-index: 70; max-width: 300px; background: #2b2f36; color: #fff; font-size: 12px; line-height: 1.4;
  padding: 7px 10px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.2); pointer-events: none; white-space: pre-line; }
/* подсказка свёрнутого меню — белая, как окно «Склада» */
.th-tip.nav-tip { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  padding: 6px 12px; box-shadow: 0 6px 18px rgba(0,0,0,.12); white-space: nowrap; }
.sklad td.ref[data-tip] { cursor: help; }
.sp-cfg-link { font-size: 13px; }
h2 .sp-cfg-link { font-weight: 400; margin-left: 12px; }
#cfg { scroll-margin-top: 8px; }
.sp-desc { margin: 0 0 8px; }
.supply tfoot tr.tot > * { font-weight: 700; background: #eef1f5; border-top: 2px solid #cfd4dc; }
@media (max-width: 700px) { .supply th.c-off { min-width: 150px; } .supply tr.of th.c-off { padding-left: 18px; } }

/* ---------- Закупки (таблица на классах .bymetric и .supply, итоги — .hero со «Сводки») ---------- */
.purchase tr { cursor: default; }
.purchase th.c-off { vertical-align: middle; }
.purchase td { min-width: 58px; }
.rnp-top ~ .table-wrap .purchase th, .rnp-top ~ .table-wrap .purchase td { padding: 8px; }
.rnp-top ~ .table-wrap .purchase th.c-off { min-width: 160px; width: 160px; max-width: 160px; padding-left: 12px; }
.pur-hero { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.pur-hero .hcard { padding: 10px 14px; }
.pur-hero .hv { font-size: 24px; }
.rnp-top ~ .table-wrap .purchase thead th.ord { background: #fff6d6; color: var(--ink); }
.purchase tbody tr.urgent > th.c-off { box-shadow: inset 3px 0 0 var(--bad); }
.purchase tbody tr.todo > th.c-off { box-shadow: inset 3px 0 0 #e3c25a; }
@media (max-width: 700px) { .pur-hero { grid-template-columns: repeat(2, 1fr); gap: 8px; } .pur-hero .hcard { padding: 10px 12px; } .pur-hero .hv { font-size: 20px; } }

/* ---------- «?» — инструкция к разделу ---------- */
main { position: relative; }
main > .rnp-top, main > h1:first-of-type, main > .card.narrow:first-of-type { padding-right: 40px; }
.help-btn { position: absolute; top: 12px; right: 14px; z-index: 30; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid #9aa3ae; background: #fff; color: #5b6470; font: 700 14px/1 system-ui, sans-serif; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.help-btn:hover, .help-btn.on { border-color: var(--accent); color: var(--accent); }
.help-panel { position: absolute; top: 44px; right: 14px; z-index: 40; width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 80px); overflow: auto; background: #fff; border: 1px solid #d5dae2; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20,30,50,.18); padding: 14px 18px 12px; font-size: 13.5px; line-height: 1.45; }
.help-panel h2 { margin: 0 24px 8px 0; font-size: 16px; }
.help-panel p { margin: 0 0 8px; }
.help-panel ul { margin: 0; padding-left: 18px; }
.help-panel li { margin-bottom: 6px; }
.help-close { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: #8a8f98; cursor: pointer; font-size: 14px; padding: 4px; }
.help-close:hover { color: var(--ink); }
@media (max-width: 700px) { .help-btn { top: 8px; right: 8px; } .help-panel { right: 8px; top: 40px; } }

/* ===== Новое оформление (30.10.2026): панель параметров, график, таблица, окно выбора периода ===== */
/* панель параметров — карточка (РнП, Реклама, Остатки, ОПиУ, экраны ввода) */
.rnp-top { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; gap: 8px 10px; }
.rnp-top h1 { font-size: 22px; letter-spacing: -.01em; margin: 0 8px 0 0; }
.rnp-top .seg.sm { border: 0; background: #e7e9ee; padding: 3px; border-radius: 10px; gap: 2px; }
.rnp-top .seg.sm a, .rnp-top .seg.sm label { padding: 5px 12px; border-radius: 8px; color: #4b5563; font-size: 13px; white-space: nowrap; }   /* контраст на сером фоне вкладок ≥ 4,5 */
.rnp-top .seg.sm a.on, .rnp-top .seg.sm label.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(20, 30, 50, .12); }
.rnp-top button, .rnp-top .pick summary, .rnp-top input[type=date], .rnp-top .month-pick { border-radius: 9px; padding: 6px 11px; font-size: 13px; }
.rnp-top .dates { gap: 6px; }
.rnp-top .dates[hidden] { display: none; }
.rnp-top .refresh button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rnp-top .refresh button:hover { background: #004ad1; border-color: #004ad1; }
.mtabs[hidden] { display: none; }   /* кнопки ± / тепловая карта / цвета спрятаны: ими управляют значки в шапке таблицы */

/* график */
.rnp-top ~ .chart-box { position: relative; border-radius: 12px; padding: 14px 16px 8px; margin-bottom: 14px; }
.rnp-top ~ .chart-box .chart-head { padding-right: 34px; }   /* место под «?» в углу */
.rnp-top ~ .chart-box #chart-title { font-size: 15px; }
.chart-tools { gap: 14px; }
.chart-tools .cmp { display: inline-flex; align-items: center; gap: 6px; }
.chart-tools .cmp[hidden] { display: none; }
.chart-help-wrap { position: absolute; top: 12px; right: 14px; z-index: 5; }
.chart-help { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1; }
.chart-help:hover, .chart-help-wrap.open .chart-help { border-color: var(--accent); color: var(--accent); }
.chart-tip { display: none; position: absolute; top: 32px; right: 0; width: 270px; max-width: calc(100vw - 48px); padding: 10px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 30, 50, .16); font-size: 13px; line-height: 1.45; color: var(--ink); text-align: left; }
.chart-tip b { display: block; margin-bottom: 4px; }
.chart-tip span { display: block; }
.chart-help-wrap:hover .chart-tip, .chart-help:focus-visible + .chart-tip, .chart-help-wrap.open .chart-tip { display: block; }
/* списки в шапке графика («метрика», «сравнить с») — окно как у «Артикулы» */
.chart-tools .pick summary { border-radius: 9px; padding: 6px 11px; font-size: 13px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tools .pick[open] summary { border-color: var(--accent); }
.chart-tools .pick-list { min-width: 230px; }
.chart-tools .sel-pick .pick-list { left: 0; right: auto; }
.chart-tools .sel-pick ~ .sel-pick .pick-list { left: auto; right: 0; }
.sel-list { padding: 6px; }
.sel-opt { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: 13px; }
.sel-opt::before { content: ""; display: inline-block; width: 16px; }
.sel-opt:hover { background: #f2f5fb; }
.sel-opt[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.sel-opt[aria-selected="true"]::before { content: "✓"; }

/* таблица */
.rnp-top ~ .table-wrap { border-radius: 12px; }
.rnp-top ~ .table-wrap .bymetric th, .rnp-top ~ .table-wrap .bymetric td { padding: 8px 12px; border-bottom: 1px solid #eef0f4; }
.rnp-top ~ .table-wrap .bymetric thead th { background: #fafbfc; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.rnp-top ~ .table-wrap .bymetric thead th small { font-size: 11.5px; }
.rnp-top ~ .table-wrap .bymetric .c-off { border-right: 1px solid #eef0f4; }
.rnp-top ~ .table-wrap .bymetric th.tot, .rnp-top ~ .table-wrap .bymetric td.tot { background: #fff; border-left: 1px solid #eef0f4; }
.rnp-top ~ .table-wrap .bymetric thead th.tot { background: #fafbfc; }
.rnp-top ~ .table-wrap .bymetric tr.total > td, .rnp-top ~ .table-wrap .bymetric tr.total > th { background: #e8f0ff; border-bottom: 1px solid #c9dbff; }
.rnp-top ~ .table-wrap .bymetric tr.total > th.c-off { color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.rnp-top ~ .table-wrap .bymetric tr.total .xp-name { color: var(--accent); }
/* подписи изменения: контраст ≥ 4,5 на цветной тепловой карте */
.bymetric td small.chg { font-size: 11px; color: #4b5563; }
.bymetric td small.chg.good { color: #145a27; }
.bymetric td small.chg.bad { color: #8f1d17; }
/* копии переключателей в шапке первой колонки (нажимают спрятанные кнопки .mtabs) */
.th-ic { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 0 5px; margin-right: 4px; font-size: 13px; line-height: 18px; color: var(--muted); cursor: pointer; vertical-align: top; }
.th-ic:hover { border-color: #b9c0cc; color: var(--ink); }
.th-ic.on { border-color: var(--accent); background: #e8f0ff; color: var(--accent); }

/* выбор периода во всплывающем окне */
.dp { position: relative; display: inline-block; }
.rnp-top .dp-btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rnp-top .dp-btn[aria-expanded="true"] { border-color: var(--accent); }
.dp-pop { position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; width: 340px; max-width: calc(100vw - 24px); padding: 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(20, 30, 50, .16); display: grid; gap: 12px; }
.dp-pop[hidden] { display: none; }
.rnp-top .dp-pop button { padding: 0; font-size: 14px; border-radius: 10px; }
.dp-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.dp-title { min-width: 96px; text-align: center; font-size: 16px; }
.rnp-top .dp-pop .dp-nav, .rnp-top .dp-pop .dp-toggle { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.rnp-top .dp-pop .dp-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.rnp-top .dp-pop .dp-nav:hover, .rnp-top .dp-pop .dp-toggle:hover { border-color: #b9c0cc; }
.dp-grid { display: grid; gap: 6px; }
.dp-months { grid-template-columns: repeat(4, 1fr); }
.dp-presets { grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); padding-top: 12px; }
.rnp-top .dp-pop .dp-cell { height: 40px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.rnp-top .dp-pop .dp-cell:hover:not(:disabled) { border-color: #b9c0cc; }
.rnp-top .dp-pop .dp-cell.on { background: #e8f0ff; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.rnp-top .dp-pop .dp-cell:disabled, .rnp-top .dp-pop .dp-day:disabled { color: #c3c8d1; cursor: default; background: #fafbfc; }
.rnp-top .dp-pop .dp-preset { height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.dp-preset b { font-size: 20px; }
.dp-preset small { font-size: 12px; color: var(--muted); }
.dp-week { grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: 600; font-size: 13px; }
.dp-days { grid-template-columns: repeat(7, 1fr); gap: 2px; }
.rnp-top .dp-pop .dp-day { height: 36px; border: 0; background: none; border-radius: 6px; font-variant-numeric: tabular-nums; }
.rnp-top .dp-pop .dp-day.other { color: #9aa3b0; }
.rnp-top .dp-pop .dp-day.in { background: #e8f0ff; border-radius: 0; }
.rnp-top .dp-pop .dp-day.end { background: var(--accent); color: #fff; border-radius: 8px; font-weight: 600; }
.rnp-top .dp-pop .dp-day:hover:not(:disabled):not(.end) { background: #dbe6fb; }
.dp-sum { text-align: center; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.rnp-top .dp-pop .dp-apply { height: 42px; background: var(--accent); border: 1px solid var(--accent); color: #fff; font-weight: 600; }
.rnp-top .dp-pop .dp-apply:hover { background: #004ad1; }

/* телефон */
@media (max-width: 700px) {
  .rnp-top { position: relative; padding: 12px; }
  .rnp-top h1 { order: -2; font-size: 20px; }
  .rnp-top .refresh { order: -1; margin-left: auto; }
  .rnp-top > .grow { display: none; }
  .rnp-top > .seg.sm { flex: 1 1 100%; display: flex; }
  .rnp-top > .seg.sm a { flex: 1; text-align: center; padding: 5px 4px; }
  .dp { position: static; }
  .dp-pop { left: 12px; right: 12px; width: auto; }
  .chart-tools .sel-pick ~ .sel-pick .pick-list { left: 0; right: auto; }
  .rnp-top ~ .table-wrap .bymetric .c-spark { display: none; }   /* колонка «Динамика» на телефоне */
  .rnp-top ~ .table-wrap .bymetric th, .rnp-top ~ .table-wrap .bymetric td { padding: 8px 10px; }
  .rnp-top ~ .table-wrap .bymetric .c-off { min-width: 150px; width: 150px; max-width: 150px; }
}

/* ===== «Склад Факт» / «Склад Возвраты»: окно выбора даты колонки (вставляется в body, поэтому без .rnp-top) ===== */
.dd-pop { gap: 10px; }
.dd-pop button { padding: 0; font: inherit; font-size: 14px; border-radius: 10px; cursor: pointer; }
.dd-pop .dp-nav { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.dd-pop .dp-nav:hover { border-color: #b9c0cc; }
.dd-pop .dp-day { height: 36px; border: 0; background: none; border-radius: 6px; font-variant-numeric: tabular-nums; }
.dd-pop .dp-day.other { color: #9aa3b0; }
.dd-pop .dp-day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.dd-pop .dp-day.end { background: var(--accent); color: #fff; font-weight: 600; border-radius: 8px; }
.dd-pop .dp-day:hover:not(:disabled):not(.end) { background: #dbe6fb; }
.dd-pop .dp-day:disabled { color: #c3c8d1; cursor: default; background: #fafbfc; }
.dd-pop .dd-today { height: 38px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; }
.dd-pop .dd-today:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.dd-pop .dd-today:disabled { color: #c3c8d1; cursor: default; }
.sklad .day-btn[aria-expanded="true"], .sklad .day-add-btn[aria-expanded="true"] { border-style: solid; border-color: var(--accent); color: var(--accent); }

/* ===== меню на телефоне: кнопка в шапке, список раскрывается под ней ===== */
.menu-btn { display: none; }
.menu-btn .m-close { display: none; }
@media (max-width: 700px) {
  .brand-row { width: 100%; justify-content: space-between; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
  .menu-btn .ico { width: 22px; height: 22px; }
  body.nav-open .menu-btn .m-open { display: none; }
  body.nav-open .menu-btn .m-close { display: inline-flex; }
  .top nav, .top .me { display: none; }
  body.nav-open .top nav { display: flex; flex-direction: column; flex-basis: 100%; overflow: visible; gap: 2px; }
  body.nav-open .top nav a { padding: 10px 12px; border-radius: 8px; white-space: normal; }
  body.nav-open .top nav .ico { display: inline-block; }
  body.nav-open .top nav .ngroup { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px 2px; }
  body.nav-open .top .me { display: flex; flex-basis: 100%; flex-wrap: wrap; justify-content: space-between; margin-left: 0; padding-top: 8px; border-top: 1px solid var(--line); }
}
@media (max-width: 700px) {
  body.nav-open .top nav .nsub-items a { padding: 10px 12px 10px 38px !important; font-size: 14px; white-space: normal; }   /* подпункты «Склад» — на одной линии с текстом пунктов */
}

/* ===== телефон: длинные подписи переносятся, окна-списки не выходят за экран ===== */
@media (max-width: 700px) {
  .supply th.c-off { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }   /* «Москва, МО и Дальние регионы · 8» и длинные артикулы */
  .rnp-top .pick:not(.cfg), .chart-tools .pick { position: static; }                       /* окно привязано к карточке, а не к кнопке в углу («Метрики» — своя панель по центру, её не трогаем) */
  .rnp-top .pick:not(.cfg) .pick-list, .chart-tools .pick-list,
  .chart-tools .sel-pick .pick-list, .chart-tools .sel-pick ~ .sel-pick .pick-list { top: auto; left: 12px; right: 12px; width: auto; min-width: 0; max-width: none; }
}

/* ===== настройки ===== */
.set-card h2 { margin: 0 0 12px; }
.set-card h3 { font-size: 14px; margin: 18px 0 8px; }
.set-card > .hint { margin: 0 0 10px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.set-grid label, .set-wide { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.set-grid input, .set-wide input { font-weight: 400; width: 100%; box-sizing: border-box; }
.set-secret { display: flex; gap: 4px; align-items: center; min-width: 0; }
.set-secret input { flex: 1; min-width: 0; width: 100%; box-sizing: border-box; }
.set-eye { flex: none; padding: 3px 6px; }
.set-table { max-height: none; min-height: 0; }
.set-table table { width: 100%; }
.set-table td input:not([type=checkbox]), .set-table td select { width: 100%; min-width: 96px; box-sizing: border-box; }
.set-table td input.num:not([type=checkbox]) { width: 76px; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.set-table td select { min-width: 132px; }
.set-table td .set-secret { min-width: 200px; }
.set-table tr[hidden], .set-add[hidden] { display: none; }
.set-add { margin-top: 10px; }
.set-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 8px; }
.set-dl { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 0; }
.set-dl dt { color: var(--muted); font-size: 12px; }
.set-dl dd { margin: 0; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .set-grid { grid-template-columns: 1fr; }
}
