/* Компоненты UI kit: кнопки, поля, таблицы, оболочка, формы, диалоги, сообщения.
   Размеры: элементы управления 24/30/36, радиусы 2/4/6/8, сетка отступов 4,
   строки таблиц 32 (справочник — 30), заголовок таблицы 34. */

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text);
  font: 13px/18px var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
.custom-object { padding: 24px; display: flex; flex: 1; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; width: 100%; overflow: auto; }
.custom-object h2 { margin: 0; }
.custom-object .custom-payload { min-height: 160px; }
.custom-result { white-space: pre-wrap; overflow-wrap: anywhere; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
svg { flex: none; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-2); }
.spacer { flex: 1 1 20px; }
.grow { flex: 1; min-width: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus-visible, textarea:focus-visible { outline: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 6px; background: var(--separator); background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--btn-hover-border); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 14px;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  background: var(--btn);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { border-color: var(--btn-hover-border); background: var(--btn-hover); }
.btn:active, .btn[aria-expanded="true"] { border-color: var(--btn-hover-border); background: var(--btn-pressed); }
.btn:disabled { border-color: var(--line); background: var(--bg-disabled); color: var(--text-disabled); cursor: not-allowed; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.btn.primary:active { border-color: var(--accent-pressed); background: var(--accent-pressed); }
.btn.primary:disabled { opacity: 0.55; }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--bg-hover); }
.btn.danger { border-color: var(--error-border); background: var(--error-field); color: var(--error-text); }
.btn.with-icon { padding: 0 14px 0 10px; }
.btn.with-menu { padding: 0 10px 0 14px; }
.btn.square { width: 30px; padding: 0; }
.btn.help { width: 30px; padding: 0; font-weight: 600; }
.btn.tall { height: 36px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.large { width: 32px; height: 32px; color: var(--text); }
.icon-btn.small { width: 22px; height: 22px; border-radius: 3px; }
.icon-btn.star { color: var(--text-muted); }
.icon-btn.star.on { color: var(--warning); }
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--bg-panel);
  border-radius: 50%;
  background: var(--accent);
}
.icon-btn { position: relative; }

.navpair { display: flex; flex: none; border: 1px solid var(--btn-border); border-radius: 4px; overflow: hidden; }
.navpair button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  background: var(--btn);
  color: var(--text);
  cursor: pointer;
}
.navpair button + button { border-left: 1px solid var(--btn-border); }
.navpair button:hover:not(:disabled) { background: var(--btn-hover); }
.navpair button:disabled { background: var(--bg-header); color: var(--text-disabled); cursor: not-allowed; }

/* ---------- Поля ввода ---------- */

.input {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  background: var(--bg-field);
  color: var(--text);
  font-size: 13px;
}
textarea.input { height: 76px; padding: 7px 10px; line-height: 18px; resize: vertical; }
.input.mono, .input.number { font-family: var(--mono); font-size: 12.5px; }
.input.number { text-align: right; }
.input.code { width: 160px; }
.input.date { width: 190px; }
.grid .input.number { max-width: 220px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly] { border-style: dashed; background: transparent; color: var(--text-2); }
.input:disabled { border-color: var(--line); background: var(--bg-disabled); color: var(--text-disabled); cursor: not-allowed; }

.combo {
  display: flex;
  height: 30px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-field);
  overflow: hidden;
}
.combo:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.combo input {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.combo button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-inner);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.combo button:hover { background: var(--bg-hover); color: var(--text); }
.combo button.dots { font-weight: 600; letter-spacing: 1px; }
.combo.open button.drop { color: var(--text); }

/* обязательное незаполненное — пунктир снизу; ошибка — красная рамка */
.field.required.empty .input,
.field.required.empty .combo { border-bottom: 2px dashed var(--error); }
.field.invalid .input,
.field.invalid .combo { border-color: var(--error); background: var(--error-field); }
.field.invalid .input:focus,
.field.invalid .combo:focus-within { box-shadow: 0 0 0 3px var(--error-soft); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.field > .input, .field > .combo { min-width: 0; max-width: 100%; }
.field-error { display: flex; align-items: center; gap: 6px; color: var(--error-text); font-size: 12px; line-height: 16px; }

.check { position: relative; display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; overflow-wrap: anywhere; cursor: pointer; }
.check input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.check .box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: none;
  border: 1px solid var(--btn-hover-border);
  border-radius: 3px;
  background: var(--bg-field);
}
.check .box svg { visibility: hidden; }
.check input:checked + .box { border-color: var(--accent); background: var(--accent); }
.check input:checked + .box svg { visibility: visible; }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--accent-soft); }
.check.disabled, .check:has(input:disabled) { color: var(--text-disabled); cursor: not-allowed; }
.check input:disabled + .box { border-color: var(--line); background: var(--bg-disabled); }
.check input:disabled:checked + .box { border-color: var(--line); background: var(--bg-hover); }
.check input:disabled:checked + .box svg { stroke: var(--text-disabled); }

.segmented { display: flex; padding: 2px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg-field); }
.segmented button {
  flex: 1;
  height: 26px;
  padding: 0 12px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--menu-active); color: var(--text); font-weight: 500; box-shadow: var(--shadow-small); }

.search {
  display: flex;
  flex: 0 1 300px;
  align-items: center;
  min-width: 180px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-field);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search > svg { margin-left: 9px; color: var(--text-muted); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 8px 0 10px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.search > svg + input { padding-left: 8px; }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { width: 28px; height: 28px; color: var(--text-muted); }

/* ---------- Меню и выпадающие списки ---------- */

.menu {
  position: fixed;
  z-index: 70;
  display: flex;
  flex-direction: column;
  min-width: min(200px, calc(100vw - 16px));
  max-width: min(480px, calc(100vw - 16px));
  max-height: 60vh;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--btn);
  box-shadow: var(--shadow-menu);
  overflow: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  flex: none;
  gap: 10px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu-item > span:not(.gap, .hint) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu-item:hover, .menu-item.active { background: var(--menu-active); }
.menu-item.selected { background: var(--accent-soft); }
.menu-item:disabled { background: transparent; color: var(--text-disabled); cursor: not-allowed; }
.menu-item .hint { margin-left: auto; color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.menu-item .gap { width: 15px; flex: none; }
.menu-item.accent { color: var(--accent-text); }
.menu-sep { height: 1px; flex: none; margin: 4px 6px; background: var(--separator); }
.menu-note { max-width: 360px; padding: 6px 10px; color: var(--text-muted); white-space: pre-line; }

/* ---------- Таблицы ---------- */

.table-wrap:focus { outline: none; }
.table-wrap {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-panel);
  overflow: auto;
}
table.list { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
table.list thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-inner);
  background: var(--bg-header);
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
table.list thead th.num { text-align: right; }
table.list thead th.state { width: 36px; padding: 0; }
table.list.bordered thead th + th { border-left: 1px solid var(--line); }
table.list tbody td {
  height: 32px;
  max-width: 420px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-row);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.list.compact tbody td { height: 30px; border-bottom-color: var(--line-row-soft); }
table.list.bordered tbody td + td { border-left: 1px solid var(--line-row-soft); }
table.list tbody td.state { width: 36px; padding: 0 0 0 12px; }
table.list tbody td.num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
table.list tbody td.mono { font-family: var(--mono); font-size: 12.5px; }
table.list tbody td.code { color: var(--text-2); font-family: var(--mono); font-size: 12px; }
table.list tbody tr { cursor: default; }
table.list tbody tr:hover { background: var(--row-hover); }
table.list tbody tr.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
table.list tbody tr.deleted { color: var(--text-muted); text-decoration: line-through; }
table.list tbody tr.empty td { height: 72px; color: var(--text-muted); text-align: center; white-space: normal; }
table.list tbody tr.empty:hover { background: transparent; }
.name-cell { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; }
.name-cell > span { overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.badge.success { background: var(--success-soft); color: var(--success-text); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.warning { background: var(--warning-soft); color: var(--warning-text); }
.badge.error { background: var(--error-soft); color: var(--error-text); }
.badge.draft { background: var(--bg-hover); color: var(--text-2); }

.pager { display: flex; gap: 4px; }
.pager button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  background: var(--btn);
  color: var(--text-2);
  cursor: pointer;
}
.pager button:hover:not(:disabled) { background: var(--btn-hover); color: var(--text); }
.pager button:disabled { border-color: var(--line); background: var(--bg-disabled); color: var(--text-disabled); cursor: not-allowed; }
.list-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 16px; }
.list-footer .summary { flex: 1; color: var(--text-2); }
.list-footer .summary .mono { color: var(--text); }

/* ---------- Оболочка рабочего места ---------- */

.shell { display: flex; flex-direction: column; height: 100vh; min-height: 0; }

.topbar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 44px;
  padding: 5px 10px 5px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}
.topbar .title { flex: 1 1 240px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar { user-select: none; }
.topbar-logo { display: flex; }
/* кнопки окна без рамки ОС */
.window-controls { display: flex; align-items: center; gap: 2px; margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--separator); }
.icon-btn.window-btn { width: 38px; height: 30px; color: var(--text-2); }
.icon-btn.window-btn:hover { color: var(--text); }
.icon-btn.window-btn.close:hover { background: var(--error); color: #FFFFFF; }
/* граница окна без рамки ОС; у развёрнутого — нет */
.login-frame { position: fixed; top: 6px; right: 8px; }
.login-frame .window-controls { border-left: 0; }
html:not(.window-maximized) .shell::after,
html:not(.window-maximized) .login-screen::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 10000;
  border: 1px solid var(--separator);
  pointer-events: none;
}
.topbar .search { border-color: var(--separator); background: var(--bg-tabs); }
.topbar .tools { display: flex; align-items: center; gap: 2px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  max-width: 260px;
  margin-left: 4px;
  padding: 0 8px 0 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.user-chip:hover { background: var(--bg-hover); }
.user-chip .avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--avatar);
  font-size: 11px;
  font-weight: 600;
}
.user-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sections {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
  overflow-x: auto;
}
.sections button {
  display: flex;
  align-items: center;
  flex: none;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.sections button:hover { color: var(--text); }
.sections button[aria-current="page"] { background: var(--bg-field); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }

.infobar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--accent-softer);
}
.infobar > span { flex: 1; }
.infobar.error { background: var(--error-softer); }

.content { position: relative; display: flex; flex: 1; min-height: 0; background: var(--bg-work); }
.content > .view { display: flex; flex: 1; min-width: 0; min-height: 0; }

.windows {
  display: flex;
  flex: none;
  align-items: stretch;
  height: 34px;
  border-top: 1px solid var(--line);
  background: var(--bg-tabs);
  overflow-x: auto;
  overflow-y: hidden;
}
.windows .tab { display: flex; flex: none; align-items: center; border-right: 1px solid var(--line); }
.windows .tab .open {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  height: 100%;
  padding: 0 4px 0 14px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}
.windows .tab .open span { overflow: hidden; text-overflow: ellipsis; }
.windows .tab.home .open { padding: 0 14px; }
.windows .tab .close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.windows .tab .close:hover { color: var(--text); }
.windows .tab.active { background: var(--bg-work); box-shadow: inset 0 2px 0 var(--accent); }
.windows .tab.active .open { color: var(--text); font-weight: 500; }
.windows .tab.active .close { color: var(--text-2); }

/* ---------- Начальная страница ---------- */

.home { display: flex; flex: 1; flex-wrap: wrap; align-content: stretch; min-height: 0; overflow: auto; }
.home > main { display: flex; flex: 999 1 560px; flex-direction: column; gap: 18px; min-width: 0; padding: 14px 20px 28px; }
.home > aside {
  display: flex;
  flex: 1 1 260px;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 18px 20px;
  border-left: 1px solid var(--line);
  background: var(--bg-panel);
}
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { flex: 1; margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
.caps-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.caps-head h2 {
  margin: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.caps-head span { flex: 1; color: var(--text-muted); font-size: 12px; }
.home section { display: flex; flex-direction: column; gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: 12px; }
.kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.kpi:hover { border-color: var(--btn-border); }
.kpi .ico { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border-radius: 50%; }
.kpi .text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi .label {
  overflow: hidden;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.kpi .value { font-family: var(--mono); font-size: 16px; font-weight: 500; line-height: 22px; white-space: nowrap; }
.tint-accent { background: var(--accent-soft); color: var(--accent-text); }
.tint-warning { background: var(--warning-soft); color: var(--warning-text); }
.tint-success { background: var(--success-soft); color: var(--success-text); }
.tint-error { background: var(--error-soft); color: var(--error-text); }
.tint-neutral { background: var(--bg-hover); color: var(--text); }
.placeholder { color: var(--text-muted); }

.todo h2 { margin: 0; color: var(--accent-text); font-size: 15px; font-weight: 600; line-height: 20px; }
.todo ul { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.todo a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.todo a:hover { background: var(--bg-hover); }
.todo a > span:first-of-type { flex: 1; min-width: 0; }
.todo a > svg { align-self: flex-start; margin-top: 3px; }
.counter {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.counter.neutral { background: var(--avatar); color: var(--text); }
.todo .footer { display: flex; justify-content: flex-end; gap: 6px; margin-top: auto; }

/* ---------- Панель раздела ---------- */

.panel { display: flex; flex: 1; flex-direction: column; gap: 22px; min-height: 0; padding: 18px 24px 28px; overflow: auto; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.panel-head h1 { flex: 1 1 200px; margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
.panel-head .search { flex-basis: 280px; }
.panel-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 28px 40px; align-items: start; }
.panel-group { display: flex; flex-direction: column; gap: 2px; }
.panel-group h2 { margin: 0 0 8px; color: var(--accent-text); font-size: 15px; font-weight: 600; line-height: 20px; }
.panel-group a { padding: 5px 0 5px 2px; color: var(--text); text-decoration: none; cursor: pointer; }
.panel-group a:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.panel-group a .hint { color: var(--text-muted); font-size: 12px; }
.panel-empty { color: var(--text-muted); }

/* ---------- Формы: списки и объекты ---------- */

.form { display: flex; flex: 1; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; padding: 12px 16px 10px; container: form / inline-size; }
.form.object { gap: 12px; padding: 12px 20px 16px; overflow: auto; }
.form-title { display: flex; align-items: center; gap: 10px; }
.form-title h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  line-height: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.form.object .form-title h1 { font-size: 20px; line-height: 28px; }
.kind { color: var(--text-2); font-weight: 400; }
.commands { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.commands .sep { width: 1px; height: 20px; background: var(--separator); }
.commands .search { flex: 0 1 300px; }
.commands > .btn:not(.square, .help) { max-width: 100%; min-height: 30px; height: auto; white-space: normal; overflow-wrap: anywhere; padding-top: 5px; padding-bottom: 5px; }
.commands > .input { min-width: 0; max-width: 100%; }

.groups { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 28px 48px; padding-top: 6px; }
.group-column { display: flex; flex: 1 1 440px; flex-direction: column; gap: 28px; min-width: 0; }
.group { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.group h2, .tabular h2 { min-width: 0; margin: 0; color: var(--accent-text); font-size: 15px; font-weight: 600; line-height: 20px; overflow-wrap: anywhere; }
.grid { display: grid; grid-template-columns: min(var(--label-width, clamp(140px, 22%, 220px)), 45%) minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; container: fields / inline-size; }
.label { min-width: 0; overflow-wrap: anywhere; }
.grid > .label { color: var(--text-2); }
.grid > .label.top { align-self: start; padding-top: 7px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline .label { color: var(--text-2); }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status-line:empty { display: none; }

.tabular { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 100%; }
.tabular .table-wrap { flex: none; min-height: 112px; max-height: 440px; background: var(--bg-work); }
table.edit tbody td { height: 32px; padding: 0; }
table.edit tbody td.n {
  width: 44px;
  padding: 0 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
}
table.edit tbody tr.selected td.n { color: var(--accent-text); }
table.edit tbody tr:hover { background: transparent; }
table.edit tbody tr.selected { background: var(--accent-softer); box-shadow: none; }
table.edit .cell { height: 31px; border-color: transparent; border-radius: 0; background: transparent; }
table.edit .cell:focus, table.edit .cell:focus-within { border-color: var(--accent); box-shadow: none; }
table.edit .field { gap: 0; }
table.edit .field.required.empty .cell { border-bottom: 2px dashed var(--error); }
table.edit .field.invalid .cell { border-color: var(--error); background: var(--error-field); }
table.edit .combo.cell button { border-left-color: transparent; }
table.edit .combo.cell:focus-within button { border-left-color: var(--line-inner); }
table.edit td .check { padding: 0 12px; }

/* ---------- Подсказки ---------- */

.tooltip {
  position: fixed;
  z-index: 90;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 4px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 12px;
  line-height: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  white-space: pre-line;
}

/* ---------- Управляемые формы ---------- */

.m-body { display: flex; flex-direction: column; gap: 24px; min-width: 0; width: 100%; padding-top: 4px; }
.m-group { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.m-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 48px; }
.m-row > .m-group { flex: 1 1 380px; }
.m-row > .m-pair, .m-row > .btn, .m-row > .m-label { flex: 0 1 auto; align-self: center; max-width: 100%; }
.m-cell { display: contents; }
.m-pair { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.m-pair > .field { min-width: 0; flex-shrink: 1; }
.m-label { color: var(--text); overflow-wrap: anywhere; }
.m-label.empty { display: none; }
.m-label.note { color: var(--text-muted); font-size: 12px; line-height: 16px; }
.m-label.info, .m-label.warning, .m-label.error { padding: 8px 12px; border: 1px solid; border-radius: 6px; }
.m-label.info { border-color: var(--accent-soft); background: var(--accent-softer); }
.m-label.warning { border-color: var(--warning-line); background: var(--warning-softer); }
.m-label.error { border-color: var(--error-line); background: var(--error-softer); color: var(--error-text); }
.m-label.link { align-self: flex-start; padding: 0; border: 0; background: transparent; color: var(--link); text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.m-label.link:hover { color: var(--link-hover); }
.grid .m-cell > .m-label { grid-column: 2; }
.grid .m-cell:has(> .m-label.empty) { display: none; }
.m-tabs { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.m-tabs button {
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--accent-text);
  font-size: 13px;
  cursor: pointer;
}
.m-tabs button:hover { background: var(--row-hover); }
.m-tabs button[aria-current="page"] { background: var(--bg-hover); color: var(--text); font-weight: 500; }
.m-pages-box { display: flex; flex-direction: column; gap: 16px; }
.m-page { display: flex; flex-direction: column; gap: 16px; min-width: 0; width: 100%; }
.m-pages-box, .m-pages { min-width: 0; width: 100%; }
.m-body > .btn, .m-page > .btn, .m-group-body > .btn { align-self: flex-start; }
.m-body .btn { max-width: 100%; min-height: 30px; height: auto; padding-top: 5px; padding-bottom: 5px; white-space: normal; overflow-wrap: anywhere; }
.m-column > .btn { align-self: stretch; }
.commands-group { display: contents; }
.btn.link { border-color: transparent; background: transparent; color: var(--link); }
.btn.link:hover { color: var(--link-hover); background: transparent; text-decoration: underline; }
.input.as-label, .field.readonly .input.as-label { border-color: transparent; background: transparent; padding-left: 0; }
.field.readonly .input:not(.cell) { border-style: dashed; background: transparent; color: var(--text-2); }
.field.readonly .combo { border-style: dashed; background: transparent; }
.field.readonly .combo input { color: var(--text-2); }
table.edit .field.readonly .cell { color: var(--text-2); }
.tabular.disabled { opacity: 0.6; }

/* настройки формы: ширина подписей, группы с рамкой, колонками и сворачиванием */
.grid .m-cell > .label { color: var(--text-2); }
.grid .m-cell > .label.top { align-self: start; padding-top: 7px; }
.m-cell.title-top > .label, .m-cell.title-top > .field { grid-column: 1 / -1; }
.m-cell.title-top > .label { margin-bottom: -4px; }
.m-cell.title-none > .label { display: none; }
.m-cell.title-none > .field { grid-column: 1 / -1; }
.m-pair.title-top { flex-direction: column; align-items: stretch; gap: 6px; }
.m-group-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; container: group / inline-size; }
.m-box { padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-panel); }
.m-tinted { padding: 10px 12px; border-radius: 6px; }
.m-box.m-tinted { padding: 14px 16px 16px; }
.m-group-title {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  cursor: pointer;
}
.m-group-title:hover { color: var(--link-hover); }
.m-group-title:focus-visible { border-radius: 2px; outline: 2px solid var(--accent); outline-offset: 2px; }
.m-group-title > svg:first-child { transition: transform 0.15s; }
.m-group.collapsed .m-group-title > svg:first-child { transform: rotate(-90deg); }
.m-columns { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); align-items: start; gap: 12px 24px; min-width: 0; }
.m-column { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* Перестроение по доступной ширине группы, включая диалоги и вложенные панели. */
@container group (max-width: 1000px) {
  .m-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container group (max-width: 680px) {
  .m-columns { grid-template-columns: minmax(0, 1fr); }
}
@container fields (max-width: 440px) {
  .grid > .label, .grid > .field, .grid > .inline,
  .grid .m-cell > .label, .grid .m-cell > .field, .grid .m-cell > .inline,
  .grid .m-cell > .m-label { grid-column: 1 / -1; }
  .grid > .label, .grid .m-cell > .label { padding-top: 0; margin-bottom: -4px; }
  .grid > .label:empty, .grid .m-cell > .label:empty { display: none; }
  .grid .m-cell > .label:has(> .m-title-text:empty):not(.with-icon) { display: none; }
}
@container group (max-width: 440px) {
  .m-pair { flex-wrap: wrap; }
  .m-pair > .label { flex-basis: 100%; }
  .m-pair > .field { flex: 1 1 160px; }
}

/* поля: растянуть, список выбора у строки и числа */
.field.stretch .input, .field.stretch .combo { width: 100%; max-width: none; }
.m-pair.stretch, .inline > .field.stretch, .m-row > .m-pair.stretch { flex: 1 1 240px; }
.m-pair.stretch > .field { flex: 1; }
.combo input.number, .combo input.mono { font-family: var(--mono); font-size: 12.5px; }
.combo input.number { text-align: right; }

/* разделитель, надписи и закладки со значком, значок формы */
.m-separator { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.m-separator::after { content: ''; flex: 1; height: 1px; background: var(--separator); }
.m-separator > span:empty { display: none; }
.m-row > .m-separator { flex: none; align-self: stretch; width: 1px; background: var(--separator); }
.m-row > .m-separator::after, .m-row > .m-separator > span { display: none; }
.m-label.with-icon:not(.empty) { display: flex; align-items: flex-start; gap: 8px; }
.m-label.link.with-icon:not(.empty) { display: inline-flex; align-items: center; }
.m-label.with-icon > svg { flex: none; margin-top: 1px; }
.m-tabs button { display: inline-flex; align-items: center; gap: 6px; }
.form-icon { display: flex; flex: none; color: var(--accent-text); }

/* итоги таблицы и отбор списка выбора */
table.edit tfoot td {
  position: sticky;
  bottom: 0;
  height: 32px;
  padding: 0 10px;
  border-top: 1px solid var(--line-inner);
  background: var(--bg-header);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
table.edit tfoot td.num { font-family: var(--mono); font-size: 12.5px; text-align: right; }
.list-filter { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; background: var(--accent-softer); color: var(--text-2); font-size: 12px; line-height: 16px; }
.list-filter svg { flex: none; color: var(--accent-text); }

/* ---------- Сообщения ---------- */

.errors { display: flex; flex-direction: column; border: 1px solid var(--error-line); border-radius: 6px; background: var(--error-softer); }
.errors header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--error-line);
  font-weight: 600;
}
/* отказ без сообщений — только заголовок */
.errors header:last-child { border-bottom: 0; }
.errors .item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.errors .item:last-child { padding-bottom: 10px; }
.errors .item:hover { color: var(--error-text); }
.errors .item svg { color: var(--error); }
.errors.info { border-color: var(--accent-line); background: var(--accent-softer); }
.errors.info header { border-bottom-color: var(--accent-soft); }
.errors.info .item:hover { color: var(--accent-text); }
.errors.info .item svg { color: var(--accent-text); }

.warning-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--warning-line);
  border-radius: 6px;
  background: var(--warning-softer);
}
.warning-note svg { margin-top: 1px; color: var(--warning); }

.toasts { position: fixed; right: 16px; bottom: 50px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 360px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--btn);
  box-shadow: var(--shadow-menu);
  animation: toast-in 0.16s ease-out;
}
.toast > svg { margin-top: 1px; }
.toast .body { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.toast .title { font-weight: 600; }
.toast .text { color: var(--text-2); overflow-wrap: anywhere; }
.toast .action { align-self: flex-start; margin-top: 4px; padding: 0; border: 0; background: transparent; color: var(--accent-text); cursor: pointer; }
.toast .action:hover { text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Диалоги ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
}
.dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  min-width: 0;
  max-height: calc(100vh - 32px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-work);
  box-shadow: var(--shadow-dialog);
  container: dialog / inline-size;
}
.dialog.wide { max-width: 900px; height: min(640px, calc(100vh - 32px)); }
.dialog.narrow { max-width: 440px; }
.dialog > header { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 14px; }
.dialog > header h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; font-size: 17px; font-weight: 600; line-height: 24px; text-overflow: ellipsis; white-space: nowrap; }
.dialog > .commands { padding: 6px 14px 12px; }
.dialog > .body { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 14px 14px 20px; border-top: 1px solid var(--line); overflow: auto; }
.dialog-form { min-width: 0; width: 100%; }
.dialog.wide > .body { flex: 1; padding: 12px 14px; }
.dialog > .body .table-wrap { min-height: 160px; }
.dialog > footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.dialog p { margin: 0; overflow-wrap: anywhere; }
.about { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 12px; }
.about dt { color: var(--text-2); }
.about dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Окно запуска ---------- */

.launcher { display: flex; flex-direction: column; height: 100vh; border: 1px solid var(--line-inner); background: var(--bg-work); overflow: hidden; }
.launcher > header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 8px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
  user-select: none;
}
.launcher > header h1 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; line-height: 20px; }
.launcher .body { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) 168px; gap: 16px; min-height: 0; padding: 16px 18px 18px; }
.launcher .bases-col { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.launcher .caption { color: var(--accent-text); font-weight: 600; }
.bases {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-panel);
  overflow: auto;
}
.bases button {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.bases button span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bases button svg { color: var(--text-muted); }
.bases button:hover { background: var(--row-hover); }
.bases button[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.bases button[aria-pressed="true"] svg { color: var(--accent-text); }
.bases .empty { margin: auto; padding: 12px; color: var(--text-muted); text-align: center; }
.connection { overflow: hidden; color: var(--text-muted); font-family: var(--mono); font-size: 11.5px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.launch-error { padding: 7px 10px; border: 1px solid var(--error-line); border-radius: 4px; background: var(--error-softer); color: var(--error-text); overflow-wrap: anywhere; }
.launcher .actions { display: flex; flex-direction: column; gap: 8px; padding-top: 26px; }
.launcher .actions .gap { height: 14px; }
.launcher .actions .fill { flex: 1; }
.browser-launcher { display: grid; place-items: center; height: 100%; padding: 24px; overflow: auto; }
.browser-launcher > .launcher { width: min(100%, 820px); height: min(520px, 100%); min-height: 280px; border-radius: 8px; }
@media (max-width: 560px) {
  .browser-launcher { padding: 12px; }
  .browser-launcher .launcher .body { grid-template-columns: minmax(0, 1fr); }
  .browser-launcher .actions { flex-direction: row; flex-wrap: wrap; padding-top: 0; }
}
.infobase-field { display: flex; gap: 8px; min-width: 0; }
.infobase-field > .input { flex: 1; min-width: 0; }
.check-result { min-height: 18px; color: var(--text-2); overflow-wrap: anywhere; }
.check-result.ok { color: var(--success-text); }
.check-result.fail { color: var(--error-text); }

/* ---------- Загрузка и ошибки запуска рабочего места ---------- */

.splash { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100vh; padding: 24px; text-align: center; }
.splash p { max-width: 560px; margin: 0; color: var(--text-2); overflow-wrap: anywhere; }
.splash .buttons { display: flex; gap: 8px; }

/* ---------- Отчёты ---------- */

.report-form { gap: 8px; overflow: auto; }
.report-status { flex: 0 1 auto; min-width: 0; max-width: 50%; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.report-commands { gap: 6px; }
.report-commands .btn { height: 28px; }
.report-commands .btn.square { width: 28px; }
.report-commands .btn.with-menu:not(.with-icon) { padding: 0 8px 0 12px; }
.report-commands .btn.square.with-menu { width: auto; padding: 0 6px 0 8px; }
.report-find { width: 200px; height: 28px; }
.input.report-sum { width: 150px; height: 28px; border-style: solid; background: var(--bg-field); color: var(--text); }

/* Быстрые настройки: колонками, как в форме отчёта 1С */
.report-quick { position: relative; flex: none; min-width: 0; padding: 12px 48px 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-panel); container: quick / inline-size; }
.report-quick-items { column-width: 460px; column-gap: 32px; }
.report-quick-tools { position: absolute; top: 12px; right: 12px; }
.rq-item {
  display: grid;
  grid-template-columns: 18px var(--rq-label, 14ch) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 6px;
  break-inside: avoid;
}
.rq-item.wide { grid-template-columns: 18px minmax(0, 1fr); }
.rq-item.wide > :first-child { align-self: start; margin-top: 6px; }
.rq-gap { width: 18px; }
.rq-label { overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.rq-item .field { min-width: 0; }
.rq-item .input { height: 28px; }
.rq-period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.rq-period-title { flex: 0 1 auto; max-width: 100%; }
.rq-bound { display: flex; flex: none; align-items: center; gap: 6px; }
.rq-bound .field { width: 132px; min-width: 120px; }
.rq-period .input.date { width: 100%; }
.rq-period.off .field { opacity: 0.5; }
.rq-dots.btn { width: 28px; height: 28px; padding: 0; }
.rq-preset { overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.rq-note { font-size: 12px; }

@container quick (max-width: 600px) {
  .rq-item:not(.wide) { grid-template-columns: 18px minmax(0, 1fr); }
  .rq-item:not(.wide) > .rq-label { grid-column: 2; white-space: normal; overflow-wrap: anywhere; }
  .rq-item:not(.wide) > .field { grid-column: 2; }
  .rq-item:not(.wide) > :first-child { grid-row: 1 / 3; align-self: start; }
  .rq-preset { flex-basis: 100%; }
}

/* Табличный документ */
.report-result {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--report-sheet);
  overflow: auto;
  outline: none;
}
.report-result:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
.report-output { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 10px 12px 18px; transition: opacity 0.15s; }
.report-result.loading .report-output { opacity: 0.45; pointer-events: none; }
.report-notice {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 6px 12px;
  border: 1px solid var(--warning-line);
  border-radius: 6px;
  background: var(--bg-work);
  box-shadow: inset 0 0 0 100px var(--warning-softer);
  color: var(--warning-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rd-head { display: flex; flex-direction: column; gap: 4px; }
.rd-title { font-size: 16px; font-weight: 600; line-height: 22px; }
.rd-description { color: var(--text-2); font-size: 12px; line-height: 17px; }
.rd-block { flex: none; max-width: 100%; }
table.rd { border-collapse: collapse; color: var(--text); font-size: 12px; line-height: 16px; user-select: none; }
table.rd th, table.rd td { padding: 2px 6px; border: 1px solid var(--report-grid); vertical-align: top; }
table.rd thead th { background: var(--report-head); font-weight: 500; text-align: left; white-space: nowrap; }
table.rd thead th.num { text-align: right; }
table.rd .rd-sortable { cursor: pointer; }
table.rd thead th.rd-sortable:hover { background: var(--report-group-1); }
table.rd thead th svg { margin-left: 4px; vertical-align: -1px; color: var(--accent-text); }
table.rd td { min-width: 64px; max-width: 360px; overflow-wrap: anywhere; }
table.rd td.num { min-width: 86px; font-family: var(--mono); font-size: 11.5px; text-align: right; white-space: nowrap; }
table.rd td.rd-label { min-width: 220px; }
table.rd tr.rd-group.level-0 > td:not(.rd-gutter) { background: var(--report-group-1); }
table.rd tr.rd-group.level-1 > td:not(.rd-gutter) { background: var(--report-group-2); }
table.rd tr.rd-group.level-2 > td:not(.rd-gutter) { background: var(--report-group-3); }
table.rd tr.rd-group:not(.leaf) > td.rd-label { font-weight: 500; }
table.rd tr.rd-group.leaf > td:not(.rd-gutter) { background: transparent; }
table.rd tr.rd-total > td:not(.rd-gutter) { background: var(--report-total); font-weight: 600; }
table.rd tr.rd-empty td { padding: 10px; color: var(--text-muted); }
table.rd td.rd-row-total, table.rd th.rd-row-total { font-weight: 600; }
table.rd td.rd-ref { cursor: default; }
table.rd td.rd-ref:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }
table.rd td.selected { background: var(--report-selected) !important; }
table.rd td.current { box-shadow: inset 0 0 0 1px var(--accent); }
table.rd .rd-corner { vertical-align: bottom; }
table.rd .rd-measure { font-size: 11.5px; font-weight: 400; }
table.rd .rd-column { text-align: center; }

/* Дерево групп слева: кнопка «−»/«+» и линии до последней строки группы */
table.rd .rd-gutter { position: relative; min-width: 0; padding: 0; border: 0; background: var(--report-sheet); }
table.rd thead .rd-gutter { background: var(--report-sheet); }
.rd-ol { position: absolute; top: 0; bottom: 0; width: 14px; }
.rd-ol.line::before, .rd-ol.end::before, .rd-ol.open::after, .rd-ol.end::after {
  content: "";
  position: absolute;
  left: 6px;
  border-color: var(--report-outline);
  border-style: solid;
  border-width: 0;
}
.rd-ol.line::before { top: 0; bottom: 0; border-left-width: 1px; }
.rd-ol.end::before { top: 0; height: 50%; border-left-width: 1px; }
.rd-ol.end::after { top: 50%; width: 6px; border-top-width: 1px; }
.rd-ol.open::after { top: calc(50% + 5px); bottom: 0; border-left-width: 1px; }
.rd-ol button {
  position: absolute;
  top: calc(50% - 6px);
  left: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  padding: 0;
  border: 1px solid var(--report-outline);
  border-radius: 2px;
  background: var(--report-sheet);
  color: var(--text-2);
  font: 600 10px/1 var(--mono);
  cursor: pointer;
}
.rd-ol button:hover { border-color: var(--accent); color: var(--accent-text); }

/* Печать: только копия документа отчёта */
.print-sheet { display: none; }
@media print {
  body.printing-report > *:not(.print-sheet) { display: none !important; }
  body.printing-report { background: #fff; }
  body.printing-report .print-sheet { display: block; color: #000; }
  .print-sheet .report-output { padding: 0; }
  .print-sheet .rd-gutter, .print-sheet .chart-footer, .print-sheet .chart-data { display: none !important; }
  .print-sheet table.rd { font-size: 9pt; }
  .print-sheet table.rd th, .print-sheet table.rd td { border-color: #999; }
  .print-sheet .chart-card { break-inside: avoid; }
}

/* Печатные формы: предпросмотр страниц (лист бумаги всегда белый) и печать */
.print-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-tabs);
  overflow: auto;
  outline: none;
}
.print-preview:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
.print-preview.loading .print-pages { opacity: 0.45; pointer-events: none; }
.print-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; width: max-content; min-width: 100%; padding: 20px 24px 28px; box-sizing: border-box; transition: opacity 0.15s; }
.print-page { flex: none; background: #fff; box-shadow: var(--shadow-small), 0 0 0 1px var(--line); }
.print-page svg { display: block; }
.print-sheet.print-pages-sheet { display: none; }
@media print {
  body.printing-form > *:not(.print-sheet) { display: none !important; }
  body.printing-form { background: #fff; }
  body.printing-form .print-pages-sheet { display: block; }
  html:has(body.printing-form), body.printing-form { height: auto !important; min-height: 0 !important; overflow: visible !important; margin: 0; padding: 0; }
  /* лист — во всю печатную область (поля принтера могут быть больше полей @page): SVG
     вписывается в неё с сохранением пропорций, лишних страниц нет */
  .print-paper { width: 100%; height: calc(100vh - 2px); overflow: hidden; break-after: page; }
  .print-paper:last-child { break-after: auto; }
  .print-paper svg { display: block; width: 100%; height: 100%; }
}

/* Диаграммы */
.report-charts { display: grid; align-self: stretch; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 14px; }
.chart-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-panel); }
.chart-card > header { display: flex; align-items: baseline; gap: 10px; }
.chart-card h3 { margin: 0; font-size: 14px; font-weight: 600; line-height: 20px; }
.chart-card > header .muted { font-size: 12px; }
.chart-plot { min-width: 0; }
.chart-svg { display: block; overflow: visible; outline: none; }
.chart-svg:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); border-radius: 4px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-baseline { stroke: var(--border); stroke-width: 1; }
.chart-tick { fill: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.chart-label { fill: var(--text-2); font-size: 11.5px; }
.chart-value { fill: var(--text-2); font-size: 11px; font-family: var(--mono); }
.chart-center { fill: var(--text); font-size: 18px; font-weight: 600; }
.chart-mark { stroke: var(--bg-panel); stroke-width: 1; }
.chart-slice { stroke-width: 2; transition: opacity 0.12s; }
.chart-slice.dim { opacity: 0.35; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: 0.12; }
.chart-dot { stroke: var(--bg-panel); stroke-width: 2; }
.chart-dot.active { r: 5; }
.chart-crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hover-band { fill: var(--text); opacity: 0.05; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); font-size: 12px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.chart-swatch.line { height: 3px; border-radius: 2px; }
.chart-note { font-size: 12px; }
.chart-footer { display: flex; justify-content: flex-end; }
.chart-table-toggle { padding: 2px 4px; border: 0; background: transparent; color: var(--link); font: inherit; font-size: 12px; cursor: pointer; }
.chart-table-toggle:hover { color: var(--link-hover); text-decoration: underline; }
.chart-data { flex: none; max-height: 260px; }
.chart-pie-box { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.chart-pie-legend { display: grid; flex: 1 1 200px; grid-template-columns: max-content minmax(0, 1fr) max-content max-content; align-items: center; gap: 6px 10px; font-size: 12.5px; }
.chart-pie-row { display: contents; }
.chart-pie-label { overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.chart-pie-row strong { font-family: var(--mono); font-size: 12px; font-weight: 500; text-align: right; }
.chart-pie-row .muted { font-family: var(--mono); font-size: 11.5px; text-align: right; }
.chart-tip {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  max-width: 320px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-work);
  box-shadow: var(--shadow-small);
  font-size: 12px;
  pointer-events: none;
}
.chart-tip-title { color: var(--text); font-weight: 600; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip-row strong { color: var(--text); font-family: var(--mono); font-weight: 500; }
.chart-key { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 2px; }

/* Окно настроек отчёта */
.report-settings > .body { gap: 10px; }
.rs-box { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.rs-page { display: flex; flex-direction: column; gap: 10px; }
.rs-hint { font-size: 12.5px; line-height: 18px; }
.rs-section { display: flex; flex-direction: column; gap: 8px; }
.rs-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-panel); }
.rs-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; }
.rs-row + .rs-row { border-top: 1px solid var(--line-row-soft); }
.rs-row-body { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.rs-tools { display: flex; flex: none; gap: 2px; padding-top: 4px; }
.rs-tools .icon-btn:disabled { opacity: 0.35; cursor: default; }
.rs-empty { padding: 10px 12px; font-size: 12.5px; }
.rs-picker { min-width: 0; max-width: min(280px, 100%); }
.rs-picker .label { overflow: hidden; text-overflow: ellipsis; }
.rs-picker.placeholder .label { color: var(--text-muted); }
.rs-value { flex: 1 1 200px; min-width: min(160px, 100%); max-width: 360px; }
.rs-name { font-weight: 500; }
.rs-code { font-family: var(--mono); font-size: 12px; }
.rs-group-head { display: flex; align-items: center; gap: 10px; }
.rs-nested { flex-basis: 100%; padding-left: 26px; }
.rs-chart { display: grid; flex: 1; grid-template-columns: fit-content(35%) minmax(0, 1fr); align-items: center; gap: 8px 12px; min-width: 0; }
.rs-chart .input { max-width: 360px; }
.rs-chart > .btn { justify-self: start; }
.rs-label { color: var(--text-2); font-size: 12.5px; }
.rs-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.rs-chips { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.rs-flags { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Вход и пользователи ---------- */

.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--bg-base); }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(420px, 100%);
  padding: 24px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-work);
  box-shadow: var(--shadow-dialog);
}
.login-head { display: flex; align-items: center; gap: 12px; }
.login-head h1 { margin: 0; font-size: 17px; font-weight: 600; line-height: 24px; }
.login-head .muted { font-size: 12.5px; }
.login-grid { display: grid; grid-template-columns: fit-content(35%) minmax(0, 1fr); align-items: center; gap: 10px 12px; min-width: 0; }
.login-grid > label { color: var(--text-2); }
.login-grid .input { width: 100%; }
.login-error { padding: 7px 10px; border: 1px solid var(--error-line); border-radius: 6px; background: var(--error-softer); color: var(--error-text); font-size: 12.5px; }
.login-buttons { display: flex; justify-content: space-between; gap: 8px; }
.users-form .table-wrap { flex: 1; }
.users-note { margin: 0; font-size: 12.5px; }
.user-dialog { max-width: 520px; }
.user-roles-title { margin: 4px 0 0; color: var(--accent-text); font-size: 14px; font-weight: 600; }
.user-roles { display: flex; flex-direction: column; gap: 8px; }
.user-parameters { display: flex; flex-direction: column; gap: 8px; }
.user-parameters[hidden] { display: none; }
.user-parameters > p { margin: 0; font-size: 12px; }
.login-grid > .user-parameter-label { align-self: start; padding-top: 8px; }
.user-parameter-list { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.user-parameter-item { display: flex; align-items: center; gap: 6px; width: 100%; }
.user-parameter-item > .field { flex: 1; min-width: 0; }
.users-form td.user-locked, .users-form td.event-error { color: var(--error-text); font-weight: 500; }
.users-form td.event-warning { color: var(--warning-text); }
.auth-log-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12.5px; }
.users-form .commands > .input { flex: 0 1 280px; width: 280px; }

@container dialog (max-width: 520px) {
  .login-grid, .rs-chart { grid-template-columns: minmax(0, 1fr); }
  .login-grid > .user-parameter-label { padding-top: 0; }
  .rs-row { flex-wrap: wrap; }
  .rs-tools { padding-top: 0; margin-left: auto; }
  .rs-nested { padding-left: 12px; }
}

@container form (max-width: 600px) {
  .m-body { gap: 16px; }
  .m-box { padding: 12px; }
  .form-title { gap: 6px; }
  .form-title h1 { font-size: 17px; line-height: 24px; white-space: normal; overflow-wrap: anywhere; }
  .report-status { max-width: 35%; }
}

/* ---------- Свои картинки, поля-файлы и фото (контракт v9) ---------- */

img.pic { display: block; flex: none; object-fit: contain; }
.kpi .ico.picture { background: var(--bg-field); }

/* поле-файл: строка «значок · имя · размер | загрузить, сохранить, очистить» */
.file-box { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; outline: none; }
.file-line {
  display: flex;
  align-items: center;
  align-self: stretch;
  height: 30px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-field);
  overflow: hidden;
}
.file-box:focus .file-line { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.file-info { display: flex; align-items: center; flex: 1; gap: 8px; min-width: 0; padding: 0 10px; color: var(--text-2); }
.file-name {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.file-name:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }
.file-name:disabled { color: var(--text-muted); text-decoration: none; cursor: default; }
.file-size { flex: none; color: var(--text-muted); font-family: var(--mono); font-size: 11.5px; }
.file-tools { display: flex; flex: none; align-self: stretch; }
.file-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-inner);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.file-tool:hover { background: var(--bg-hover); color: var(--text); }
.file-tool:disabled { color: var(--text-disabled); background: transparent; cursor: not-allowed; }
.file-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  height: 126px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-field);
  overflow: hidden;
  cursor: zoom-in;
}
.file-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; color: var(--text-muted); font-size: 11.5px; line-height: 15px; text-align: center; cursor: default; }
.file-box.drop .file-thumb,
.file-box.drop .file-line { border-style: dashed; border-color: var(--accent); background: var(--accent-softer); }
.field.file-field.busy .file-line,
.field.file-field.busy .file-thumb { opacity: 0.6; cursor: progress; }
.field.required.empty .file-line { border-bottom: 2px dashed var(--error); }
.field.invalid .file-line { border-color: var(--error); background: var(--error-field); }
.field.readonly .file-line { border-style: dashed; background: transparent; }
.file-box.disabled .file-line { border-color: var(--line); background: var(--bg-disabled); }
.file-box.disabled .file-name { color: var(--text-disabled); }
.file-box.cell { border: 1px solid transparent; }
.file-box.cell .file-line { height: 29px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.file-box.cell .file-tool { border-left-color: transparent; }

/* элемент формы «Картинка»: общая картинка (логотип) или фото из реквизита */
.m-picture { display: flex; flex: none; align-items: center; justify-content: center; width: 64px; overflow: hidden; }
.m-picture.bound { width: 160px; height: 160px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-field); }
.m-picture.filled { cursor: zoom-in; }
.m-picture-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.m-picture.bound .m-picture-img { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.m-picture-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; color: var(--text-muted); font-size: 12px; text-align: center; overflow-wrap: anywhere; }
.m-picture-box { display: flex; flex: none; flex-direction: column; gap: 6px; margin: 0; }
.m-picture-box figcaption { color: var(--text-2); font-size: 12px; }
.m-row > .m-picture, .m-row > .m-picture-box { align-self: flex-start; }

/* просмотр картинки реквизита */
.dialog.image-view { width: auto; max-width: min(92vw, 1100px); }
.image-view-body { display: flex; align-items: center; justify-content: center; min-width: 280px; min-height: 180px; }
.image-full { display: block; max-width: 100%; max-height: 70vh; object-fit: contain; }
.file-cell { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; color: var(--text-2); }
.file-cell > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Значки элементов форм (контракт v10): icon или picture, only_icon ---------- */

img.glyph { display: block; flex: none; object-fit: contain; }
.label.with-icon { display: flex; align-items: center; gap: 6px; }
.label.with-icon.top { align-items: flex-start; }
.label.with-icon > svg, .label.with-icon > img { flex: none; color: var(--text-muted); }
.group h2.with-icon, .tabular h2.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.group h2.with-icon > svg, .tabular h2.with-icon > svg { flex: none; }
.m-label.with-icon > img { flex: none; margin-top: 1px; }
.m-label.only-icon { display: inline-flex; align-self: flex-start; }
.m-separator > svg, .m-separator > img { flex: none; }
table.list th .th-in { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; vertical-align: middle; }
table.list th .th-in > svg, table.list th .th-in > img { flex: none; color: var(--text-muted); }
table.list th.only-icon { text-align: center; }

/* панель раздела: значки команд (свой у объекта или значок вида) и групп */
.panel-group h2.with-icon { display: flex; align-items: center; gap: 8px; }
.panel-group h2.with-icon > svg { flex: none; }
.panel-group a { display: flex; align-items: center; gap: 9px; }
.panel-group a .panel-ico { display: flex; flex: none; align-items: center; justify-content: center; width: 18px; color: var(--text-muted); }
.panel-group a:hover .panel-ico { color: var(--accent-text); }
.panel-group a > span:last-child { min-width: 0; }
