:root {
  --bg: #f5f6f3; --surface: #ffffff; --surface2: #eef1ed; --text: #1c2420; --muted: #66726b; --border: #dde2dd;
  --accent: #2c7a58; --accent-ink: #ffffff; --accent-soft: #e0f0e8; --warn: #b26a00; --warn-soft: #fdf0d9;
  --bad: #b3322d; --bad-soft: #fbe5e3; --info: #2b5fa8; --info-soft: #e3edf9; --radius: 10px; --shadow: 0 1px 2px rgba(20,30,25,.06), 0 4px 14px rgba(20,30,25,.05);
  --font: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121714; --surface: #1a211d; --surface2: #222b26; --text: #e6ece8; --muted: #93a099; --border: #2c3631;
    --accent: #4fb88a; --accent-ink: #0d1713; --accent-soft: #1d3a2d; --warn: #e0a64a; --warn-soft: #3a2f17;
    --bad: #ef7b74; --bad-soft: #3d1f1d; --info: #7fb0ee; --info-soft: #1c2c42; --shadow: none;
  }
}
@font-face { font-family: "Noto Sans"; src: url("/static/fonts/NotoSans-Regular.ttf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("/static/fonts/NotoSans-Bold.ttf"); font-weight: 700; font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; cursor: pointer; } a:hover { text-decoration: underline; }
button { font: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.hidden { display: none !important; }

/* каркас */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav a.item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.nav a.item:hover { background: var(--surface2); text-decoration: none; }
.nav a.item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav .grow { flex: 1; }
.main { min-width: 0; padding: 22px 26px 60px; max-width: 1280px; width: 100%; }
.pagehead { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* карточки и сетки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.top { align-items: flex-start; } .spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.empty { padding: 18px; text-align: center; color: var(--muted); background: var(--surface2); border-radius: 8px; }

/* элементы форм */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.field { margin-bottom: 10px; } .field input, .field select { width: 100%; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 13px; cursor: pointer; min-height: 38px; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; } .btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: var(--bad); } .btn.small { padding: 4px 9px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* чипы */
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--accent-soft); color: var(--accent); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.tag-fact { color: var(--accent); } .tag-hyp { color: var(--warn); } .tag-gap { color: var(--muted); }

/* таблица */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--surface2); position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; } tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface2); }
td.name { min-width: 180px; font-weight: 600; max-width: 320px; overflow-wrap: anywhere; }

/* прогресс */
.bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; min-width: 90px; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .4s; }

/* вкладки */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 700; }

/* модальные окна и уведомления */
.overlay { position: fixed; inset: 0; background: rgba(10,15,12,.5); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; padding: 20px; width: min(720px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal.wide { width: min(1040px, 100%); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 80; max-width: 90vw; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 14px; background: var(--info-soft); color: var(--info); } .notice.warn { background: var(--warn-soft); color: var(--warn); } .notice.bad { background: var(--bad-soft); color: var(--bad); } .notice.ok { background: var(--accent-soft); color: var(--accent); }
pre.draft { white-space: pre-wrap; word-wrap: break-word; font: inherit; background: var(--surface2); padding: 12px; border-radius: 8px; margin: 6px 0; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--surface2); border-radius: var(--radius); padding: 10px; min-height: 80px; } .col h3 { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.dealcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px; margin-bottom: 8px; cursor: pointer; }
.login { max-width: 360px; margin: 14vh auto; }
.bottomnav { display: none; }
.sticky-actions { position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 5; }

.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.pstat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.pnum { font-size: 32px; font-weight: 700; line-height: 1.1; color: var(--accent); } .plab { font-weight: 600; margin-top: 2px; } .phint { margin-top: 6px; }
.scorerow { flex-wrap: wrap; gap: 6px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .main { padding: 14px 14px 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 40; overflow-x: auto; }
  .bottomnav a { flex: 1 0 auto; min-width: 68px; text-align: center; padding: 8px 6px 10px; font-size: 11px; color: var(--muted); } .bottomnav a b { display: block; font-size: 17px; }
  .bottomnav a.active { color: var(--accent); font-weight: 700; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { margin-top: 8px; }
  .tablewrap.cards table, .tablewrap.cards thead, .tablewrap.cards tbody, .tablewrap.cards tr, .tablewrap.cards td { display: block; width: 100%; }
  .tablewrap.cards thead { display: none; }
  .tablewrap.cards tr { border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .tablewrap.cards td { border: 0; padding: 2px 0; } .tablewrap.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  .modal { padding: 16px; border-radius: 12px; } .overlay { padding: 2vh 8px; }
  h1 { font-size: 19px; }
}

/* К обращению */
.outreach { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 14px; align-items: start; }
.outreach-list { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.olist-item { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; color: inherit; text-decoration: none; }
.olist-item.active, .olist-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.ocontact { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.ocontact.sel { border-color: var(--accent); border-width: 2px; }
.chip.bad { background: var(--bad-soft, #fbe3e3); color: var(--bad); }
@media (max-width: 860px) { .outreach { grid-template-columns: minmax(0, 1fr); } .outreach-list { position: static; max-height: 320px; } }

.odetail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1180px) { .odetail-grid { grid-template-columns: minmax(0, 1fr); } }
.olist-item .small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* проверка людей и контактов */
.stack.tight > * + * { margin-top: 3px; }
.vcard { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.vcard.first { border-color: var(--accent); border-width: 2px; }
.vgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 760px) { .vgrid { grid-template-columns: minmax(0, 1fr); } }
.evlist { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.warnText { color: var(--warn); }
