/* Прежние страницы Свода. Каждое правило ограничено .legacy; новая шапка и модули живут в ms/*.css.
   У предков таблиц нет overflow: липкие заголовки следят за прокруткой окна. */
:root {
  --ms-blue: #1f75a8; --ms-link: #186999; --ms-menu-text: #c6ddea;
  --ms-text: #222; --ms-muted: #777; --ms-border: #ddd; --ms-divider: #ececec;
  --ms-filter-bg: #e3e3e3; --ms-white: #fff; --ms-hover: #f4f8fa;
  --ms-green: #6bb24a; --ms-green-dark: #559839; --ms-red: #c34a36;
  --ms-orange: #e18a23; --ms-top-h: 58px; --ms-tabs-h: 40px;
  --ms-header-h: calc(var(--ms-top-h) + var(--ms-tabs-h));
  --ms-font: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  --ms-table-font: Tahoma, Geneva, sans-serif;
  /* Старые шаблоны используют эти имена, поэтому оставляем их общими с новым видом. */
  --bg: var(--ms-white); --surface: var(--ms-white); --surface-2: #f7f7f7;
  --line: var(--ms-border); --line-strong: #ccc; --text: var(--ms-text);
  --text-2: #666; --text-3: #888; --accent: var(--ms-link); --accent-soft: #eaf3f8;
  --ok: #488b2c; --ok-soft: #edf6e8; --bad: var(--ms-red); --bad-soft: #fff0ed;
  --warn: #936200; --warn-soft: #fff7da;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 32px; --s7: 48px;
  --r1: 2px; --r2: 3px; --r3: 3px;
  --f0: 11px; --f1: 12px; --f2: 12px; --f3: 16px; --f4: 20px; --f5: 20px;
  --topbar-h: var(--ms-header-h); --sidebar-w: 0px;
  --shadow-1: none; --shadow-2: 0 3px 12px rgba(0,0,0,.16);
  --font: var(--ms-font); --mono: Consolas, "Liberation Mono", monospace;
}
.legacy, .legacy * { box-sizing: border-box; }
.legacy { min-height: 100%; }
.legacy { scroll-padding-top: calc(var(--ms-header-h) + 12px); }
.legacy { margin: 0; color: var(--ms-text); background: var(--ms-white); font: 12px/1.4 var(--ms-font); }
.legacy a { color: var(--ms-link); text-decoration: none; }
.legacy a:hover { text-decoration: underline; }
.legacy h1, .legacy h2, .legacy h3 { margin: 0; font-weight: 700; }
.legacy h1 { font-size: 20px; line-height: 1.3; }
.legacy h2 { font-size: 16px; } .legacy h3 { font-size: 13px; }
.legacy p { margin: 0 0 12px; } .legacy p:last-child { margin-bottom: 0; }
.legacy svg { vertical-align: middle; }
.legacy [hidden] { display: none !important; }
.legacy .muted { color: var(--text-2); } .legacy .small { font-size: 11px; } .legacy .nowrap { white-space: nowrap; }
.legacy a:focus-visible, .legacy button:focus-visible, .legacy summary:focus-visible { outline: 2px solid var(--ms-link); outline-offset: 2px; }

/* Верхняя полоса, вкладки и человек. Они не являются предками содержимого страницы. */
.legacy .shell { display: flex; flex-direction: column; min-height: 100vh; padding-top: var(--ms-header-h); }
.legacy .ms-header { position: fixed; top: 0; left: 0; right: 0; z-index: 40; }
.legacy .ms-top { display: flex; align-items: center; height: var(--ms-top-h); background: var(--ms-blue); color: #fff; padding: 0 12px 0 20px; gap: 12px; }
.legacy .ms-brand { flex: 0 0 auto; color: #fff; font-size: 23px; font-weight: 700; letter-spacing: -.8px; padding-right: 8px; text-decoration: none; }
.legacy .ms-brand:hover { color: #fff; text-decoration: none; }
.legacy .ms-menu { display: flex; align-self: stretch; min-width: 0; }
.legacy .ms-menu-item { position: relative; }
.legacy .ms-menu-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 58px; padding: 0 8px; color: var(--ms-menu-text); font-size: 11px; white-space: nowrap; }
.legacy .ms-menu-link .ico { display: flex; width: 20px; height: 20px; color: #fff; }
.legacy .ms-menu-link:hover, .legacy .ms-menu-link:focus, .legacy .ms-menu-item.on > .ms-menu-link { background: var(--ms-link); color: #fff; text-decoration: none; }
.legacy .ms-top a:focus-visible, .legacy .ms-top summary:focus-visible, .legacy .ms-logout button:focus-visible { outline-color: #fff; outline-offset: -3px; }
.legacy .ms-mobile-tabs { display: none; }
.legacy .ms-menu-toggle, .legacy .ms-burger { display: none; }
.legacy .ms-tabs { display: flex; align-items: stretch; gap: 4px; height: var(--ms-tabs-h); padding: 0 20px; background: #fff; border-bottom: 1px solid var(--ms-divider); white-space: nowrap; overflow-x: auto; scrollbar-width: thin; }
.legacy .ms-tabs a { display: block; flex-shrink: 0; height: 40px; line-height: 37px; padding: 0 12px; font-size: 13px; color: var(--ms-link); border-bottom: 3px solid transparent; }
.legacy .ms-tabs a:first-child { padding-left: 0; padding-right: 12px; }
.legacy .ms-tabs a:hover { text-decoration: none; background: var(--ms-hover); }
.legacy .ms-tabs a.on { border-bottom-color: var(--ms-link); }
.legacy .ms-user { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; min-width: 0; }
.legacy .ms-user-menu { position: relative; }
.legacy .ms-user-menu > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; min-height: 44px; }
.legacy .ms-user-menu > summary::-webkit-details-marker { display: none; }
.legacy .ms-user .who { display: block; text-align: right; line-height: 1.35; max-width: 185px; }
.legacy .ms-user .who b { display: block; font-size: 12px; font-weight: 400; }
.legacy .ms-user .who small { display: block; font-size: 10px; color: var(--ms-menu-text); }
.legacy .ms-user .ava { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 1px solid var(--ms-menu-text); border-radius: 50%; font-size: 11px; background: var(--ms-link); color: #fff; }
.legacy .ms-user-arrow { color: var(--ms-menu-text); font-size: 10px; }
.legacy .ms-user-menu.empty .ms-user-arrow, .legacy .ms-user-menu.empty .ms-service { display: none; }
.legacy .ms-service { position: absolute; right: 0; top: 49px; min-width: 205px; padding: 5px 0; background: #fff; border: 1px solid #ccc; box-shadow: var(--shadow-2); }
.legacy .ms-service a { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 5px 14px; color: var(--ms-text); font-size: 12px; white-space: nowrap; }
.legacy .ms-service .ico { display: flex; color: var(--ms-link); }
.legacy .ms-service a:hover, .legacy .ms-service a.on { background: var(--accent-soft); color: var(--ms-link); text-decoration: none; }
.legacy .ms-logout button { background: transparent; border-color: transparent; color: #fff; padding: 0 3px; font-size: 11px; gap: 4px; }
.legacy .ms-logout button:hover { background: var(--ms-link); }
.legacy .ms-logout svg { width: 16px; height: 16px; }
.legacy .ms-page { flex: 1; width: 100%; min-width: 0; }
.legacy .content { padding: 16px 20px; width: 100%; }
.legacy .content.wide, body.page-wide .legacy .content { max-width: none; }
.legacy .crumbs { display: flex; align-items: center; gap: 8px; padding: 10px 20px 0; color: var(--text-2); font-size: 11px; }
.legacy .crumbs:empty { display: none; } .legacy .crumbs .sep { color: #aaa; } .legacy .crumbs b { font-weight: 400; }
.legacy .ms-fresh { padding: 8px 20px; color: var(--ms-muted); text-align: right; font-size: 10px; border-top: 1px solid var(--ms-divider); }
.legacy #progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: #b9e6ff; z-index: 100; opacity: 0; }
.legacy #progress.on { opacity: 1; transition: width .35s ease; }
.legacy .content.loading { opacity: .55; transition: opacity .12s ease .08s; pointer-events: none; }

/* Заголовок, кнопки и формы — общие для прежних страниц и новых модулей. */
.legacy .ms-head, .legacy .cardhead { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.legacy .ms-title { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; }
.legacy .ms-help { display: inline-flex; align-items: center; justify-content: center; background: var(--ms-blue); color: #fff; border-radius: 50%; width: 18px; height: 18px; flex-shrink: 0; font-size: 13px; font-weight: 700; }
.legacy .ms-head .ms-title { margin-right: 6px; }
.legacy .ms-toolbar, .legacy .ms-card-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.legacy .ms-toolbar .right, .legacy .cardhead .right { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.legacy .cardhead > div:first-child { min-width: 0; }
.legacy button, .legacy .btn, .legacy .ms-btn { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid #ccc; border-radius: 3px; background: linear-gradient(#fff, #e6e6e6); color: var(--ms-text); font: 12px var(--ms-font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.legacy button:hover, .legacy .btn:hover, .legacy .ms-btn:hover { background: linear-gradient(#fff, #dedede); text-decoration: none; }
.legacy button:active, .legacy .ms-btn.on, .legacy .btn.on, .legacy .ms-btn[aria-pressed="true"] { background: #d9d9d9; box-shadow: inset 0 1px 3px #bbb; }
.legacy button.primary, .legacy .btn.primary, .legacy .ms-btn.primary, .legacy .actions > button[type=submit]:not(.ghost):not(.link) { color: #fff; background: linear-gradient(#78bd56, var(--ms-green)); border-color: var(--ms-green-dark); }
.legacy button.primary:hover, .legacy .btn.primary:hover, .legacy .ms-btn.primary:hover { background: var(--ms-green-dark); }
.legacy .ms-btn.drop::after { content: "▾"; font-size: 10px; margin-left: 6px; }
.legacy button.ghost, .legacy .btn.ghost { background: linear-gradient(#fff, #e6e6e6); color: var(--ms-text); border-color: #ccc; }
.legacy button.small, .legacy .btn.small { height: 24px; padding: 0 8px; font-size: 11px; }
.legacy button.link { background: none; border: 0; color: var(--ms-link); padding: 0; box-shadow: none; }
.legacy button:disabled, .legacy .ms-btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.legacy .ms-btn svg, .legacy .btn svg { width: 16px; height: 16px; }
.legacy .ms-btn.icon { width: 26px; padding: 0; }
.legacy label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-2); }
.legacy label.inline { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: var(--ms-text); }
.legacy input[type=text], .legacy input[type=password], .legacy input[type=search], .legacy input[type=date], .legacy input[type=email], .legacy input[type=number], .legacy select, .legacy textarea { width: 100%; min-width: 0; height: 26px; padding: 3px 6px; border: 1px solid #ccc; border-radius: 2px; font: 12px var(--ms-font); color: var(--ms-text); background: #fff; }
.legacy textarea { height: auto; min-height: 64px; resize: vertical; }
.legacy input:focus, .legacy select:focus, .legacy textarea:focus { outline: 1px solid var(--ms-blue); outline-offset: 0; border-color: var(--ms-blue); }
.legacy input[type=checkbox], .legacy input[type=radio] { width: auto; accent-color: var(--ms-link); vertical-align: middle; }
.legacy input.ms-search, .legacy .ms-search input { width: 210px; }
.legacy .ms-search { min-width: 170px; }
.legacy form.ms-search { display: flex; align-items: center; gap: 5px; }
.legacy .field { min-width: 0; } .legacy .field.narrow { max-width: 240px; }
.legacy form.inline { display: inline; }
.legacy .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Фильтры, период и наборы. */
.legacy .ms-filter { margin-bottom: 10px; padding: 4px 15px 10px 20px; background: var(--ms-filter-bg); border-radius: 3px; }
.legacy .ms-filter-row { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 10px 22px; margin-top: 8px; }
.legacy .ms-filter-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 3px 0; }
.legacy .ms-field { min-width: 0; }
.legacy .ms-field > label { color: var(--ms-text); margin: 0 0 3px; font-size: 12px; }
.legacy .ms-filter .ms-field > label::before { content: "▾"; margin-right: 5px; font-size: 10px; color: #666; }
.legacy .ms-filter input:not([type=checkbox]):not([type=radio]), .legacy .ms-filter select { border: 0; border-radius: 0; height: 22px; padding: 1px 4px; }
.legacy .ms-period { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.legacy .ms-period input[type=date] { flex: 1 1 95px; width: 95px; }
.legacy .ms-period a { font-size: 11px; } .legacy .ms-period .ms-period-label { width: 100%; }
.legacy .ms-chips, .legacy .chips { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.legacy .ms-chip, .legacy .chip { display: inline-block; padding: 3px 10px; border: 1px solid transparent; border-radius: 3px; background: var(--ms-filter-bg); color: var(--ms-text); font-size: 11px; text-decoration: none; }
.legacy .ms-chip:hover, .legacy .chip:hover { border-color: #bbb; text-decoration: none; }
.legacy .ms-chip.on, .legacy .chip.on { background: #c6ddea; border-color: #9bbbd0; color: var(--ms-link); }

/* Списки прежних отчётов: после прокрутки заголовок остаётся у края окна. */
.legacy table { width: 100%; border-collapse: separate; border-spacing: 0; font: 11px/1.35 var(--ms-table-font); }
.legacy thead th { position: sticky; top: 0; z-index: 5; height: 30px; padding: 5px 8px; text-align: left; font-weight: 400; color: var(--ms-link); background: #fff; border-bottom: 2px solid var(--ms-link); white-space: nowrap; }
.legacy tbody td, .legacy tfoot td { height: 30px; padding: 5px 8px; vertical-align: middle; border-bottom: 1px solid var(--ms-border); }
.legacy tbody tr:hover > td { background: var(--ms-hover); }
.legacy table a, .legacy .ms-link { color: var(--ms-link); text-decoration: underline; }
.legacy th a { text-decoration: none; color: inherit; }
.legacy td.num, .legacy th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legacy .ms-list th.sort { font-weight: 700; }
.legacy .ms-list th.sort::after { content: " ↓"; font-weight: 400; }
.legacy .ms-check { width: 30px; text-align: center; }
.legacy input.ms-check { width: 13px; height: 13px; margin: 0; }
.legacy .ms-list .ms-check input { width: 13px; height: 13px; margin: 0; }
.legacy .ms-status { display: inline-block; padding: 1px 10px 3px; color: #fff; background: var(--ms-blue); border-radius: 2px; font: 11px/1.3 var(--ms-table-font); white-space: nowrap; }
.legacy .ms-bar { display: block; position: relative; height: 3px; min-width: 40px; margin-top: 3px; background: #edf1e9; }
.legacy .ms-bar::after { content: ""; display: block; width: clamp(0%, var(--p, 0%), 100%); height: 3px; background: var(--ms-green); }
.legacy .ms-pager { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; font: 11px var(--ms-table-font); }
.legacy .ms-pager .ms-totals { margin-left: auto; }
.legacy .ms-pager form, .legacy .ms-pager form label { display: inline-flex; align-items: center; gap: 5px; margin: 0; }
.legacy .ms-pager select { width: auto; }
.legacy .ms-card-toolbar .ms-pager { margin: 0; }
.legacy .ms-totals { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 14px; font-weight: 700; padding: 8px 0; }
.legacy .ms-totals a { font-weight: 400; }
.legacy tr.total td, .legacy tfoot td { font-weight: 700; background: #f7f7f7; border-top: 1px solid #ccc; }
.legacy .tablewrap { width: 100%; }
.legacy .tablewrap.wide { overflow-x: auto; }
.legacy .tablewrap.wide thead th { position: static; }
.legacy .ms-empty, .legacy .empty { padding: 28px 20px; color: var(--text-2); text-align: center; }
.legacy .empty .big { color: var(--ms-text); font-size: 16px; margin-bottom: 8px; }
.legacy .ms-list .ms-empty { height: 80px; }
.legacy .delta.up, .legacy .ms-delta.up { color: var(--ok); } .legacy .delta.down, .legacy .ms-delta.down { color: var(--bad); }

/* Карточка документа: три колонки пар «подпись — значение», позиции, итог справа. */
.legacy .ms-card { margin-bottom: 20px; background: #fff; }
.legacy .ms-card-toolbar { padding: 8px 0; border-bottom: 1px solid var(--ms-divider); margin-bottom: 14px; }
.legacy .ms-card-meta { margin-left: auto; text-align: right; color: var(--ms-muted); font-size: 11px; }
.legacy .ms-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin: 12px 0 16px; }
.legacy .ms-card-title .ms-status, .legacy .ms-card-title label { font-weight: 400; }
.legacy .ms-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 400; white-space: nowrap; }
.legacy .ms-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #aaa; }
.legacy .ms-badge.paid::before { background: var(--ms-green); } .legacy .ms-badge.unpaid::before { background: var(--ms-red); }
.legacy .ms-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 24px; margin-bottom: 20px; }
.legacy .ms-fields.ms-dash { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.legacy .ms-fields .ms-field { display: grid; grid-template-columns: minmax(95px, 35%) minmax(0, 1fr); align-content: start; gap: 8px; padding: 3px 0; }
.legacy .ms-fields .ms-field label, .legacy .ms-fields .ms-field .label { color: #777; margin: 0; font-weight: 400; }
.legacy .ms-fields .value { min-width: 0; overflow-wrap: anywhere; }
.legacy .ms-fields .value small { display: block; margin-top: 3px; color: var(--ms-muted); }
.legacy .ms-fields > .ms-field-column { min-width: 0; }
.legacy .ms-subtabs { display: flex; align-items: center; gap: 20px; border-bottom: 1px solid #ddd; margin: 10px 0; }
.legacy .ms-subtabs a, .legacy .ms-subtabs > span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 2px; color: var(--ms-link); border-bottom: 2px solid transparent; }
.legacy .ms-subtabs .on { border-bottom-color: var(--ms-link); }
.legacy .ms-positions { margin-bottom: 10px; }
.legacy .ms-positions td { vertical-align: middle; } .legacy .ms-positions .available { background: #fff6d5; }
.legacy .ms-total { width: 340px; max-width: 100%; margin: 16px 0 20px auto; }
.legacy .ms-total > div, .legacy .ms-total > p { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; margin: 0; }
.legacy .ms-total .grand, .legacy .ms-total > div:last-child { font-weight: 700; font-size: 16px; padding-top: 10px; border-top: 1px solid var(--ms-border); }
.legacy .ms-total .num { white-space: nowrap; }
.legacy .ms-card-note { color: var(--ms-muted); margin: 8px 0 12px; }

/* Показатели и переключатели. SVG наследует цвета и шрифт от виджета. */
.legacy .ms-dash { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.legacy .ms-widget { min-width: 0; border: 1px solid var(--ms-border); border-radius: 3px; padding: 16px 18px; background: #fff; }
.legacy .ms-widget.wide { grid-column: 1 / -1; }
.legacy .ms-widget-title { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; color: var(--ms-link); font-size: 18px; font-weight: 400; }
.legacy .ms-widget-title.warn { color: var(--ms-orange); }
.legacy .ms-kpi { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.legacy .ms-kpi .n, .legacy .ms-kpi .sum { font-size: 27px; line-height: 1.15; font-weight: 400; font-variant-numeric: tabular-nums; }
.legacy .ms-kpi .unit { color: #777; font-size: 12px; margin-right: 12px; }
.legacy .ms-delta { font-size: 12px; margin: 5px 0 14px; }
.legacy .ms-chart { width: 100%; max-width: 100%; margin-top: 12px; color: var(--ms-blue); }
.legacy svg.ms-chart, .legacy .ms-chart svg { display: block; width: 100%; height: auto; }
.legacy .ms-chart text { font: 11px var(--ms-font); fill: #777; }
.legacy .ms-chart .axis, .legacy .ms-chart .gridline { stroke: #e3e3e3; stroke-width: 1; fill: none; }
.legacy .ms-chart .series { fill: none; stroke: var(--ms-blue); stroke-width: 2; }
.legacy .ms-chart .previous { stroke: #adc8d9; stroke-dasharray: 4 3; }
.legacy .ms-chart .expense { stroke: var(--ms-orange); }
.legacy .ms-chart-legend { display: flex; gap: 16px; margin-top: 6px; font-size: 11px; color: #777; }
.legacy .ms-chart-legend span::before { content: ""; display: inline-block; width: 18px; height: 2px; margin-right: 5px; vertical-align: middle; background: var(--ms-blue); }
.legacy .ms-chart-legend .previous::before { background: #adc8d9; }
.legacy .ms-seg { display: inline-flex; flex-wrap: wrap; align-items: center; margin: 0; }
.legacy .ms-seg > a, .legacy .ms-seg > button, .legacy .ms-seg > label { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; margin: 0 0 0 -1px; font: 12px var(--ms-font); color: var(--ms-text); background: linear-gradient(#fff, #e6e6e6); border: 1px solid #ccc; border-radius: 0; text-decoration: none; }
.legacy .ms-seg > :first-child { margin-left: 0; border-radius: 3px 0 0 3px; }
.legacy .ms-seg > :last-child { border-radius: 0 3px 3px 0; }
.legacy .ms-seg > .on, .legacy .ms-seg > [aria-pressed="true"] { background: #d8d8d8; box-shadow: inset 0 1px 3px #bbb; }
.legacy .ms-seg > a:hover { background: #e3e3e3; }

/* Существующие страницы: отчёты, цены, ценники, состояние, пользователи и права. */
.legacy .card { padding: 20px; margin-bottom: 16px; border: 1px solid var(--ms-border); border-radius: 3px; background: #fff; }
.legacy .card.tight { padding: 12px 16px; } .legacy .card.flush { padding: 0; }
.legacy .card > h1 { margin-bottom: 8px; } .legacy .card > h2 { margin-bottom: 12px; }
.legacy .card.flush thead th:first-child, .legacy .card.flush tbody td:first-child { padding-left: 16px; }
.legacy .card.flush thead th:last-child, .legacy .card.flush tbody td:last-child { padding-right: 16px; }
.legacy .grid { display: grid; gap: 16px; }
.legacy .grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.legacy .grid.c3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.legacy .tile { border: 1px solid var(--ms-border); border-radius: 3px; padding: 16px; background: #fff; }
.legacy .tile .label { color: #777; font-size: 12px; }
.legacy .tile .value { font-size: 26px; font-weight: 400; margin-top: 4px; font-variant-numeric: tabular-nums; }
.legacy .tile .sub { color: #888; font-size: 11px; margin-top: 4px; }
.legacy a.tile:hover { text-decoration: none; border-color: var(--ms-blue); }
.legacy .pill { display: inline-block; padding: 1px 6px; border-radius: 2px; font-size: 11px; background: #eee; color: #666; border: 1px solid #ddd; }
.legacy .pill.ok { background: var(--ok-soft); color: var(--ok); border-color: #cbdcbe; }
.legacy .pill.bad { background: var(--bad-soft); color: var(--bad); border-color: #edc8bf; }
.legacy .pill.warn { background: var(--warn-soft); color: var(--warn); border-color: #e9d79e; }
.legacy .flash { padding: 10px 14px; margin-bottom: 12px; border: 1px solid #c6ddea; border-radius: 3px; color: var(--ms-link); background: var(--accent-soft); }
.legacy .flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #cbdcbe; }
.legacy .flash.bad { background: var(--bad-soft); color: var(--bad); border-color: #edc8bf; }
.legacy .flash.warn { background: var(--warn-soft); color: var(--warn); border-color: #e9d79e; }
.legacy .viewas { display: flex; align-items: center; gap: 12px; padding: 8px 20px; background: #fff4d6; color: #6b4300; border-bottom: 1px solid #f1d9a3; font-size: 12px; }
.legacy .viewas .eye { font-size: 18px; } .legacy .viewas form { margin-left: auto; flex-shrink: 0; }
.legacy .mono { font-family: var(--mono); font-size: 12px; }
.legacy .once { display: inline-block; font: 20px var(--mono); padding: 8px 16px; border: 1px solid #e9d79e; border-radius: 3px; background: var(--warn-soft); }

/* Встроенные страницы парсера: без полей, липкие панели самой страницы остаются у края окна. */
.legacy .ext-page { border: 1px solid var(--ms-border); border-radius: 3px; background: #fff; font-size: initial; line-height: initial; }
.legacy .ext-page > :first-child { margin-top: 0; }
/* Ни .shell, ни .ms-page, ни #app, ни .card.flush, ни .ext-page не получают overflow. */
body.page-embed .legacy .shell { padding-top: 0; }
body.page-embed .legacy .ms-header { position: static; }
body.page-embed .legacy .crumbs { display: none; }
body.page-embed .legacy .content { max-width: none; padding: 0; }
body.page-embed .legacy .ext-page { border: 0; border-radius: 0; box-shadow: none; min-height: calc(100vh - var(--ms-header-h)); }
body.page-embed .legacy .content > .flash, body.page-embed .legacy .content > .card { margin: 16px; }

/* Вход. */
.legacy .loginwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: #f5f5f5; }
.legacy .loginbox { width: 100%; max-width: 380px; }
.legacy .loginbox .logo { text-align: center; margin-bottom: 20px; }
.legacy .loginbox .logo .name { color: var(--ms-blue); font-size: 30px; font-weight: 700; }
.legacy .loginbox .logo .sub { color: #777; font-size: 12px; margin-top: 4px; }
.legacy .loginbox .field { margin-bottom: 12px; }
.legacy .loginbox button { width: 100%; height: 32px; }
.legacy .ms-styleguide-section { margin: 26px 0 12px; padding-top: 12px; border-top: 1px solid var(--ms-divider); font-size: 16px; }
.legacy .ms-styleguide-note { color: #777; margin-bottom: 14px; }
.legacy .ms-styleguide-icons { display: flex; flex-wrap: wrap; gap: 16px; color: var(--ms-link); }
.legacy .ms-styleguide-icons span { display: inline-flex; align-items: center; gap: 5px; }

@media (min-width: 1500px) { .legacy .ms-filter-row { grid-template-columns: repeat(5, minmax(130px, 1fr)); } }
@media (max-width: 1200px) { .legacy .ms-user .who { display: none; } }
@media (min-width: 901px) and (max-width: 1100px) {
  .legacy .ms-top { padding-left: 12px; gap: 6px; }
  .legacy .ms-menu-link { padding: 0 5px; }
  .legacy .ms-brand { font-size: 21px; padding-right: 2px; }
  .legacy .ms-logout span { display: none; }
}
@media (max-width: 900px) {
  .legacy .ms-top { padding: 0 12px; gap: 10px; }
  .legacy .ms-brand { font-size: 22px; }
  .legacy .ms-burger { display: inline-flex; align-items: center; justify-content: center; margin: 0; color: #fff; width: 34px; height: 34px; font-size: 24px; cursor: pointer; }
  .legacy .ms-menu-toggle { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }
  .legacy .ms-menu-toggle:focus-visible + .ms-burger { outline: 2px solid #fff; }
  .legacy .ms-menu { display: none; position: absolute; top: 58px; left: 0; right: 0; max-height: calc(100vh - 58px); overflow-y: auto; background: var(--ms-blue); box-shadow: var(--shadow-2); padding: 6px 12px 14px; }
  .legacy .ms-menu-toggle:checked ~ .ms-menu { display: block; }
  .legacy .ms-menu-item { border-bottom: 1px solid rgba(255,255,255,.15); padding: 3px 0; }
  .legacy .ms-menu-link { height: 34px; padding: 0 8px; flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 12px; }
  .legacy .ms-mobile-tabs { display: flex; flex-wrap: wrap; gap: 2px 6px; padding: 2px 6px 7px 38px; }
  .legacy .ms-mobile-tabs a { padding: 4px; color: var(--ms-menu-text); font-size: 12px; }
  .legacy .ms-mobile-tabs a.on { color: #fff; text-decoration: underline; }
  .legacy .ms-tabs { padding: 0 12px; }
  .legacy .ms-tabs a { font-size: 12px; padding: 0 10px; }
  .legacy .content { padding: 12px; } .legacy .crumbs { padding: 8px 12px 0; }
  .legacy .ms-fresh { padding: 8px 12px; text-align: left; }
  .legacy .ms-filter { padding-left: 12px; padding-right: 12px; }
  .legacy .ms-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
  .legacy .ms-fields, .legacy .ms-fields.ms-dash { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
  .legacy .ms-dash { grid-template-columns: 1fr; }
  .legacy .ms-card-meta { margin-left: 0; text-align: left; width: 100%; }
  .legacy .ms-card-title { font-size: 18px; }
  .legacy .viewas { flex-wrap: wrap; padding: 8px 12px; }
  .legacy .viewas form { margin-left: 0; }
  .legacy .tablewrap { overflow-x: auto; }
  .legacy thead th { position: static; }
}
@media (max-width: 540px) {
  .legacy .ms-filter-row, .legacy .ms-fields, .legacy .ms-fields.ms-dash, .legacy .grid.c2, .legacy .grid.c3 { grid-template-columns: 1fr; }
  .legacy .ms-head { align-items: flex-start; }
  .legacy .ms-toolbar { width: 100%; }
  .legacy .ms-search, .legacy input.ms-search { width: 100%; }
  .legacy .ms-fields .ms-field { grid-template-columns: minmax(105px, 35%) minmax(0, 1fr); }
  .legacy .ms-pager .ms-totals { margin-left: 0; }
  .legacy .ms-total { width: 100%; }
  .legacy .ms-widget { padding: 12px; }
  .legacy .ms-widget-title { font-size: 16px; }
  .legacy .ms-user { gap: 3px; }
  .legacy .ms-logout span { display: none; }
}
@media print {
  .legacy .ms-header, .legacy .ms-fresh, .legacy .crumbs, .legacy .viewas, .legacy #progress { display: none; }
  .legacy .shell, body.page-embed .legacy .shell { padding-top: 0; }
  .legacy .content { padding: 0; }
  .legacy thead th { position: static; }
  .legacy .ms-widget, .legacy .ms-card { break-inside: avoid; }
}

.legacy .ms-card-title h1, .legacy .ms-card-title h2 { font-size: inherit; }
.legacy .ms-guide-totals { margin-left: auto; text-align: right; }
.legacy .ms-guide-totals > summary { cursor: pointer; }
