/* Кабинет договоров AVIGRID — визуальный язык avigrid.ru: Manrope, белый фон, тёмно-зелёный акцент,
   спокойные плашки, радиус 16px, без декоративных эффектов. Токены сняты с боевого сайта 29.09.2026. */
:root {
  --c-primary: #53944C;          /* основной зелёный сайта */
  --c-primary-dark: #244F3E;     /* тёмно-зелёный акцент заголовков и кнопок */
  --c-primary-deep: #0F6E56;
  --c-text: #2c2c2c;
  --c-text-soft: #736464;
  --c-muted: #9a8f8f;
  --c-line: #E5E7E5;
  --c-plate: #F5F7F9;
  --c-plate-action: #EBF4F3;
  --c-white: #ffffff;
  --c-warn-bg: #FFF6E5; --c-warn: #8A5A00;
  --c-err-bg: #FDECEC; --c-err: #A12A2A;
  --c-ok-bg: #EAF6EA; --c-ok: #2F6B2A;
  --c-info-bg: #EEF3F8; --c-info: #2C4A6B;
  --r: 16px; --r-sm: 10px;
  --gap: 32px;
  --font: "Manrope", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--c-text); background: var(--c-white); font-size: 15px; line-height: 1.5; }
a { color: var(--c-primary-deep); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding: 24px 16px 48px; min-height: 60vh; }
.topbar { border-bottom: 1px solid var(--c-line); background: var(--c-white); position: sticky; top: 0; z-index: 10; }
.topbar__in { display: flex; align-items: center; gap: 20px; min-height: 64px; flex-wrap: nowrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--c-text); }
.brand img { display: block; height: 30px; width: auto; }
.brand__sub { font-weight: 600; color: var(--c-text-soft); font-size: 14px; border-left: 1px solid var(--c-line); padding-left: 12px; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 16px; flex: 1 1 auto; min-width: 0; }
.nav a { text-decoration: none; color: var(--c-text-soft); font-weight: 600; padding: 6px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav .btn { white-space: nowrap; }
.nav a.is-active, .nav a:hover { color: var(--c-primary-dark); border-color: var(--c-primary); }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--c-text-soft); margin-left: auto; flex-shrink: 0; }
.userbox__name { font-weight: 700; color: var(--c-text); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox__role { background: var(--c-plate); padding: 2px 8px; border-radius: 999px; }
.footer { border-top: 1px solid var(--c-line); color: var(--c-muted); font-size: 13px; padding: 16px 0; }
.inline { display: inline; margin: 0; }
.link-muted { color: var(--c-text-soft); }

.h1 { font-size: 26px; font-weight: 800; color: var(--c-primary-dark); margin: 0 0 8px; letter-spacing: -0.01em; }
.h2 { font-size: 19px; font-weight: 700; color: var(--c-primary-dark); margin: 24px 0 10px; }
.h3 { font-size: 15px; font-weight: 700; margin: 18px 0 8px; color: var(--c-text); }
.muted { color: var(--c-text-soft); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.card { background: var(--c-white); border: 1px solid var(--c-line); border-radius: var(--r); padding: 24px; margin-bottom: 20px; }
.card--narrow { max-width: 460px; margin: 40px auto; }
.card--plate { background: var(--c-plate); border-color: transparent; }
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .topbar__in { flex-wrap: wrap; } .nav { flex-wrap: wrap; } }
@media (max-width: 640px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .topbar__in { gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; min-height: 0; }
  .brand__sub { display: none; }
  .brand { margin-right: auto; }
  .userbox { gap: 8px; }
  .userbox__name, .userbox__role { display: none; }
  .nav { order: 3; width: 100%; justify-content: space-between; gap: 10px; border-top: 1px solid var(--c-line); padding-top: 8px; }
  .nav .btn { white-space: nowrap; }
  .nav a { font-size: 14px; }
  .nav .btn--sm { padding: 6px 10px; }
  .h1 { font-size: 22px; }
  .main { padding-top: 16px; }
}

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--c-text-soft); }
.field input, .field select, .field textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--c-line); border-radius: var(--r-sm); background: var(--c-white);
  color: var(--c-text); width: 100%; min-height: 42px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--c-primary); outline-offset: 0; border-color: var(--c-primary); }
.field.is-error input, .field.is-error select, .field.is-error textarea { border-color: var(--c-err); background: #fffafa; }
.field .hint { font-size: 12px; color: var(--c-muted); }
.field .src { font-size: 12px; color: var(--c-primary-deep); background: var(--c-plate-action); border-radius: 999px; padding: 1px 8px; display: inline-block; margin-left: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--c-primary); }
.req::after { content: " *"; color: var(--c-err); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; padding: 10px 18px;
  border-radius: 999px; border: 1px solid var(--c-primary-dark); background: var(--c-primary-dark); color: #fff; cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--c-primary-deep); border-color: var(--c-primary-deep); }
.btn--primary { background: var(--c-primary); border-color: var(--c-primary); }
.btn--primary:hover { background: #4C834C; border-color: #4C834C; }
.btn--ghost { background: transparent; color: var(--c-primary-dark); border-color: var(--c-line); }
.btn--ghost:hover { background: var(--c-plate); }
.btn--danger { background: transparent; color: var(--c-err); border-color: var(--c-err); }
.btn--danger:hover { background: var(--c-err-bg); }
.btn--sm { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 20px; }

.flash { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: 14px; }
.flash--ok { background: var(--c-ok-bg); color: var(--c-ok); }
.flash--warn { background: var(--c-warn-bg); color: var(--c-warn); }
.flash--error { background: var(--c-err-bg); color: var(--c-err); }
.flash--info { background: var(--c-info-bg); color: var(--c-info); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--c-line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-soft); font-weight: 700; background: var(--c-plate); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table tr:hover td { background: #fafbfa; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--c-plate); color: var(--c-text-soft); white-space: nowrap; }
.chip--draft { background: var(--c-plate); }
.chip--review { background: var(--c-warn-bg); color: var(--c-warn); }
.chip--ready { background: var(--c-ok-bg); color: var(--c-ok); }
.chip--signed { background: var(--c-plate-action); color: var(--c-primary-deep); }
.chip--cancelled { background: var(--c-err-bg); color: var(--c-err); }
.chip--archived { background: #eee; color: #666; }

.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }
.steps li a { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; min-height: 40px; border-radius: 999px; border: 1px solid var(--c-line); text-decoration: none; color: var(--c-text-soft); font-size: 13px; font-weight: 600; background: var(--c-white); }
.steps li a.is-active { background: var(--c-primary-dark); color: #fff; border-color: var(--c-primary-dark); }
.steps li a .n { display: inline-block; min-width: 20px; height: 20px; border-radius: 999px; background: var(--c-plate); color: var(--c-text-soft); font-size: 12px; text-align: center; line-height: 18px; }
.steps li a.is-active .n { background: rgba(255,255,255,.2); color: #fff; }
.steps li a .n { line-height: 20px; }
.steps li a .badge { font-size: 12px; padding: 0 6px; border-radius: 999px; }
.badge--err { background: var(--c-err-bg); color: var(--c-err); }
.badge--warn { background: var(--c-warn-bg); color: var(--c-warn); }

.section { border-top: 1px solid var(--c-line); padding-top: 16px; margin-top: 20px; }
.section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.cond[hidden] { display: none !important; }
.issue-list { margin: 0; padding: 0; list-style: none; }
.issue-list li { padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: 6px; font-size: 14px; }
.issue-list li.error { background: var(--c-err-bg); color: var(--c-err); }
.issue-list li.warning { background: var(--c-warn-bg); color: var(--c-warn); }
.issue-list li.info { background: var(--c-info-bg); color: var(--c-info); }
.issue-list li a { color: inherit; }
.kv { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--c-text-soft); }
.kv dd { margin: 0; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 8px; } }

.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat a { display: block; padding: 14px 16px; border-radius: var(--r); background: var(--c-plate); text-decoration: none; color: var(--c-text); }
.stat a.is-active { outline: 2px solid var(--c-primary); }
.stat b { display: block; font-size: 24px; color: var(--c-primary-dark); }
.stat span { font-size: 13px; color: var(--c-text-soft); }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; font: inherit; padding: 10px 12px; border: 1px solid var(--c-line); border-radius: 999px; }

.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pages figure { margin: 0; border: 1px solid var(--c-line); border-radius: var(--r-sm); overflow: hidden; background: var(--c-plate); }
.pages img { width: 100%; height: auto; display: block; }
.pages figcaption { font-size: 12px; color: var(--c-text-soft); padding: 6px 8px; }
.preview-frame { width: 100%; height: 80vh; border: 1px solid var(--c-line); border-radius: var(--r-sm); }

.lines-table td { white-space: normal; }
.lines-table input { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--c-line); border-radius: 8px; min-height: 36px; display: block; }
.lines-table select { font: inherit; padding: 6px 8px; border: 1px solid var(--c-line); border-radius: 8px; min-height: 36px; display: block; width: 100%; }
.lines-table td.num .small, .lines-table td .small { white-space: normal; }
.lines-table .num input { text-align: right; }
.dropdown { position: relative; }
.dropdown__list { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--c-line); border-radius: var(--r-sm); box-shadow: 0 8px 24px rgba(0,0,0,.08); max-height: 320px; overflow: auto; }
.dropdown__item { padding: 8px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--c-line); }
.dropdown__item:hover { background: var(--c-plate-action); }
.dropdown__item small { display: block; color: var(--c-text-soft); }
.rep-card { border: 1px solid var(--c-line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; background: #fff; }
.rep-card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
details.card summary { cursor: pointer; font-weight: 700; color: var(--c-primary-dark); }
.diff { font-size: 13px; }
.diff .old { color: var(--c-err); text-decoration: line-through; }
.diff .new { color: var(--c-ok); font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
