:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-hover: #f5f7fa;
  --ink: #1a2233;
  --muted: #6b7688;
  --line: #e3e7ee;
  --brand: #1f4e79;
  --brand-ink: #16324e;
  --brand-soft: rgba(31,78,121,.10);
  --accent: #2e7d5b;
  --danger: #c0392b;
  --amber: #b7791f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,32,60,.06), 0 6px 20px rgba(16,32,60,.06);
  --shadow-lg: 0 4px 12px rgba(16,32,60,.10), 0 20px 48px rgba(16,32,60,.12);
  --ease: .28s cubic-bezier(.4,0,.2,1);
}

/* ночная тема */
:root[data-theme="dark"] {
  --bg: #0e131a;
  --surface: #161d27;
  --surface-2: #1b2430;
  --surface-hover: #202a37;
  --ink: #e7edf5;
  --muted: #93a1b4;
  --line: #29333f;
  --brand-soft: rgba(120,170,230,.14);
  /* осветляем «фирменные» тексты (лого, заголовки) — иначе тёмно-синий на тёмном не читается */
  --brand-ink: color-mix(in srgb, var(--brand) 42%, #ffffff);
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 6px 18px rgba(0,0,0,.45), 0 24px 60px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--ease), color var(--ease);
}
.card, .topbar, .stat, input, select, textarea, .btn, .footer, .form-actions {
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}
/* защита глаз — тёплый фильтр, снижающий синий свет */
body.eye-shield::after {
  content: ""; position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: rgba(255,167,74,.11); mix-blend-mode: multiply;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 24px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--brand-ink); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px;
  background: var(--brand); color: #fff; border-radius: 8px; font-size: 18px; font-weight: 700;
}
/* ============ БОКОВОЕ МЕНЮ ============
   Разделов стало 14+, горизонтальная строка их уже не вмещала (занимала 3–4 ряда
   и съедала экран). Меню перенесено влево и сгруппировано по смыслу:
   Работа · Проверки · Справочники · Контроль · Настройки. */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.col { min-width: 0; display: flex; flex-direction: column; }
/* Элементы внутри колонки — flex-элементы, у них min-width по умолчанию auto:
   они не сжимаются меньше своего содержимого и распирают страницу вбок.
   Явный min-width:0 разрешает сжатие, а широкие таблицы внутри прокручиваются сами. */
.col > * { min-width: 0; }
/* У .wrap стоит `margin: 28px auto`: горизонтальные auto-поля ОТКЛЮЧАЮТ растягивание
   flex-элемента по ширине колонки — блок начинает мерить себя по содержимому и
   вылезает за экран. Явная ширина 100% возвращает его в колонку, а max-width
   по-прежнему центрует контент на широких мониторах. */
.col > .wrap { width: 100%; box-sizing: border-box; }

.side {
  grid-column: 1; background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
  display: flex; flex-direction: column; padding: 14px 12px 10px;
}
.side-brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px;
  font-weight: 700; color: var(--brand-ink); font-size: 16px;
}
.side-brand:hover { text-decoration: none; }
.side-brand .brand-logo { max-height: 30px; max-width: 120px; object-fit: contain; }
.side-brand-name { line-height: 1.2; font-size: 14.5px; overflow-wrap: anywhere; }
.side-nav { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-cap {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 0 10px 5px;
}
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: var(--ink); font-size: 14px; font-weight: 500; line-height: 1.25;
  transition: background var(--ease), color var(--ease);
}
.side-link:hover { background: var(--surface-hover); text-decoration: none; color: var(--brand-ink); }
.side-link.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.side-link .si { width: 18px; height: 18px; flex: none; stroke: currentColor; stroke-width: 1.6;
  fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side-link.on .si { opacity: 1; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px; }
.side-veil { display: none; }

/* верхняя полоса стала узкой: в ней только действия и пользователь */
.top-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.brand-mobile { display: none; }
.burger { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.burger span { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; margin: 4px 0; }

/* ---------- панель массовых действий ---------- */
.batch-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.batch-all { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.batch-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- история изменений договора ---------- */
.changes { margin: 14px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.changes > summary { cursor: pointer; padding: 11px 16px; font-weight: 600; font-size: 14px; }
.changes > summary::-webkit-details-marker { display: none; }
.changes > summary::before { content: "▸ "; color: var(--muted); }
.changes[open] > summary::before { content: "▾ "; }
.ch-item { padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.ch-head { font-size: 13.5px; margin-bottom: 6px; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ch-table td { padding: 4px 6px; vertical-align: top; border-top: 1px solid var(--line); }
.ch-f { color: var(--muted); width: 34%; }
.ch-old { color: var(--danger, #a5382f); text-decoration: line-through; }
.ch-arr { color: var(--muted); width: 18px; text-align: center; }
.ch-new { color: var(--brand-ink); font-weight: 600; }

/* ---------- поиск по платформе (Ctrl+K) ---------- */
.search-trigger {
  display: flex; align-items: center; gap: 8px; margin-left: 8px;
  background: var(--surface-2, var(--surface)); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 12px; cursor: pointer; color: var(--muted);
  font-family: inherit; font-size: 13.5px; min-width: 210px;
}
.search-trigger:hover { border-color: var(--brand); color: var(--ink); }
.search-trigger .si { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.search-trigger kbd {
  margin-left: auto; font-family: inherit; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}
.sp-veil { display: none; position: fixed; inset: 0; background: rgba(10,20,40,.45); z-index: 90; }
.sp-veil.on { display: block; }
.sp { display: none; position: fixed; z-index: 95; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.sp.on { display: block; }
.sp-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sp-box .sp-ico { width: 18px; height: 18px; stroke: var(--muted); stroke-width: 1.8; fill: none; flex: none; }
.sp-box input { flex: 1; border: none; outline: none; background: none; font-size: 16px; color: var(--ink); }
.sp-esc { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.sp-res { max-height: 60vh; overflow-y: auto; padding: 6px; }
.sp-hint { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.sp-grp { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  font-weight: 700; padding: 10px 10px 4px; }
.sp-item { display: flex; flex-direction: column; gap: 1px; padding: 9px 10px; border-radius: 8px; color: var(--ink); }
.sp-item:hover, .sp-item.sel { background: var(--brand-soft); text-decoration: none; }
.sp-t { font-weight: 600; font-size: 14.5px; }
.sp-s { font-size: 12.5px; color: var(--muted); }

/* цифра непрочитанных задач у пункта меню */
.side-badge { margin-left: auto; min-width: 20px; height: 19px; padding: 0 6px;
  background: var(--brand); color: #fff; border-radius: 10px; font-size: 11px;
  font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.side-link.on .side-badge { background: var(--brand-ink); }

/* ---------- колокольчик ---------- */
.bell { position: relative; display: inline-flex; padding: 6px; color: var(--muted); }
.bell:hover { color: var(--brand-ink); }
.bell .si { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.7; fill: none;
  stroke-linecap: round; stroke-linejoin: round; }
.bell-dot { position: absolute; top: -1px; right: -2px; min-width: 17px; height: 17px; padding: 0 4px;
  background: #c0392b; color: #fff; border-radius: 9px; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; }

/* ---------- пошаговая инструкция «как работать» ---------- */
.gd-veil { position: fixed; inset: 0; background: rgba(10,20,40,.55); z-index: 130; }
.gd-box {
  position: fixed; z-index: 140; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 28px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px 24px;
}
.gd-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.gd-badge { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  color: var(--brand); background: var(--brand-soft); padding: 4px 10px; border-radius: 20px; }
.gd-x { margin-left: auto; background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 0 4px; }
.gd-x:hover { color: var(--ink); }
.gd-step { font-size: 12px; color: var(--muted); font-weight: 600; }
.gd-title { font-size: 20px; font-weight: 700; margin: 6px 0 8px; line-height: 1.25; }
.gd-text { font-size: 15px; color: var(--ink); line-height: 1.55; }
.gd-note { margin-top: 10px; font-size: 13px; color: var(--amber); }
.gd-bar { height: 4px; background: var(--line); border-radius: 4px; margin: 16px 0 14px; overflow: hidden; }
.gd-bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .25s; }
.gd-act { display: flex; align-items: center; gap: 8px; }
/* подсветка элемента, на который показывает стрелка */
.gd-spot { position: relative; z-index: 135; outline: 3px solid var(--brand); outline-offset: 3px;
  border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10,20,40,.12); }
.gd-arrow { position: fixed; z-index: 138; font-size: 42px; line-height: 1; color: var(--brand);
  text-shadow: 0 2px 10px rgba(0,0,0,.35); animation: gdPulse 1.1s ease-in-out infinite; pointer-events: none; }
@keyframes gdPulse { 0%,100% { transform: translateX(0); } 50% { transform: translateX(7px); } }
.gd-arrow[style*="scaleX(-1)"] { animation: gdPulseL 1.1s ease-in-out infinite; }
@keyframes gdPulseL { 0%,100% { transform: scaleX(-1) translateX(0); } 50% { transform: scaleX(-1) translateX(7px); } }
.side-guide { color: var(--brand-ink); font-weight: 600; }

/* ---------- обучающий тур ---------- */
.tour-veil { position: fixed; inset: 0; background: rgba(10,20,40,.5); z-index: 120; }
.tour-box { position: fixed; z-index: 125; width: 320px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 18px; }
.tour-step { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); font-weight: 700; }
.tour-title { font-size: 17px; font-weight: 700; margin: 6px 0 6px; }
.tour-text { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.tour-act { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.tour-spot { position: relative; z-index: 122; outline: 3px solid var(--brand);
  outline-offset: 3px; border-radius: 10px; background: var(--surface); }

@media (max-width: 900px) {
  .search-trigger { min-width: 0; padding: 7px; }
  .search-trigger .st-text, .search-trigger kbd { display: none; }
  .tour-box { width: min(320px, calc(100vw - 24px)); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; height: 100dvh;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .side.open { transform: none; }
  .side-veil.on { display: block; position: fixed; inset: 0; background: rgba(10,20,40,.42); z-index: 35; }
  .burger { display: block; }
  .brand-mobile { display: flex; }
  .btn-new { display: none; }          /* на телефоне «Новая сделка» есть в меню */
  .user-chip { display: none; }
}

/* ---------- layout ---------- */
.wrap { max-width: 1000px; margin: 28px auto; padding: 0 24px; }
.wrap.wide { max-width: 1280px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 0; }
.footer { text-align: center; color: var(--muted); padding: 30px; font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.btn:hover { text-decoration: none; border-color: var(--line); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }

/* ---------- cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.section { padding: 22px 24px; }
.section + .section { border-top: 1px solid var(--line); }
.section h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 16px; }

/* ---------- form ---------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,78,121,.12); }
textarea { resize: vertical; min-height: 76px; }
.hint { font-size: 12px; color: var(--muted); }

.two-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.party-title { font-weight: 700; color: var(--brand-ink); margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--line); }

/* ---------- items table ---------- */
table.items { width: 100%; border-collapse: collapse; }
table.items th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 6px 8px; }
table.items td { padding: 4px 6px; vertical-align: top; }
table.items input { padding: 7px 9px; }
.col-num { width: 34px; color: var(--muted); text-align: center; padding-top: 14px !important; }
.col-x { width: 40px; }
.icon-btn { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--danger); background: #fbe9e7; }

.form-actions { display: flex; align-items: center; gap: 14px; padding: 20px 24px; background: #fafbfc; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.form-actions .spacer { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.check input { width: auto; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); color: var(--ink); transition: .15s;
}
a.stat:hover { text-decoration: none; border-color: var(--line); transform: translateY(-1px); }
.stat-num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand-ink); }
.stat-lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-money .stat-num { color: var(--accent); font-size: 20px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters .filter-search { flex: 1; min-width: 240px; }
.filters select { width: auto; min-width: 150px; }

/* ---------- list ---------- */
.right { text-align: right; }
.empty-row { text-align: center; color: var(--muted); padding: 40px !important; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
table.list td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr { transition: background-color var(--ease); }
table.list tr:hover td { background: var(--surface-hover); }
.mono { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.draft { background: #eef1f5; color: #55627a; }
.badge.generated { background: #e6f4ec; color: var(--accent); }
.badge.on_review { background: #fff4e0; color: #a86616; }
.badge.approved { background: #e3f0fb; color: #1d6fb8; }
.badge.rejected { background: #fbe4e2; color: var(--danger); }
.badge.signed { background: #e7effa; color: var(--brand); }
.badge.archived { background: #f3eee2; color: var(--amber); }

/* ---------- auth ---------- */
.user-chip { display: inline-flex; flex-direction: column; line-height: 1.15; margin-left: 8px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.user-role { font-size: 11px; color: var(--muted); }
.logout { color: var(--muted); font-size: 13px; }
.login-wrap { max-width: 440px; margin: 6vh auto 0; }
.login-card .section:first-child { text-align: center; }
.login-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; color: var(--brand-ink); }
.login-brand .brand-mark { width: 34px; height: 34px; font-size: 20px; }
.login-card .field { text-align: left; }
.login-card button { width: 100%; justify-content: center; }
.login-demo { background: #fafbfc; }
.demo-list { list-style: none; margin: 10px 0 0; padding: 0; }
.demo-list li { padding: 5px 0; font-size: 14px; color: var(--muted); }

/* ---------- approval ---------- */
.approval-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.approval-form { display: flex; gap: 8px; align-items: center; }
.approval-form input[type=text] { width: 260px; }
.timeline { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.tl-item { display: flex; gap: 12px; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex-shrink: 0; position: relative; }
.tl-item:not(:last-child) .tl-dot::after { content: ""; position: absolute; left: 50%; top: 12px; width: 2px; height: calc(100% + 6px); background: var(--line); transform: translateX(-50%); }
.tl-body { font-size: 14px; }
.tl-comment { color: var(--danger); font-style: italic; margin: 3px 0; }

/* ---------- signature ---------- */
.sign-box { background: #f4faf6; border: 1px solid #cfe8d8; border-radius: var(--radius); padding: 18px; }
.sign-badge { display: inline-block; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; padding: 4px 12px; border-radius: 20px; }
.sign-hashes { margin-top: 12px; padding-top: 12px; border-top: 1px solid #cfe8d8; }
.hash-row { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.hash-row > span:first-child { font-weight: 600; font-size: 13px; }
.hash-row .hash { font-size: 11px; color: var(--muted); word-break: break-all; }

/* ---------- detail ---------- */
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.doc-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: none; }
.doc-name { display: flex; align-items: center; gap: 10px; }
.file-ico { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.file-ico.docx { background: #2b579a; }
.file-ico.pdf { background: #c0392b; }
.dl-group { display: flex; gap: 8px; }

/* ---------- template library ---------- */
.tpl-card { margin-bottom: 16px; }
.tpl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tpl-title { font-weight: 700; color: var(--ink); }
.tpl-ver { text-align: right; white-space: nowrap; }
.tpl-note { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.tpl-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.tpl-label { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.clickable { cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; background: var(--surface-hover); color: var(--brand-ink); padding: 3px 9px; border-radius: 6px; }
a.chip { font-family: inherit; font-size: 13px; padding: 7px 13px; border: 1px solid var(--line); transition: all var(--ease); }
a.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.history { list-style: none; margin: 10px 0 0; padding: 0; }
.history li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history li:last-child { border-bottom: none; }
.hist-dl { margin-left: auto; }
.tpl-upload { display: flex; gap: 10px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tpl-upload input[type=text] { flex: 1; min-width: 200px; }
.tpl-upload input[type=file] { width: auto; padding: 6px; font-size: 13px; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 60px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty p { color: var(--muted); }

/* ---------- ИНН автозаполнение ---------- */
.inn-row { display: flex; gap: 6px; }
.inn-row input { flex: 1; }
.inn-btn { white-space: nowrap; flex-shrink: 0; }

/* ---------- admin users ---------- */
.edit-row > td { background: var(--surface-2); padding: 18px 16px !important; }
.user-form-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- помощник ---------- */
.help-link { color: var(--brand); font-weight: 600; font-size: 13px; }
.help-search { width: 100%; padding: 14px 16px; font-size: 16px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.help-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,78,121,.12); }
.help-start { margin-bottom: 24px; }
.help-steps { margin: 12px 0 0; padding-left: 22px; color: var(--ink); }
.help-steps li { margin: 7px 0; }
.help-h { font-size: 20px; margin: 26px 0 14px; }
.help-path { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.hp { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.hp-n { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.hp b { font-size: 15px; } .hp p { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
#help-list { display: flex; flex-direction: column; gap: 10px; }
.help-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.help-item summary { padding: 15px 20px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.help-item summary::-webkit-details-marker { display: none; }
.help-item summary::after { content: "+"; color: var(--brand); font-size: 22px; font-weight: 400; }
.help-item[open] summary::after { content: "–"; }
.help-a { padding: 0 20px 18px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.6; }
.help-a b { color: var(--ink); }
@media (max-width: 760px) { .help-path { grid-template-columns: 1fr; } }

/* ---------- ИИ-помощник ---------- */
.ai-bar { margin-bottom: 16px; border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.ai-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 12px; }
.ai-tool textarea { min-height: 60px; }
.ai-tool > button { margin-top: 8px; }
.ai-risks { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ai-risk { padding: 10px 14px; border-radius: 8px; font-size: 14.5px; border-left: 3px solid var(--muted); background: var(--surface-2); }
.ai-risk.lvl-высокий { border-left-color: var(--danger); background: #fbe9e7; }
.ai-risk.lvl-средний { border-left-color: var(--amber); background: #fff4e0; }
.ai-risk.lvl-низкий { border-left-color: var(--accent); background: #e6f4ec; }
@media (prefers-color-scheme: dark) { .ai-risk.lvl-высокий{background:#2a1512;} .ai-risk.lvl-средний{background:#2e2712;} .ai-risk.lvl-низкий{background:#12291c;} }
@media (max-width: 700px) { .ai-tools { grid-template-columns: 1fr; } }

/* ---------- заготовки ---------- */
.preset-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- аналитика: столбцы по месяцам ---------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: 12px; }
.bar-lbl { font-size: 13px; color: var(--muted); }
.bar-track { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 6px; min-width: 3px; }
.bar-val { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- интеграции ---------- */
.integ-row { display: flex; align-items: center; gap: 16px; }
.integ-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.integ-dot.on { background: var(--accent); box-shadow: 0 0 0 4px #e6f4ec; }
.integ-dot.off { background: var(--line); }
.integ-body { flex: 1; }
.integ-name { font-weight: 600; color: var(--ink); }

/* ---------- конструктор видов ---------- */
.doc-build-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc-build-row .doc-num { width: 22px; text-align: center; color: var(--muted); font-weight: 700; flex-shrink: 0; }
.doc-build-row input[type=file] { width: auto; padding: 6px; font-size: 13px; }

.banner { padding: 14px 18px; border-radius: 8px; margin-bottom: 20px; font-weight: 500; }
.banner.err { background: #fbe9e7; color: var(--danger); border: 1px solid #f3c9c2; }
.banner.ok { background: #e6f4ec; color: var(--accent); border: 1px solid #c3e6d1; }

@media (max-width: 760px) {
  .g2, .g3, .two-parties { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 10px; }
  /* компактная шапка: логотип-значок + меню в одну прокручиваемую строку */
  .topbar { height: auto; padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand span:not(.brand-mark) { display: none; }
  .nav { gap: 14px; flex-wrap: wrap; row-gap: 8px; }
  .user-chip { margin-left: 0; }
  .page-head { flex-wrap: wrap; }
  .page-head > .btn-primary { display: none; }  /* дублирующая «Новая сделка» — в шапке уже есть */
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-money { grid-column: 1 / -1; }
}

/* ==================== ПРЕМИУМ-ОФОРМЛЕНИЕ И ТЕМЫ ==================== */
/* токенизация хардкода — чтобы темы работали корректно */
input, select, textarea { background: var(--surface); }
label { color: var(--ink); opacity: .82; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px var(--brand-soft); }
.form-actions { background: var(--surface-2); }
.login-demo { background: var(--surface-2); }
.stat, .card { background: var(--surface); }

/* топбар — лёгкое стекло и мягкая тень */
.topbar {
  backdrop-filter: saturate(1.2) blur(8px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 1px 0 var(--line);
}
/* карточки — деликатный подъём при наведении */
.card { box-shadow: var(--shadow); transition: box-shadow var(--ease), transform var(--ease); }
.card:hover { box-shadow: var(--shadow-lg); }
.stat { box-shadow: var(--shadow); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-primary { box-shadow: 0 2px 8px var(--brand-soft); }
.btn-primary:hover { transform: translateY(-1px); }

/* логотип бренда (white-label) */
.brand-logo { height: 30px; max-width: 168px; object-fit: contain; display: block; }
.login-brand .brand-logo { height: 40px; max-width: 220px; }

/* переключатели темы и защиты глаз */
.theme-controls { display: inline-flex; gap: 4px; align-items: center; }
.theme-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1; transition: all var(--ease); padding: 0;
}
.theme-btn:hover { color: var(--ink); border-color: var(--brand); }
.theme-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* приветственный сплэш-экран */
.splash {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--brand) 24%, var(--bg)), var(--bg));
  opacity: 1; transition: opacity .6s ease; text-align: center;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-inner { display: grid; justify-items: center; gap: 18px; animation: splashUp .7s cubic-bezier(.2,.7,.2,1) both; }
.splash-mark {
  width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 40px; font-weight: 700;
  box-shadow: 0 12px 40px var(--brand-soft), 0 4px 12px rgba(0,0,0,.15);
}
.splash-mark img { width: 76px; height: 76px; object-fit: contain; border-radius: 20px; }
.splash-name { font-size: 26px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.splash-greet { font-size: 16px; color: var(--muted); }
.splash-bar { width: 168px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.splash-bar > i { display: block; height: 100%; width: 40%; background: var(--brand); border-radius: 4px; animation: splashBar 1.1s ease-in-out infinite; }
@keyframes splashUp { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes splashBar { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
@media (prefers-reduced-motion: reduce) { .splash-inner, .splash-bar > i { animation: none; } }

/* приветствие на дашборде */
.greeting { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 2px; }
.greeting .accent { color: var(--brand); }

/* тёмная тема: точечные правки контраста */
:root[data-theme="dark"] .badge.draft { background: rgba(148,161,180,.16); color: #b3bece; }
:root[data-theme="dark"] .badge.generated { background: rgba(46,125,91,.22); color: #6fd6a3; }
:root[data-theme="dark"] .badge.on_review { background: rgba(183,121,31,.22); color: #e6b25e; }
:root[data-theme="dark"] .badge.approved { background: rgba(29,111,184,.24); color: #74b6f5; }
:root[data-theme="dark"] .badge.rejected { background: rgba(192,57,43,.22); color: #f08a7e; }
:root[data-theme="dark"] .badge.signed { background: var(--brand-soft); color: #9ec3ee; }
:root[data-theme="dark"] .badge.archived { background: rgba(183,121,31,.18); color: #e0bd7a; }
:root[data-theme="dark"] .banner.err { background: rgba(192,57,43,.16); border-color: rgba(192,57,43,.4); }
:root[data-theme="dark"] .banner.ok { background: rgba(46,125,91,.16); border-color: rgba(46,125,91,.4); }
:root[data-theme="dark"] .icon-btn:hover { background: rgba(192,57,43,.18); }

/* ==================== ВИЗУАЛ v2 — усиление ==================== */
/* глубина фона: мягкие фирменные свечения по углам */
body {
  background:
    radial-gradient(900px 520px at 100% -8%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 60%),
    radial-gradient(760px 520px at -12% 112%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 56%),
    var(--bg);
  background-attachment: fixed;
}

/* топбар — плотнее и премиальнее */
.topbar { height: auto; min-height: 62px; overflow: visible; flex-wrap: wrap; row-gap: 8px; padding-top: 8px; padding-bottom: 8px;
  box-shadow: 0 1px 0 var(--line), 0 8px 24px -18px rgba(16,32,60,.4); }
.brand-mark { box-shadow: 0 6px 16px var(--brand-soft); }
/* подчёркивание пунктов меню при наведении */
.nav a:not(.btn):not(.help-link) { position: relative; padding: 6px 0; }
.nav a:not(.btn):not(.help-link)::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 2px; transition: width var(--ease);
}
.nav a:not(.btn):not(.help-link):hover::after { width: 100%; }

/* заголовки страниц крупнее и с характером */
.page-head h1 { font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
.greeting { font-size: 26px; }
.section h2 { font-size: 12.5px; }

/* кнопки — объёмнее */
.btn { border-radius: 9px; font-weight: 600; }
.btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-ink));
  border-color: var(--brand-ink);
  box-shadow: 0 4px 14px var(--brand-soft), inset 0 1px 0 rgba(255,255,255,.16);
}
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 9px 24px var(--brand-soft); }
.btn-lg { border-radius: 11px; }

/* карточки статистики — акцентная полоса, градиент, крупные числа */
.stats { gap: 16px; }
.stat {
  position: relative; overflow: hidden; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 93%, var(--brand)));
  padding: 18px 18px 16px;
}
.stat::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 55%, transparent));
}
.stat-num { font-size: 28px; letter-spacing: -.01em; }
.stat-money .stat-num { font-size: 23px; }

/* карточки — мягче и глубже */
.card { border-radius: 14px; border: 1px solid var(--line); }
.section { padding: 24px 26px; }

/* поля ввода — крупнее и мягче */
input, select, textarea { border-radius: 10px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

/* ---------- ВХОД: премиум-hero ---------- */
.login-wrap {
  max-width: 470px; margin: 0 auto; min-height: calc(100vh - 210px);
  display: flex; flex-direction: column; justify-content: center;
}
.login-card { box-shadow: var(--shadow-lg); border-radius: 18px; overflow: hidden; }
.login-card .section:first-child {
  background: linear-gradient(165deg, color-mix(in srgb, var(--brand) 16%, var(--surface)), var(--surface) 70%);
  padding: 34px 26px 26px;
}
.login-brand { font-size: 25px; letter-spacing: -.01em; }
.login-brand .brand-mark { width: 46px; height: 46px; font-size: 25px; border-radius: 13px; box-shadow: 0 10px 26px var(--brand-soft); }
.login-card .btn-lg { margin-top: 10px; }

/* ---------- СПЛЭШ: богаче ---------- */
.splash-mark { position: relative; }
.splash-mark::before {
  content: ""; position: absolute; inset: -16px; border-radius: 30px; z-index: -1;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 45%, transparent), transparent 68%);
  animation: splashPulse 2.1s ease-in-out infinite;
}
.splash-name { font-size: 30px; }
.splash-greet { font-size: 17px; }
@keyframes splashPulse { 0%,100% { transform: scale(1); opacity: .55; } 50% { transform: scale(1.18); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .splash-mark::before { animation: none; } }

/* бейджи и чипы — аккуратнее */
.badge { padding: 4px 11px; letter-spacing: .01em; }

@media (max-width: 760px) {
  .page-head h1, .greeting { font-size: 22px; }
  .login-wrap { min-height: auto; margin-top: 4vh; }
}

/* ---------- выпадающее меню «Настройки» ---------- */
.nav-dd { position: relative; }
.nav-dd > summary {
  list-style: none; cursor: pointer; color: var(--muted); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px; user-select: none;
}
.nav-dd > summary::-webkit-details-marker { display: none; }
.nav-dd > summary:hover { color: var(--ink); }
.nav-dd[open] > summary { color: var(--brand); }
.nav-dd-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 210px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 8px; display: grid; gap: 2px;
  animation: ddIn .16s ease;
}
.nav-dd-menu a {
  display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink); font-weight: 500; font-size: 14px;
}
.nav-dd-menu a:hover { background: var(--surface-hover); text-decoration: none; color: var(--brand); }
@keyframes ddIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Поле ввода не должно быть шире своего контейнера: в админке факсимиле
   длинные input внутри ячеек таблицы распирали страницу на телефоне. */
input, select, textarea { max-width: 100%; }
/* У поля выбора файла есть собственная минимальная ширина (кнопка + имя файла),
   и max-width его не сжимает — на телефоне такое поле распирало страницу вбок. */
input[type="file"] { width: 100%; min-width: 0; }

/* ---------- таблицы на узких экранах ----------
   Широкие таблицы (реестр счетов, досье, пользователи, факсимиле, позиции КП)
   на планшете и телефоне вылезали за правый край — страница ехала вбок, а
   правые колонки с кнопками становились недоступны. Делаем саму таблицу
   прокручиваемой по горизонтали: содержимое остаётся целым, страница — нет. */
@media (max-width: 900px) {
  table.table, table.list, table.items {
    display: block; width: 100%; max-width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  table.table > thead, table.list > thead, table.items > thead,
  table.table > tbody, table.list > tbody, table.items > tbody { display: table; width: 100%; }
}

/* ---------- премиальное пустое состояние ---------- */
.empty-state {
  text-align: center; padding: 54px 24px; color: var(--muted);
}
.empty-state .es-ico {
  font-size: 40px; display: block; margin-bottom: 12px; opacity: .6;
}
.empty-state .es-title { font-size: 17px; font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.empty-state p { margin: 0 auto; max-width: 440px; }

/* ============================ Кабинет руководителя ============================ */
.cab-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.cab-tab {
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  transition: all var(--ease);
}
.cab-tab:hover { color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.cab-tab.active { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--line); }
.cab-back { font-size: 13px; color: var(--muted); }

/* KPI */
/* Плашек в строке стало 6 (добавились «Досье» и «Счета»), поэтому не фиксируем
   4 колонки — иначе последние две висят рваным рядом. auto-fit подгоняет число
   колонок под ширину экрана и делит остаток поровну. */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 3px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); color: var(--ink); transition: all var(--ease);
}
a.kpi:hover { transform: translateY(-1px); border-color: var(--brand); text-decoration: none; }
.kpi-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand-ink); line-height: 1; }
.kpi-lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-accent { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.kpi-accent .kpi-num { color: var(--accent); }
.kpi-warn { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.kpi-warn .kpi-num { color: var(--danger); }

/* карточки кабинета */
.cab-card { padding: 18px 20px; margin-bottom: 16px; }
.cab-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cab-selall { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.cab-empty { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.cab-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cab-more { display: inline-block; margin-top: 8px; font-size: 13px; }

/* таблица кабинета */
.cab-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.cab-table td, .cab-table th { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.cab-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.cab-table tr:last-child td { border-bottom: none; }
.cab-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cab-table .strong { font-weight: 700; color: var(--brand-ink); }
.cab-table .c-sum, .cab-table .c-wait { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cab-table .c-act { text-align: right; }
.row-overdue { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.wait-bad { color: var(--danger); font-weight: 600; }
.cab-batchbar { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* списки кабинета */
.cab-list { list-style: none; margin: 10px 0 0; padding: 0; }
.cab-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; flex-wrap: wrap; }
.cab-list li:last-child { border-bottom: none; }
.cab-cp { color: var(--muted); }
.cab-sum { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.cab-badge { font-size: 12px; background: var(--brand-soft); color: var(--brand-ink); padding: 2px 8px; border-radius: 6px; margin-left: auto; }
.chip-warn { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)) !important; color: var(--amber) !important; }

/* ---------- доска команды ---------- */
.team-wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.team-board { display: flex; flex-direction: column; gap: 14px; }
.team-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.team-group-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.team-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; color: var(--ink); transition: background var(--ease); }
.team-card:hover { background: var(--surface-hover); text-decoration: none; }
.team-name { font-weight: 600; }
.team-name em { color: var(--muted); font-weight: 400; font-style: normal; font-size: 12px; }
.team-activity { grid-column: 2; color: var(--muted); font-size: 13px; }
.team-load { grid-column: 3; grid-row: 1 / span 2; font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.team-load-bad { color: var(--danger); font-weight: 600; }

/* точки присутствия */
.pres-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: #b7bfca; }
.pres-online { background: #2fb36a; box-shadow: 0 0 0 3px color-mix(in srgb, #2fb36a 22%, transparent); }
.pres-recent { background: var(--amber); }
.pres-offline { background: #aab2bd; }
.pres-away { background: #7c8aa0; }

/* лента */
.team-feed { align-self: start; }
.feed-list { list-style: none; margin: 10px 0 0; padding: 0; }
.feed-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.feed-list li:last-child { border-bottom: none; }
.feed-time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.feed-user { font-weight: 600; }
.feed-act { color: var(--ink); }
.feed-num { font-weight: 600; }
.feed-cp, .feed-comment { color: var(--muted); }
.feed-comment { font-style: italic; }

/* фирмы */
.firms-table .firm-name { font-weight: 600; }
.firm-inn { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

/* адаптив */
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .cab-2col, .team-wrap { grid-template-columns: 1fr; }
}

/* ---------- мобильное подписание (кабинет под большой палец) ---------- */
@media (max-width: 640px) {
  .cab-tabs { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .cab-tab { white-space: nowrap; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px 14px; }
  .kpi-num { font-size: 22px; }

  /* очередь на подпись → крупные карточки */
  #sign-form .table-wrap { overflow: visible; }
  #sign-form .cab-table, #sign-form .cab-table tbody, #sign-form .cab-table tr, #sign-form .cab-table td { display: block; width: 100%; }
  #sign-form .cab-table tr {
    border: 1px solid var(--line); border-radius: 12px; padding: 14px;
    margin-bottom: 12px; box-shadow: var(--shadow); position: relative;
  }
  #sign-form .cab-table td { border: none; padding: 2px 0; }
  #sign-form .c-check { position: absolute; top: 14px; right: 14px; }
  #sign-form .c-num { font-size: 18px; font-weight: 700; }
  #sign-form .c-num a { color: var(--brand-ink); }
  #sign-form .c-cp { color: var(--muted); }
  #sign-form .c-sum { font-weight: 700; font-size: 16px; }
  #sign-form .c-wait { font-size: 13px; }
  #sign-form .c-act { margin-top: 10px; text-align: stretch; }
  #sign-form .c-act .btn { width: 100%; padding: 14px; font-size: 16px; border-radius: 10px; }
  .cab-batchbar .btn { width: 100%; padding: 14px; font-size: 16px; }
  .cab-batchbar { flex-direction: column; align-items: stretch; }

  /* доска команды и списки — компактнее */
  .team-card { grid-template-columns: auto 1fr; }
  .team-load { grid-column: 1 / -1; grid-row: auto; text-align: left; margin-top: 2px; padding-left: 19px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* панель делегирования на доске команды */
.deleg-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 16px; }
.deleg-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.deleg-sub { color: var(--muted); display: flex; align-items: center; gap: 8px; font-size: 14px; }
.deleg-sub select { width: auto; min-width: 160px; }

/* ============================ Отчёты отдела ============================ */
.rep-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.rep-periods { display: flex; gap: 4px; flex-wrap: wrap; }
.rep-per { font-size: 14px; font-weight: 600; color: var(--muted); padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px; transition: all var(--ease); }
.rep-per:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.rep-per.active { color: #fff; background: var(--brand); border-color: var(--brand); }
.rep-custom { display: flex; align-items: center; gap: 6px; }
.rep-custom input[type=date] { width: auto; }
.rep-export { margin-left: auto; display: flex; gap: 6px; }

.rep-send { display: none; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; }
.rep-send.open { display: flex; }
.rep-send label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.rep-send input, .rep-send select { width: auto; min-width: 180px; }

/* дельты (стрелки) */
.dl { font-size: 12px; font-weight: 600; margin-top: 2px; display: inline-block; }
.dl-up { color: var(--accent); } .dl-down { color: var(--danger); }
.dl-flat, .dl-new { color: var(--muted); }
.rep-kpi { grid-template-columns: repeat(5, 1fr); }

/* воронка */
.funnel { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.fn-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; font-size: 14px; }
.fn-lbl { color: var(--muted); }
.fn-bar { height: 16px; background: var(--surface-hover); border-radius: 4px; overflow: hidden; }
.fn-fill { display: block; height: 100%; background: var(--brand); }
.fn-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* динамика (столбики) */
.dyn { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 12px; overflow-x: auto; padding-bottom: 18px; }
.dyn-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 28px; height: 100%; position: relative; }
.dyn-bar { width: 20px; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; transition: height var(--ease); }
.dyn-lbl { position: absolute; bottom: -18px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.row-idle td { color: var(--muted); }

@media (max-width: 900px) { .rep-kpi { grid-template-columns: repeat(2, 1fr); } .rep-export { margin-left: 0; } }

/* ---- проверка перед подписанием ---- */
.presign{border:1px solid var(--line);border-left:3px solid #b8860b;border-radius:10px;
  padding:14px 16px;margin:0 0 16px;background:rgba(184,134,11,.06)}
.presign-head{font-weight:600;display:flex;align-items:center;gap:8px;margin-bottom:10px}
.presign-count{background:#b8860b;color:#fff;border-radius:999px;font-size:12px;
  min-width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;padding:0 6px}
.presign ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.presign li{display:flex;gap:10px;align-items:flex-start;font-size:14px;line-height:1.45}
.presign-mark{flex:none;width:20px;height:20px;border-radius:50%;display:inline-flex;
  align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#fff}
.presign-stop .presign-mark{background:#a5382f}
.presign-warn .presign-mark{background:#b8860b}
.presign-hint{color:var(--muted);font-size:13px}
.presign-foot{margin:12px 0 0;font-size:13px;color:var(--muted)}
