/* Оформление в стилистике программы «Учет КРС»: белое боковое меню, светлая шапка с поиском,
   серый фон, белые карточки с тонкой рамкой, шрифт Inter, основной зелёный #167743. */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #212529;
  --ink-2: #495057;
  --muted: #868e96;
  --line: #e9ecef;
  --line-2: #dee2e6;
  --accent: #167743;
  --accent-hover: #006737;
  --accent-soft: #eaf6ef;
  --accent-soft-2: #d6ebdf;
  --warn: #d9480f;
  --warn-soft: #fff4e6;
  --danger: #e03131;
  --danger-soft: #fff5f5;
  --info: #1971c2;
  --info-soft: #e7f5ff;
  --yellow-soft: #fff9db;
  --radius: 8px;
  --sidebar: 264px;
  --header: 60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font);
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; line-height: 1.3; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.icon { flex-shrink: 0; }

/* --- Каркас: боковое меню + шапка ----------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 30;
}
.sidebar-head { height: var(--header); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, #2f9a5e, #0b5a33); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 16px; font-weight: 700; }
.brand-text small { font-size: 12px; color: var(--muted); }
.nav-close { display: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius);
  color: var(--ink); font-weight: 500; }
.sidebar-nav a .icon { color: var(--ink-2); }
.sidebar-nav a:hover { background: #f1f3f5; text-decoration: none; }
.sidebar-nav a.active { background: var(--accent-soft-2); color: var(--accent); }
.sidebar-nav a.active .icon { color: var(--accent); }
.nav-section { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  padding: 18px 12px 6px; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar-nav a .label, .collapse-btn .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn { margin: 0 12px 8px; display: flex; align-items: center; gap: 12px; padding: 9px 12px; background: none; border: 0;
  color: var(--muted); font-weight: 500; border-radius: var(--radius); }
.collapse-btn:hover { background: #f1f3f5; color: var(--ink); border: 0; }
.collapse-toggle { flex-shrink: 0; }

/* Свёрнутое меню (широкий экран): полоса значков, название — подсказкой при наведении */
:root.nav-collapsed { --sidebar: 72px; }
.nav-collapsed .sidebar-head { justify-content: center; padding: 0; }
.nav-collapsed .brand-text, .nav-collapsed .sidebar-nav .label, .nav-collapsed .collapse-btn .label,
.nav-collapsed .sidebar-foot { display: none; }
.nav-collapsed .sidebar-nav { padding: 16px 12px; overflow: visible; }
.nav-collapsed .sidebar-nav a { justify-content: center; padding: 10px 0; position: relative; }
.nav-collapsed .nav-section { font-size: 0; padding: 10px 6px; }
.nav-collapsed .nav-section::before { content: ""; display: block; border-top: 1px solid var(--line); }
.nav-collapsed .collapse-btn { justify-content: center; padding: 10px 0; }
.nav-collapsed .collapse-btn .icon { transform: rotate(180deg); }
.nav-collapsed .sidebar-nav a:hover::after, .nav-collapsed .sidebar-nav a:focus-visible::after {
  content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #212529; color: #fff; font-size: 13px; font-weight: 500; padding: 5px 10px; border-radius: 6px;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.18); z-index: 50; pointer-events: none; }
.sidebar { transition: width .15s ease; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.headerbar { height: var(--header); background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0;
  z-index: 20; display: flex; align-items: center; gap: 16px; padding: 0 32px; }
.nav-toggle { display: none; }
.global-search { flex: 0 1 440px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--muted); background: #fff; }
.global-search:focus-within { border-color: var(--accent); }
.global-search input { border: 0; padding: 0; height: 100%; flex: 1; min-width: 0; outline: none; background: transparent; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--accent-soft-2); color: var(--accent); flex-shrink: 0; }
.user-text { display: flex; flex-direction: column; line-height: 1.25; }
.user-text b { font-weight: 600; }
.user-text small { font-size: 12px; color: var(--muted); }
.icon-btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; background: #fff; color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: var(--radius); }
.icon-btn:hover { background: #f8f9fa; filter: none; }

main { padding: 32px; width: 100%; max-width: 1584px; margin: 0 auto; }
main.bare { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head > div:first-child > .muted:not(.small) { font-size: 14px; }

/* --- Карточки -------------------------------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid > * { min-width: 0; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Главная */
.dash { display: grid; gap: 20px; }
.dash-kpis { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
.dash-kpis.kpis-4 { grid-template-columns: repeat(4, 1fr); }
.dash-kpis.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--ink); }
.kpi.link:hover { text-decoration: none; border-color: var(--accent); }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.kpi.hero .kpi-value { font-size: 44px; }
.kpi-unit { font-size: 18px; font-weight: 500; color: var(--muted); }
.kpi-note { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi.link .kpi-note { color: var(--accent); font-weight: 500; }

table.attention td, table.attention th { padding: 10px 12px; }
table.attention th.num { white-space: normal; }
.cnt { display: inline-block; min-width: 36px; padding: 1px 8px; border-radius: 6px; font-weight: 600;
       background: #f1f3f5; color: var(--ink); text-align: center; }
.cnt.danger { background: var(--danger-soft); color: var(--danger); }
.cnt.warn { background: var(--warn-soft); color: var(--warn); }
.cnt:hover { text-decoration: none; filter: brightness(.97); }
.zero { color: #ced4da; }

.dash-ents { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.ent-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ent-head h2 { margin: 0; }
.ent-head h2 a { color: var(--ink); }
.ent-total { color: var(--muted); white-space: nowrap; }
.ent-total b { color: var(--ink); font-size: 18px; font-weight: 600; }

/* Вид права: цвет закреплён за видом (порядок фиксирован в services.KIND_ORDER) */
.k-lease { background: #2a78d6; }
.k-emphyteusis { background: #eb6834; }
.k-state_lease { background: #1baf7a; }
.k-sublease { background: #eda100; }
.k-no_contract { background: #e87ba4; }
.kindbar { display: flex; gap: 2px; height: 12px; background: var(--panel); }
.kindbar .seg { flex-basis: 0; min-width: 3px; }
.kindbar .seg:first-child { border-radius: 4px 0 0 4px; }
.kindbar .seg:last-child { border-radius: 0 4px 4px 0; }
.kindbar .seg:only-child { border-radius: 4px; }
.kindlegend { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.kindlegend li { display: grid; grid-template-columns: 12px 1fr auto 48px; gap: 8px; align-items: center; }
.kindlegend a { color: var(--ink); }
.kindlegend .pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 3px; }
.ent-foot { color: var(--muted); font-size: 13px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.ent-more { margin-top: 12px; }
.ent-more summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 500; }
.ent-more[open] summary { margin-bottom: 8px; }

/* --- Таблицы --------------------------------------------------------------------------------- */
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.data th { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--panel); white-space: nowrap;
  position: sticky; top: var(--header); z-index: 1; }
table.data tbody tr:hover { background: #f8f9fa; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td a { font-weight: 500; }
table.compact td, table.compact th { padding: 6px 8px; }
.panel table.data th { position: static; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table-wrap > table.data { border-radius: var(--radius); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,.12); vertical-align: middle; }

/* --- Метки ----------------------------------------------------------------------------------- */
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1.6;
  background: #f1f3f5; color: var(--ink-2); white-space: nowrap; }
.tag.green { background: var(--accent-soft); color: var(--accent); }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.orange { background: var(--warn-soft); color: var(--warn); }
.tag.blue { background: var(--info-soft); color: var(--info); }
a.tag:hover { text-decoration: none; filter: brightness(.97); }
.dead { color: var(--danger); }

/* --- Формы и кнопки -------------------------------------------------------------------------- */
input, select, textarea, button {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { accent-color: var(--accent); }
button, .btn { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; padding: 8px 16px;
  border-radius: var(--radius); display: inline-flex; align-items: center; gap: 8px; font-weight: 600; line-height: 1.4; }
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn.secondary, button.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.btn.secondary:hover, button.secondary:hover { background: #f8f9fa; border-color: var(--line-2); }
.btn.small, button.small { padding: 4px 10px; font-size: 12px; }
button.wide { width: 100%; justify-content: center; }
button:disabled { opacity: .45; cursor: not-allowed; }

form.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
form.filters label { display: flex; flex-direction: column; font-size: 12px; font-weight: 500; color: var(--ink-2); gap: 4px; }
input[type=search] { min-width: 280px; }

/* Переключатель предприятий — «таблетки», как фильтр категорий в КРС */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 5px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line-2); color: var(--ink); font-weight: 500; }
.tabs a.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tabs a:hover { text-decoration: none; border-color: var(--accent); }

.pager { display: flex; gap: 12px; align-items: center; margin: 16px 0; }

/* Дерево владения */
.tree { list-style: none; padding-left: 0; margin: 0; }
.tree .tree { padding-left: 22px; border-left: 2px solid var(--line); margin-left: 8px; }
.tree li { padding: 4px 0; }
.owner-node { display: inline-flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 6px 10px; border-radius: var(--radius); }
.owner-node.current { background: var(--accent-soft); }
.owner-node.past { background: #f8f9fa; color: var(--muted); }
.share { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Сообщения */
.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-soft-2); border-radius: var(--radius);
  padding: 10px 14px; font-weight: 500; }
.messages li.error { background: var(--danger-soft); color: var(--danger); border-color: #ffc9c9; }

/* Вход */
.login { width: 100%; max-width: 380px; display: grid; gap: 20px; }
.login .brand { justify-content: center; }
.login form p { display: flex; flex-direction: column; gap: 4px; }
.login input { width: 100%; }

.renew-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.renew-form select, .renew-form input { padding: 4px 8px; font-size: 12px; }
.renew-form input[type=text] { width: 150px; }
.months { display: flex; gap: 4px; align-items: flex-end; height: 70px; }
.months div { flex: 1; background: #ffd8a8; border-radius: 4px 4px 0 0; position: relative; min-width: 28px; }
.months div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; }
.months-labels { display: flex; gap: 4px; font-size: 11px; color: var(--muted); }
.months-labels div { flex: 1; text-align: center; min-width: 28px; }

/* Документы */
.upload-form { display: grid; gap: 14px; max-width: 640px; }
.upload-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.doc-page { margin-bottom: 16px; }
.doc-pdf { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 4px; }
.doc-img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 4px; }
.review-layout { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(360px, 1fr); gap: 16px; align-items: start; }
.review-scan { position: sticky; top: calc(var(--header) + 16px); max-height: calc(100vh - var(--header) - 32px); overflow: auto; }
table.review tr.same td { color: var(--muted); }
table.review tr.warn { background: var(--warn-soft); }

/* Рабочие журналы */
.notice { background: var(--yellow-soft); border-color: #ffec99; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.check { width: 22px; height: 22px; padding: 0; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); color: #fff;
  font-size: 13px; line-height: 20px; justify-content: center; }
.check:hover { background: #fff; border-color: var(--accent); }
.check.on, .check.on:hover { background: var(--accent); border-color: var(--accent); }
tr.urgent td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* --- Узкий экран ------------------------------------------------------------------------------ */
.nav-backdrop { display: none; }
@media (max-width: 900px) {
  .review-layout { grid-template-columns: minmax(0, 1fr); }
  .review-scan { position: static; max-height: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 32px rgba(0,0,0,.18); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .nav-close { display: block; background: none; border: 0; color: var(--muted); font-size: 24px; padding: 0 4px; }
  .nav-toggle { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: #fff; color: var(--ink);
    border: 1px solid var(--line-2); }
  .collapse-toggle, .collapse-btn { display: none; }
  /* На телефоне меню всегда полное — выезжает по кнопке ☰ */
  :root.nav-collapsed { --sidebar: 264px; }
  .nav-collapsed .sidebar-head { justify-content: space-between; padding: 0 16px; }
  .nav-collapsed .brand-text, .nav-collapsed .sidebar-nav .label, .nav-collapsed .sidebar-foot { display: revert; }
  .nav-collapsed .brand-text { display: flex; }
  .nav-collapsed .sidebar-nav a { justify-content: flex-start; padding: 9px 12px; }
  .nav-collapsed .nav-section { font-size: 12px; padding: 18px 12px 6px; }
  .nav-collapsed .nav-section::before { display: none; }
  .nav-collapsed .sidebar-nav a:hover::after { display: none; }
  .headerbar { padding: 0 16px; gap: 10px; }
  .user-text { display: none; }
  main { padding: 20px 16px 40px; }
}
@media (max-width: 760px) {
  h1 { font-size: 22px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .table-wrap, .panel { overflow-x: auto; }
  table.data th { position: static; }
  input[type=search] { min-width: 0; width: 100%; }
  form.filters label { flex: 1 1 140px; }
  .dash-kpis, .dash-kpis.kpis-4, .dash-kpis.kpis-3 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 22px; }
  .dash-kpis .hero { grid-column: 1 / -1; }
  .kpi.hero .kpi-value { font-size: 34px; }
  .renew-form input[type=text] { width: 100%; }
  .avatar { width: 34px; height: 34px; }
}

/* === Решения из «Учет КРС» =============================================================== */

/* Поиск в шапке: подсказка Ctrl K */
.kbd-hint { display: flex; gap: 3px; flex-shrink: 0; }
kbd { font: 600 10px/1 var(--font); color: var(--ink-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px;
  padding: 3px 5px; background: #fff; }
.global-search { cursor: text; }

/* Метка версии: «● Локальная версия» */
.env-badge { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border: 1px solid var(--line-2);
  border-radius: 6px; font-weight: 500; font-size: 13px; color: var(--ink); white-space: nowrap; }
.env-badge i { width: 8px; height: 8px; border-radius: 50%; background: #f76707; }
.env-badge.prod i { background: #2f9e44; }

/* Меню пользователя */
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: #f8f9fa; }
.user-menu summary .icon { color: var(--muted); }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); width: 260px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 40; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-head small { color: var(--muted); font-size: 12px; }
.user-menu .menu a, .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px;
  color: var(--ink); font-weight: 500; background: none; border: 0; font-size: 14px; }
.user-menu .menu a:hover, .menu-item:hover { background: #f1f3f5; text-decoration: none; border: 0; }
.menu-item.danger { color: var(--danger); }
.user-menu form { margin: 0; }

/* Окно быстрого поиска (как Spotlight в КРС) */
.spotlight[hidden] { display: none; }
.spotlight { position: fixed; inset: 0; z-index: 100; }
.spotlight-backdrop { position: absolute; inset: 0; background: rgba(33,37,41,.35); backdrop-filter: blur(3px); }
.spotlight-box { position: relative; width: min(600px, calc(100% - 32px)); margin: 80px auto 0; background: #fff; border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.2); overflow: hidden; }
.spotlight-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 56px; border-bottom: 1px solid var(--line); color: var(--muted); }
.spotlight-input input { flex: 1; border: 0; font-size: 17px; padding: 0; height: 100%; box-shadow: none; }
.spotlight-input input:focus { box-shadow: none; }
.spotlight-results { max-height: 60vh; overflow-y: auto; padding: 6px 8px 10px; }
.spotlight-group { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 12px 12px 6px; }
.spotlight .hit { display: flex; gap: 14px; align-items: center; padding: 8px 12px; border-radius: var(--radius); color: var(--ink); }
.spotlight .hit:hover, .spotlight .hit.active { background: #f1f3f5; text-decoration: none; }
.spotlight .hit b { display: block; font-weight: 500; }
.spotlight .hit small { display: block; color: var(--muted); font-size: 12px; }
.spotlight .hit-icon { color: var(--muted); display: grid; }
.spotlight .hit.all { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0; padding-top: 12px; }
.spotlight mark { background: #fff3bf; color: inherit; border-radius: 2px; }
.spotlight-empty { padding: 20px 12px; color: var(--muted); }
html.spotlight-open { overflow: hidden; }

/* Плитки с цветным значком в углу */
.kpi { position: relative; }
.kpi-icon { position: absolute; top: 16px; right: 16px; width: 42px; height: 42px; border-radius: var(--radius); display: grid; place-items: center; }
.kpi-icon.green { background: var(--accent-soft-2); color: var(--accent); }
.kpi-icon.cyan { background: #c5f6fa; color: #0c8599; }
.kpi-icon.orange { background: #ffe8cc; color: #e8590c; }
.kpi-icon.red { background: #ffe3e3; color: #e03131; }
.kpi-icon.blue { background: #d0ebff; color: #1971c2; }
.kpi-icon + .kpi-label, .kpi-icon ~ .kpi-label { padding-right: 52px; }

/* «Таблетки» с галочкой у выбранной и счётчиком */
.tabs a { display: inline-flex; align-items: center; gap: 6px; }
.tabs a.active::before { content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/contain no-repeat; }
.tabs a .count { color: var(--muted); font-weight: 400; }
.tabs a.active .count { color: inherit; }

/* Жёлтая плашка с заголовком (как «Демонстрационные данные») */
.banner { display: flex; gap: 14px; padding: 16px 20px; background: var(--yellow-soft); border: 1px solid #ffec99; border-radius: var(--radius);
  margin-bottom: 20px; }
.banner > .icon { color: #e8590c; margin-top: 2px; }
.banner-title { font-weight: 600; color: #d9480f; margin-bottom: 4px; }
.banner.red { background: var(--danger-soft); border-color: #ffc9c9; }
.banner.red > .icon, .banner.red .banner-title { color: var(--danger); }
.notice { background: var(--yellow-soft); border-color: #ffec99; }

/* Заголовок карточки: «← назад», статус рядом с названием, кнопка «Действия» */
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; margin-bottom: 10px; }
.back-link:hover { text-decoration: none; color: var(--accent); }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row .sub { font-size: 22px; color: var(--muted); font-weight: 400; }
.actions-menu { position: relative; }
.actions-menu summary { list-style: none; }
.actions-menu summary::-webkit-details-marker { display: none; }
.actions-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 40; }
.actions-menu .menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink); font-weight: 500; }
.actions-menu .menu a:hover { background: #f1f3f5; text-decoration: none; }

/* Ключевые сведения — сетка «подпись над значением» */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 40%), 1fr)); gap: 18px 24px; }
.facts .fact-label { font-size: 13px; color: var(--muted); line-height: 1.3; margin-bottom: 3px; }
.facts .fact-value { font-weight: 500; overflow-wrap: anywhere; }
.facts > div, .metrics > div { min-width: 0; }

/* Ряд показателей */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 45%), 1fr)); gap: 12px; margin: 16px 0 24px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.metric-label { font-size: 13px; color: var(--muted); }
.metric-value { font-size: 24px; font-weight: 600; margin-top: 2px; line-height: 1.2; }
.metric-value small { font-size: 13px; font-weight: 400; color: var(--muted); }
.metric-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.metric-note.warn { color: var(--warn); }
.metric-note.danger { color: var(--danger); }

/* Вкладки карточки: подчёркивание, значки */
.card-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.card-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 0;
  color: var(--ink); font-weight: 500; padding: 10px 14px; white-space: nowrap; }
.card-tabs button:hover { background: none; color: var(--accent); border-color: transparent; border-bottom-color: var(--line-2); }
.card-tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.card-tabs button .icon { color: var(--ink-2); }
.card-tabs .count { color: var(--muted); font-weight: 400; }

/* Значок предупреждения «!» с причиной при наведении */
.warning-mark { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 6px; border-radius: 50%;
  background: #e8590c; color: #fff; font-size: 11px; font-weight: 800; line-height: 1; vertical-align: 1px; cursor: help; position: relative; }
.warning-mark:hover::after, .warning-mark:focus::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%); width: max-content; max-width: 300px; white-space: normal; background: #212529; color: #fff;
  font-size: 12px; font-weight: 500; line-height: 1.45; padding: 6px 10px; border-radius: 6px; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,.18); }

/* Счётчик в заголовке блока */
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head .muted { font-size: 12px; margin-top: 2px; }
.count-badge { display: inline-block; min-width: 24px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: #ffe3e3; color: #e03131; text-align: center; }

@media (max-width: 900px) {
  .env-badge, .kbd-hint { display: none; }
}

.docs-section { margin-top: 16px; }
[data-pane] > .docs-section { margin-top: 0; }
[data-pane][hidden] { display: none !important; }

/* График «истекают по месяцам»: 12 узких столбцов, число над каждым, клик открывает месяц */
.chart-total b { font-size: 22px; font-weight: 600; }
.mchart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.mcol { display: flex; flex-direction: column; align-items: center; border-radius: var(--radius); padding: 4px 0 6px; color: var(--ink); }
.mcol:hover { background: #f8f9fa; text-decoration: none; }
.mcol.active { background: var(--accent-soft); }
.mplot { height: 112px; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  border-bottom: 1px solid var(--line-2); }
.mval { font-size: 12px; font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.mcol.empty .mval { color: #ced4da; font-weight: 400; }
.mbar { width: 56%; max-width: 36px; background: #55ad7b; border-radius: 4px 4px 0 0; }
.mcol:hover .mbar, .mcol.active .mbar { background: var(--accent); }
.mlab { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.2; text-align: center; }
.mlab small { display: block; font-size: 11px; color: #adb5bd; }
@media (max-width: 760px) {
  .mchart { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 10px; }
}

/* --- Договоры, заполненные ИИ --- */
.draft-form .panel { margin-bottom: 16px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; line-height: 1.4; }
.check-row input { margin-top: 3px; flex: none; }
.check-row .tag { margin-left: 4px; }
.draft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; margin-top: 16px; }
.draft-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; }
.draft-side .panel h2 { font-size: 15px; margin-bottom: 8px; }
.draft-side .kv { grid-template-columns: 1fr; gap: 2px; }
.draft-side .kv dt { margin-top: 6px; font-size: 12px; }
.doc-text { font-family: "Times New Roman", Georgia, serif; font-size: 15px; line-height: 1.55; max-width: 820px; }
.doc-text .par { position: relative; padding: 3px 28px 3px 8px; border-left: 3px solid transparent; border-radius: 4px; }
.doc-text .par.changed { background: #fff9db; border-left-color: #fab005; margin: 4px 0; }
.doc-text .par textarea { width: 100%; font: inherit; line-height: 1.5; resize: vertical; border: 1px solid #ffe066;
  border-radius: 4px; padding: 4px 6px; background: #fff; }
.doc-text .par-meta { font-family: Inter, system-ui, sans-serif; display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.doc-text .par-was { font-family: Inter, system-ui, sans-serif; font-size: 12px; color: var(--muted); margin-top: 2px; }
.doc-text .par-was summary { cursor: pointer; }
.doc-text .par-edit { position: absolute; right: 2px; top: 2px; padding: 0 6px; background: none; border: 0; color: var(--muted);
  opacity: 0; cursor: pointer; font-size: 14px; }
.doc-text .par:hover .par-edit, .doc-text .par-edit:focus { opacity: 1; }
.doc-text.only-changed .par:not(.changed) { display: none; }
.warn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.warn-list li { line-height: 1.4; }
.warn-list li.stop { color: var(--danger); }
ul.plain { margin: 0; padding-left: 18px; }
.approve-box .check-row { font-size: 13px; }
.approve-box button[value=approve] { margin-top: 8px; }
.banner.ok { background: var(--accent-soft); border-color: #b2f2bb; }
.banner.ok > .icon { color: var(--accent); }
.banner.ok .banner-title { color: var(--accent); }
.draft-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.inline-upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-upload input[type=file] { max-width: 260px; font-size: 13px; }
.draft-mark { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 600;
  line-height: 18px; vertical-align: middle; background: var(--warn-soft); color: var(--warn); cursor: help; }
.draft-mark.review { background: var(--info-soft); color: var(--info); }
@media (max-width: 1100px) {
  .draft-layout { grid-template-columns: 1fr; }
  .draft-side { position: static; }
}
.banner.info { background: var(--info-soft); border-color: #a5d8ff; }
.banner.info > .icon, .banner.info .banner-title { color: var(--info); }
.banner + .banner { margin-top: 10px; }
.sidebar-nav .nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn-soft);
  color: var(--warn); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.nav-collapsed .sidebar-nav .nav-count { position: absolute; top: 3px; right: 6px; min-width: 8px; width: 8px; height: 8px;
  padding: 0; font-size: 0; background: var(--warn); }
@media (max-width: 900px) { .nav-collapsed .sidebar-nav .nav-count { position: static; width: auto; height: auto; font-size: 11px;
  background: var(--warn-soft); padding: 0 6px; } }
