* { box-sizing: border-box; }
body { margin: 0; font: 13px system-ui, "Segoe UI", sans-serif; color: #222; background: #fff; display: flex; height: 100vh; overflow: hidden; }
#side { width: 270px; min-width: 270px; border-right: 1px solid #e3e6ea; padding: 10px 12px; overflow-y: auto; background: #fafbfc; }
#side h3 { margin: 4px 0 10px; }
#side section { border-bottom: 1px solid #e8eaee; padding: 8px 0 10px; }
#side label { display: block; font-weight: 600; margin: 6px 0 3px; font-size: 12px; color: #444; }
#side .radios label { display: inline; font-weight: 400; margin-right: 8px; }
.row { display: flex; gap: 6px; align-items: center; }
select, input[type=number], input:not([type]) { width: 100%; padding: 4px 6px; border: 1px solid #cfd4da; border-radius: 5px; font: inherit; }
button, .btn { padding: 5px 10px; border: 1px solid #cfd4da; border-radius: 5px; background: #fff; cursor: pointer; font: inherit; color: #222; text-decoration: none; display: inline-block; text-align: center; }
button:hover, .btn:hover { background: #f1f3f5; }
button.primary { background: #1c5fb8; color: #fff; border-color: #1c5fb8; }
button.ghost { background: transparent; }
.wide { width: 100%; margin-top: 6px; }
button:disabled { opacity: .5; cursor: default; }
.muted { color: #6b7280; font-size: 12px; margin-top: 4px; }
.cats { max-height: 210px; overflow-y: auto; border: 1px solid #e3e6ea; border-radius: 5px; background: #fff; padding: 3px 6px; margin-top: 4px; }
.cats label { font-weight: 400 !important; margin: 2px 0 !important; color: #222 !important; }
.legend div { margin: 3px 0; font-size: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border: 1px solid #ccc; vertical-align: middle; margin-right: 6px; }
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 8px 10px; min-width: 0; }
#warns div { background: #fff8e1; border: 1px solid #f1d27a; border-radius: 5px; padding: 4px 8px; margin-bottom: 4px; font-size: 12px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin: 4px 0 6px; flex-wrap: wrap; }
.toolbar input:not([type=checkbox]) { width: 260px; }
#summary { font-size: 12px; margin-bottom: 6px; }
#summary table { border-collapse: collapse; }
#summary td, #summary th { padding: 2px 10px; border-bottom: 1px solid #eee; text-align: right; }
#summary th { background: #f4f6f8; }
#summary td:first-child, #summary th:first-child { text-align: left; }
.wrap { flex: 1; overflow: auto; border: 1px solid #dde1e6; }
#t { border-collapse: separate; border-spacing: 0; font-size: 12px; }
#t th, #t td { border-right: 1px solid #e6e8eb; border-bottom: 1px solid #e6e8eb; padding: 3px 6px; text-align: right; white-space: nowrap; }
#t thead th { background: #eef1f5; position: sticky; z-index: 2; font-weight: 600; text-align: center; }
#t thead tr:first-child th { top: 0; height: 24px; }
#t thead tr:nth-child(2) th { top: 24px; }
#t th.grp { cursor: pointer; color: #1c5fb8; }
#t th.grp:hover { background: #e2e8f0; }
#t th.pl { background: #fff1b8; }
#t .sticky { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; min-width: 340px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
#t thead .sticky { z-index: 3; background: #eef1f5; }
#t tr.sku td { font-weight: 600; background: #f7f8fa; border-top: 1px solid #cfd5dc; }
#t tr.sku td.sticky { background: #f7f8fa; }
#t tr.mp td.sticky { padding-left: 26px; }
#t tr.ul td.sticky { padding-left: 48px; color: #555; }
#t td.l { text-align: left; }
#t td.m { font-weight: 400; color: #555; text-align: left; cursor: pointer; max-width: 86px; min-width: 70px; overflow: hidden; text-overflow: ellipsis; }
#t td.m:hover { text-decoration: underline; }
.tw { cursor: pointer; display: inline-block; width: 14px; color: #1c5fb8; }
.nm { cursor: pointer; }
.nm:hover { text-decoration: underline; }
.fl { font-weight: 400; color: #8a5a00; font-size: 11px; margin-left: 4px; }
#t td.in { background: #fff6c8; outline: none; min-width: 52px; cursor: text; }
#t td.in:focus { box-shadow: inset 0 0 0 2px #e0a800; background: #fff; }
#t td.in.manual { background: #ffe48a; }
#t td.in.over { background: #ffd8a8; }
#t td.tot { background: #fbf6dc; }
#t td.lost { color: #b42318; }
#t td.lost small { font-size: 10px; }
#t td.saving { opacity: .5; }
.empty { padding: 30px; color: #555; font-size: 14px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal.hidden { display: none; }
.card { background: #fff; border-radius: 8px; padding: 16px 18px; width: 460px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.card h4 { margin: 0 0 4px; }
.card label { display: block; margin: 8px 0 3px; }
.card .scores td { padding: 1px 8px; }
.card .btns { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }
.dd { position: relative; }
.ddp { position: absolute; top: 30px; left: 0; z-index: 20; background: #fff; border: 1px solid #cfd4da; border-radius: 6px;
       box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 8px; width: 380px; }
.ddp.hidden { display: none; }
.ddp .cats { max-height: 360px; }
.ddp .cats label { display: block; font-weight: 400; margin: 2px 0; }
.ddp .cats .cnt { color: #888; font-size: 11px; }
#more { padding: 10px; color: #6b7280; }

/* вкладки */
main { gap: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #dde1e6; margin-bottom: 6px; }
.tabs button { border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; padding: 6px 14px; }
.tabs button.on { border-color: #dde1e6; background: #fff; font-weight: 600; margin-bottom: -1px; }
.page { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.page.hidden { display: none; }
.help { overflow-y: auto; padding: 4px 18px 30px 6px; line-height: 1.5; font-size: 13.5px; max-width: 1100px; display: block; }
.help h2 { margin: 14px 0 6px; }
.help h3 { margin: 14px 0 4px; }
.help li { margin: 3px 0; }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; border: 1px solid #d0d5db; }
.htab { border-collapse: collapse; margin: 6px 0; }
.htab td, .htab th { border: 1px solid #dde1e6; padding: 4px 8px; vertical-align: top; text-align: left; }
.htab th { background: #f1f3f5; }

/* блоки колонок */
#t th.b-sales, .chip.b-sales { background: #dbeafe; }
#t th.b-stock, .chip.b-stock { background: #dcfce7; }
#t th.b-arr,   .chip.b-arr   { background: #ede9fe; }
#t th.b-money, .chip.b-money { background: #f1f5f9; }
#t th.b-mdl,   .chip.b-mdl   { background: #fde2e2; }
#t th.b-plan,  .chip.b-plan  { background: #fde68a; }
#t th.b-tot,   .chip.b-tot   { background: #e5e7eb; }
#t tr.mp td.b-sales, #t tr.ul td.b-sales { background: #f7faff; }
#t tr.mp td.b-stock, #t tr.ul td.b-stock { background: #f6fdf8; }
#t tr.mp td.b-arr,   #t tr.ul td.b-arr   { background: #fbfaff; }
#t tr.mp td.b-mdl,   #t tr.ul td.b-mdl   { background: #fffafa; }
#t .bs { border-left: 2px solid #7b8794 !important; }
#t th.grp { color: #1c4f9c; }
/* строка категории */
#t tr.cat td { background: #e3e9f1 !important; font-weight: 600; border-top: 2px solid #9aa7b6; }
#t tr.cat td.sticky { cursor: pointer; }
#t tr.cat .muted { font-weight: 400; }
#t tr.sku td.sticky { padding-left: 18px; }
#t tr.mp td.sticky { padding-left: 40px; }
#t tr.ul td.sticky { padding-left: 60px; }

.userbar { font-size: 12px; color: #444; margin: -4px 0 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.userbar a { color: #1c5fb8; text-decoration: none; }
.userbar a:hover { text-decoration: underline; }
.hidden { display: none !important; }
#t td.ro { background: #fdf8e1; }

.btngrp { display: inline-flex; gap: 4px; align-items: center; border: 1px solid #e3e6ea; border-radius: 6px; padding: 1px 4px; }
.btngrp button { padding: 3px 8px; }
#t th.srt { cursor: pointer; }
#t th.srt:hover { text-decoration: underline; }

/* прогноз поставок */
.basebar { background: #eef6ee; border: 1px solid #b7dcb7; border-radius: 6px; padding: 6px 10px; margin-bottom: 6px; font-size: 13px; }
.basebar.none { background: #fff8e1; border-color: #f1d27a; }
.basebar select { width: auto; margin-left: 8px; }
#sup { border-collapse: separate; border-spacing: 0; font-size: 12px; }
#sup th, #sup td { border-right: 1px solid #e6e8eb; border-bottom: 1px solid #e6e8eb; padding: 3px 6px; white-space: nowrap; }
#sup thead th { position: sticky; top: 0; z-index: 2; background: #eef1f5; cursor: pointer; text-align: center; white-space: normal; min-width: 70px; }
#sup thead th:hover { text-decoration: underline; }
#sup td.n { text-align: right; } #sup td.t { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
#sup th.g-ship { background: #e0e7ff; } #sup th.g-sku { background: #dbeafe; } #sup th.g-prod { background: #ede9fe; }
#sup th.g-money { background: #fef3c7; } #sup th.g-date { background: #dcfce7; }
#sup td.late { color: #b42318; font-weight: 600; }
#sup tbody tr:hover td { background: #f6f8fb; }

#t td.tip { cursor: help; text-decoration: underline dotted #9aa7b6; text-underline-offset: 3px; }
