/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * Цвета здесь хардкодом, а не Tailwind-переменными, потому что Propshaft
 * не прогоняет файл через PostCSS — но они отражают brand-graphite шкалу
 * из tailwind/application.css. Если меняешь токены там — поправь и тут.
 *
 *   brand-50  #F5F7FA   (мягкая подложка)
 *   brand-300 #94A3B8   (border-hover)
 *   brand-600 #334155   (текст основной)
 *   brand-700 #243044   (hover для primary)
 *   brand-800 #1E293B   (primary — графит логотипа)
 */

/* Токены handoff — дублируют tailwind/application.css @theme для чистого CSS. */
:root {
  --font-sans: "Inter", "Helvetica Neue", Helvetica, Arial, ui-sans-serif,
               system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Inter", ui-monospace, monospace;

  --g-50: #F5F7FA;
  --g-75: #EEF1F6;
  --g-100: #E4E9F1;
  --g-200: #D2D9E3;
  --g-300: #B7C0CD;
  --g-400: #94A0B4;
  --g-500: #64748B;
  --g-600: #475569;
  --g-700: #334155;
  --g-800: #1E293B;
  --g-900: #0F172A;

  --ink: var(--g-900);
  --muted: var(--g-500);
  --bg: #FBFBFC;
  --paper: #FFFFFF;
  --line: var(--g-100);
  --line-strong: var(--g-200);

  --ok-fg: #13693F;
  --warn-fg: #8A6611;
  --bad-fg: #963131;
}

.ok-fg { color: var(--ok-fg); }
.bad-fg { color: var(--bad-fg); }
.warn-fg { color: var(--warn-fg); }

/* ---------- Унифицированные form-контролы ---------- */
/* Используются для согласованного вида input/select/checkbox в формах,
   когда нативный вид браузера ломает сетку. */
.app-input,
.app-select,
.app-textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  color: #111827;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.app-input,
.app-select {
  height: 40px;
  padding: 0 12px;
}
.app-textarea {
  padding: 10px 12px;
  min-height: 80px;
  line-height: 1.45;
  resize: vertical;
}
.app-input::placeholder,
.app-textarea::placeholder { color: #9ca3af; }
.app-input.font-mono,
.app-select.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.app-input:focus,
.app-select:focus,
.app-textarea:focus {
  outline: none;
  border-color: #1E293B;
  box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.18);
}
.app-input[readonly],
.app-textarea[readonly] {
  background: #f9fafb;
  color: #6b7280;
  cursor: default;
}
.app-input[disabled],
.app-select[disabled],
.app-textarea[disabled] {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

.app-select {
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7280'><path stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M6 8l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

/* Boolean-контрол в виде toggle switch.
   Семантически остаётся <input type="checkbox"> — серверный код и тесты не меняются. */
.app-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  background: #e5e7eb;
  cursor: pointer;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
  transition: background 150ms ease, border-color 150ms ease;
  vertical-align: middle;
}
.app-checkbox::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 150ms ease;
}
.app-checkbox:hover { border-color: #94A3B8; }
.app-checkbox:checked {
  background: #1E293B;
  border-color: #1E293B;
}
.app-checkbox:checked::before {
  transform: translateX(20px);
}
.app-checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.25);
}
.app-checkbox[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Базовая кнопка — h-10, под высоту .app-input. Использовать как
   <button class="btn"> или <a class="btn">.
   Модификаторы: .btn-primary (графит), .btn-danger (красный outline). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: #F5F7FA; border-color: #94A3B8; color: #111827; }

.btn-primary {
  background: #1E293B;
  border-color: #1E293B;
  color: #fff;
}
.btn-primary:hover { background: #0F172A; border-color: #0F172A; color: #fff; }

.btn-danger {
  color: #b42318;
  border-color: #fecdca;
}
.btn-danger:hover { background: #fef3f2; border-color: #fda29b; color: #912018; }

/* Маленькая кнопка для действий в таблицах ("Открыть", "Редактировать", "Превью PDF").
   Соответствует .btn-sm в wireframes.html. */
.btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn-sm:hover { background: #F5F7FA; border-color: #94A3B8; color: #111827; }
.btn-sm.btn-danger { color: #b42318; border-color: #fecdca; }
.btn-sm.btn-danger:hover { background: #fef3f2; border-color: #fda29b; color: #912018; }
.btn-sm + .btn-sm { margin-left: 6px; }

/* Модалка. Контроллер app/javascript/controllers/modal_controller.js
   клонирует <template> в body, эти стили задают вид оверлея и окна.
   Закрытие — клик по подложке, Esc или явная data-action="modal#close". */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 24px;
}
.modal-window {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px -8px rgba(15, 23, 42, .18),
              0 2px  6px         rgba(15, 23, 42, .06);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalIn 140ms ease-out;
  /* Клонируется в body — явно наследуем handoff-типографику (Inter 14px). */
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: #0F172A;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) }
  to   { opacity: 1; transform: none }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #E4E9F1;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #0F172A;
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  cursor: pointer;
  background: transparent;
  border: 0;
}
.modal-close:hover { background: #F5F7FA; color: #0F172A; }
.modal-body {
  padding: 20px 22px;
  font-size: 13.5px;
  color: #334155;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  background: #FAFBFC;
  border-top: 1px solid #E4E9F1;
}

/* Сводка и поля внутри модалок (mark paid, share и т.д.) */
.modal-body > p {
  margin: 0;
  line-height: 1.45;
}
.modal-body .side-card--muted {
  margin-top: 14px;
  padding: 14px 16px;
  background: #F5F7FA;
}
.modal-body .field {
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-body .field label {
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
}

/* Кнопки и поля в модалке — как .btn / .input в handoff (13.5px, h 36px). */
.modal-foot .btn {
  height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
  font-family: inherit;
}
.modal-body .app-input,
.modal-body .flatpickr-input {
  font-size: 13.5px;
  color: #0F172A;
  font-family: var(--font-sans);
}
.modal-body .app-input.font-mono,
.modal-body .flatpickr-input.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Унифицированная карточка-контейнер для блоков (форма, превью, таблицы).
   Заменяет россыпь bg-white + border + rounded + shadow по шаблонам. */
.app-card {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Чип плейсхолдера — жёлтая "таблетка" как в прототипе. */
.placeholder-chip {
  display: inline-flex;
  align-items: center;
  background: rgba(212,160,23,.13);
  color: #B45309;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(212,160,23,.28);
  margin: 0 1px;
  cursor: default;
  user-select: none;
  white-space: nowrap;
  font-family: inherit;
  transition: box-shadow .12s;
}
.placeholder-chip:hover { box-shadow: 0 0 0 2px rgba(212,160,23,.22); }
.placeholder-chip.var-fresh { animation: varFresh .55s cubic-bezier(.18,.89,.32,1.28); }
@keyframes varFresh {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
@media print {
  .placeholder-chip { background: transparent; border: 0; padding: 0; color: inherit; }
}

/* Обёртка редактора (border, border-radius, flex column). */
.tt-editor {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
}

/* Холст редактора — куда Tiptap рендерит .ProseMirror. */
.tt-canvas {
  padding: 32px 56px 24px 56px;
  min-height: 420px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--g-800);
  position: relative;
}
.tt-canvas .ProseMirror {
  outline: none;
  min-height: 320px;
}
.tt-canvas .ProseMirror > * + * { margin-top: 0.4em; }
.tt-canvas .ProseMirror p { margin: 0; }
.tt-canvas .ProseMirror h1 { font-size: 28px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
.tt-canvas .ProseMirror h2 { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.015em; }
.tt-canvas .ProseMirror ul,
.tt-canvas .ProseMirror ol { padding-left: 1.5em; }
.tt-canvas .ProseMirror li + li { margin-top: 0.2em; }
.tt-canvas .ProseMirror-selectednode { outline: 2px solid var(--g-700); outline-offset: 2px; border-radius: 4px; }

/* Таблица позиций — визуально как placeholder. */
.tt-canvas table.line-items {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0;
  font-size: 12.5px;
  background: var(--g-50);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  cursor: default;
}
.tt-canvas table.line-items th,
.tt-canvas table.line-items td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--g-700);
  text-align: left;
}
.tt-canvas table.line-items tr:last-child th,
.tt-canvas table.line-items tr:last-child td { border-bottom: 0; }
.tt-canvas table.line-items th {
  font-size: 10.5px; color: var(--g-500);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 500; background: #FAFBFC;
}
.tt-canvas table.line-items tr[data-loop-row="true"] td { color: var(--g-400); }

/* ===================================================================
   New-act wizard
   Десктоп: sticky steps sidebar слева (240px) + body справа.
   Шаги: Клиент → Шаблон → Позиции → Проверка. Стилизация повторяет
   референс дизайна (графит + Inter + 6/8px скругления).
   =================================================================== */
.wizard {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: flex-start;
}
.wiz-steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 80px;
}
.wiz-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: #64748B;
}
.wiz-step.active {
  background: #F5F7FA;
  color: #0F172A;
  font-weight: 500;
}
.wiz-step.done { color: #334155; }
.wiz-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  background: #E4E9F1; color: #64748B;
}
.wiz-step.active .wiz-step-num,
.wiz-step.done   .wiz-step-num { background: #1E293B; color: #fff; }

.wiz-body {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 28px 32px;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}
.wiz-body h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #0F172A;
}
.wiz-body .wiz-sub {
  font-size: 13.5px;
  color: #64748B;
  margin-top: 4px;
  margin-bottom: 24px;
}
.wiz-body > .wiz-step-pane { display: none; flex-direction: column; flex: 1; }
.wiz-body > .wiz-step-pane.is-active { display: flex; }

.wiz-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid #E4E9F1;
}
.wiz-foot .wiz-foot-right { display: flex; gap: 8px; }

/* Карточки выбора шаблона */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.template-card {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms;
  text-align: left;
  font-family: inherit;
}
.template-card:hover { border-color: #D2D9E3; }
.template-card.is-selected {
  border-color: #1E293B;
  box-shadow: 0 0 0 3px rgba(30, 41, 59, .08);
}
.template-card h4 {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 600;
  color: #0F172A;
}
.template-card p {
  margin: 0;
  font-size: 12.5px;
  color: #64748B;
  line-height: 1.5;
}
.template-card .tmpl-meta {
  display: flex; gap: 10px;
  margin-top: 10px;
  font-size: 11.5px;
  color: #94A0B4;
}

/* Список шаблонов (прототип TemplatesList — 3 колонки) */
.template-grid--list {
  grid-template-columns: repeat(3, 1fr);
}
.template-grid--list .template-card .tmpl-meta {
  gap: 14px;
  color: #64748B;
}
a.template-card {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.template-card:hover {
  border-color: #D2D9E3;
}
.tmpl-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.tmpl-fields .pill {
  font-size: 11px;
}

/* Список клиентов в шаге «Клиент» */
.client-pick-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  background: #fff;
}
.client-pick-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #E4E9F1;
  cursor: pointer;
  background: #fff;
  transition: background 120ms;
  font-family: inherit;
  text-align: left;
  width: 100%;
}
.client-pick-row:last-child { border-bottom: 0; }
.client-pick-row:hover     { background: #FAFBFC; }
.client-pick-row.is-selected { background: #F5F7FA; }
.client-pick-row .cp-name {
  font-weight: 500; font-size: 13.5px; color: #0F172A;
}
.client-pick-row .cp-meta {
  font-size: 12px; color: #64748B; margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

/* Carrд-плейсхолдер для шага без клиентов */
.wiz-empty {
  background: #F5F7FA;
  border: 1px dashed #D2D9E3;
  border-radius: 6px;
  padding: 18px 20px;
  font-size: 13px;
  color: #475569;
}

/* Призрачная кнопка — нейтральная подложка для второстепенных действий
   (например, «+ Добавить позицию» под таблицей). Не имеет рамки, hover —
   серый прямоугольник. */
/* Призрачная кнопка — нейтральная подложка для второстепенных действий.
   Высоту не задаём здесь — пусть совпадает с .btn (40px), чтобы рядом
   стоящие primary и ghost не отличались по высоте. .btn-sm перебивает. */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #334155;
}
.btn-ghost:hover { background: #EEF1F6; color: #0F172A; border-color: transparent; }
.btn-ghost svg { width: 14px; height: 14px; }

/* === Таблица позиций (items-table) ===
   Используется на шаге «Позиции» визарда и на форме редактирования акта.
   Структурно отличается от .tbl: нет обёртки, шапка — мелкая uppercase,
   ячейки — компактные с инпутами, специальные классы для узких колонок. */
.items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.items-table th {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748B;
  text-align: left;
  padding: 8px 4px;
  font-weight: 500;
}
.items-table th.num { text-align: right; }
.items-table td {
  padding: 4px 4px;
  vertical-align: top;
}
.items-table .col-n     { width: 36px; }
.items-table .col-qty   { width: 90px; }
.items-table .col-price { width: 130px; }
.items-table .col-sum   { width: 130px; }
.items-table .col-rm    { width: 36px; }
.items-table input {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13.5px;
  color: #0F172A;
  width: 100%;
  font-family: inherit;
}
.items-table input:focus {
  outline: none;
  border-color: #1E293B;
  box-shadow: 0 0 0 3px rgba(30, 41, 59, .08);
}
.items-table input.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.items-table .sum-cell {
  padding: 9px 10px;
  font-size: 13.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #0F172A;
  font-weight: 500;
}
.items-table .col-num-cell {
  padding-top: 14px;
  color: #64748B;
  font-variant-numeric: tabular-nums;
}

/* Маленькая trash-кнопка на каждой строке. */
.items-rm {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94A0B4;
  margin-top: 4px;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.items-rm svg { width: 14px; height: 14px; }
.items-rm:hover {
  background: rgba(184, 49, 49, .1);
  color: #963131;
}

/* На мобиле items-table → стек labelled-полей. */
@media (max-width: 600px) {
  .items-table thead { display: none; }
  .items-table tr {
    display: grid;
    grid-template-columns: 24px 1fr 32px;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid #E4E9F1;
  }
  .items-table tr:last-child { border-bottom: 0; }
  .items-table td { padding: 0; }
  .items-table .col-n {
    grid-row: 1; grid-column: 1;
    color: #64748B;
    align-self: center;
    text-align: center;
    padding-top: 0;
  }
  .items-table td:nth-child(2) { grid-row: 1; grid-column: 2; }
  .items-table .col-rm { grid-row: 1; grid-column: 3; align-self: center; }
  .items-table .col-qty,
  .items-table .col-price,
  .items-table .col-sum { grid-column: 2; }
  .items-table .col-qty   { grid-row: 2; }
  .items-table .col-price { grid-row: 3; }
  .items-table .col-sum   { grid-row: 4; }
  .items-table .col-qty::before,
  .items-table .col-price::before,
  .items-table .col-sum::before {
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748B;
    margin-bottom: 3px;
    font-weight: 500;
  }
  .items-table .col-qty::before   { content: "Кол-во"; }
  .items-table .col-price::before { content: "Цена"; }
  .items-table .col-sum::before   { content: "Сумма"; }
  .items-table .sum-cell {
    text-align: left;
    padding: 8px 10px;
    background: #F5F7FA;
    border-radius: 6px;
  }
}

/* Итог-плашка под таблицей позиций. Прибита вправо, графитовый акцент. */
.items-total {
  display: flex;
  justify-content: flex-end;
  font-size: 14px;
  color: #475569;
}
.items-total > div {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 18px 4px;
  border-top: 1px solid #E4E9F1;
  min-width: 220px;
  justify-content: space-between;
}
.items-total strong {
  font-size: 18px;
  color: #0F172A;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Редактируемое поле «Итого, ₽» внутри плашки. Без рамки — читается
   как продолжение текстовой строки; при фокусе подсвечиваем подложку. */
.items-total-input {
  width: 140px;
  text-align: right;
  font-size: 18px;
  font-weight: 600;
  color: #0F172A;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 4px 6px;
  margin-right: -6px;
  border-radius: 4px;
  font-family: inherit;
}
.items-total-input::placeholder { color: #B7C0CD; font-weight: 500; }
.items-total-input:focus       { background: #F5F7FA; }
.items-total-input:hover       { background: #FAFBFC; }
/* Спрятать спин-кнопки в number-input, чтобы они не ломали выравнивание. */
.items-total-input::-webkit-outer-spin-button,
.items-total-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.items-total-input { -moz-appearance: textfield; }

/* Review paper — кремовый превью-блок на 4-м шаге. */
.review-paper {
  background: #FAFBFC;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 24px 28px;
}
.review-doc-h-title { font-size: 20px; font-weight: 600; color: #0F172A; }
.review-doc-h-meta  { font-size: 12px; color: #64748B; margin-top: 4px; }
.review-parties {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin: 18px 0;
}
.review-label { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #64748B; margin-bottom: 4px; }
.review-strong { font-weight: 600; font-size: 14px; color: #0F172A; }
.review-dim    { font-size: 12.5px; color: #64748B; margin-top: 2px; font-variant-numeric: tabular-nums; }
.review-table  { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.review-table th {
  font-weight: 500; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #64748B;
  text-align: left; padding: 10px 8px; border-bottom: 1px solid #E4E9F1;
}
.review-table td {
  padding: 11px 8px; border-bottom: 1px solid #E4E9F1; color: #334155;
}
.review-table tr:last-child td { border-bottom: 0; }
.review-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.review-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 8px 0; border-top: 1px solid #D2D9E3; margin-top: 8px;
  font-size: 14px;
}
.review-total strong { font-size: 20px; color: #0F172A; font-variant-numeric: tabular-nums; }

/* На мобиле — sidebar шагов превращается в горизонтальную скролл-полосу,
   а footer прилипает над BottomNav, как в дизайне. */
@media (max-width: 767px) {
  .wizard { grid-template-columns: 1fr; gap: 14px; }
  .wiz-steps {
    flex-direction: row; flex-wrap: nowrap;
    position: sticky; top: 56px; z-index: 5;
    background: #fff; border: 1px solid #E4E9F1; border-radius: 8px;
    padding: 5px; overflow-x: auto; gap: 2px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .wiz-steps::-webkit-scrollbar { display: none; }
  .wiz-step { flex-shrink: 0; padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
  .wiz-step-num { width: 18px; height: 18px; font-size: 11px; }
  .wiz-body { padding: 18px 16px; min-height: 0; }
  .template-grid { grid-template-columns: 1fr; gap: 10px; }
  .review-parties { grid-template-columns: 1fr; gap: 14px; }
  .wiz-foot { flex-wrap: wrap; gap: 8px; padding-top: 16px; }
  .wiz-foot .btn { flex: 1; justify-content: center; }
}

/* ===================================================================
   Screen head — заголовок экрана (act#show, clients#show, …)
   =================================================================== */
.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.screen-title {
  font-size: 24px;
  font-weight: 600;
  color: #0F172A;
  letter-spacing: -0.02em;
  margin: 0;
}
.screen-title-muted {
  color: #94A0B4;
  font-weight: 500;
  margin-left: 8px;
}
.screen-sub {
  font-size: 13.5px;
  color: #64748B;
  margin-top: 4px;
}
.screen-head-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Форма «Реквизиты» — как Requisites в handoff (max 720px, side-card). */
.profile-form {
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.profile-form .side-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.profile-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.profile-form .field label {
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
}
.profile-form .hint {
  font-size: 11.5px;
  color: #64748B;
  margin: 0;
}
.profile-form .input-row {
  display: grid;
  gap: 12px;
}
.profile-form .input-row.two {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 640px) {
  .profile-form .input-row.two { grid-template-columns: 1fr; }
}

/* Act detail — сетка документ + сайдбар 320px */
.detail-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
}
.detail-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Sticky bottom action bar — на детальной странице акта.
   На десктопе скрыта; на мобиле фиксируется снизу, primary action занимает
   весь ряд, рядом — outline «Скачать PDF» и kebab. */
.detail-action-bar { display: none; }

/* Bottom nav + FAB — как в handoff, только до 900px */
.bottom-nav,
.fab {
  display: none;
}

@media (max-width: 900px) {
  .bottom-nav {
    display: flex;
  }

  body.has-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    z-index: 35;
    height: 52px;
    padding: 0 18px;
    background: #1E293B;
    color: #fff;
    border-radius: 999px;
    box-shadow:
      0 8px 24px -6px rgba(15, 23, 42, .35),
      0 2px  6px      rgba(15, 23, 42, .18);
    font-size: 14.5px;
    font-weight: 500;
    text-decoration: none;
    transition: transform 120ms ease, box-shadow 120ms ease;
  }
  .fab:active { transform: scale(.96); }
  .fab-label { display: inline; }

  .screen-head { margin-bottom: 16px; }
  .screen-title { font-size: 22px; }
  .acts-screen-head { display: none; }
  .screen-head-actions {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .screen-head-actions .btn { flex: 1; min-width: 120px; }
  .screen-head-actions .btn.icon-only {
    flex: 0 0 auto;
    width: 44px;
    min-width: 44px;
  }
  .hide-on-mobile { display: none !important; }
  /* На /acts/:id блок действий из шапки скрыт — он переезжает в .detail-action-bar внизу. */
  .act-detail-actions { display: none; }
  .view-switch-note { display: none; }
  .detail-wrap { grid-template-columns: 1fr; gap: 12px; }

  /* Sticky bottom toolbar — iOS Mail-style: 4 равные иконки-кнопки.
     Никакого primary-растягивания; редкие экшены — в kebab (bottom-sheet).
     Архив — особый случай, один full-width .btn внутри. */
  .detail-action-bar {
    display: flex;
    align-items: stretch;
    gap: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: #fff;
    border-top: 1px solid #E4E9F1;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 20px -10px rgba(15, 23, 42, .18);
  }
  /* Каждый слот — иконка сверху, подпись 11px снизу. */
  .detail-action {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    background: transparent;
    border: 0;
    color: #475569;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 80ms ease, color 80ms ease;
    -webkit-tap-highlight-color: transparent;
  }
  .detail-action:active   { background: #EEF1F6; }
  .detail-action:focus-visible {
    outline: 2px solid #1E293B;
    outline-offset: 2px;
  }
  .detail-action.is-disabled,
  .detail-action[aria-disabled="true"] {
    opacity: .35;
    pointer-events: none;
  }
  .detail-action-icon {
    width: 22px;
    height: 22px;
  }
  .detail-action-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* button_to оборачивает в <form> — пусть форма не ломает flex-сетку. */
  .detail-action-form { display: contents; }

  /* Kebab обёрнут в .dropdown (нужен для anchor menu + data-controller).
     По умолчанию .dropdown — inline-block; внутри toolbar делаем его
     полноценным flex-слотом наравне с link_to/button. */
  .detail-action-bar .dropdown {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    position: relative;
  }
  .detail-action-bar .dropdown > .detail-action {
    width: 100%;
  }

  /* Лёгкий спиннер на месте иконки, когда PDF генерируется. */
  .detail-action-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #CBD2DE;
    border-top-color: #475569;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Архив: одна full-width кнопка вместо тулбара. */
  .detail-action-bar--archived {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .detail-action-bar--archived .btn { width: 100%; }

  /* Высота бара ~ 60px без safe-area; даём чуть запас под label. */
  body.has-action-bar {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* Когда внутри бара открыт kebab-шит — поднимаем сам бар над .dropdown-backdrop
     (он на z:60 от <body>). Без этого меню внутри бара остаётся пленником его
     stacking context'а (z:40) и пропускает клики в backdrop, который их съедает. */
  body.dropdown-sheet-open .detail-action-bar {
    z-index: 80;
  }
}

@media (max-width: 560px) {
  .screen-title { font-size: 20px; }
}

/* ===================================================================
   Act show: переключатель Документ/PDF + бумага + pdf-viewer
   =================================================================== */
.view-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.view-switch-note {
  font-size: 12px;
  color: #64748B;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.view-switch-note svg { width: 12px; height: 12px; color: #94A0B4; }

/* Segmented control (универсальный). */
.seg {
  display: inline-flex;
  background: #E4E9F1;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: #64748B;
  border-radius: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.seg button svg { width: 13px; height: 13px; }
.seg button.is-active {
  background: #fff;
  color: #0F172A;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}

/* Бумажный лист с данными акта. */
.detail-paper {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 32px 36px;
}
.doc { font-size: 13.5px; color: #334155; }
.doc-h {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid #E4E9F1;
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.doc-h-title { font-size: 20px; font-weight: 600; color: #0F172A; }
.doc-h-meta  { font-size: 12px; color: #64748B; margin-top: 4px; }
.doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 22px;
}
.doc-label {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748B;
  margin-bottom: 4px;
}
.doc-strong { font-weight: 600; font-size: 14px; color: #0F172A; }
.doc-dim    { font-size: 12.5px; color: #64748B; margin-top: 2px; font-variant-numeric: tabular-nums; }
.doc table  { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc table th {
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748B;
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #E4E9F1;
}
.doc table td {
  padding: 11px 8px;
  border-bottom: 1px solid #E4E9F1;
  color: #334155;
}
.doc table tr:last-child td { border-bottom: 0; }
.doc table .num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 8px 0;
  border-top: 1px solid #D2D9E3;
  margin-top: 8px;
  font-size: 14px;
}
.doc-total strong { font-size: 20px; color: #0F172A; font-variant-numeric: tabular-nums; }
.doc-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 32px;
}
.doc-foot .sig-line {
  height: 1px;
  background: #B7C0CD;
  margin-bottom: 6px;
  width: 80%;
}

@media (max-width: 767px) {
  .detail-paper { padding: 20px 18px; }
  .doc-parties { grid-template-columns: 1fr; gap: 14px; }
  .doc-foot    { grid-template-columns: 1fr; gap: 14px; }
  .doc { font-size: 13px; }
  .doc-h-title { font-size: 18px; }
}

/* PDF-viewer — обёртка над <object> с тёмной шапкой-тулбаром. */
.pdf-viewer {
  background: #E4E9F1;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pdf-viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2A3447;
  color: #E2E8F0;
  padding: 8px 14px;
  font-size: 12.5px;
}
.pdf-viewer-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pdf-viewer-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pdf-icon {
  background: #D4A017;
  color: #fff;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 3px;
}
.pdf-filename {
  font-weight: 500;
  color: #fff;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-meta { color: rgba(255, 255, 255, .5); font-size: 11.5px; }
.pdf-tool {
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  border-radius: 4px;
  color: rgba(255, 255, 255, .7);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}
.pdf-tool:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.pdf-tool svg { width: 13px; height: 13px; }
.pdf-tool-sep { width: 1px; height: 14px; background: rgba(255, 255, 255, .18); margin: 0 4px; }
.pdf-viewer-canvas {
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(15, 23, 42, .018) 12px 13px),
    #E4E9F1;
  padding: 0;
  min-height: 800px;
}
.pdf-viewer-canvas object {
  width: 100%;
  height: 800px;
  display: block;
}

@media (max-width: 767px) {
  .pdf-filename, .pdf-meta { display: none; }
  .pdf-viewer-canvas object { height: 60vh; }
}

/* ===================================================================
   Edit-страница акта: flat-form секции + sticky save-bar
   =================================================================== */
.edit-form { display: flex; flex-direction: column; gap: 18px; }
.form-section {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 22px 24px;
}
.form-section-h {
  margin: 0 0 16px;
  font-size: 12.5px;
  font-weight: 500;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-section-h .btn {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: #334155;
  font-size: 12.5px;
}
.form-section-lead {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: #64748B;
  line-height: 1.5;
}
.form-section-lead code {
  font-size: 11.5px;
  background: #F5F7FA;
  padding: 1px 5px;
  border-radius: 3px;
  color: #8A6611;
  font-family: var(--font-mono);
}

/* Свои поля шаблона — таблица cf-list (прототип) */
.cf-empty {
  padding: 24px 16px;
  text-align: center;
  color: #64748B;
  font-size: 13px;
  background: #F5F7FA;
  border-radius: 6px;
}
.cf-list {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, 130px) 70px 30px;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
}
.cf-list [data-custom-fields-target="rows"] {
  display: contents;
}
.cf-list [data-custom-fields-target="rows"] > .cf-row {
  display: contents;
}
.cf-row.cf-head {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #64748B;
  font-weight: 500;
}
.cf-row.cf-head span:nth-child(4) {
  justify-self: center;
}
.cf-row .app-input,
.cf-row .app-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 13px;
  height: auto;
  min-height: 34px;
  padding: 7px 10px;
  box-sizing: border-box;
}
.cf-required {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  background: #fff;
  margin: 0;
  justify-self: center;
}
.cf-required input {
  cursor: pointer;
  accent-color: #1E293B;
}
.cf-rm {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94A3B8;
  cursor: pointer;
  padding: 0;
}
.cf-rm svg { width: 14px; height: 14px; }
.cf-rm:hover {
  background: rgba(184, 49, 49, .1);
  color: #963131;
}

.client-box {
  background: #F5F7FA;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.client-box-name { font-weight: 600; font-size: 14.5px; color: #0F172A; }
.client-box-meta { font-size: 12.5px; color: #64748B; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* Side-card — белая плашка с тонкой рамкой. База для карточек справа
   на странице акта (Сводка / Клиент / История) и для tinted-вариантов
   .warn-card / .bad-card на edit-странице. */
.side-card {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 18px 20px;
}
.side-card h5 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: .05em;
}
/* Tinted-варианты — только перекрывают рамку и фон, остальное от side-card. */
.warn-card { border-color: rgba(212, 160, 23, .35); background: #FFFCF4; }
.bad-card  { border-color: rgba(184, 49, 49, .25);  background: #FEF7F7; }

/* Строки таблицы внутри side-card (label : value). Тонкая граница снизу
   между строками; последняя — без линии. Значение — графит, табличные цифры. */
.side-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: #334155;
  padding: 6px 0;
  border-bottom: 1px solid #E4E9F1;
  gap: 12px;
}
.side-card-row:last-child { border-bottom: 0; }
.side-card-row strong {
  color: #0F172A;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Outline-кнопка — на белом, с тонкой рамкой; используется в side-card
   (например, «Открыть карточку»). */
.btn-outline {
  background: #fff;
  color: #0F172A;
  border-color: #D2D9E3;
}
.btn-outline:hover { border-color: #1E293B; background: #fff; color: #0F172A; }

/* Маленькая высота кнопки — для side-card и таблиц. */
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* Таймлайн внутри side-card «История». Точки слева, между ними тонкая
   вертикальная линия. Активная точка (последняя) — графит. */
.timeline { display: flex; flex-direction: column; gap: 0; margin-top: 4px; }
.tl-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 4px 0;
  align-items: flex-start;
}
.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #B7C0CD;
  margin-top: 6px;
  justify-self: center;
  position: relative;
}
.tl-dot.is-active { background: #1E293B; }
.tl-row:not(:last-child) .tl-dot::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 1px;
  height: 24px;
  background: #E4E9F1;
  transform: translateX(-.5px);
}
.tl-label { font-size: 13px; color: #334155; }
.tl-time  { font-size: 11.5px; color: #64748B; margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ── Клиентская форма: field, input-row, tag-picker ──────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--g-600); }

.input-row { display: grid; gap: 12px; }
.input-row.two   { grid-template-columns: 1fr 1fr; }
.input-row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .input-row.two, .input-row.three { grid-template-columns: 1fr; }
}

.tag-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tag-option {
  display: flex; flex-direction: column; gap: 2px;
  border: 1.5px solid var(--line); border-radius: 8px;
  padding: 12px 14px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; color: var(--g-800);
  background: #fff; transition: border-color .15s;
}
.tag-option:hover { border-color: var(--line-strong); }
.tag-option:has(input:checked),
.tag-option.active { border-color: var(--g-800); background: var(--g-50); box-shadow: 0 0 0 3px rgba(30,41,59,.06); }
.tag-desc { font-size: 12px; font-weight: 400; color: var(--g-500); }
@media (max-width: 640px) {
  .tag-picker { grid-template-columns: 1fr; }
}

.form-section-hint { font-size: 12px; font-weight: 400; color: var(--g-400); margin-left: 6px; }

/* Кнопка удаления — деструктивное действие, но мягко */
.danger-btn { color: var(--bad-fg, #DC2626) !important; border-color: transparent; }
.danger-btn:hover { background: #FEF2F2; border-color: rgba(220,38,38,.2); }

/* Sticky save-bar: лежит внизу страницы, всплывает (тенью) когда есть
   несохранённые изменения. Управляется JS — добавляет класс is-dirty
   при любом изменении формы. */
.save-bar {
  position: sticky;
  bottom: 0;
  margin: 24px -28px -28px;
  background: #fff;
  border-top: 1px solid #E4E9F1;
  padding: 14px 28px;
  z-index: 30;
  transition: box-shadow .2s, background .2s;
}
.save-bar.is-dirty {
  box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, .18);
}
.save-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}
.save-bar-msg {
  font-size: 13.5px;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}
.save-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #D4A017;
  box-shadow: 0 0 0 3px rgba(212, 160, 23, .18);
  animation: pulseDot 1.8s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(212, 160, 23, .18); }
  50%      { box-shadow: 0 0 0 6px rgba(212, 160, 23, .10); }
}
.save-bar-actions { display: flex; gap: 8px; }

@media (max-width: 767px) {
  .save-bar {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    padding: 10px 16px;
  }
  .save-bar-msg { font-size: 12.5px; }
  .save-bar-actions .btn { height: 44px; font-size: 14px; }
  .save-bar-actions .btn-primary { flex: 1; }
  .save-bar-actions .btn-ghost   { display: none; }
  .save-bar-inner { gap: 10px; }
  .form-section   { padding: 18px 16px; }
  .form-section-h { font-size: 11.5px; }
  .cf-list {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .cf-list [data-custom-fields-target="rows"] {
    display: flex;
    flex-direction: column;
  }
  .cf-list [data-custom-fields-target="rows"] > .cf-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    position: relative;
    padding-bottom: 8px;
    border-bottom: 1px solid #E4E9F1;
  }
  .cf-list [data-custom-fields-target="rows"] > .cf-row:last-child { border-bottom: 0; }
  .cf-row.cf-head { display: none; }
  .cf-row-key,
  .cf-row-label { grid-column: 1 / -1; }
  .cf-row-kind { grid-column: 1 / 2; }
  .cf-required { grid-column: 2 / 3; justify-self: start; }
  .cf-rm {
    position: absolute;
    right: 0;
    top: 0;
  }
}

/* ===================================================================
   Dropdown-меню (kebab «ещё действия»). Управляется dropdown_controller.js.
   =================================================================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  min-width: 220px;
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  box-shadow: 0 12px 40px -8px rgba(15, 23, 42, .18),
              0 2px  6px         rgba(15, 23, 42, .06);
  padding: 6px 4px;
  z-index: 40;
  animation: dropdownIn .12s ease;
}
.dropdown-right { right: 0; }
.dropdown-left  { left:  0; }
/* В таблице позиционируется через fixed (dropdown_controller.js). */
.dropdown-menu.dropdown-fixed {
  position: fixed;
  z-index: 50;
}
.dropdown-up .dropdown-menu {
  top: auto;
  bottom: calc(100% + 6px);
}
.tbl tbody tr.is-dropdown-open {
  position: relative;
  z-index: 2;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 13.5px;
  color: #1E293B;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.dropdown-item:hover:not(:disabled) { background: #EEF1F6; }
.dropdown-item:disabled             { opacity: .45; cursor: not-allowed; }
.dropdown-item.danger               { color: #963131; }
.dropdown-item.danger:hover         { background: rgba(184, 49, 49, .1); }
.dropdown-item form, .dropdown-item form > button {
  display: contents;       /* button_to оборачивает в <form>, чтобы layout не ломался. */
}

.dropdown-icon {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  flex-shrink: 0;
}
.dropdown-icon svg { width: 14px; height: 14px; }
.dropdown-item.danger .dropdown-icon { color: #963131; }
.dropdown-label { flex: 1; }
.dropdown-sep   { height: 1px; background: #E4E9F1; margin: 4px 6px; }

/* Drag-handle отображается только в bottom-sheet режиме (см. mobile-блок ниже). */
.dropdown-handle { display: none; }

/* Кнопка только с иконкой — стандартный .btn, ужатый под квадрат. */
.btn.icon-only { width: 38px; padding: 0; justify-content: center; }
.btn.icon-only svg { width: 16px; height: 16px; }

/* ===================================================================
   Bottom-sheet вариант dropdown'а на мобиле.
   На <=900px меню превращается в нижний лист: full-width, поднимается
   снизу, с drag-handle сверху и затемнённым бэкдропом. Контроллер
   dropdown_controller добавляет body.dropdown-sheet-open и монтирует
   .dropdown-backdrop в <body>, чтобы блокировать скролл и ловить
   клик-снаружи.
   =================================================================== */
.dropdown-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  z-index: 60;
  animation: sheetBackdropIn .16s ease;
}
@keyframes sheetBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@media (max-width: 900px) {
  /* Затираем абсолютное позиционирование, fixed-trick из таблиц,
     любые координаты от _placeFixed — всё мимо в bottom-sheet режиме. */
  .dropdown-menu,
  .dropdown-menu.dropdown-fixed,
  .dropdown-up .dropdown-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    min-width: 0;
    max-height: 80vh;
    overflow-y: auto;
    border: 0;
    border-top: 1px solid #E4E9F1;
    border-radius: 16px 16px 0 0;
    padding: 6px 8px calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -16px 40px -10px rgba(15, 23, 42, .28);
    z-index: 70;
    animation: sheetSlideUp .22s cubic-bezier(.2, .8, .2, 1);
  }

  /* Drag-handle: полоска 36×4 по центру, как в iOS/Material нижних листах. */
  .dropdown-handle {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: #CBD2DE;
    margin: 8px auto 6px;
  }

  /* Тач-таргеты крупнее, шрифт чуть больше. */
  .dropdown-item {
    min-height: 52px;
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 8px;
    gap: 14px;
  }
  .dropdown-icon { width: 28px; height: 28px; }
  .dropdown-icon svg { width: 18px; height: 18px; }

  .dropdown-sep { margin: 6px 10px; }

  /* Блокируем скролл фона, пока лист открыт. */
  body.dropdown-sheet-open {
    overflow: hidden;
  }
}

/* ===================================================================
   Список актов — KPI, чипы, поиск, таблица (handoff ActsList).
   =================================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-row--2 {
  grid-template-columns: repeat(2, 1fr);
}
.kpi {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 16px 18px;
}
.kpi-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748B;
  font-weight: 500;
}
.kpi-value {
  font-size: 24px;
  font-weight: 600;
  color: #0F172A;
  margin-top: 6px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  font-size: 12px;
  color: #64748B;
  margin-top: 4px;
}
/* .ok-fg / .bad-fg — глобально в :root выше */

@media (max-width: 900px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #475569;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #E4E9F1;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: #CBD5E1; color: #0F172A; }
.chip.active { background: #1E293B; color: #fff; border-color: #1E293B; }
.chip .chip-count {
  font-size: 11.5px;
  color: #64748B;
  background: #EEF1F6;
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.chip.active .chip-count { background: rgba(255, 255, 255, .18); color: #fff; }
.filter-spacer { flex: 1; min-width: 8px; }
.filter-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #E4E9F1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #334155;
  cursor: default;
  font-family: inherit;
}
.filter-sort svg { width: 13px; height: 13px; color: #64748B; flex-shrink: 0; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 8px;
  padding: 6px 10px;
  width: 240px;
  font-size: 13px;
  color: #334155;
}
.search input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: #0F172A;
  font-family: inherit;
}
.search input::placeholder { color: #94A3B8; }
.search svg { width: 14px; height: 14px; color: #94A3B8; flex-shrink: 0; }

.table-wrap {
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 10px;
  /* visible — иначе kebab-меню обрезается на последних строках */
  overflow: visible;
}
.table-wrap .tbl thead th:first-child { border-top-left-radius: 9px; }
.table-wrap .tbl thead th:last-child  { border-top-right-radius: 9px; }
.table-wrap .tbl tbody tr:last-child td:first-child { border-bottom-left-radius: 9px; }
.table-wrap .tbl tbody tr:last-child td:last-child  { border-bottom-right-radius: 9px; }
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748B;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid #E4E9F1;
  font-weight: 500;
  background: #FAFBFC;
}
.tbl td {
  padding: 14px 16px;
  border-bottom: 1px solid #E4E9F1;
  color: #1E293B;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background-color .12s; }
.tbl tbody tr:hover { background: #FAFBFC; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  color: #64748B;
}
.tbl .num-mono { font-variant-numeric: tabular-nums; color: #334155; }
.client-name { font-weight: 500; color: #0F172A; }
.client-meta {
  font-size: 11.5px;
  color: #64748B;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.kebab {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.kebab:hover { background: #EEF1F6; color: #0F172A; }
.kebab svg { width: 16px; height: 16px; }

.tbl .num-warn  { color: #8A6611; }
.tbl .num-muted { color: #94A3B8; }

/* Список актов/клиентов на мобиле — card-rows (handoff @media 900px).
   Блок после десктопных .filter-row / .tbl, иначе flex-wrap и padding ячеек перебивают макет. */
@media (max-width: 900px) {
  .filter-row {
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 16px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-row .chip { flex-shrink: 0; }
  .filter-row .filter-spacer,
  .filter-row .filter-sort,
  .filter-row .search { display: none; }

  .table-wrap {
    border: 0;
    background: transparent;
    border-radius: 0;
    margin: 0 -16px;
    overflow: visible;
  }
  .table-wrap .tbl tbody tr:last-child td:first-child,
  .table-wrap .tbl tbody tr:last-child td:last-child {
    border-radius: 0;
  }

  .tbl thead { display: none; }
  .tbl,
  .tbl tbody { display: block; }
  .tbl tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #E4E9F1;
    background: #fff;
    align-items: center;
    cursor: pointer;
    transition: none;
  }
  .tbl tbody tr:hover { background: #fff; }
  .tbl tr:active { background: #F8FAFC; }
  .tbl td {
    display: block;
    padding: 0;
    border: 0;
    vertical-align: initial;
  }
  .tbl tr:last-child td { border-bottom: 0; }

  .tbl-acts td:nth-child(1) { display: none; }
  .tbl-acts td:nth-child(2) {
    grid-row: 1;
    grid-column: 1;
    font-weight: 500;
    color: #0F172A;
  }
  .tbl-acts td:nth-child(2) .client-meta { display: none; }
  .tbl-acts td:nth-child(3) {
    grid-row: 2;
    grid-column: 1;
    font-size: 12.5px;
    color: #64748B;
    text-align: left;
  }
  .tbl-acts td:nth-child(4) { display: none; }
  .tbl-acts td:nth-child(5) {
    grid-row: 1;
    grid-column: 2;
    text-align: right;
    font-weight: 600;
    color: #0F172A;
    font-size: 15px;
  }
  .tbl-acts td:nth-child(6) {
    grid-row: 2;
    grid-column: 2;
    justify-self: end;
    text-align: right;
  }
  .tbl-acts td:nth-child(7) { display: none; }

  .tbl-clients td:nth-child(1) {
    grid-row: 1;
    grid-column: 1;
    font-weight: 500;
    color: #0F172A;
  }
  .tbl-clients td:nth-child(2) { display: none; }
  .tbl-clients td:nth-child(3) {
    grid-row: 2;
    grid-column: 1;
    justify-self: start;
  }
  .tbl-clients td:nth-child(4) { display: none; }
  .tbl-clients td:nth-child(5) {
    grid-row: 1;
    grid-column: 2;
    text-align: right;
    font-weight: 600;
    color: #0F172A;
    font-size: 15px;
  }
  .tbl-clients td:nth-child(6) {
    grid-row: 2;
    grid-column: 2;
    text-align: right;
    font-size: 12.5px;
    color: #64748B;
  }
  .tbl-clients td:nth-child(7) { display: none; }
}

.empty {
  border: 1px dashed #CBD5E1;
  border-radius: 10px;
  padding: 48px 28px;
  text-align: center;
  color: #64748B;
  background: #fff;
}
.empty h4 {
  font-size: 16px;
  color: #0F172A;
  font-weight: 600;
  margin: 0 0 6px;
}
.empty p { margin: 0 0 16px; font-size: 13.5px; }

/* ===================================================================
   Status pills (.pill) — для бейджей статуса оплаты, фильтров и т.п.
   Маленькие плашки с точкой и приглушёнными цветами.
   =================================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  line-height: 1.6;
  white-space: nowrap;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.ok    { background: rgba(31, 138, 91, .1);  color: #13693F; }
.pill.ok    .pill-dot { background: #1F8A5B; }
.pill.warn  { background: rgba(212, 160, 23, .13); color: #8A6611; }
.pill.warn  .pill-dot { background: #D4A017; }
.pill.bad   { background: rgba(184, 49, 49, .1);  color: #963131; }
.pill.bad   .pill-dot { background: #B83131; }
.pill.muted { background: #EEF1F6; color: #475569; }
.pill.muted .pill-dot { background: #B7C0CD; }

/* ===================================================================
   Toast — глобальные уведомления (контроллер app/javascript/controllers/toast_controller.js).
   Появляются снизу по центру, графитовая плашка с зелёной галочкой.
   =================================================================== */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #0F172A;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 12px 40px -8px rgba(15, 23, 42, .35);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  animation: toastIn .22s cubic-bezier(.18,.89,.32,1.15);
  pointer-events: auto;
}
.toast-mark { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.toast--ok .toast-mark { color: #86E1B0; }
.toast--err .toast-mark { color: #FCA5A5; }
.toast.is-leaving {
  animation: toastOut .25s ease forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(8px); } }

/* На мобиле учитываем safe-area и BottomNav. */
@media (max-width: 767px) {
  .toast-host {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* ===================================================================
   Share-act модал
   Дизайн повторяет референс из claude-design: link-box с URL и кнопкой
   копирования, ниже — три choice-карточки (Просто ссылка / Email / Telegram)
   с радио-точкой. Активный выбор подсвечивается графитовой каймой.
   =================================================================== */
.link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #F5F7FA;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: #334155;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.link-box .link-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  font-size: 12px;
  color: #0F172A;
  font-weight: 500;
  padding: 4px 10px;
  border: 1px solid #D2D9E3;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms, background 120ms, color 120ms;
}
.copy-btn:hover { border-color: #1E293B; }
.copy-btn.is-copied {
  background: rgba(31, 138, 91, .1);
  border-color: #1F8A5B;
  color: #13693F;
}

.choice-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  font-size: 13.5px;
  color: #334155;
  cursor: pointer;
  background: #fff;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: border-color 120ms, background 120ms;
}
.choice:hover { border-color: #D2D9E3; }
.choice.is-selected {
  border-color: #1E293B;
  background: #F5F7FA;
}
.choice-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid #B7C0CD;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.choice.is-selected .choice-dot { border-color: #1E293B; }
.choice.is-selected .choice-dot::after {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #1E293B;
}
.choice-title { font-weight: 500; color: #0F172A; }
.choice-sub   { font-size: 12px; color: #64748B; margin-top: 1px; }

/* FAB на узких экранах — круг без подписи (см. также блок @media max-width 900px). */
@media (max-width: 380px) {
  .fab        { padding: 0; width: 52px; justify-content: center; }
  .fab-label  { display: none; }
}

/* ---------- Bottom-sheet модал на мобиле ----------
   Тот же .modal-overlay/.modal-window, но на ≤767px прилипает к низу,
   с drag-handle и slide-up анимацией. Безопасная зона для iOS — учли.
   Контроллер modal_controller.js не трогает разметку, только эта CSS. */
@media (max-width: 767px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-window {
    max-width: none;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: sheetIn 260ms cubic-bezier(.18,.89,.32,1.15);
  }
  .modal-head {
    position: relative;
    padding-top: 22px;
  }
  .modal-head::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 6px;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: #D2D9E3;
  }
  .modal-body {
    flex: 1;
    overflow-y: auto;
  }
  .modal-foot {
    padding: 14px 16px;
  }
  .modal-foot .btn,
  .modal-foot .btn-sm {
    flex: 1;
    justify-content: center;
  }
}
@media (max-width: 480px) {
  .modal-foot {
    flex-direction: column-reverse;
  }
  .modal-foot .btn,
  .modal-foot .btn-sm {
    width: 100%;
  }
}
@keyframes sheetIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ===================================================================
   Sidebar (прототип myakr — .sidebar / .side-brand / .side-link)
   =================================================================== */
.sidebar {
  background: #FAFBFC;
  border-right: 1px solid #E4E9F1;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  font-weight: 600;
  font-size: 14px;
  color: #0F172A;
  text-decoration: none;
}
.side-brand:hover { color: #0F172A; }
.side-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  display: inline-flex;
  flex-shrink: 0;
}
.side-section { margin-top: 10px; }
.side-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94A0B4;
  padding: 6px 10px 4px;
  font-weight: 500;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: #475569;
  text-decoration: none;
  border: 1px solid transparent;
}
.side-link:hover {
  background: #EEF1F6;
  color: #0F172A;
}
.side-link.active {
  background: #fff;
  color: #0F172A;
  border-color: #E4E9F1;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}
.side-link-icon {
  width: 16px;
  height: 16px;
  color: #64748B;
  flex-shrink: 0;
}
.side-link.active .side-link-icon { color: #1E293B; }
.side-count {
  margin-left: auto;
  font-size: 11px;
  color: #64748B;
  background: #EEF1F6;
  padding: 1px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.side-link.active .side-count {
  background: #EEF1F6;
  color: #334155;
}
.side-account {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-top: 1px solid #E4E9F1;
}
.side-account-logout { margin: 0; display: inline-flex; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1E293B;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.side-account-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
  flex: 1;
}
.side-account-name {
  font-size: 13px;
  font-weight: 500;
  color: #0F172A;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-account-mail {
  font-size: 11.5px;
  color: #64748B;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===================================================================
   App topbar (прототип myakr — .topbar / .crumbs / .topbar-search)
   =================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid #E4E9F1;
  background: rgba(251, 251, 252, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
@media (min-width: 768px) {
  .topbar { padding: 14px 28px; }
}

.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  color: #64748B;
}
.crumbs .crumb-sep { color: #B7C0CD; user-select: none; }
.crumbs .crumb-link {
  color: #64748B;
  text-decoration: none;
}
.crumbs .crumb-link:hover { color: #0F172A; }
.crumbs .crumb-muted { color: #64748B; }
.crumbs .crumb-current {
  color: #0F172A;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #E4E9F1;
  border-radius: 6px;
  padding: 6px 10px;
  width: 280px;
  max-width: 40vw;
  font-size: 13px;
  color: #334155;
}
.topbar-search svg {
  width: 14px;
  height: 14px;
  color: #94A0B4;
  flex-shrink: 0;
}
.topbar-search input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  min-width: 0;
  padding: 0;
  font-size: 13px;
  color: inherit;
}
.topbar-search input::placeholder { color: #94A0B4; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #E4E9F1;
  background: #fff;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.icon-btn:hover:not(:disabled) {
  border-color: #D2D9E3;
  color: #0F172A;
}
.icon-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 767px) {
  .topbar { padding: 12px 16px; }
  .crumbs .crumb-link,
  .crumbs .crumb-muted,
  .crumbs .crumb-sep { display: none; }
  .crumbs .crumb-current {
    font-size: 16px;
    font-weight: 600;
  }
  .topbar-search { display: none; }
}


/* ===================================================================
   Редактор шаблона — тулбар, bubble-меню, slash-меню.
   Стиль порт из прототипа (tt-* классы).
   =================================================================== */
@keyframes ttPop {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* Toolbar */
.tt-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #FAFBFC;
  position: sticky;
  top: 56px;
  z-index: 10;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  flex-wrap: wrap;
}
.tt-group { display: flex; gap: 2px; }
.tt-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 7px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
  font-size: 12.5px;
  color: var(--g-600);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background-color .12s, color .12s;
}
.tt-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.tt-btn:hover { background: var(--g-75); color: var(--g-900); }
.tt-btn.is-active {
  background: var(--g-100);
  color: var(--g-900);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.tt-btn-primary {
  color: var(--g-800);
  font-weight: 500;
  border: 1px solid var(--line) !important;
}
.tt-btn-primary:hover { border-color: var(--line-strong) !important; background: #fff; }
.tt-sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 2px;
  flex-shrink: 0;
}
.tt-hint {
  font-size: 11.5px;
  color: var(--g-400);
  white-space: nowrap;
}
.tt-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10.5px;
  font-family: inherit;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--g-700);
  margin: 0 1px;
}

/* Bubble-меню */
.tt-bubble {
  position: absolute;
  z-index: 50;
  transform: translate(-50%, calc(-100% - 8px));
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--g-900);
  color: #fff;
  padding: 4px;
  border-radius: 8px;
  box-shadow: 0 8px 24px -8px rgba(15,23,42,.4);
  pointer-events: auto;
  visibility: hidden;
  animation: ttPop .12s ease;
}
.tt-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%) rotate(45deg);
  width: 9px;
  height: 9px;
  background: var(--g-900);
  border-radius: 1px;
}
.tt-bubble-btn {
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,.78);
  font-weight: 500;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background 100ms, color 100ms;
}
.tt-bubble-btn svg { width: 13px; height: 13px; }
.tt-bubble-btn:hover     { background: rgba(255,255,255,.1); color: #fff; }
.tt-bubble-btn.is-active { background: rgba(255,255,255,.15); color: #fff; }
.tt-bubble-btn.tt-bubble-primary { color: #F2D08A; }
.tt-bubble-btn.tt-bubble-primary:hover { background: rgba(242,208,138,.15); color: #FBE3AF; }
.tt-bubble-sep {
  width: 1px; height: 16px;
  background: rgba(255,255,255,.18);
  margin: 0 2px;
  flex-shrink: 0;
}

/* Slash-меню */
.tt-slash {
  position: absolute;
  width: 340px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 32px -8px rgba(15,23,42,.18), 0 2px 8px rgba(15,23,42,.08);
  z-index: 60;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: hidden;
  animation: ttPop .14s ease;
}
.tt-slash-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--g-600);
  font-weight: 500;
}
.tt-slash-head svg { width: 13px; height: 13px; color: var(--g-500); flex-shrink: 0; }
.tt-slash-q {
  margin-left: auto;
  font-size: 12px;
  color: #B45309;
  background: rgba(212,160,23,.1);
  padding: 1px 7px;
  border-radius: 4px;
}
.tt-slash-list { overflow-y: auto; padding: 4px 0; }
.tt-slash-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 12px;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.tt-slash-row:hover, .tt-slash-row.is-active { background: var(--g-50); }
.tt-slash-key { font-size: 12px; color: #B45309; font-weight: 500; }
.tt-slash-key.is-custom { color: var(--g-700); }
.tt-slash-label { font-size: 13px; color: var(--g-800); }
.tt-slash-preview { font-size: 11.5px; color: var(--g-400); text-align: right; }
.tt-slash-foot {
  display: flex;
  gap: 10px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--g-400);
}
.tt-slash-foot kbd {
  display: inline-block;
  padding: 0 4px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--g-700);
}
.tt-slash-empty { padding: 14px 12px; font-size: 13px; color: var(--g-500); }

/* Gutter (плавающий, показывается при hover над блоком) */
.tt-gutter {
  position: absolute;
  left: 34px;
  display: none;
  align-items: flex-start;
  gap: 1px;
  z-index: 10;
}
.tt-block-add, .tt-block-handle {
  width: 20px; height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g-400);
  background: transparent;
  border: 0;
  transition: background .12s, color .12s;
  font-family: inherit;
}
.tt-block-add { cursor: pointer; }
.tt-block-handle { cursor: grab; }
.tt-block-handle:active { cursor: grabbing; }
.tt-block-add:hover, .tt-block-handle:hover { background: var(--g-75); color: var(--g-800); }
.tt-block-add svg { width: 13px; height: 13px; }

/* Контекстное меню блока */
.tt-block-menu {
  position: absolute;
  left: 0; top: 26px;
  width: 230px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px -8px rgba(15,23,42,.18), 0 2px 8px rgba(15,23,42,.08);
  padding: 6px 4px;
  z-index: 30;
  animation: ttPop .14s ease;
}
.tt-block-menu-section {
  padding: 6px 10px 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--g-400);
  font-weight: 500;
}
.tt-block-menu-row {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 6px;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.tt-block-menu-row:hover { background: var(--g-75); }
.tt-block-menu-row.danger { color: #DC2626; }
.tt-block-menu-row.danger:hover { background: #FEF2F2; }
.tt-block-menu-icon {
  width: 22px; height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px; font-weight: 600;
  color: var(--g-700);
}
.tt-block-menu-row.danger .tt-block-menu-icon { color: #DC2626; border-color: #FEE2E2; }
.tt-block-menu-icon svg { width: 12px; height: 12px; }
.tt-block-menu-label { font-size: 13px; color: var(--g-900); }
.tt-block-menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* Кнопка «+ Добавить блок» внизу холста */
.tt-add-block {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0 -4px;
  color: var(--g-400);
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, color .12s;
}
.tt-add-block:hover { color: var(--g-700); background: var(--g-50); }
.tt-add-block svg { width: 13px; height: 13px; }

/* Palette flash */
@keyframes paletteFlash {
  0%   { box-shadow: 0 0 0 0 rgba(30,41,59,.0); }
  30%  { box-shadow: 0 0 0 4px rgba(30,41,59,.22); }
  100% { box-shadow: 0 0 0 0 rgba(30,41,59,.0); }
}
.placeholder-palette.palette-flash {
  animation: paletteFlash .7s ease-out;
  border-radius: 8px;
}
