/* AI-контроль сделок: визуальный язык, близкий к Bitrix24. Без внешних ресурсов. */
:root {
  --bg: #eef2f4;
  --card: #fff;
  --text: #333;
  --muted: #5f6975;
  --line: #dfe5ea;
  --nav: #1f3a57;
  --nav-2: #2a4a6b;
  --link: #2067b0;
  --accent: #2fc6f6;
  --ok: #bbed21;
  --ok-h: #aedd12;
  --good: #1b6b1f; --good-bg: #e4f3e5;
  --mid: #9a4a00;  --mid-bg: #fff0dc;
  --bad: #b3261e;  --bad-bg: #fde8e7;
  --info: #0b5f86; --info-bg: #dff4fc;
  --grey-bg: #e9edf0;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 300; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
ul { margin: 0; padding-left: 20px; }
li + li { margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 3px; }
.side :focus-visible { outline-color: #fff; }

/* Каркас */
.app { display: flex; min-height: 100vh; }
.side { width: 232px; flex: none; background: var(--nav); color: #fff; padding: 16px 12px; }
.brand { display: block; color: #fff; font-size: 20px; font-weight: 300; padding: 4px 10px 18px; letter-spacing: .2px; }
.brand b { font-weight: 700; color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; color: rgba(255,255,255,.85); }
.nav a:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: #e8f0f7; color: var(--nav); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-height: 48px; padding: 6px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.top form { margin: 0; }
.who { display: flex; align-items: center; gap: 6px; }
.content { padding: 24px; max-width: 1280px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sub { color: var(--muted); margin-top: 2px; }

/* Карточки и сетки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(31,58,87,.06); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 2px rgba(31,58,87,.06); }
.kpi .v { font-size: 28px; font-weight: 300; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Кнопки и формы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 16px; font: inherit; font-weight: 600; color: var(--text); background: #fff; border: 1px solid #c6cdd3; border-radius: 6px; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f4f6f8; text-decoration: none; }
.btn-primary { background: var(--ok); border-color: var(--ok); }
.btn-primary:hover { background: var(--ok-h); border-color: var(--ok-h); }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn-icon { min-width: 30px; padding: 3px 6px; }
form.inline { display: inline; margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit; color: var(--text); background: #fff; border: 1px solid #c6cdd3; border-radius: 6px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.diff-up { color: #1b7a3a; } .diff-down { color: #b42318; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--link); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 0; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--link); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters .f { flex: 1 1 200px; min-width: 0; }
.filters .f-btn { display: flex; gap: 8px; }

/* Таблицы */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #f6f8f9; white-space: nowrap; }
tbody tr:hover { background: #f8fafb; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.card .table-wrap { margin: 0 -18px; }
.card .table-wrap th:first-child, .card .table-wrap td:first-child { padding-left: 18px; }
.card .table-wrap th:last-child, .card .table-wrap td:last-child { padding-right: 18px; }

/* Бейджи и оценки */
.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--grey-bg); color: #3f4852; white-space: nowrap; }
.st-done, .risk-low { background: var(--good-bg); color: var(--good); }
.st-error, .risk-high { background: var(--bad-bg); color: var(--bad); }
.st-running { background: var(--info-bg); color: var(--info); }
.risk-mid { background: var(--mid-bg); color: var(--mid); }
.env { background: var(--info-bg); color: var(--info); text-transform: uppercase; letter-spacing: .4px; }
.score { display: inline-block; min-width: 40px; padding: 1px 8px; border-radius: 6px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-good { background: var(--good-bg); color: var(--good); }
.score-mid { background: var(--mid-bg); color: var(--mid); }
.score-bad { background: var(--bad-bg); color: var(--bad); }
.score-xl { font-size: 36px; font-weight: 300; padding: 4px 16px; border-radius: 10px; }

/* Полоски */
.bar { height: 8px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.rows { display: grid; gap: 10px; }
.row-bar { display: grid; grid-template-columns: 56px 1fr 120px; gap: 10px; align-items: center; }
.row-bar.wide { grid-template-columns: minmax(0, 2fr) minmax(80px, 1fr) 56px; }

/* Сообщения */
.flash, .notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--info-bg); color: #08455f; border: 1px solid #b6e3f6; }
.notice.warn { background: var(--mid-bg); color: #6e3500; border-color: #f2cf9f; }
.notice.err { background: var(--bad-bg); color: #8a1b15; border-color: #f2b9b5; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty p { margin-bottom: 14px; font-size: 15px; }

/* Карточка сделки */
.criteria { display: grid; gap: 14px; }
.criteria .head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.criteria p { color: var(--muted); margin-top: 4px; }
.result-top { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 12px; }
.timeline { list-style: none; padding: 0; display: grid; gap: 10px; }
.timeline li { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid #b7c0c8; border-radius: 6px; background: #fff; }
.timeline .client { border-left-color: var(--accent); background: #f5fbfe; }
.timeline .mgr { border-left-color: var(--nav-2); }
.timeline .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 4px; }

/* Вход и ошибка */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg); }
.login { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px rgba(31,58,87,.1); padding: 32px 28px; }
.login .brand { color: var(--nav); text-align: center; padding: 0 0 4px; font-size: 26px; }
.login .sub { text-align: center; margin-bottom: 22px; }
.login .field { margin-bottom: 14px; }
.login .btn { width: 100%; }
.err-code { font-size: 64px; font-weight: 300; color: var(--nav); line-height: 1; margin-bottom: 8px; }
.login.err-box { text-align: center; }
.login.err-box p { margin-bottom: 18px; }

/* Настройки */
.agent { border-top: 1px solid var(--line); padding: 14px 0; }
.agent:first-of-type { border-top: 0; padding-top: 0; }
.agent .head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; margin-bottom: 10px; }
.agent .head b { font-size: 15px; }
.agent form > .form-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stage-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 16px; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
fieldset legend { padding: 0; font-weight: 600; margin-bottom: 8px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.narrow { max-width: 220px; margin-bottom: 16px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .side { width: 100%; padding: 8px 12px; }
  .brand { padding: 2px 6px 6px; font-size: 18px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 6px 10px; }
  .top { padding: 6px 12px; }
  .content { padding: 16px 12px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .row-bar { grid-template-columns: 52px 1fr 100px; }
  h1 { font-size: 22px; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
