/* Фирстиль ООО «АС»: Tahoma, зелёный #3F8D49, светло-зелёный #E2F4E1.
   Цвета можно переопределить в Администрирование → Общие настройки */
:root {
  --brand: #3F8D49;
  --brand-dark: #2d6634;
  --brand-light: #E2F4E1;
  --accent: #3F8D49;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #d9dee6;
  --border-strong: #b9c2cf;
  --text: #1e2733;
  --muted: #6b7686;
  --ok: #2e7d32;
  --danger: #c62828;
  --warn: #b26a00;
  --row-hover: #f1f8f1;
  --row-sel: #E2F4E1;
  --radius: 6px;
  --font: Tahoma, Verdana, "Segoe UI", Geneva, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 13px/1.4 var(--font); color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

#app { display: grid; grid-template-columns: 96px auto 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 18px; background: #fff; color: var(--text); border-bottom: 3px solid var(--brand); }
.logo { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.logo .logomark { height: 36px; width: auto; display: block; }
.logo .divider { width: 1px; height: 28px; background: var(--border); }
.logo #appName { font-weight: 700; font-size: 18px; letter-spacing: .06em; color: var(--brand); }
.logo small { font-size: 13px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar .org { color: var(--muted); }

.sections { grid-column: 1; grid-row: 2; background: var(--brand-dark); color: #d9ecdb; overflow-y: auto; padding: 6px 0; }
.sections .sec { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px; cursor: pointer; font-size: 11px; text-align: center; overflow-wrap: anywhere; border-left: 3px solid transparent; }
.sections .sec .ic { font-size: 19px; line-height: 1; }
.sections .sec:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sections .sec.active { background: var(--brand); color: #fff; border-left-color: #fff; }

.navpanel { grid-column: 2; grid-row: 2; width: 250px; background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 0; }
.navpanel.hidden { display: none; }
.navpanel h3 { margin: 0 16px 8px; font-size: 15px; color: var(--brand-dark); }
.navpanel h4 { margin: 14px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.navpanel a { display: block; padding: 5px 16px; color: var(--text); }
.navpanel a:hover { background: var(--row-hover); color: var(--brand); text-decoration: none; }
.navpanel a.create { color: var(--muted); font-size: 12px; padding-left: 28px; }

.main { grid-column: 3; grid-row: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--bg); border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; flex-shrink: 0; scrollbar-width: thin; }
.tab { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid transparent; border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; white-space: nowrap; max-width: 260px; color: var(--muted); }
.tab span { overflow: hidden; text-overflow: ellipsis; }
.tab:hover { background: #e9edf3; }
.tab.active { background: var(--panel); border-color: var(--border); color: var(--text); margin-bottom: -1px; font-weight: 600; }
.tab .x { opacity: .5; padding: 0 2px; border-radius: 3px; }
.tab .x:hover { opacity: 1; background: #dde3eb; }
.tab.dirty span::after { content: " *"; color: var(--warn); }
.view { flex: 1; overflow: auto; background: var(--panel); padding: 14px 18px 30px; }

h1.title { font-size: 19px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
h1.title .badge { font-size: 11px; font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.toolbar .grow { flex: 1; }
.btn { padding: 5px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f4f6f9; border-color: #9aa6b6; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent-dark, #d9a300); color: var(--on-accent, #fff); font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.blue { background: #fff; border-color: var(--brand); color: var(--brand); font-weight: 600; }
.btn.blue:hover { background: var(--brand-light); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.icon { padding: 4px 8px; }

input.inp, select.inp, textarea.inp { padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: 4px; background: #fff; min-width: 0; }
input.inp:focus, select.inp:focus, textarea.inp:focus { outline: 2px solid color-mix(in srgb, var(--brand) 25%, transparent); border-color: var(--brand); }
input.inp[readonly] { background: #f6f7f9; color: var(--muted); }
input.num { text-align: right; }

/* Списки */
.grid-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { position: sticky; top: 0; background: var(--brand); color: #fff; text-align: left; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1; }
table.grid td { padding: 5px 8px; border-bottom: 1px solid #edf0f4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
table.grid tbody tr:hover { background: var(--row-hover); }
table.grid tbody tr.sel { background: var(--row-sel); }
table.grid tr.deleted td { color: #9aa3ae; text-decoration: line-through; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.group td { background: var(--brand-light); font-weight: 600; color: var(--brand-dark); }
table.grid tfoot td { background: var(--brand-light); font-weight: 600; position: sticky; bottom: 0; }
.st { display: inline-block; width: 16px; text-align: center; font-weight: 700; }
.st.posted { color: var(--ok); }
.st.draft { color: #9aa3ae; }
.st.del { color: var(--danger); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Формы */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 8px 22px; margin-bottom: 14px; max-width: 1200px; }
.field { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 8px; }
.field.wide { grid-column: 1 / -1; }
.field > label { color: var(--muted); }
.field > label.req::after { content: " *"; color: var(--danger); }
.field .hint { grid-column: 2; font-size: 11px; color: var(--muted); margin-top: -4px; }
.field textarea { min-height: 56px; resize: vertical; }
.chk { display: flex; gap: 6px; align-items: center; }

.ref { position: relative; display: flex; min-width: 0; }
.ref input { flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ref .rb { border: 1px solid var(--border-strong); border-left: none; background: #f6f7f9; padding: 0 7px; cursor: pointer; color: var(--muted); }
.ref .rb:last-child { border-radius: 0 4px 4px 0; }
.ref .rb:hover { background: #e9edf3; color: var(--text); }
.dropdown { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--border-strong); border-radius: 4px; box-shadow: 0 6px 18px rgba(20, 40, 70, .18); max-height: 280px; overflow-y: auto; min-width: 240px; }
.dropdown div { padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.dropdown div small { color: var(--muted); margin-left: 8px; }
.dropdown div.hl, .dropdown div:hover { background: var(--row-sel); }
.dropdown .create { color: var(--brand); border-top: 1px solid var(--border); }

.subtabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin: 6px 0 8px; }
.subtabs div { padding: 6px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs div.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
table.tp td { padding: 2px 3px; overflow: visible; }
table.tp td.ln { color: var(--muted); text-align: right; width: 34px; padding-right: 8px; }
table.tp input.inp, table.tp select.inp { width: 100%; padding: 3px 6px; border-color: transparent; background: transparent; }
table.tp input.inp:hover, table.tp select.inp:hover { border-color: var(--border); }
table.tp input.inp:focus, table.tp select.inp:focus { background: #fff; border-color: var(--brand); }
table.tp .ref input { border-color: transparent; background: transparent; }
table.tp .ref .rb { border-color: transparent; background: transparent; }
table.tp tr:hover .ref .rb { border-color: var(--border); }
.totals { display: flex; justify-content: flex-end; gap: 24px; margin-top: 10px; font-size: 14px; }
.totals b { font-variant-numeric: tabular-nums; }
.comment-row { margin-top: 14px; max-width: 1100px; }
.helpbox { background: var(--brand-light); border-left: 3px solid var(--brand); padding: 8px 12px; margin-bottom: 12px; border-radius: 4px; max-width: 1100px; }
.warnbox { background: #fff6e0; border-left: 3px solid var(--accent); padding: 8px 12px; margin: 8px 0; border-radius: 4px; }
.menu-wrap { position: relative; }
.menu { position: absolute; top: 100%; left: 0; z-index: 50; background: #fff; border: 1px solid var(--border-strong); border-radius: 4px; box-shadow: 0 6px 18px rgba(20, 40, 70, .18); min-width: 220px; margin-top: 2px; }
.menu div { padding: 6px 12px; cursor: pointer; }
.menu div:hover { background: var(--row-sel); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: #eef1f5; color: var(--muted); }
.badge.ok { background: #e3f2e5; color: var(--ok); }
.badge.del { background: #fde8e8; color: var(--danger); }
.badge.new { background: var(--brand-light); color: var(--brand); }
.badge.warn { background: #fff3d6; color: var(--warn); }

/* Начальная страница */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: #fff; border-top: 3px solid var(--brand); }
.kpi .v { color: var(--text); }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.home-cols { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
.quick a { display: block; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; color: var(--text); }
.quick a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; background: var(--row-hover); }
h2.sub { font-size: 14px; margin: 0 0 10px; color: var(--brand-dark); }

/* Модальные окна и уведомления */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 30, 50, .35); display: grid; place-items: center; z-index: 2000; }
.modal { background: #fff; border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); min-width: 380px; max-width: min(900px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.modal .mh { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border); font-size: 15px; }
.modal .mb { padding: 14px 16px; overflow: auto; white-space: pre-wrap; }
.modal .mf { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #22303f; color: #fff; padding: 9px 14px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); max-width: 420px; animation: tin .2s; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
.mov h4 { margin: 14px 0 6px; color: var(--brand-dark); }
pre.xml { background: #f6f8fb; border: 1px solid var(--border); padding: 10px; border-radius: 6px; max-height: 360px; overflow: auto; font-size: 12px; }
.card { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; max-width: 1100px; }
.card h2 { margin: 0 0 6px; font-size: 15px; color: var(--brand-dark); }
.card p.muted, .muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@media print {
  .topbar, .sections, .navpanel, .tabs, .toolbar, .no-print { display: none !important; }
  #app { display: block; height: auto; }
  .view { overflow: visible; padding: 0; }
  .grid-wrap { max-height: none; overflow: visible; border: none; }
}

/* Вход и пользователь */
fieldset.plain { border: none; margin: 0; padding: 0; min-width: 0; }
.topbar .org { display: flex; align-items: center; gap: 10px; }
.topbar .divider { width: 1px; height: 26px; background: var(--border); }
.user-chip { display: flex; flex-direction: column; line-height: 1.2; color: var(--text); font-weight: 600; }
.user-chip small { font-weight: 400; color: var(--muted); font-size: 11px; }
.login-bg { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand-light), #fff 60%); }
.login { width: 340px; background: #fff; border: 1px solid var(--border); border-top: 4px solid var(--brand); border-radius: 10px; padding: 28px; display: grid; gap: 12px; box-shadow: 0 12px 40px rgba(20, 60, 30, .12); }
.login-logo { height: 54px; justify-self: center; }
.login-title { text-align: center; font-weight: 700; font-size: 20px; letter-spacing: .06em; color: var(--brand); margin-bottom: 6px; }
.login .inp { padding: 8px 10px; }
.login .btn { padding: 8px; }
.login-err { color: var(--danger); min-height: 16px; font-size: 12px; }
.kpi.user { border-top-color: var(--border-strong); background: var(--brand-light); }

/* ---------- Аналитика ---------- */
.note { margin: 8px 0; font-size: 12px; }
.neg { color: var(--danger) !important; }
td.neg { background: #fdecec; font-weight: 600; }
.ctr { text-align: center !important; }
.limit-line { margin-top: 10px; }

/* Планирование отгрузок */
.load-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; }
.load-day { flex: 0 0 74px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; background: #fff; }
.load-day:hover { border-color: var(--brand); }
.load-day.empty { cursor: default; opacity: .65; }
.load-day.we { background: #f7f8fa; }
.load-day.overdue { border-color: var(--danger); background: #fff5f5; }
.ld-d { font-size: 11px; color: var(--muted); }
.ld-bar { position: relative; height: 54px; margin: 4px 10px; background: var(--brand-light); border-radius: 4px; overflow: hidden; }
.ld-bar i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--brand); }
.ld-bar i.over { background: var(--danger); }
.ld-bar b { position: absolute; left: 0; right: 0; border-top: 2px dashed #c62828; }
.ld-t { font-weight: 600; font-size: 12px; }
.plan-wrap { max-height: calc(100vh - 330px); }
table.plan td, table.plan th { padding: 4px 6px; }
table.plan .sticky { position: sticky; z-index: 2; background: #fff; }
table.plan thead .sticky { background: var(--brand); z-index: 3; }
table.plan .c0 { left: 0; width: 300px; min-width: 300px; max-width: 300px; }
table.plan .c1 { left: 300px; width: 70px; min-width: 70px; }
table.plan .c2 { left: 370px; width: 80px; min-width: 80px; }
table.plan .c3 { left: 450px; width: 74px; min-width: 74px; border-right: 2px solid var(--border-strong); }
table.plan { table-layout: auto; border-collapse: separate; border-spacing: 0; }
table.plan th.day { border-left: 1px solid rgba(255,255,255,.4); }
table.plan th.day.we { background: var(--brand-dark); }
table.plan td.o { border-left: 1px solid var(--border); color: var(--brand-dark); }
table.plan td.r { color: var(--muted); }
table.plan tr.grp td { background: var(--brand-light); font-weight: 600; cursor: pointer; }
table.plan tr.grp.lvl0 td { background: #cfe8cd; }
table.plan tr.grp td.r { color: var(--text); }
table.plan .code { color: var(--muted); font-size: 11px; margin-right: 6px; }
.tw { display: inline-block; width: 14px; color: var(--brand); }

/* Платёжный календарь */
.gap-alert { background: #fdecec; border: 1px solid #f3b9b9; color: #8e1c1c; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; }
.kpi.bad { border-top-color: var(--danger); } .kpi.bad .v { color: var(--danger); }
.kpi .v small { font-size: 14px; color: var(--muted); font-weight: 400; }
.bal-chart { display: flex; gap: 8px; align-items: stretch; height: 150px; margin-bottom: 18px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.bc-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 40px; }
.bc-v { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bc-area { flex: 1; width: 70%; display: flex; align-items: flex-end; }
.bc-area i { display: block; width: 100%; background: #9fd09a; border-radius: 4px 4px 0 0; }
.bc-area i.fact { background: var(--brand); }
.bc-area i.neg { background: var(--danger); }
.bc-d { font-size: 11px; margin-top: 3px; }
details.pc-day { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: #fff; }
details.pc-day.bad { border-color: #f3b9b9; }
details.pc-day > summary { display: flex; align-items: center; gap: 14px; padding: 9px 14px; cursor: pointer; list-style: none; }
details.pc-day > summary::-webkit-details-marker { display: none; }
details.pc-day[open] > summary { border-bottom: 1px solid var(--border); background: #fafbfc; border-radius: 8px 8px 0 0; }
.pc-flow.in { color: var(--ok); font-weight: 600; } .pc-flow.out { color: var(--danger); font-weight: 600; }
.pc-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 12px 14px; }
.pc-side-h { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; color: var(--brand-dark); }
.pc-side.out .pc-side-h { color: #8e1c1c; }
.pc-add { font-weight: 400; font-size: 12px; }
table.pc th { background: #eef1f5 !important; color: var(--text) !important; position: static; }
table.pc td.diff { color: var(--warn); font-weight: 600; }
table.pc tfoot td { position: static; }

/* Анализ доходности */
.pf-panel { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; background: #fbfcfd; }
.pf-row { display: flex; flex-wrap: wrap; gap: 14px 26px; margin-bottom: 12px; align-items: flex-start; }
.pf { display: flex; flex-direction: column; gap: 4px; }
.pf > label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg-b { border: none; background: #fff; padding: 4px 10px; cursor: pointer; border-right: 1px solid var(--border); }
.seg-b:last-child { border-right: none; }
.seg-b.on { background: var(--brand); color: #fff; }
.mpick, .grp-box { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: 360px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-light); border-radius: 12px; padding: 2px 4px 2px 10px; font-size: 12px; }
.chip.strong { background: var(--brand); color: #fff; }
.chip i { font-style: normal; cursor: pointer; padding: 0 5px; border-radius: 8px; }
.chip i:hover { background: rgba(0,0,0,.12); }
.inp.small { padding: 2px 6px; font-size: 12px; }
.dd-chk { padding: 3px 4px !important; }
.col { display: flex; flex-direction: column; gap: 2px; }
table.prof td.nm { white-space: nowrap; max-width: 420px; }
table.prof tr.has { cursor: pointer; }
table.prof tr.lv0 td { font-weight: 600; }
table.prof tr.lv0 td.nm { color: var(--brand-dark); }
table.prof td.pct { color: var(--ok); }
table.prof td.pct.low { color: var(--warn); }
table.prof th.tot, table.prof td:last-child { background-color: rgba(226, 244, 225, .45); }
table.prof thead th.tot { background: var(--brand-dark); }
.abc { display: inline-block; margin-left: 8px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; color: #fff; }
.abc-A { background: var(--ok); } .abc-B { background: #d39b00; } .abc-C { background: #9aa3ae; }

/* Анализ цен в заявке */
.an-panel { margin-top: 14px; border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 14px; max-width: 1200px; background: #fbfdfb; }
.an-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.an-kpis { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.an-kpis > div { display: flex; flex-direction: column; }
.an-kpis span { font-size: 11px; color: var(--muted); }
.an-kpis b { font-size: 16px; font-variant-numeric: tabular-nums; }
.an-kpis .good b { color: var(--ok); }
.an-kpis .bad b { color: var(--danger); }
.an-approvals { display: flex; align-items: center; gap: 16px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.an-approvals .ap { display: flex; align-items: center; gap: 6px; }
table.tp tr.below td { background: #fdecec; }
table.tp tr.below td .inp { color: #a11; }
td.chg { font-weight: 600; color: var(--brand-dark); }

/* Расшифровка отчётов */
table.grid tr.drill { cursor: pointer; }
table.grid tr.drill:hover td { background: var(--row-sel); }
tr.drill-detail > td { background: #f7faf7; padding: 6px 10px 12px 34px; white-space: normal; max-width: none; }
table.grid.sub th { background: #e6efe6; color: var(--text); position: static; }
table.grid.sub tr.doc-row { cursor: pointer; }

/* ---------- Телефон и узкие экраны ---------- */
@media (max-width: 760px) {
  html, body { font-size: 14px; }
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: 100dvh; }
  .topbar { grid-column: 1; grid-row: 1; padding: 6px 10px; gap: 8px; min-height: 50px; }
  .logo .logomark { height: 28px; }
  .logo small, .logo .divider, .topbar .org > span:first-child, .topbar .org > .divider { display: none; }
  .logo #appName { font-size: 16px; }
  .user-chip { font-size: 12px; max-width: 110px; overflow: hidden; }
  .user-chip small { display: none; }
  .topbar .btn.small { padding: 3px 6px; }
  .sections { grid-column: 1; grid-row: 2; display: flex; overflow-x: auto; padding: 0; scrollbar-width: none; }
  .sections .sec { flex: 0 0 auto; flex-direction: row; gap: 5px; padding: 9px 12px; border-left: none; border-bottom: 3px solid transparent; font-size: 13px; }
  .sections .sec.active { border-bottom-color: #fff; }
  .sections .sec .ic { font-size: 15px; }
  .navpanel { position: fixed; z-index: 900; left: 0; right: 0; top: 98px; bottom: 0; width: auto; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
  .navpanel a { padding: 9px 16px; }
  .main { grid-column: 1; grid-row: 3; }
  .view { padding: 10px 10px 40px; }
  h1.title { font-size: 17px; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; gap: 8px; }
  .field { grid-template-columns: 112px minmax(0, 1fr); }
  .field .hint { grid-column: 1 / -1; }
  .comment-row { display: grid; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 8px 10px; }
  .kpi .v { font-size: 17px; }
  .home-cols { grid-template-columns: 1fr; }
  .toolbar { gap: 5px; }
  .toolbar .sep { display: none; }
  .grid-wrap { max-height: none; -webkit-overflow-scrolling: touch; }
  .totals { flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
  .pc-body { grid-template-columns: 1fr; }
  details.pc-day > summary { flex-wrap: wrap; gap: 6px 10px; }
  table.plan .c0 { width: 150px; min-width: 150px; max-width: 150px; white-space: normal; }
  table.plan .c1 { left: 150px; } table.plan .c2 { left: 220px; } table.plan .c3 { left: 300px; }
  table.plan .code { display: none; }
  .pf-row { flex-direction: column; gap: 10px; }
  .modal { min-width: 0; width: 96vw; }
  .modal .mb > div[style] { min-width: 0 !important; }
  .an-kpis > div { min-width: 42%; }
  .login { width: 92vw; }
  .bal-chart { gap: 3px; } .bc-col { min-width: 0; } .bc-v { font-size: 8px; }
}

/* Свод себестоимости */
table.csum td { white-space: nowrap; }
table.csum td.tot { background: rgba(226, 244, 225, .5); font-weight: 600; }
table.csum tr.sec td { background: var(--brand-light); font-weight: 700; color: var(--brand-dark); }
table.csum tr.it td { font-style: italic; color: var(--muted); }
table.csum tr.bold td { font-weight: 700; border-top: 2px solid var(--border-strong); }
table.csum tr.rent td { background: #e0f4f7; font-weight: 700; }
table.csum tr.final td { background: #fff3c4; font-weight: 700; font-size: 14px; }
table.csum td.sub-l { padding-left: 22px; }
table.grid th.link { cursor: pointer; text-decoration: underline dotted; }

/* ---------- Отчёт на всю высоту (шапка и первые колонки закреплены) ---------- */
.tabview.fill { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.fill-head { flex-shrink: 0; }
.fill-body { flex: 1; min-height: 0; display: flex; }
.sp-title { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.sp-title h1 { margin-bottom: 8px; }
.sp-info { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.sp-chip { padding: 2px 9px; border-radius: 10px; font-weight: 600; text-decoration: none !important; }
.sp-chip.bad { background: #fdecec; color: var(--danger); cursor: pointer; }
.sp-chip.warn { background: #fff3d6; color: var(--warn); cursor: pointer; }
.sp-chip.ok { background: var(--brand-light); color: var(--brand-dark); }
.sp-legend { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 11px; padding-top: 6px; }
.sp-legend .o { color: #8a6d00; font-weight: 600; }
.lg-def { display: inline-block; width: 10px; height: 10px; background: #fde7e7; border: 1px solid #f2b8b8; vertical-align: -1px; }

.sp-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
table.sp { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 12.5px; }
table.sp th, table.sp td { padding: 0 8px; height: 30px; border-bottom: 1px solid #eef0f3; white-space: nowrap; background: #fff; }
table.sp thead th { position: sticky; z-index: 3; background: #f7f8fa; color: #3b4656; font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); }
table.sp thead tr:first-child th { top: 0; height: 52px; vertical-align: bottom; padding-bottom: 4px; }
table.sp thead tr:nth-child(2) th { top: 52px; height: 24px; font-weight: 400; color: var(--muted); font-size: 11px; }
table.sp th.grp-h { text-align: center; color: var(--muted); font-weight: 400; font-size: 11px; vertical-align: bottom; }
table.sp .num { text-align: right; }
/* закреплённые колонки */
table.sp .stk { position: sticky; z-index: 2; }
table.sp thead .stk { z-index: 4; }
table.sp .c0 { left: 0; width: 300px; min-width: 300px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
table.sp .c1 { left: 300px; width: 64px; min-width: 64px; }
table.sp .c2 { left: 364px; width: 72px; min-width: 72px; }
table.sp .c3 { left: 436px; width: 66px; min-width: 66px; }
table.sp .c4 { left: 502px; width: 86px; min-width: 86px; }
table.sp .c5 { left: 588px; width: 74px; min-width: 74px; border-right: 1px solid var(--border-strong); }
table.sp thead th.c1.grp-h { width: 202px; }
table.sp thead th.c4.grp-h { width: 160px; border-right: 1px solid var(--border-strong); }
table.sp td.c0 .nm { overflow: hidden; text-overflow: ellipsis; }
table.sp td.c0 .code { color: #9aa3ae; font-size: 11px; margin-left: 8px; }
/* дни */
table.sp .d { min-width: 74px; border-left: 1px solid #f0f2f5; }
table.sp.two .d { min-width: 58px; }
table.sp th.d { text-align: center; }
table.sp th.d .dd b { font-size: 12.5px; color: var(--text); }
table.sp th.d .dd span { margin-left: 4px; font-weight: 400; color: var(--muted); }
table.sp th.d .lt { font-weight: 400; font-size: 10.5px; color: var(--muted); }
table.sp th.d .lb { height: 3px; background: #e9ecf0; border-radius: 2px; margin: 2px 4px 0; overflow: hidden; }
table.sp th.d .lb i { display: block; height: 100%; background: var(--brand); }
table.sp th.d .lb i.over { background: var(--danger); }
table.sp th.d.clk { cursor: pointer; }
table.sp th.d.clk:hover { background: var(--brand-light); }
table.sp .we { background: #fafafa; }
table.sp thead .we { background: #f0f1f4; }
table.sp td.d { line-height: 1.1; }
table.sp td.d .o { display: block; font-size: 10.5px; color: #8a6d00; font-weight: 600; text-decoration: none; }
table.sp td.d a.o:hover { text-decoration: underline; }
table.sp td.d .r { color: #2b3440; }
table.sp.two td.d .o { display: inline; font-size: 12px; }
table.sp td.def { background: #fde7e7; }
table.sp td.def .r { color: var(--danger); font-weight: 600; }
table.sp td.neg, table.sp .neg { color: var(--danger); font-weight: 600; }
/* строки */
table.sp tbody tr:hover td { background: #f3f7fc; }
table.sp tbody tr:hover td.def { background: #fbd9d9; }
table.sp tr.g td { background: #f4f5f7; font-weight: 600; cursor: pointer; border-bottom: 1px solid #e3e6ea; }
table.sp tr.g.g0 td { background: #eceef1; }
table.sp tr.g td.def { background: #f8dede; }
table.sp tr.g .cnt { color: #9aa3ae; font-weight: 400; font-size: 11px; }
table.sp tr.g .tw { color: var(--muted); }
table.sp tr:not(.g) td.c0 { padding-left: 26px; }
table.sp tr.g.g1 td.c0 { padding-left: 16px; }
table.sp tr.g.g2 td.c0 { padding-left: 26px; }

@media (max-width: 760px) {
  table.sp .c0 { width: 150px; min-width: 150px; max-width: 150px; }
  table.sp .c1, table.sp .c2, table.sp .c3, table.sp .c4, table.sp .c5 { position: static; }
  table.sp thead .stk { position: sticky; }
  table.sp td.c0 .code { display: none; }
}
