/* =========================================================================
   Генератор договоров C-SPACE — оформление интерфейса.
   Углы намеренно почти прямые (2–3px): документооборот, а не лендинг.
   ========================================================================= */

:root {
  --brand: #64177c;
  --brand-dark: #4e1161;
  --brand-light: #f3ecf6;
  --brand-line: #d9c6e2;

  --bg: #f1f2f5;
  --panel: #ffffff;
  --ink: #191a1f;
  --ink-soft: #4a4f5a;
  --muted: #767d8a;
  --line: #d8dbe1;
  --line-soft: #e6e8ec;
  --danger: #b3261e;

  --r: 3px;
  --r-lg: 4px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

/* ---------- Шапка ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 0 14px; height: 54px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-logo { display: flex; align-items: center; height: 34px; flex: 0 0 auto; }
.topbar-logo img { height: 30px; width: auto; display: block; }

.nav { display: flex; gap: 2px; margin-left: 4px; }
.nav a {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--r);
  color: var(--ink-soft); text-decoration: none;
  font-size: 13px; font-weight: 550; white-space: nowrap;
}
.nav a:hover { background: #f2f3f6; color: var(--ink); }
.nav a.active { background: var(--brand-light); color: var(--brand); }

.topbar-actions { display: flex; gap: 7px; margin-left: auto; }

.pill {
  display: none; min-width: 18px; padding: 1px 6px;
  border-radius: 9px; background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 650; text-align: center; line-height: 16px;
}
.pill.on { display: inline-block; }
.nav a.active .pill { background: var(--brand); }

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

/* Кнопкой может быть и <a> (переходы между страницами) — сбрасываем стиль ссылки */
.btn, .btn-mini { text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; border: 1px solid transparent; border-radius: var(--r);
  padding: 0 14px; font: inherit; font-size: 13px; font-weight: 550;
  white-space: nowrap; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-primary:disabled { background: #c9ccd3; color: #fff; cursor: not-allowed; }

.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }

.btn-mini {
  display: inline-flex; align-items: center; justify-content: center;
  height: 26px; padding: 0 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft);
  border-radius: var(--r);
  font: inherit; font-size: 12px; font-weight: 550; white-space: nowrap; cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.btn-mini:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.btn-mini.danger:hover { border-color: var(--danger); color: var(--danger); background: #fdf1f0; }

.btn:focus-visible, .btn-mini:focus-visible, .nav a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

/* ---------- Раскладка ---------- */

/* Ширину колонки заполнения двигает разделитель — она хранится в --form-w */
.layout {
  display: grid;
  grid-template-columns: var(--form-w, 440px) 10px minmax(0, 1fr);
  gap: 0; padding: 10px;
  align-items: start;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .splitter { display: none; }
}

/* ---------- Разделитель колонок ---------- */

.splitter {
  position: relative; align-self: stretch;
  cursor: col-resize; touch-action: none;
}
/* Полоска-захват шире самого зазора, иначе в неё трудно попасть мышью */
.splitter::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -3px; right: -3px;
}
.splitter::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 3px; height: 34px; margin: -17px 0 0 -1.5px;
  border-radius: 2px; background: var(--line);
  transition: background .12s ease, height .12s ease;
}
.splitter:hover::after, .splitter:focus-visible::after { background: var(--brand); height: 56px; }
.splitter:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 2px; }
.splitter.dragging::after { background: var(--brand); height: 100%; margin-top: 0; top: 0; }

/* На время перетаскивания гасим выделение текста и курсоры внутри панелей */
body.resizing { user-select: none; cursor: col-resize; }
body.resizing iframe, body.resizing .preview-stage { pointer-events: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.form-panel { padding: 14px; }

.page {
  max-width: 1280px; margin: 0 auto; padding: 12px 14px 40px;
}

/* ---------- Поля ---------- */

label {
  display: block;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  color: var(--ink-soft);
}

.field { margin-bottom: 14px; }
.field > label { margin-bottom: 4px; }
.hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

input[type=text], input[type=date], input[type=number], input[type=search],
input[type=password], input[type=email], input[type=tel],
input:not([type]), select, textarea {
  width: 100%; height: 32px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); color: var(--ink);
  font: inherit; font-size: 13px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.45; }

input::placeholder, textarea::placeholder { color: #a5abb5; }

input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover { border-color: #b9bec7; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(100, 23, 124, .14);
}

input:disabled, select:disabled { background: #f6f7f9; color: var(--muted); cursor: not-allowed; }

select {
  appearance: none; cursor: pointer; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6'%3E%3Cpath fill='%23767d8a' d='M0 0h9L4.5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}

/* Стрелки-счётчики мешают в денежных полях — там вводят вручную */
input.no-spin::-webkit-outer-spin-button,
input.no-spin::-webkit-inner-spin-button { appearance: none; margin: 0; }
input.no-spin { appearance: textfield; -moz-appearance: textfield; }

input[type=date] { position: relative; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }
input[type=date]:hover::-webkit-calendar-picker-indicator { opacity: .9; }

input[type=search] { appearance: none; }
input[type=search]::-webkit-search-cancel-button { appearance: none; }

/* Флажок */
.check { display: flex; align-items: center; gap: 8px; }
.check input[type=checkbox] {
  appearance: none; flex: 0 0 auto;
  width: 16px; height: 16px; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 2px;
  background: var(--panel); cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.check input[type=checkbox]:hover { border-color: var(--brand); }
.check input[type=checkbox]:checked {
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='9'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='square' d='M1 4.5 4 7.5 10 1.5'/%3E%3C/svg%3E") center no-repeat;
  border-color: var(--brand);
}
.check input[type=checkbox]:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.check label { margin: 0; cursor: pointer; font-weight: 500; color: var(--ink); }

/* ---------- Стороны договора ---------- */

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 640px) { .parties { grid-template-columns: 1fr; } }

.party { display: flex; flex-direction: column; min-width: 0; }
.party-title {
  margin: 0 0 4px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--brand);
}

/* Переключатель «компания группы / контрагент» */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  margin-bottom: 6px; padding: 2px; gap: 2px;
  background: #eef0f3; border-radius: var(--r);
}
.seg button {
  padding: 4px 6px; border: none; border-radius: 2px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 650; white-space: nowrap;
  cursor: pointer; transition: background .12s ease, color .12s ease;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Поиск контрагента по ИНН */
.inn-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
.inn-row input { font-variant-numeric: tabular-nums; }
.inn-note {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 5px; font-size: 11px; line-height: 15px; color: var(--muted);
}
.inn-note.warn { color: var(--danger); }
.inn-or {
  margin: 6px 0 4px; font-size: 10.5px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}

.req-card {
  flex: 1; margin-top: 7px; padding: 8px 10px;
  background: #fafafb; border: 1px solid var(--line-soft);
  border-left: 2px solid var(--brand-line);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 11.5px; line-height: 1.5; color: var(--ink-soft);
  min-width: 0; overflow-wrap: anywhere;
}
.req-name { font-weight: 650; color: var(--ink); margin-bottom: 3px; font-size: 12px; }
/* Строкой, а не колонками: в узкой колонке значения иначе рвутся по одному слову */
.req-row { display: block; }
.req-k { color: var(--muted); margin-right: 4px; }
.req-empty { color: var(--muted); font-style: italic; }
.req-tools { margin-top: 8px; display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- Секции и сетка полей ---------- */

.group { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 14px; }
.group-title {
  margin: 0 0 10px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}

/* Вертикальный зазор оставлен под подсказку номера: она выводится вне потока,
   иначе ячейка становилась бы выше соседних и поля переставали быть на одной линии. */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px 10px; }
.grid > div { display: flex; flex-direction: column; justify-content: flex-end;
  min-width: 0; position: relative; }
.grid > div > label { margin-bottom: 4px; }

.cell-full  { grid-column: span 12; }
.cell-half  { grid-column: span 6; }
.cell-third { grid-column: span 4; }
@media (max-width: 560px) { .cell-half, .cell-third { grid-column: span 12; } }

.grid > div.check { flex-direction: row; align-items: center; padding-bottom: 7px; }

/* Подсказка номера договора — вне потока, чтобы не сдвигать соседние поля */
.suggest {
  position: absolute; top: calc(100% + 3px); left: 0; right: 0;
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; line-height: 15px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest > span { overflow: hidden; text-overflow: ellipsis; }
.suggest:empty { display: none; }
.suggest button {
  border: 1px solid var(--brand-line); background: var(--brand-light);
  color: var(--brand); border-radius: 2px; padding: 1px 7px;
  font: inherit; font-size: 11.5px; font-weight: 650; cursor: pointer;
}
.suggest button:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Редактор таблицы услуг ---------- */

.tbl-wrap { grid-column: span 12; align-items: stretch; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 5px; table-layout: fixed; }
.tbl th {
  text-align: left; padding: 0 4px 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.tbl td { padding: 2px; vertical-align: middle; }
.tbl .col-n { width: 24px; text-align: center; color: var(--muted); font-size: 12px; }
.tbl .col-x { width: 28px; }
.tbl .col-unit { width: 74px; }
.tbl .col-qty { width: 64px; }
.tbl input { height: 30px; }

.row-del {
  width: 26px; height: 26px; border: none; background: none;
  color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
  border-radius: 2px;
}
.row-del:hover { background: #fdf1f0; color: var(--danger); }

.panel-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft);
}

/* ---------- Предпросмотр: лист A4 в натуральную величину ---------- */

.preview-panel {
  position: sticky; top: 64px;
  display: flex; flex-direction: column;
  height: calc(100vh - 74px); overflow: hidden;
}
@media (max-width: 980px) { .preview-panel { position: static; height: 80vh; } }

.preview-head {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.preview-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); flex: 0 0 auto;
}
.preview-status {
  font-size: 12px; color: var(--ink-soft); margin-left: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.zoom-bar { display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.zoom-bar button {
  width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft);
  border-radius: 2px; font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
}
.zoom-bar button:hover { border-color: var(--brand); color: var(--brand); }
.zoom-bar .zoom-fit { width: auto; padding: 0 8px; font-size: 11.5px; font-weight: 600; }
.zoom-bar .zoom-fit.on { background: var(--brand-light); border-color: var(--brand-line); color: var(--brand); }
.zoom-level {
  min-width: 40px; text-align: center; font-size: 11.5px;
  font-variant-numeric: tabular-nums; color: var(--muted);
}

.preview-stage { flex: 1; overflow: auto; background: #9c9ea6; padding: 14px 0; }
.preview-zoom { transform-origin: top center; margin: 0 auto; }

/* Лист ровно A4; поля совпадают с полями договора в Word */
.paper {
  width: 210mm; min-height: 297mm;
  padding: 25.4mm 20mm 25.4mm 30mm;   /* заменяется полями шаблона при предпросмотре */
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  position: relative;
}
/* Ориентир: примерно здесь текст перейдёт на следующий лист */
.page-break {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px dashed rgba(100, 23, 124, .45);
  pointer-events: none;
}
.page-break span {
  position: absolute; right: 0; top: 2px;
  font: 600 9px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .05em; text-transform: uppercase; color: rgba(100, 23, 124, .6);
}

/* ---------- Архив ---------- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
}
.page-head h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.page-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.filters {
  display: grid; grid-template-columns: 1.3fr 1.3fr 1fr auto;
  gap: 10px; align-items: end;
  padding: 12px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
}
@media (max-width: 820px) { .filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .filters { grid-template-columns: 1fr; } }
.filters > div { display: flex; flex-direction: column; min-width: 0; }
.filters label { margin-bottom: 4px; }

.arc-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }

.arc-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
}
.arc-row:last-child { border-bottom: none; }
.arc-row:hover { background: #fafafb; }

.arc-num { font-size: 13.5px; font-weight: 650; }
.arc-date { margin-left: 8px; font-weight: 400; font-size: 12px; color: var(--muted); }
.arc-parties { margin-top: 2px; font-size: 12.5px; color: var(--ink-soft); overflow-wrap: anywhere; }
.arc-meta { margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.arc-tag {
  display: inline-block; margin-left: 7px; padding: 0 5px;
  border: 1px solid var(--brand-line); border-radius: 2px;
  background: var(--brand-light); color: var(--brand);
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.arc-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) {
  .arc-row { grid-template-columns: 1fr; }
  .arc-actions { justify-content: flex-start; }
}

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 5px; color: var(--ink-soft); font-size: 14px; }

/* ---------- Папки архива ---------- */

.archive-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 10px; align-items: start; }
@media (max-width: 820px) { .archive-layout { grid-template-columns: 1fr; } }

.folders { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.folders-title {
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.folder {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; border: none; border-left: 2px solid transparent;
  background: none; color: var(--ink-soft);
  font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.folder:hover { background: #fafafb; color: var(--ink); }
.folder.on { background: var(--brand-light); border-left-color: var(--brand); color: var(--brand); font-weight: 600; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count {
  flex: 0 0 auto; padding: 0 5px; border-radius: 8px;
  background: #eef0f3; color: var(--muted);
  font-size: 10.5px; font-weight: 650; line-height: 15px;
}
.folder.on .folder-count { background: var(--brand); color: #fff; }
.folders-path { padding: 9px 12px; border-top: 1px solid var(--line-soft); }
.folders-path-label {
  display: block; margin-bottom: 3px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.folders-path code {
  font-size: 10.5px; line-height: 1.4; color: var(--muted);
  overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Справочник компаний ---------- */

.tabs { display: flex; gap: 2px; margin-bottom: 10px; }
.tabs button {
  padding: 7px 14px; border: 1px solid transparent; border-radius: var(--r);
  background: none; color: var(--ink-soft);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
}
.tabs button:hover { background: #eaecf0; }
.tabs button.on { background: var(--brand-light); color: var(--brand); }

.co-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }
.co-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
}
.co-row:last-child { border-bottom: none; }
.co-row:hover { background: #fafafb; }
.co-name { font-size: 13.5px; font-weight: 650; }
.co-badge {
  display: inline-block; margin-left: 7px; padding: 0 5px;
  border: 1px solid var(--line); border-radius: 2px; background: #f4f5f7;
  color: var(--muted); font-size: 10px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.co-badge.own { border-color: var(--brand-line); background: var(--brand-light); color: var(--brand); }
.co-meta { margin-top: 3px; font-size: 12px; color: var(--ink-soft); overflow-wrap: anywhere; }
.co-sub { margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.co-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .co-row { grid-template-columns: 1fr; }
  .co-actions { justify-content: flex-start; }
}

/* ---------- Диалог реквизитов ---------- */

.dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0;
  width: min(660px, 94vw); box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
}
.dialog::backdrop { background: rgba(25, 26, 31, .5); }
.dialog form { padding: 18px; }
.dialog h2 { margin: 0 0 3px; font-size: 16px; font-weight: 650; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .span2 { grid-column: span 1 !important; } }
.grid2.nested {
  margin-top: 0; padding: 11px;
  background: #fafafb; border: 1px solid var(--line-soft); border-radius: var(--r);
}
.span2 { grid-column: span 2; }
.fld { display: flex; flex-direction: column; min-width: 0; }
.fld > span { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.fld > input, .fld > select { margin-top: 4px; }
.req { color: var(--danger); font-weight: 700; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 7px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}

/* ---------- Уведомление ---------- */

.toast {
  position: fixed; bottom: 18px; left: 50%; z-index: 80;
  transform: translate(-50%, 14px);
  max-width: 80vw; padding: 9px 15px;
  background: var(--ink); color: #fff;
  border-radius: var(--r); font-size: 12.5px;
  opacity: 0; pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* Предупреждение о незаполненных данных площадки */
.req-warn {
  margin-top: 7px; padding: 6px 8px;
  background: #fdf6e8; border: 1px solid #ecd9ad; border-radius: 2px;
  font-size: 11px; line-height: 1.45; color: #7a5a12;
}
.req-warn .link {
  border: none; background: none; padding: 0;
  font: inherit; font-weight: 650; color: var(--brand);
  text-decoration: underline; cursor: pointer;
}

/* ---------- Площадки коворкинга ---------- */

.co-badge.ok { border-color: #b9d9c0; background: #eef7f0; color: #1f6b3a; }
.co-badge.warn { border-color: #ecd9ad; background: #fdf6e8; color: #7a5a12; }

.site-grid {
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 10px; margin-top: 5px; font-size: 12px;
}
.site-k { color: var(--muted); white-space: nowrap; }
.site-v { color: var(--ink-soft); overflow-wrap: anywhere; }
@media (max-width: 560px) { .site-grid { grid-template-columns: 1fr; } .site-k { margin-top: 5px; } }

.site-missing {
  margin-top: 7px; padding: 5px 8px;
  background: #fdf6e8; border: 1px solid #ecd9ad; border-radius: 2px;
  font-size: 11.5px; color: #7a5a12;
}

/* ---------- Страница входа ---------- */

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }

.login {
  width: min(340px, 100%); padding: 28px 26px 26px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 14px 36px rgba(16, 24, 40, .08);
}
.login-logo { height: 28px; width: auto; display: block; margin-bottom: 22px; }
.login h1 { margin: 0 0 20px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .btn { width: 100%; height: 36px; margin-top: 2px; }

/* Поле пароля с переключателем видимости */
.pwd { position: relative; display: block; margin-top: 4px; }
.pwd input { padding-right: 70px; }
.pwd-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  padding: 4px 7px; border: none; border-radius: 2px; background: none;
  font: inherit; font-size: 11px; color: var(--muted); cursor: pointer;
}
.pwd-toggle:hover { color: var(--brand); background: var(--brand-light); }

.login-error:empty { display: none; }
.login-error {
  margin: 0; padding: 8px 10px;
  background: #fdf1f0; border: 1px solid #f0c8c2; border-radius: var(--r);
  font-size: 12px; color: var(--danger);
}

/* Кто вошёл + выход */
.who {
  display: flex; align-items: center; gap: 8px; margin-left: 10px;
  padding-left: 12px; border-left: 1px solid var(--line);
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.who a { color: var(--muted); text-decoration: none; font-weight: 550; }
.who a:hover { color: var(--brand); text-decoration: underline; }
.arc-tag.draft { border-color: var(--line); background: #f4f5f7; color: var(--muted); }

/* =========================================================================
   Обзор: показатели и графики
   ========================================================================= */

:root {
  /* Цвет данных светлее фирменного #64177c: тёмный оттенок не проходит
     по светлотной полосе для марок, хотя и хорош для кнопок. */
  --series-1: #7d2a99;
  --series-wash: rgba(125, 42, 153, .10);
  --grid: #e6e8ec;
}

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 10px;
}
.tile {
  padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-lg);
}
.tile-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.tile-value {
  margin: 5px 0 3px; font-size: 26px; font-weight: 650;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink);
}
.tile-note { font-size: 11.5px; color: var(--muted); min-height: 16px; }
.tile-note a { color: var(--brand); text-decoration: none; }
.tile-note a:hover { text-decoration: underline; }
.tile-delta.up { color: #1f6b3a; }
.tile-delta.down { color: var(--danger); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.dash-grid > :first-child, .dash-grid > :last-child { grid-column: 1 / -1; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }

.chart-card { padding: 14px; }
.chart-head { margin-bottom: 10px; }
.chart-head h2 { margin: 0; font-size: 13px; font-weight: 650; }
.chart-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.chart-sub a { color: var(--brand); text-decoration: none; }
.chart-sub a:hover { text-decoration: underline; }
.chart-body { min-height: 40px; }
.chart-empty { margin: 18px 0; font-size: 12.5px; color: var(--muted); text-align: center; }

/* Линия */
.chart { display: block; max-width: 100%; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-wash); stroke: none; }
.chart .dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.chart .value { fill: var(--ink); font-size: 11px; font-weight: 650; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(100, 23, 124, .05); }

/* Полосы */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 9rem) 1fr auto; gap: 10px; align-items: center; }
.bar-label {
  font-size: 12px; color: var(--ink-soft); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.bar-label:hover { color: var(--brand); text-decoration: underline; }
.bar-track { height: 14px; background: #f2f3f6; border-radius: 2px; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bar-value { font-size: 12px; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums; min-width: 1.5rem; text-align: right; }
@media (max-width: 520px) { .bar-row { grid-template-columns: minmax(0, 6rem) 1fr auto; } }

/* Таблица к графику — данные доступны и без цвета */
.chart-table { margin-top: 12px; }
.chart-table summary {
  font-size: 11.5px; color: var(--muted); cursor: pointer; list-style: none;
}
.chart-table summary::-webkit-details-marker { display: none; }
.chart-table summary::before { content: '▸ '; }
.chart-table[open] summary::before { content: '▾ '; }
.chart-table summary:hover { color: var(--brand); }
.mini-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.mini-table th, .mini-table td {
  padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--line-soft);
}
.mini-table th { font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); }
.mini-table td { font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* Последние договоры */
.recent { display: flex; flex-direction: column; }
.recent-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none;
}
.recent-row:last-child { border-bottom: none; }
.recent-row:hover .recent-num { color: var(--brand); }
.recent-main { min-width: 0; }
.recent-num { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink); }
.recent-party { display: block; font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { display: flex; align-items: center; gap: 7px; flex: 0 0 auto;
  font-size: 11.5px; color: var(--muted); }

/* ---------- Выбор типа договора ---------- */

.pick { padding: 18px; }
.pick-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.pick-head h2 { margin: 0 0 3px; font-size: 16px; font-weight: 650; }
.pick-list { display: grid; gap: 8px; margin-top: 16px; }
.pick-item {
  display: block; padding: 11px 13px; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .12s ease, background .12s ease;
}
.pick-item:hover { border-color: var(--brand); background: var(--brand-light); }
.pick-name { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.pick-desc { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
