/* ЕДИНЫ CRM — фирменный стиль из презентации агентства: тёмно-синий, латунь, тёплая бумага, Georgia */
:root {
  --navy: #202C4C;
  --navy-2: #2A3860;
  --navy-3: #3B4772;
  --ink: #1D2436;
  --muted: #5E6377;
  --brass: #B0894E;
  --brass-text: #7A5B27;
  --brass-soft: #F1E6CF;
  --paper: #F6F2EA;
  --card: #FFFDF8;
  --line: #E4DED1;
  --line-2: #D6CEBD;
  --ok: #2F6B4F;
  --ok-soft: #E2EFE7;
  --warn: #8A5A12;
  --warn-soft: #F7EBD3;
  --bad: #9B3438;
  --bad-soft: #F6E1E0;
  --serif: Georgia, "Noto Serif", "PT Serif", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PT Sans", Arial, sans-serif;
  --r-s: 6px;
  --r-m: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--navy-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; color: var(--navy); margin: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 19px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.35; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--navy) 232px, transparent 232px); }
.side { background: var(--navy); color: #E9E4D8; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; }
.side .logo { height: 30px; margin: 4px 10px 22px; align-self: flex-start; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-s); color: #D9D3C4; text-decoration: none; }
.side a.nav:hover { background: var(--navy-2); color: #fff; }
.side a.nav.on { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.side .badge { margin-left: auto; background: var(--brass); color: var(--navy); font-size: 12px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--navy-3); font-size: 13px; color: #B9B4A8; }
.side .me button { background: none; border: 0; color: #E9E4D8; text-decoration: underline; padding: 0; cursor: pointer; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; gap: 12px; align-items: center; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
.top .search { flex: 1; position: relative; max-width: 560px; }
.top .search input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--paper); }
.top .search svg { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.results { position: absolute; top: 44px; left: 0; right: 0; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-m); box-shadow: 0 10px 30px rgba(32,44,76,.18); max-height: 60vh; overflow: auto; }
.results a { display: block; padding: 9px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.results a:hover, .results a:focus { background: var(--brass-soft); }
.top .mobile-logo { display: none; height: 22px; }
.page { padding: 26px 28px 60px; max-width: 1240px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.bottom-nav { display: none; }
.head-side { text-align: right; }
.head-side .chips { justify-content: flex-end; }
.head-price { font-family: var(--serif); font-size: 28px; color: var(--navy); line-height: 1.1; }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--card); color: var(--navy); padding: 8px 14px; border-radius: var(--r-s); cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--navy-3); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn.gold:hover { background: #9C7740; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.f.req > span::after { content: " *"; color: var(--brass-text); }
input.i, select.i, textarea.i { border: 1px solid var(--line-2); background: #fff; border-radius: var(--r-s); padding: 8px 10px; font-size: 15px; color: var(--ink); width: 100%; }
textarea.i { min-height: 90px; resize: vertical; }
input.i:focus, select.i:focus, textarea.i:focus { border-color: var(--navy-3); outline: none; box-shadow: 0 0 0 3px rgba(176,137,78,.25); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.hint { font-size: 12px; color: var(--muted); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.grid-form .wide { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 12px; background: #EEE9DE; color: var(--navy); font-size: 12.5px; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.gold { background: var(--brass-soft); color: var(--brass-text); }
.chip.navy { background: var(--navy); color: #fff; }

/* ---------- блоки ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols > div { min-width: 0; }
.cols > div > .panel + .panel { margin-top: 16px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.list { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
a.row:hover { background: #FBF7EE; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { text-align: right; flex-shrink: 0; }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar select.i, .toolbar input.i { width: auto; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-s); overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 6px 12px; cursor: pointer; font-size: 13.5px; color: var(--navy); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--navy); color: #fff; }

/* ---------- рельс этапов: главный элемент карточки ---------- */
.rail { margin: 4px 0 6px; }
.rail-track { display: flex; align-items: flex-start; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.rail-stop { position: relative; flex: 1 0 96px; text-align: center; background: none; border: 0; padding: 22px 4px 0; cursor: pointer; color: var(--muted); font-size: 12.5px; line-height: 1.25; }
.rail-stop::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: var(--line-2); }
.rail-stop:first-child::before { left: 50%; }
.rail-stop:last-child::before { right: 50%; }
.rail-stop::after { content: ""; position: absolute; top: 3px; left: calc(50% - 8px); width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 3px solid var(--line-2); box-sizing: border-box; }
.rail-stop.done { color: var(--navy); }
.rail-stop.done::before { background: var(--navy); }
.rail-stop.done::after { background: var(--navy); border-color: var(--navy); }
.rail-stop.cur { color: var(--navy); font-weight: 700; }
.rail-stop.cur::before { background: linear-gradient(90deg, var(--navy) 50%, var(--line-2) 50%); }
.rail-stop.cur:first-child::before { background: var(--line-2); }
.rail-stop.cur::after { background: var(--brass); border-color: var(--brass); box-shadow: 0 0 0 4px rgba(176,137,78,.25); }
.rail-stop:hover:not(.cur) { color: var(--navy-2); }
.rail-next { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 14px; border-radius: var(--r-s); background: var(--paper); border: 1px dashed var(--line-2); font-size: 13.5px; }
.rail-next.blocked { background: var(--warn-soft); border-color: #E3CFA3; }
.rail-next ul { margin: 0; padding-left: 18px; }
.rail-lost { margin-top: 6px; font-size: 13px; }

/* ---------- деньги месяца ---------- */
.money { display: grid; grid-template-columns: repeat(3, auto) 1fr; gap: 6px 28px; align-items: end; }
.money .v { font-family: var(--serif); font-size: 28px; color: var(--navy); line-height: 1.1; }
.money .l { font-size: 13px; color: var(--muted); }
.meter { grid-column: 1 / -1; position: relative; height: 12px; border-radius: 6px; background: #ECE6D9; overflow: hidden; margin-top: 10px; }
.meter .fact { position: absolute; left: 0; top: 0; bottom: 0; background: var(--navy); }
.meter .pot { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, var(--brass) 0 6px, #C9A86F 6px 12px); }
.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 2px; margin-top: 4px; }
.funnel a { min-width: 0; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; text-decoration: none; text-align: center; padding: 8px 4px; background: #EFEADF; color: var(--navy); font-size: 12px; }
.funnel a:first-child { border-radius: var(--r-s) 0 0 var(--r-s); }
.funnel a:last-child { border-radius: 0 var(--r-s) var(--r-s) 0; }
.funnel a b { display: block; font-family: var(--serif); font-size: 20px; }
.funnel a:hover { background: var(--brass-soft); }

/* ---------- задачи ---------- */
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.task input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--navy); flex-shrink: 0; }
.task .grow { flex: 1; min-width: 0; }
.task.over .when { color: var(--bad); font-weight: 600; }
.task.prio .tt::before { content: "● "; color: var(--brass); }
.task .when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- объекты ---------- */
.obj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.obj-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.obj-card:hover { border-color: var(--line-2); box-shadow: 0 6px 20px rgba(32,44,76,.08); }
.obj-card .ph { aspect-ratio: 4 / 3; background: #E9E3D6 center / cover no-repeat; position: relative; }
.obj-card .ph .chip { position: absolute; left: 10px; top: 10px; }
.obj-card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.obj-card .price { font-family: var(--serif); font-size: 19px; color: var(--navy); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-s); overflow: hidden; background: #E9E3D6; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.photo .tools button { background: rgba(255,255,255,.9); border: 0; border-radius: 4px; font-size: 11.5px; padding: 2px 6px; cursor: pointer; }
.photo.cover { outline: 3px solid var(--brass); }
.drop { display: block; border: 2px dashed var(--line-2); border-radius: var(--r-m); padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--brass); background: var(--brass-soft); }
.checks li { list-style: none; padding: 3px 0; }
.checks { padding: 0; margin: 0; }
.checks .ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.checks .no::before { content: "○ "; color: var(--warn); font-weight: 700; }
.score { font-family: var(--serif); font-size: 18px; color: var(--navy); width: 42px; text-align: right; }
.score.hi { color: var(--ok); }

/* ---------- сделки: доска ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.lane { background: #EFEADF; border-radius: var(--r-m); padding: 10px; min-height: 120px; }
.lane h3 { font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 600; margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.deal-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; text-decoration: none; color: var(--ink); margin-bottom: 8px; }
.deal-card:hover { border-color: var(--navy-3); }
.deal-card .t { font-weight: 600; font-size: 14px; }
.deal-card .m { font-family: var(--serif); color: var(--navy); }

/* ---------- лента ---------- */
.feed { display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ev .ic { width: 22px; height: 22px; border-radius: 50%; background: #EEE9DE; display: grid; place-items: center; font-size: 11px; color: var(--navy); }
.ev.k-message .ic { background: var(--brass-soft); color: var(--brass-text); }
.ev.k-call .ic { background: #E1E7F2; }
.ev.k-agent .ic { background: var(--navy); color: #fff; }
.ev.k-stage .ic { background: var(--brass); color: #fff; }
.ev .meta { font-size: 12px; color: var(--muted); }
.ev .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 8px; margin-bottom: 10px; }
.composer textarea { min-height: 42px; height: 42px; }

/* ---------- одобрения ---------- */
.appr { border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px 16px; background: var(--card); }
.appr + .appr { margin-top: 12px; }
.appr .from { font-size: 12.5px; color: var(--muted); }
.appr .msg { margin: 10px 0; }
.appr .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- окна, уведомления ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,26,44,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: var(--card); border-radius: var(--r-m); width: min(760px, 100%); padding: 22px 24px; box-shadow: 0 20px 60px rgba(20,26,44,.35); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: var(--r-s); z-index: 60; max-width: min(560px, 92vw); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); }
.toast ul { margin: 6px 0 0; padding-left: 18px; }
.menu { position: absolute; right: 0; top: 46px; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-m); box-shadow: 0 10px 30px rgba(32,44,76,.18); min-width: 200px; overflow: hidden; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 14px; cursor: pointer; }
.menu button:hover { background: var(--brass-soft); }
.rel { position: relative; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--brass); font-weight: 600; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
code.k { background: #EFEADF; padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .brand { background: var(--navy); color: #E9E4D8; padding: 8vh 7vw; display: flex; flex-direction: column; justify-content: space-between; }
.login .brand img { width: 190px; }
.login .brand p.slogan { font-family: var(--serif); font-size: 34px; line-height: 1.2; color: #FBF3E0; max-width: 12em; }
.login .brand .line { width: 54px; height: 2px; background: var(--brass); margin: 22px 0; }
.login form { align-self: center; justify-self: center; width: min(380px, 88vw); display: flex; flex-direction: column; gap: 12px; padding: 30px 0; }
.btn.yandex { justify-content: center; padding: 11px; background: #fff; border: 1px solid var(--line-2); font-size: 15px; }

@media (max-width: 1020px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .cols3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .task .when { white-space: normal; text-align: right; max-width: 42%; }
  .page-head > .chips, .head-side { width: 100%; text-align: left; }
  .head-side .chips { justify-content: flex-start; }
  .head-price { font-size: 22px; }
  .side { display: none; }
  .top { padding: 10px 16px; }
  .top .mobile-logo { display: block; }
  .page { padding: 18px 16px 96px; }
  h1 { font-size: 22px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy); z-index: 10; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; text-align: center; color: #D9D3C4; text-decoration: none; font-size: 11px; padding: 6px 2px; border-radius: var(--r-s); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
  .bottom-nav a.on { color: #fff; background: var(--navy-3); }
  .bottom-nav a .badge { position: absolute; top: 2px; right: calc(50% - 20px); background: var(--brass); color: var(--navy); font-size: 10px; font-weight: 700; border-radius: 8px; padding: 0 5px; }
  .money { grid-template-columns: repeat(3, 1fr); gap: 4px 12px; }
  .money .v { font-size: 20px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .login { grid-template-columns: 1fr; }
  .login .brand { padding: 36px 24px; }
  .login .brand p.slogan { font-size: 26px; }
  .board { grid-auto-columns: 82vw; }
  .modal { padding: 18px 16px; }
  .row .r .chip { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
