/* Imzoon — фирменный стиль: ультрамарин «чернил» и знак «i с росчерком» (бренд от 31.10.2026).
   Все цвета и компоненты — только отсюда; логотип — app/static/img/logo.svg. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: local("Inter"), local("Inter Variable"),
       url("/static/fonts/InterVariable.woff2") format("woff2");
}

:root {
  --brand: #3D2BE0;
  --brand-600: #2F1FC2;
  --brand-50: #EEECFF;
  --ok: #12A150;
  --ok-50: #E7F6EC;
  --warn: #F79009;
  --warn-50: #FEF4E6;
  --err: #F04438;
  --err-50: #FEEDEC;
  --ink: #14123A;
  --muted: #5F5C7A;
  --bg: #F7F6FB;
  --card: #FFFFFF;
  --line: #E4E2F0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 18, 58, .05), 0 4px 14px rgba(20, 18, 58, .06);
  --shadow-lg: 0 12px 32px rgba(20, 18, 58, .16);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --sidebar-w: 248px;
  --gap: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 15px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-50); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { display: flex; width: 100%; }

/* ---------- Поля форм ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-weight: 600; font-size: 14px; }
.field .req { color: var(--err); }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: 15px/1.4 var(--font);
}
.field textarea { min-height: 96px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50);
}
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--err); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--err); }
.field.has-error input:focus { box-shadow: 0 0 0 4px var(--err-50); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.code-input { letter-spacing: .4em; text-align: center; font-size: 22px; font-weight: 700; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; }
.cards { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card-link { display: block; color: inherit; transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }

/* ---------- Таблица ---------- */
.table-wrap {
  overflow-x: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 13px;
  background: #FAFBFD; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFD; }

/* ---------- Чипы статусов ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-draft, .chip-pending { background: #F2F4F7; color: #475467; }
.chip-sent, .chip-viewed { background: var(--brand-50); color: var(--brand); }
.chip-partially_signed { background: var(--warn-50); color: #B54708; }
.chip-signed { background: var(--ok-50); color: #067647; }
.chip-declined { background: var(--err-50); color: #B42318; }
.chip-cancelled { background: #F2F4F7; color: var(--muted); text-decoration: line-through; }
.chip-expired { background: #FFF1E6; color: #93370D; }

/* ---------- Модальное окно (<dialog class="modal">) ---------- */
.modal {
  border: 0; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--ink);
}
.modal::backdrop { background: rgba(11, 18, 32, .45); }
.modal-head { display: flex; align-items: center; padding: 18px 20px 0; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 20px 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Пустое состояние ---------- */
.empty { text-align: center; padding: 48px 20px; }
.empty-icon {
  width: 56px; height: 56px; border-radius: 16px; background: var(--brand-50); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.empty-title { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.empty-text { color: var(--muted); margin-bottom: 16px; }

/* ---------- Тосты ---------- */
.toast-stack {
  position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px; display: flex; gap: 10px; align-items: center;
  animation: toast-in .2s ease-out;
}
.toast-ok { background: #054F31; } .toast-err { background: #912018; } .toast-warn { background: #7A2E0E; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Шаги 1-2-3 ---------- */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; counter-reset: step; }
.step {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 600;
  counter-increment: step; min-width: 0;
}
.step::before {
  content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: var(--bg); font-size: 13px;
}
.step.is-active { border-color: var(--brand); color: var(--ink); }
.step.is-active::before { background: var(--brand); color: #fff; }
.step.is-done::before { content: "✓"; background: var(--ok); color: #fff; }
.step span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Флеш-сообщения ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-ok { background: var(--ok-50); color: #067647; }
.alert-err { background: var(--err-50); color: #B42318; }
.alert-warn { background: var(--warn-50); color: #93370D; }
.alert-info { background: var(--brand-50); color: var(--brand-600); }

/* ---------- Переключатель языка ---------- */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--card); }
.lang-switch a { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lang-switch a:hover { text-decoration: none; color: var(--ink); }
.lang-switch a.is-active { background: var(--brand); color: #fff; }

/* ---------- Кабинет: левое меню + шапка ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: block; padding: 4px 8px 20px; }
.sidebar .brand img { height: 34px; width: auto; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: #344054; font-weight: 600; font-size: 15px;
}
.nav-link svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.is-active { background: var(--brand-50); color: var(--brand); }
.nav-link.is-active svg { color: var(--brand); }
.sidebar-foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 8px 12px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .org { font-weight: 700; }
.topbar .user { font-size: 14px; color: var(--muted); }
.topbar form { margin: 0; }
.nav-toggle { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.topbar-logo { display: none; }
.page { padding: 28px; max-width: 1200px; width: 100%; }
.page-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h1 { margin: 0; }
.page-header .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.backdrop { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 85vw); z-index: 50;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(11, 18, 32, .4); z-index: 40; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar-logo { display: inline-flex; }
  .topbar-logo img { height: 28px; width: auto; }
  .topbar .org, .topbar .user { display: none; }
  .page { padding: 16px; }
  .table th, .table td { padding: 10px 12px; }
  .steps .step span { display: none; }
  .steps .step.is-active span { display: inline; }
}

/* ---------- Публичные страницы: одна колонка ---------- */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.public-header .brand { flex: none; }
.public-header .brand img { height: 30px; width: auto; display: block; }
.public-main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px 32px; }
.public-main.wide { max-width: 1040px; }
.public-footer {
  border-top: 1px solid var(--line); background: var(--card); padding: 16px; font-size: 13px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center;
}
.public-footer a { color: var(--muted); }

@media (max-width: 400px) {
  body { font-size: 14px; }
  h1 { font-size: 21px; }
  .card { padding: 16px; }
  .btn { padding: 0 14px; }
}

/* ---------- Загрузка файла (ui.file_drop) ---------- */
.file-drop { position: relative; }
.field .file-drop input.file-drop-input[type=file] {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0;
  border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; box-shadow: none;
}
.field .file-drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 136px; padding: 20px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--bg);
  font-weight: 400; font-size: 14px; color: var(--muted); transition: border-color .15s, background .15s;
}
.file-drop-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 6px;
  border-radius: 50%; background: var(--brand-50); color: var(--brand); transition: transform .15s;
}
.file-drop-title { font-weight: 600; font-size: 15px; color: var(--ink); }
.file-drop-hint { font-size: 13px; color: var(--muted); max-width: 420px; }
.file-drop-zone:hover, .file-drop.is-dragover .file-drop-zone { border-color: var(--brand); background: var(--brand-50); }
.file-drop-zone:hover .file-drop-title { color: var(--brand); }
.file-drop.is-dragover .file-drop-icon { transform: translateY(-3px); }
.file-drop.is-dragover .file-drop-card { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.file-drop.is-filled .file-drop-zone { display: none; }
.file-drop-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.file-drop-card[hidden] { display: none; }
.file-drop-thumb {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px;
  border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); color: var(--brand); overflow: hidden;
}
.file-drop-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.file-drop-thumb [hidden] { display: none; }
.file-drop-meta { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-drop-name { font-weight: 600; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop-size { font-size: 13px; color: var(--muted); }
.file-drop-actions { display: flex; gap: 8px; margin-left: auto; }
.field .file-drop-actions label.btn { font-weight: 600; }
.file-drop:has(.file-drop-input:focus-visible) .file-drop-zone,
.file-drop:has(.file-drop-input:focus-visible) .file-drop-card { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.field.has-error .file-drop-zone, .field.has-error .file-drop-card { border-color: var(--err); }
.field.has-error .file-drop-zone { background: var(--err-50); }
.field.has-error .file-drop-icon { background: var(--card); color: var(--err); }
.file-drop-remove { margin-top: 10px; }
.file-drop-remove[hidden], .file-drop-actions [hidden] { display: none; }
.file-drop:has(.file-drop-remove input:checked) .file-drop-card { opacity: .5; }
.field-error[hidden] { display: none; }
@media (max-width: 400px) {
  .field .file-drop-zone { min-height: 120px; padding: 16px 12px; }
  .file-drop-thumb { width: 52px; height: 52px; }
  .file-drop-actions { width: 100%; margin-left: 0; }
  .file-drop-actions .btn { flex: 1; }
}

/* ---------- Выпадающий список (ui.select + Imzoon.initSelect) ---------- */
/* Шеврон и иконки — SVG-маски: форма из SVG, цвет из переменных. */
.select { position: relative; width: 100%; min-width: 0; }
.select::after, .filter-search::before {
  content: ""; position: absolute; top: 50%; width: 18px; height: 18px; margin-top: -9px; pointer-events: none;
  background: var(--muted); transition: transform .15s, background .15s;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.select::after {
  right: 10px;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.select > select, .select-trigger {
  width: 100%; min-height: 44px; margin: 0; padding: 10px 34px 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font: 15px/1.4 var(--font);
  text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none; text-overflow: ellipsis;
}
.select > select:hover, .select-trigger:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.select > select:focus, .select-trigger:focus { outline: none; }
.select > select:focus-visible, .select-trigger:focus-visible, .select.is-open .select-trigger {
  border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50);
}
.select:hover::after, .select:focus-within::after { background: var(--ink); }
.select.is-open::after { transform: rotate(180deg); background: var(--brand); }
.select > select:disabled, .select-trigger:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; border-color: var(--line); }
.select:has(:disabled)::after { opacity: .5; }
.field.has-error .select-trigger { border-color: var(--err); }
.field.has-error .select-trigger:focus-visible, .field.has-error .select.is-open .select-trigger { box-shadow: 0 0 0 4px var(--err-50); }
/* с JS настоящий select остаётся в форме, но невидим: фокус с него переводится на кнопку */
.select > select.select-native {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0;
  border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; box-shadow: none; opacity: 0;
}
.select-trigger { display: flex; align-items: center; }
.select-value { display: flex; align-items: center; gap: 8px; min-width: 0; }
.select-value.is-placeholder { color: var(--muted); }
.select-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-panel {
  position: fixed; z-index: 60; margin: 0; padding: 6px; list-style: none; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  visibility: hidden; opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top center;
  transition: opacity .14s ease-out, transform .14s ease-out, visibility 0s linear .14s;
}
.select-panel.is-up { transform: translateY(4px) scale(.98); transform-origin: bottom center; }
.select.is-open .select-panel { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
.select-option {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 15px; line-height: 1.35; color: var(--ink); cursor: pointer; user-select: none;
}
.select-option + .select-option { margin-top: 2px; }
.select-option.is-active { background: var(--brand-50); }
.select-option[aria-selected=true] { color: var(--brand); font-weight: 600; }
.select-option[aria-disabled=true] { opacity: .45; cursor: default; background: none; }
.select-option .select-text { flex: 1; white-space: normal; }
.select-check { flex: none; display: inline-flex; color: var(--brand); visibility: hidden; }
.select-option[aria-selected=true] .select-check { visibility: visible; }
.select-group { padding: 10px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
/* точка статуса: цвет и кружок берём у существующего .chip-<статус> */
.chip.select-dot { flex: none; padding: 0; gap: 0; background: none; width: 8px; justify-content: center; }
.chip.select-dot::before { width: 8px; height: 8px; }
@media (max-width: 480px) {
  .select-panel { padding: 4px; }
  .select-option { min-height: 44px; padding: 10px 12px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .select-panel, .select::after { transition: none; }
}

/* ---------- Даты ---------- */
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; transition: opacity .15s; }
input[type=date]:hover::-webkit-calendar-picker-indicator { opacity: 1; }
input[type=date].is-empty:not(:focus)::-webkit-datetime-edit { color: var(--muted); }

/* ---------- Календарь (Imzoon.initDatePicker / initDateRange) ---------- */
/* Настоящие <input type="date"> остаются в форме, но невидимы: фокус с них переводится на своё поле. */
.datepicker { position: relative; width: 100%; min-width: 0; }
.datepicker > input.datepicker-native[type], .date-range.is-enhanced > input.date-range-native[type] {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0;
  border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; box-shadow: none; opacity: 0;
}
.date-range.is-enhanced { position: relative; }
.date-range.is-enhanced > .date-range-sep { display: none; }
.datepicker > input.datepicker-input[type] { padding-right: 46px; font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s; }
.datepicker > input.datepicker-input[type]:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.datepicker > input.datepicker-input[type]:focus, .datepicker.is-open > input.datepicker-input[type] {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50);
}
.datepicker > .datepicker-input::placeholder { color: var(--muted); opacity: 1; }
.datepicker > input.datepicker-input[type]:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.datepicker > input.datepicker-input[type].is-invalid, .field.has-error .datepicker > input.datepicker-input[type] { border-color: var(--err); }
.datepicker > input.datepicker-input[type].is-invalid:focus, .field.has-error .datepicker > input.datepicker-input[type]:focus { box-shadow: 0 0 0 4px var(--err-50); }
.datepicker-toggle {
  position: absolute; top: 50%; right: 4px; width: 36px; height: 36px; margin-top: -18px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted); cursor: pointer; transition: color .15s, background .15s;
}
.datepicker-toggle:hover { color: var(--ink); background: var(--bg); }
.datepicker.is-open .datepicker-toggle { color: var(--brand); }
.datepicker-toggle:disabled { opacity: .5; cursor: not-allowed; background: none; }

/* поле периода: кнопка с текстом «01.10.2026 — 31.10.2026» */
.date-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; margin: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink);
  font: 15px/1.4 var(--font); font-variant-numeric: tabular-nums; text-align: left; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.date-trigger:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.date-trigger:focus { outline: none; }
.date-trigger:focus-visible, .date-range.is-open > .date-trigger { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.date-trigger-icon { flex: none; display: inline-flex; color: var(--muted); transition: color .15s; }
.date-trigger:hover .date-trigger-icon, .date-range.is-open .date-trigger-icon { color: var(--brand); }
.date-trigger-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-trigger-value.is-placeholder { color: var(--muted); }
/* внутри рамки фильтра «Период» рамку рисует сама рамка */
.filter-period .date-trigger, .filter-period .date-range.is-open > .date-trigger { min-height: 42px; padding: 0; border: 0; background: none; box-shadow: none; }
.filter-period:has(.date-range.is-open) { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.filter-period:has(.date-range.is-enhanced) { cursor: pointer; }

/* панель */
.dp-panel {
  position: fixed; z-index: 60; display: flex; flex-direction: column; padding: 12px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  color: var(--ink); font: 14px/1.3 var(--font); cursor: default; outline: none;
  visibility: hidden; opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top left;
  transition: opacity .14s ease-out, transform .14s ease-out, visibility 0s linear .14s;
}
.dp-probe { position: fixed; top: 0; left: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; }
.dp-panel.is-up { transform: translateY(4px) scale(.98); transform-origin: bottom left; }
.is-open > .dp-panel { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
.dp-range { flex-direction: row; gap: 12px; }
.dp-months { display: flex; gap: 24px; }
.dp-month { width: 280px; }
.dp-head { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.dp-nav, .dp-nav-gap { flex: none; width: 36px; height: 36px; }
.dp-nav, .dp-title, .dp-cell, .dp-link, .dp-preset {
  margin: 0; border: 0; background: none; color: var(--ink); font: inherit; cursor: pointer;
  border-radius: var(--radius-sm); transition: background .12s, color .12s;
}
.dp-nav { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.dp-nav:hover, .dp-title:hover, .dp-cell:hover, .dp-link:hover, .dp-preset:hover { background: var(--bg); }
.dp-nav:disabled { opacity: .3; cursor: default; background: none; }
.dp-title {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; height: 36px; padding: 0 8px;
  font-weight: 600; font-size: 15px; white-space: nowrap;
}
.dp-title svg { flex: none; color: var(--muted); }
.dp-title-static { cursor: default; }
.dp-title-static:hover { background: none; }
.dp-nav:focus-visible, .dp-title:focus-visible, .dp-cell:focus-visible, .dp-link:focus-visible, .dp-preset:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

/* сетка дней: сегодня — обводкой, выбранная — заливкой, период — полосой */
.dp-grid { width: 100%; border-collapse: separate; border-spacing: 0 2px; table-layout: fixed; }
.dp-grid th { height: 28px; padding: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.dp-grid td {
  position: relative; height: 40px; padding: 0; text-align: center; font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm); cursor: pointer; user-select: none; outline: none; transition: background .1s;
}
.dp-grid td[data-iso]:hover { background: var(--bg); }
.dp-grid td.is-outside { color: var(--muted); opacity: .6; }
.dp-grid td.is-today { box-shadow: inset 0 0 0 1.5px var(--brand); color: var(--brand); font-weight: 600; }
.dp-grid td.is-in { background: var(--brand-50); border-radius: 0; }
.dp-grid td.is-in:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.dp-grid td.is-in:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.dp-grid td.is-selected, .dp-grid td.is-selected:hover { background: var(--brand); color: #fff; font-weight: 600; opacity: 1; }
.dp-grid td.is-selected.is-today { box-shadow: inset 0 0 0 2px var(--brand), inset 0 0 0 3.5px var(--card); }
.dp-grid td.is-start:not(:last-child) { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.dp-grid td.is-end:not(:first-child) { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
/* пока выбран только первый день — полоса до курсора светлее, конец не залит */
.dp-panel.is-picking td.is-in { background: color-mix(in srgb, var(--brand-50) 60%, var(--card)); }
.dp-panel.is-picking td.is-selected:not(.is-anchor) { background: var(--brand-50); color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.dp-grid td[aria-disabled=true] { color: var(--muted); opacity: .35; cursor: default; background: none; }
.dp-grid td:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; z-index: 1; }
.dp-grid td.is-selected:focus-visible { outline-color: var(--ink); }

/* выбор месяца и года сеткой */
.dp-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-top: 6px; }
.dp-cell { height: 44px; padding: 0 4px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--brand); color: var(--brand); font-weight: 600; }
.dp-cell.is-selected, .dp-cell.is-selected:hover { background: var(--brand); color: #fff; font-weight: 600; }
.dp-cell:disabled { opacity: .35; cursor: default; background: none; }

.dp-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.dp-link { min-height: 36px; padding: 0 12px; font-weight: 600; color: var(--brand); }
.dp-link-muted { color: var(--muted); font-weight: 500; }
.dp-link:disabled { opacity: .4; cursor: default; background: none; }

/* быстрые периоды: слева от календаря, на телефоне — под ним */
.dp-presets {
  order: -1; display: flex; flex-direction: column; gap: 2px; min-width: 148px;
  padding-right: 12px; border-right: 1px solid var(--line);
}
.dp-preset { min-height: 36px; padding: 0 10px; text-align: left; white-space: nowrap; }
.dp-preset[aria-pressed=true] { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.dp-preset-reset { margin-top: auto; color: var(--muted); }
@media (max-width: 480px) {
  .dp-panel { padding: 10px; }
  .dp-range { flex-direction: column; gap: 10px; }
  .dp-month { width: 100%; }
  .dp-grid td { height: 44px; font-size: 15px; }
  .dp-presets {
    order: 0; flex-direction: row; flex-wrap: wrap; gap: 6px; min-width: 0;
    padding: 10px 0 0; border-right: 0; border-top: 1px solid var(--line);
  }
  .dp-preset { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; }
  .dp-preset[aria-pressed=true] { border-color: var(--brand); }
  .dp-preset-reset { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dp-panel, .dp-grid td { transition: none; }
}

/* ---------- Фильтры списка документов ---------- */
.filters { margin-bottom: 16px; padding: 16px; container-type: inline-size; }
.filters-grid {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: minmax(160px, 1.1fr) minmax(136px, 1fr) minmax(136px, 1fr) auto auto;
}
.filter-search { position: relative; min-width: 0; }
.filter-search::before {
  left: 12px; z-index: 1;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
}
.filter-search .input { padding-left: 40px; transition: border-color .15s, box-shadow .15s; }
.filter-search .input:hover, .filter-period:hover, .date-range:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.filter-search .input:focus { border-color: var(--brand); }
.filter-period {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); transition: border-color .15s, box-shadow .15s;
}
.filter-period:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.filter-period-label { font-size: 14px; color: var(--muted); white-space: nowrap; }
.date-range { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.date-range-input {
  flex: none; width: 104px; min-width: 0; min-height: 42px; padding: 0; border: 0; background: transparent;
  color: var(--ink); font: 15px/1.4 var(--font);
}
.date-range-input:focus { outline: none; }
.date-range-sep { color: var(--muted); }
.filter-actions { display: flex; gap: 8px; }
/* «Сбросить» на широком экране — крестик (текст остаётся для экранного диктора), на узком — кнопка с текстом */
.filter-reset { width: 44px; padding: 0; }
.filter-reset:hover { background: var(--bg); color: var(--ink); }
.filter-reset-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@container (max-width: 940px) {
  .filters-grid:has(.filter-reset) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-grid:has(.filter-reset) .filter-search { grid-column: 1 / -1; }
}
@container (max-width: 860px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { grid-column: 1 / -1; }
  .filter-actions .btn { flex: 1; }
  .filter-reset { width: auto; padding: 0 14px; }
  .filter-reset-text { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}
@container (max-width: 560px) {
  .filters-grid, .filters-grid:has(.filter-reset) { grid-template-columns: minmax(0, 1fr); }
  .filter-period { display: block; padding: 0; border: 0; background: none; min-height: 0; }
  .filter-period:focus-within { box-shadow: none; }
  .filter-period-label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--ink); }
  .date-range-input { flex: 1 1 0; width: 100%; }
  .date-range {
    min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--card); transition: border-color .15s, box-shadow .15s;
  }
  .date-range:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
}

/* ---------- Шапка кабинета: выпадающие меню (организация, уведомления, профиль) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 240px; max-width: min(360px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.menu-label { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.menu-panel form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--radius-sm);
  border: 0; background: none; font: 500 14px/1.35 var(--font); color: var(--ink); text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--bg); text-decoration: none; }
.menu-item svg, .menu-item-icon { width: 16px; height: 16px; flex: none; color: var(--brand); }
.menu-item-text { display: flex; flex-direction: column; min-width: 0; }
.menu-item-text small { color: var(--muted); font-size: 12px; }
.menu-item.is-current { background: var(--brand-50); cursor: default; }
.menu-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 14px; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; color: var(--muted); transition: background .15s, color .15s;
}
.icon-btn:hover, .menu[open] > .icon-btn { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
.notif-dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--card); }
.notif-dot[hidden] { display: none; }
.notif-panel { width: 360px; padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-list { list-style: none; margin: 0; padding: 4px; }
.notif-panel .notif-list { max-height: min(420px, 70vh); overflow-y: auto; }
.notif-item a { display: flex; gap: 10px; padding: 10px; border-radius: var(--radius-sm); color: var(--ink); }
.notif-item a:hover { background: var(--bg); text-decoration: none; }
.notif-item.is-unread a { background: var(--brand-50); }
.notif-icon { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #F2F4F7; color: #475467; }
.notif-icon svg { width: 16px; height: 16px; }
.notif-icon.is-signed, .notif-icon.is-doc_signed { background: var(--ok-50); color: #067647; }
.notif-icon.is-declined { background: var(--err-50); color: #B42318; }
.notif-icon.is-opened { background: var(--brand-50); color: var(--brand); }
.notif-icon.is-expiring { background: var(--warn-50); color: #B54708; }
.notif-body { display: flex; flex-direction: column; min-width: 0; font-size: 14px; line-height: 1.35; }
.notif-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-empty { padding: 16px 14px; margin: 0; }
.org-switch-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 280px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); font-weight: 600; font-size: 14px;
}
.org-switch-btn:hover, .menu[open] > .org-switch-btn { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.org-switch-btn svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.org-switch-btn .chevron { width: 16px; height: 16px; }
.org-switch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-org { display: none; margin: 0 0 12px; }
.sidebar-org .org-switch-btn { width: 100%; max-width: none; }
.sidebar-org .org-switch-name { flex: 1; }
.sidebar-org .menu-panel { left: 0; right: auto; width: 100%; }
.sidebar-foot .nav-link { font-size: 14px; }
.nav-link.is-placeholder { cursor: default; color: var(--muted); }
.nav-link.is-placeholder:hover { background: none; }
.nav-link span small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
@media (max-width: 900px) {
  .topbar-org { display: none; }
  .sidebar-org { display: block; }
  .topbar { gap: 6px; }
  .notif .menu-panel { position: fixed; top: 60px; right: 16px; left: 16px; width: auto; max-width: none; }
}

/* ---------- Страница «Организация» ---------- */
.org-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.org-head { display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: 20px; align-items: start; }
.org-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.org-logo-img {
  width: 96px; height: 96px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted);
}
.org-logo-img img { width: 100%; height: 100%; object-fit: contain; }
.org-logo-img svg { width: 40px; height: 40px; }
.org-logo form { margin: 0; }
.org-logo-btn { position: relative; font-size: 13px; font-weight: 600; color: var(--brand); cursor: pointer; }
.org-logo-btn:hover { text-decoration: underline; }
.org-logo-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.org-logo-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.org-info h2 { font-size: 20px; margin: 8px 0 4px; }
.org-info .muted { font-size: 14px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); font: 600 12px/1.6 ui-monospace, Consolas, monospace; color: #344054; }
.chip-brand { background: var(--brand-50); color: var(--brand); }
.chip-brand::before, .chip-muted::before { display: none; }
.chip-muted { background: #F2F4F7; color: #475467; }
.org-block { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.org-block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.org-block > summary::-webkit-details-marker { display: none; }
.org-block > summary svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.org-block > summary .chevron { margin-left: auto; transition: transform .15s; }
.org-block[open] > summary .chevron { transform: rotate(180deg); }
.org-block-body { margin-top: 12px; }
.person-list { list-style: none; margin: 0; padding: 0; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person:last-child { border-bottom: 0; }
.person form { margin: 0; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.avatar svg { width: 20px; height: 20px; }
.person-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.person-main b { font-weight: 600; }
.person-main .muted { font-size: 13px; }
.person-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.person.is-off .person-main { opacity: .55; }
.invite { margin-top: 14px; }
.invite > summary { list-style: none; display: inline-flex; }
.invite > summary::-webkit-details-marker { display: none; }
.invite-form { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); max-width: 560px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.usage-card {
  border-radius: var(--radius); padding: 22px; color: #fff; box-shadow: var(--shadow);
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-600) 100%);
}
.usage-card h2 { font-size: 18px; margin-bottom: 2px; }
.usage-sub { font-size: 13px; opacity: .8; margin: 0 0 18px; }
.usage-big { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.usage-num { background: rgba(255, 255, 255, .12); border-radius: var(--radius-sm); padding: 12px; }
.usage-num b { display: block; font-size: 30px; line-height: 1.1; font-weight: 800; }
.usage-num span { font-size: 13px; opacity: .85; }
.usage-rows { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.usage-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, .18); }
.usage-rows b { font-weight: 700; }
.usage-note { font-size: 12px; opacity: .85; margin: 14px 0 0; line-height: 1.45; }
@media (max-width: 1100px) {
  .org-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .org-head { grid-template-columns: 1fr; }
  .org-logo { flex-direction: row; text-align: left; }
  .org-logo-img { width: 72px; height: 72px; }
  .person-side { margin-left: 52px; }
}
