:root {
  --bg: #e7e6df;
  --card: #f4f3ee;
  --field: #e8e7e1;
  --field-hover: #e2e1da;
  --line: #dcdbd3;
  --ink: #1f1f1f;
  --muted: #8b8a84;
  --faint: #b5b4ad;
  --dark: #3a3a3a;
  --dark-2: #474746;
  --dark-3: #555553;
  --on-dark: #f3f3f1;
  --on-dark-muted: #a9a9a5;
  --accent: #efec6d;
  --accent-ink: #1f1f1f;
  --black: #262626;
  --danger: #c0412f;
  --danger-dark: #ff8f7d;
  --radius-card: 28px;
  --radius-field: 22px;
  --shadow: 0 18px 40px -24px rgba(30, 30, 25, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.4 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }

.shell { max-width: 1480px; margin: 0 auto; padding: 18px 20px 48px; }

/* ------------------------------------------------------------------ навигация */
.topbar {
  display: flex; align-items: center; gap: 10px;
  background: #2f2f2f; color: #eee; border-radius: 40px; padding: 8px 10px 8px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding-right: 8px; }
.brand img { height: 22px; filter: invert(1); }
.brand span { font-size: 13px; color: #a5a5a0; letter-spacing: .02em; }
.circle-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid #4a4a48; background: transparent; color: #ddd;
}
.nav { display: flex; gap: 4px; margin-left: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav button {
  border: 0; background: transparent; color: #dcdcd8; padding: 0 20px; height: 44px; border-radius: 999px;
  font-size: 14px; white-space: nowrap;
}
.nav button:hover { background: #3c3c3b; }
.nav button.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.nav button:disabled { color: #6d6d69; cursor: default; background: transparent; }
.top-right { display: flex; gap: 8px; align-items: center; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px;
}

/* ------------------------------------------------------------------ сетка страницы */
.page { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 22px; margin-top: 22px; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.right-col { position: sticky; top: 16px; align-self: start; }

/* ------------------------------------------------------------------ шапка договора */
.hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 4px 0; }
.hero-badge {
  width: 58px; height: 58px; border-radius: 50%; background: var(--card); display: grid; place-items: center;
  font-weight: 600; font-size: 18px; border: 1px solid var(--line);
}
.hero h1 { margin: 0; font-weight: 400; font-size: 46px; letter-spacing: -0.035em; line-height: 1; }
.hero h1 small { font-size: 18px; letter-spacing: 0; color: #5d5c57; margin-left: 6px; }
.hero-actions { margin-left: auto; display: flex; gap: 8px; }
.pill-btn {
  height: 50px; padding: 0 24px; border-radius: 999px; border: 1px solid #cfcec6; background: transparent;
  font-size: 14px; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none;
}
.pill-btn:hover { background: var(--card); }
.pill-btn.yellow { background: var(--accent); border-color: var(--accent); }
.pill-btn.yellow:hover { filter: brightness(.97); }
.pill-btn.black { background: var(--black); color: #fff; border-color: var(--black); }
.pill-btn.small { height: 40px; padding: 0 18px; font-size: 13px; }
.pill-btn:disabled { opacity: .45; cursor: not-allowed; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; padding: 18px 4px 4px; }
.fact span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.fact b { font-weight: 500; font-size: 15px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fact b.empty { color: var(--faint); font-weight: 400; }

/* ------------------------------------------------------------------ шаги */
.stepper { display: flex; align-items: center; background: var(--card); border-radius: 999px; padding: 6px; gap: 6px; }
.steps { display: flex; flex: 1; min-width: 0; gap: 4px; }
.step {
  flex: 1; height: 48px; border: 0; background: transparent; border-radius: 999px; font-size: 13px; color: var(--faint);
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; padding: 0 10px;
}
.step.current { color: var(--ink); font-weight: 500; }
.step.done { background: var(--black); color: #fff; }
.stepper .pill-btn { height: 48px; flex: none; }

/* ------------------------------------------------------------------ карточки и поля */
.card { background: var(--card); border-radius: var(--radius-card); padding: 22px 22px 24px; }
.card, .dark, .field { scroll-margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.card-head .hint { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.icon-circle {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--field); color: #444;
}
.grid { display: grid; gap: 14px 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.field label, .label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px 18px; }
.control {
  display: flex; align-items: center; gap: 10px; background: var(--field); border-radius: var(--radius-field);
  min-height: 52px; padding: 0 18px; border: 1.5px solid transparent; transition: background .15s, border-color .15s;
}
.control:hover { background: var(--field-hover); }
.control:focus-within { border-color: #2f2f2f; background: #fff; }
.control input, .control select, .control textarea {
  border: 0; background: transparent; outline: none; width: 100%; min-width: 0; font-size: 14px; padding: 14px 0;
}
.control textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
.control .suffix { color: var(--muted); font-size: 14px; }
.control svg.i { color: #8e8d87; width: 18px; height: 18px; }
.control.big input { font-size: 22px; letter-spacing: .06em; font-weight: 500; }
.field .error-text { color: var(--danger); font-size: 12px; margin: 6px 0 0 18px; }
.field.invalid .control { border-color: var(--danger); }
.field .note { color: var(--muted); font-size: 12px; margin: 6px 0 0 18px; }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid transparent; background: var(--field); border-radius: 999px; height: 42px; padding: 0 18px;
  font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--field-hover); }
.chip.on { background: var(--black); color: #fff; }
.chip.yellow.on { background: var(--accent); color: var(--accent-ink); }
.chip:disabled { color: var(--faint); background: transparent; border-color: var(--line); cursor: not-allowed; }
.chip small { font-size: 11px; opacity: .7; }

/* проект */
.lookup { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.lookup-line { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 2px; }
.lookup-line b { font-weight: 500; font-size: 17px; }
.lookup-line span { display: block; color: var(--muted); font-size: 13px; }
.ok-dot { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; flex: none; }
.warn-box { background: #fff7d6; border-radius: 18px; padding: 12px 16px; font-size: 13px; line-height: 1.45; }
.warn-box b { font-weight: 600; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice {
  text-align: left; border: 1.5px solid var(--line); background: transparent; border-radius: 18px; padding: 10px 16px;
  display: flex; gap: 10px; align-items: center;
}
.choice:hover { background: #fff; }
.choice.on { border-color: var(--black); background: #fff; }
.choice span { color: var(--muted); font-size: 12px; }

/* подрядчик */
.search-wrap { position: relative; }
.dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 22px; z-index: 20;
  box-shadow: var(--shadow); padding: 6px; max-height: 340px; overflow: auto;
}
.option {
  width: 100%; border: 0; background: transparent; border-radius: 16px; display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; text-align: left;
}
.option:hover, .option.hl { background: var(--field); }
.option .icon-circle { width: 36px; height: 36px; }
.option b { font-weight: 500; display: block; }
.option span { font-size: 12px; color: var(--muted); }
.person { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.person .initials { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); display: grid;
  place-items: center; font-weight: 600; }
.person b { font-size: 18px; font-weight: 500; display: block; }
.tags { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 12px; background: var(--field); border-radius: 999px; padding: 3px 10px; color: #55544f; }
.person .pill-btn { margin-left: auto; }
.requisites {
  margin-top: 12px; background: var(--field); border-radius: 20px; padding: 14px 18px; white-space: pre-wrap;
  font-size: 13px; line-height: 1.5; color: #3a3a37; max-height: 220px; overflow: auto;
}

/* ------------------------------------------------------------------ правая тёмная панель */
.banner {
  display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: 999px; padding: 8px 8px 8px 10px;
}
.banner .icon-circle { background: transparent; border: 1px solid var(--line); }
.banner-text { flex: 1; min-width: 0; }
.banner-text b { font-weight: 500; display: block; }
.banner-text span { font-size: 12px; color: var(--muted); }
.banner .pill-btn { height: 46px; }
.banner.alert { border-radius: 26px; }

.dark { background: var(--dark); color: var(--on-dark); border-radius: var(--radius-card); padding: 20px 20px 22px; }
.dark .card-head h2 { color: var(--on-dark); font-weight: 400; font-size: 22px; }
.dark .card-head .sub { font-size: 12px; color: var(--on-dark-muted); }
.dark .icon-circle { background: var(--dark-2); color: #ddd; }
.dark .icon-circle.light { background: #f3f3f1; color: var(--ink); }
.dark .icon-circle.yellow { background: var(--accent); color: var(--accent-ink); }
.rows { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 14px; align-items: flex-start; }
.row .icon-circle { margin-top: 2px; }
.row-body { min-width: 0; flex: 1; }
.row-body span { display: block; font-size: 12px; color: var(--on-dark-muted); }
.row-body b { display: block; font-weight: 400; font-size: 16px; line-height: 1.35; }
.row-body .acc { color: var(--accent); }
.row-body small { display: block; color: var(--on-dark-muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.inner { background: var(--dark-2); border-radius: 22px; padding: 16px 18px; margin-top: 16px; }
.inner h3 { margin: 0 0 10px; font-size: 15px; font-weight: 500; }
.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.todo li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: #dededa; cursor: pointer; }
.todo li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none;
  transform: translateY(-2px); }
.todo li.err::before { background: var(--danger-dark); }
.todo li:hover { color: #fff; }
.files { display: flex; flex-direction: column; gap: 8px; }
.file {
  display: flex; align-items: center; gap: 12px; background: var(--dark-3); border-radius: 18px; padding: 10px 14px;
  color: var(--on-dark); text-decoration: none; font-size: 13px; word-break: break-all;
}
.file:hover { background: #605f5c; }
.file .icon-circle { width: 36px; height: 36px; }
.big-btn {
  width: 100%; height: 60px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 16px; font-weight: 500; margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.big-btn:disabled { background: var(--dark-3); color: #8f8f8b; cursor: not-allowed; }
.empty-note { color: var(--on-dark-muted); font-size: 14px; padding: 8px 0 4px; }

/* последние договоры / реестр */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item b { font-weight: 500; display: block; }
.list-item span { font-size: 12px; color: var(--muted); }
.list-item .when { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.list-item a { color: inherit; }
.status { font-size: 12px; border-radius: 999px; padding: 4px 10px; background: var(--accent); white-space: nowrap; }

.table { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 14px; }
.table th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 0 14px; }
.table td { background: var(--field); padding: 12px 14px; vertical-align: middle; }
.table td:first-child { border-radius: 18px 0 0 18px; }
.table td:last-child { border-radius: 0 18px 18px 0; }
.table td small { display: block; color: var(--muted); font-size: 12px; }
.dl { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; background: var(--card); align-items: center;
  justify-content: center; color: var(--ink); margin-right: 4px; }
.dl:hover { background: var(--accent); }
.table-wrap { overflow-x: auto; }

/* модальное окно */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 30, 28, .45); display: grid; place-items: center; z-index: 50;
  padding: 16px; }
.modal { background: var(--card); border-radius: 30px; padding: 24px; width: min(640px, 100%); max-height: 92vh; overflow: auto;
  box-shadow: var(--shadow); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--black); color: #fff;
  border-radius: 999px; padding: 12px 22px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ телефон и планшет */
@media (max-width: 1080px) {
  .page { grid-template-columns: 1fr; }
  .right-col { position: static; }
}
@media (max-width: 680px) {
  .shell { padding: 10px 12px 32px; }
  .topbar { border-radius: 26px; flex-wrap: wrap; }
  .brand span, .top-right .circle-btn { display: none; }
  .top-right { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; margin-left: 0; }
  .hero h1 { font-size: 34px; }
  .hero-actions { margin-left: 0; width: 100%; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .step:not(.current) span.lbl { display: none; }
  .step.current { flex: 3; }
  .card, .dark { padding: 18px 16px 20px; border-radius: 24px; }
  .banner { border-radius: 24px; flex-wrap: wrap; }
}
