/* Сигнал — интерфейс арендатора. Свой небольшой CSS без фреймворков. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;
  --border: #e3e8ef;
  --border-strong: #cfd6e0;
  --ink: #0f1a2a;
  --ink-2: #2f3b4d;
  --muted: #5f6b7c;
  --faint: #8c97a6;

  --primary: #1f4fd1;
  --primary-hover: #1a43b3;
  --primary-soft: #edf2ff;
  --primary-ink: #ffffff;

  --hot: #e4572e;
  --hot-soft: #fff1eb;
  --success: #12805c;
  --success-soft: #e7f6ef;
  --warning: #a85b06;
  --warning-soft: #fff6e0;
  --danger: #c4320a;
  --danger-soft: #fdeeea;
  --info: #0b6e8c;
  --info-soft: #e6f6fb;

  --g-design: #3b5bdb;
  --g-funding: #7048e8;
  --g-tender: #0c8599;
  --g-seed: #e8590c;
  --g-install: #2b8a3e;
  --g-contract: #087f5b;
  --g-stale: #7b8794;
  --g-canceled: #b42318;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --topbar: 60px;
  --sidebar: 244px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-head: 'Geologica', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01';
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; margin: 0; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.ic { flex: none; vertical-align: -3px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #1f4fd1 0%, #3b7bf6 60%, #e4572e 140%);
}
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 16.5px; letter-spacing: -.02em; }
.brand-sub { display: block; font-size: 11px; color: var(--faint); font-weight: 500; letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2);
  font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--surface-3); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a .count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600;
  display: inline-grid; place-items: center; background: var(--surface-3); color: var(--ink-2);
}
.nav a .count.alert { background: var(--hot); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 4px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--border); }

.scrim { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.btn.burger { display: none; }
.tenant-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tenant-name { font-family: var(--font-head); font-weight: 600; font-size: 15px; }
.tenant-name-m { display: none; }
.tenant-switch select { padding: 5px 28px 5px 10px; height: 32px; font-size: 13px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topsearch { position: relative; }
.topsearch input[type=search] { width: 280px; padding-left: 34px; height: 36px; background: var(--surface-2); }
.topsearch .ic { position: absolute; left: 10px; top: 9px; color: var(--faint); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu {
  position: absolute; right: 0; top: 42px; min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40;
}
.menu .menu-head { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu a, .menu button {
  display: flex; gap: 8px; align-items: center; width: 100%; padding: 8px 10px; border-radius: 6px; color: var(--ink-2);
  background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); text-decoration: none; }

.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .grow { flex: 1 1 360px; min-width: 0; }
.page-head p { color: var(--muted); margin: 4px 0 0; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

/* ---------- сетки ---------- */
.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)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h h2 { font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-h .right select { width: auto; max-width: 200px; height: 32px; font-size: 13px; }
.card-b { padding: 16px 18px; }
.card-b.tight { padding: 8px 10px; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card.flat { box-shadow: none; }
.card.accent-hot { border-color: #f7c6b4; box-shadow: 0 0 0 3px var(--hot-soft); }

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-family: var(--font-head); font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi .hint { font-size: 12.5px; color: var(--faint); }
.kpi.hot .value { color: var(--hot); }
.kpi a.value { color: var(--ink); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; color: var(--ink); }
.list a.title:hover { color: var(--primary); }
.list .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2);
  font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.success:hover { filter: brightness(.94); }
.btn.hot { background: var(--hot); border-color: var(--hot); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f1c4b8; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12.5px; border-radius: 6px; }
.btn.icon { width: 36px; padding: 0; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.htmx-request .btn[type=submit], .btn.htmx-request { opacity: .65; cursor: progress; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a, .seg button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; color: var(--ink-2); font-weight: 500; border: 0; background: none; font: inherit; cursor: pointer; }
.seg a + a { border-left: 1px solid var(--border-strong); }
.seg a:hover { background: var(--surface-3); text-decoration: none; }
.seg a.on { background: var(--ink); color: #fff; }

/* ---------- формы ---------- */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=date], input[type=tel], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  color: var(--ink); font: 14px/1.4 var(--font); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.5; }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6b7c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 79, 209, .14); outline: none; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: -3px; margin: 0; }
input[type=file] { font: inherit; max-width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 500; font-size: 13.5px; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.field .errors, .errorlist { color: var(--danger); font-size: 12.5px; margin: 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { flex: 1 1 180px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.radio-cards ul, ul.radio-cards { list-style: none; margin: 0; padding: 0; }
.radio-cards label { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; font-weight: 500; }
.radio-cards label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.w-num { max-width: 90px; }
.w-sm { max-width: 140px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; }
.filters .field { flex: 1 1 150px; }
.filters .field.q { flex: 2 1 260px; }
.filters .field > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.filters .check { height: 38px; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.chip:hover { text-decoration: none; background: var(--surface-3); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .n { font-size: 11.5px; opacity: .75; }

/* ---------- бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  white-space: nowrap; background: var(--surface-3); color: var(--ink-2); line-height: 1; vertical-align: middle;
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-3); color: var(--muted); }
.badge.hot { background: var(--hot); color: #fff; }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--ink-2); }
.badge.stage { background: color-mix(in srgb, var(--gc) 11%, white); color: var(--gc); }
.stage-design { --gc: var(--g-design); } .stage-funding { --gc: var(--g-funding); } .stage-tender { --gc: var(--g-tender); }
.stage-seed { --gc: var(--g-seed); } .stage-install { --gc: var(--g-install); } .stage-contract { --gc: var(--g-contract); }
.stage-stale { --gc: var(--g-stale); } .stage-canceled { --gc: var(--g-canceled); }

.score {
  --s: 0; --c: var(--faint);
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--s) * 1%), var(--surface-3) 0);
  font: 600 14px/1 var(--font-head); color: var(--ink); position: relative;
}
.score::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.score span { position: relative; }
.score.hi { --c: var(--hot); } .score.mid { --c: var(--primary); } .score.lo { --c: var(--faint); }
.score.sm { width: 34px; height: 34px; font-size: 12.5px; }
.score.sm::before { inset: 3px; }
.score.lg { width: 76px; height: 76px; font-size: 24px; }
.score.lg::before { inset: 6px; }
.scorepill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font: 600 12px/1 var(--font-head); }
.scorepill.hi { background: var(--hot-soft); color: var(--hot); }
.scorepill.mid { background: var(--primary-soft); color: var(--primary); }
.scorepill.lo { background: var(--surface-3); color: var(--muted); }

/* ---------- таблицы ---------- */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
.table-wrap.scroll { max-height: calc(100vh - 250px); min-height: 240px; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.t th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-weight: 600; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.t td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: #fafbfd; }
.t tr.is-hot td:first-child { box-shadow: inset 3px 0 0 var(--hot); }
.t tr.is-hot td { background: #fffaf7; }
.t .title-cell { min-width: 280px; max-width: 520px; }
.t .title-cell a { color: var(--ink); font-weight: 500; }
.t .title-cell a:hover { color: var(--primary); }
.t .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.t td.r, .t th.r { text-align: right; }
.t td.c, .t th.c { text-align: center; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }

/* ---------- канбан ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); min-height: 160px; }
.col-h { padding: 12px 14px 10px; display: flex; align-items: center; gap: 8px; border-top: 3px solid var(--gc); border-radius: var(--radius) var(--radius) 0 0; }
.col-h h3 { font-size: 14px; }
.col-h .range { font-size: 12px; color: var(--muted); }
.col-h .n { margin-left: auto; font: 600 12.5px var(--font-head); background: var(--surface); border-radius: 10px; padding: 2px 8px; color: var(--ink-2); }
.col-b { padding: 4px 10px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); display: block; color: var(--ink); }
.kcard:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: 0 4px 12px rgba(16, 24, 40, .08); }
.kcard.is-hot { border-color: #f6c3b0; background: linear-gradient(180deg, #fff7f3 0, #fff 60%); }
.kcard .kt { font-weight: 500; font-size: 13.5px; line-height: 1.35; }
.kcard .km { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.col-empty { font-size: 12.5px; color: var(--faint); text-align: center; padding: 18px 6px; }
.side-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }

/* ---------- воронка ---------- */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 40px; gap: 12px; align-items: center; font-size: 13.5px; color: var(--ink); }
.funnel-row:hover { text-decoration: none; }
.funnel-row .bar { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.funnel-row .bar i { display: block; height: 100%; border-radius: 5px; background: var(--gc); min-width: 2px; }
.funnel-row .nm { display: flex; gap: 6px; align-items: baseline; }
.funnel-row .nm small { color: var(--faint); }
.funnel-row .cnt { text-align: right; font: 600 14px var(--font-head); }
.funnel-row.side { opacity: .75; }

/* ---------- лента событий ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ''; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--gc, var(--primary)); }
.timeline .when { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline .what { font-weight: 500; margin: 2px 0; }
.timeline .src { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- причины оценки ---------- */
.reasons { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.reasons li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.reasons .d { flex: none; min-width: 42px; text-align: center; font: 600 12px/22px var(--font-head); border-radius: 6px; height: 22px; }
.reasons .plus .d { background: var(--success-soft); color: var(--success); }
.reasons .minus .d { background: var(--danger-soft); color: var(--danger); }
.reasons .info .d { background: var(--surface-3); color: var(--muted); }

/* ---------- определения ---------- */
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.party { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 16px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.party:last-child { border-bottom: 0; }
.party .role { color: var(--muted); font-size: 13px; font-weight: 500; padding-top: 1px; }
.party .org + .org { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.party .org-name { font-weight: 500; }
.party .org-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 3px; }
.party.missing .role { color: var(--faint); }

/* ---------- сообщения ---------- */
.toasts { position: fixed; right: 20px; top: 72px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in .18s ease-out;
}
.toast .ic { margin-top: 1px; }
.toast.success { border-left: 4px solid var(--success); } .toast.success .ic { color: var(--success); }
.toast.error { border-left: 4px solid var(--danger); } .toast.error .ic { color: var(--danger); }
.toast.info { border-left: 4px solid var(--info); } .toast.info .ic { color: var(--info); }
.toast.warning { border-left: 4px solid var(--warning); } .toast.warning .ic { color: var(--warning); }
.toast .x { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--faint); padding: 0; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; }
.note .ic { margin-top: 1px; }
.note.info { background: var(--info-soft); color: #084f66; }
.note.warning { background: var(--warning-soft); color: #7a4204; }
.note.success { background: var(--success-soft); color: #0b5d43; }
.note.danger { background: var(--danger-soft); color: #8f2306; }
.note.neutral { background: var(--surface-3); color: var(--ink-2); }
.note strong { font-weight: 600; }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .ic { color: var(--faint); margin-bottom: 8px; }
.empty h3 { color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 460px; margin: 0 auto 12px; font-size: 13.5px; }
.empty.sm { padding: 18px 14px; }

/* ---------- черновики ---------- */
.draft { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.draft + .draft { margin-top: 12px; }
.draft-h { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-2); border-radius: 10px 10px 0 0; }
.draft-h .who { font-size: 12.5px; color: var(--muted); }
.draft-b { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.draft-b textarea { font-size: 13.5px; min-height: 180px; }
.draft-body-ro { white-space: pre-wrap; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; max-height: 280px; overflow: auto; }
.draft-f { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); }
.draft-f .reject { display: flex; gap: 6px; margin-left: auto; flex: 1 1 260px; justify-content: flex-end; }
.draft-f .reject input { height: 30px; max-width: 220px; font-size: 13px; }
.gate { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: #fff8e8; border: 1px solid #f6dfa6; color: #6d4206; font-size: 13.5px; }
.gate .ic { color: #b7791f; }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

details.more > summary { cursor: pointer; color: var(--primary); font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary .ic { transform: rotate(180deg); }

.link-box { display: flex; gap: 6px; align-items: center; }
.link-box input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side {
  background: radial-gradient(1200px 600px at -10% 110%, rgba(228, 87, 46, .35), transparent 60%),
              radial-gradient(900px 500px at 120% -10%, rgba(59, 123, 246, .45), transparent 60%), #0e1a33;
  color: #e6ecf7; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h1 { color: #fff; font-size: 34px; line-height: 1.15; max-width: 520px; letter-spacing: -.02em; }
.auth-side p { color: #b6c2d9; font-size: 15px; max-width: 480px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #d5ddec; }
.auth-points .ic { color: #8fb1ff; margin-top: 2px; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card .lead-in { color: var(--muted); margin-bottom: 24px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn.primary { width: 100%; height: 42px; font-size: 15px; }
.auth-alt { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------- кабинет проектировщика ---------- */
.portal-top { background: #0e1a33; color: #fff; }
.portal-top .in { max-width: 1080px; margin: 0 auto; padding: 18px 20px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.portal-top .who { margin-left: auto; text-align: right; font-size: 13px; color: #b6c2d9; }
.portal-top .who strong { color: #fff; display: block; font-size: 14px; }
.portal-wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 48px; }
.portal-hero { padding: 22px 0 6px; }

/* ---------- BPMN ---------- */
.bpmn-box { height: 460px; border-top: 1px solid var(--border); background: #fcfdff; position: relative; }
.bpmn-box .bpmn-placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; }
.bpmn-box .djs-palette { display: none; }

/* ---------- адаптив ---------- */
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-wide { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topsearch input[type=search] { width: 200px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 26, 42, .4); z-index: 55; }
  .btn.burger { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topsearch { display: none; }
  .content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 28px 20px; }
  .auth-side h1 { font-size: 24px; }
  .auth-points { display: none; }
  .tenant-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-meta { display: none; }
  .radio-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .hide-m { display: none !important; }
  h1 { font-size: 20px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 24px; }
  .card-h, .card-b { padding-left: 14px; padding-right: 14px; }
  .list > li { padding-left: 14px; padding-right: 14px; }
  .funnel-row { grid-template-columns: 112px minmax(0, 1fr) 32px; gap: 8px; font-size: 12.5px; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .party { grid-template-columns: minmax(0, 1fr); padding: 12px 14px; }
  .table-wrap.scroll { max-height: none; }
  .board { grid-auto-columns: 84%; }
  .side-cols { grid-template-columns: minmax(0, 1fr); }
  .tenant-switch { display: none; }
  .tenant-name-m { display: inline; }
  .page-actions { width: 100%; }
  .draft-f .reject { margin-left: 0; justify-content: flex-start; }
  .draft-f .reject input { max-width: none; }
  .t .title-cell { min-width: 220px; }
  .filters { padding: 12px; }
  .toasts { right: 16px; left: 16px; top: 68px; }
  .bpmn-box { height: 340px; }
  .portal-top .who { margin-left: 0; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Схема сбора лидов (главная) ---------- */
.c-green { --c: var(--success); --c-soft: var(--success-soft); }
.c-yellow { --c: #d08700; --c-soft: var(--warning-soft); }
.c-red { --c: var(--danger); --c-soft: var(--danger-soft); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--border-strong)); flex: none; }
.sn-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); align-self: center; }
.sn-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sn-tag { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font: 600 12px/1 var(--font); vertical-align: 2px; }

.sn-lights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sn-lightcard { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--border-strong)); border-radius: var(--radius); color: var(--ink); box-shadow: var(--shadow); }
.sn-lightcard:hover { text-decoration: none; border-color: var(--c, var(--border-strong)); }
.sn-lightcard .dot { margin-top: 5px; width: 12px; height: 12px; }

.sn-board { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; overscroll-behavior-x: contain; }
.sn-lane { display: grid; grid-template-columns: 44px max-content; min-width: 100%; width: max-content; border-top: 1px solid var(--border-strong); position: relative; scroll-margin-top: calc(var(--topbar) + 12px); }
.sn-lane:first-child { border-top: 0; }
.sn-lane-h { writing-mode: vertical-rl; transform: rotate(180deg); font: 600 13px/1 var(--font-head); color: var(--ink-2); display: flex; align-items: center; justify-content: center; padding: 12px 0; background: var(--surface-3); border-right: 1px solid var(--border-strong); letter-spacing: .01em; position: sticky; left: 0; z-index: 2; }
.sn-lane.c-red .sn-lane-h, .sn-lane.c-yellow .sn-lane-h, .sn-lane.c-green .sn-lane-h { box-shadow: inset -4px 0 0 var(--c); }
.sn-flow { display: flex; flex-wrap: nowrap; align-items: center; padding: 18px 16px 30px; }
.sn-arrow { width: 22px; height: 2px; background: var(--ink-2); position: relative; flex: none; margin: 0 2px; }
.sn-arrow::after { content: ''; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--ink-2); border-right: 0; }

.sn-step { width: 150px; min-height: 112px; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1.5px solid var(--ink-2); border-radius: 10px; background: var(--surface); color: var(--ink); position: relative; flex: none; transition: box-shadow .15s, transform .15s; }
.sn-step:hover { text-decoration: none; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.sn-step.c-red, .sn-step.c-yellow { border-color: var(--c); background: var(--c-soft); }
.sn-step.c-green { box-shadow: inset 0 -3px 0 var(--c); }
.sn-num { font: 600 11.5px/1 var(--font); color: var(--muted); }
.sn-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.sn-val { margin-top: auto; font: 600 20px/1.1 var(--font-head); letter-spacing: -.02em; }
.sn-step.c-red .sn-val { color: var(--c); }
.sn-cap { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

.sn-light { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 92px; text-align: center; flex: none; }
.sn-ring { width: 40px; height: 40px; border-radius: 50%; border: 3px double var(--c, var(--faint)); background: var(--c-soft, var(--surface)); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--c, var(--border-strong)); }
.sn-lname { font-size: 11.5px; line-height: 1.25; color: var(--ink-2); }
.sn-light .sn-cap { font-weight: 600; color: var(--c, var(--muted)); }

.sn-gate { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 120px; text-align: center; flex: none; }
.sn-diamond { width: 34px; height: 34px; transform: rotate(45deg); border: 1.5px solid var(--ink-2); background: var(--surface); display: grid; place-items: center; margin: 4px 0; }
.sn-diamond .ic { transform: rotate(-45deg); stroke-width: 3; }
.sn-q { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--ink-2); }
.sn-exits { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); line-height: 1.35; }

.sn-event { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 92px; text-align: center; color: var(--ink-2); flex: none; }
a.sn-event:hover { text-decoration: none; color: var(--primary); }
.sn-circle { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--hot); display: grid; place-items: center; color: var(--hot); background: var(--surface); }
.sn-event.e-start .sn-circle { border-color: var(--hot); }
.sn-event.e-end .sn-circle { border: 4px solid var(--ink); }
.sn-ename { font-size: 12px; font-weight: 600; }

.sn-split { display: flex; align-items: center; flex: none; }
.sn-branches { display: flex; flex-direction: column; gap: 10px; padding-left: 14px; border-left: 2px solid var(--ink-2); margin-left: 6px; }
.sn-branch { display: flex; flex-direction: column; gap: 4px; position: relative; }
.sn-branch::before { content: ''; position: absolute; left: -14px; top: 50%; width: 12px; height: 2px; background: var(--ink-2); }
.sn-blabel { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.sn-bflow { display: flex; align-items: center; flex-wrap: nowrap; }

.sn-handoff { position: absolute; left: 60px; bottom: 6px; font-size: 11.5px; color: var(--success); display: flex; align-items: center; gap: 4px; font-weight: 500; }

@media (max-width: 1180px) { .sn-lights { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .sn-lights { grid-template-columns: minmax(0, 1fr); }
  .sn-board { overflow-x: visible; }
  .sn-lane { grid-template-columns: minmax(0, 1fr); width: auto; }
  .sn-lane-h { writing-mode: horizontal-tb; transform: none; justify-content: flex-start; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border-strong); position: static; }
  .sn-flow, .sn-bflow { flex-direction: column; align-items: stretch; }
  .sn-flow { padding: 14px 14px 34px; gap: 0; }
  .sn-arrow { width: 2px; height: 18px; margin: 2px auto; }
  .sn-arrow::after { right: -4px; top: auto; bottom: -1px; border: 5px solid transparent; border-top: 7px solid var(--ink-2); border-bottom: 0; }
  .sn-step, .sn-gate, .sn-light, .sn-event { width: 100%; }
  .sn-step { min-height: 0; }
  .sn-split { flex-direction: column; align-items: stretch; }
  .sn-branches { margin-left: 0; }
}
.sn-wrap { position: relative; }
.sn-wrap.more::after { content: ''; position: absolute; top: 1px; right: 1px; bottom: 1px; width: 48px; pointer-events: none; border-radius: 0 var(--radius) var(--radius) 0; background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.95)); }
.sn-scrollhint { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; }
.sn-scrollhint[hidden] { display: none; }
