:root {
  --bg: #f7f5f1;
  --surface: #ffffff;
  --ink: #22212b;
  --muted: #64626f;
  --line: #e8e4dd;
  --lav: #ebe6fb;
  --lav-deep: #d3c9f5;
  --peach: #fde7da;
  --mint: #ddf1e6;
  --butter: #f8efcb;
  --sky: #deebf9;
  --rose: #fbe2e9;
  --danger: #b4474b;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 500 15px/1.5 "Manrope", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: clip; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
ol, ul { list-style: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 22px; border-radius: 14px; border: 0; font-weight: 700; cursor: pointer; transition: transform .2s var(--ease), background-color .2s; white-space: nowrap; }
.btn--ink { background: var(--ink); color: #fff; }
.btn--ink:hover { transform: translateY(-1px); }
.btn--soft { background: var(--lav); }
.btn--soft:hover { background: var(--lav-deep); }
.btn--sm { height: 40px; padding: 0 16px; border-radius: 11px; font-size: 14px; }
.btn--block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--lav); color: var(--ink); }
:focus-visible { outline: 3px solid var(--lav-deep); outline-offset: 2px; }

.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.logo__mark { display: inline-grid; grid-template-columns: repeat(3, 8px); gap: 3px; }
.logo__mark i { width: 8px; height: 20px; border-radius: 4px; }
.logo__mark i:nth-child(1) { background: var(--lav-deep); }
.logo__mark i:nth-child(2) { background: #f6c9b0; transform: translateY(-4px); }
.logo__mark i:nth-child(3) { background: #b9e2cc; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(600px 400px at 85% 10%, var(--peach), transparent 70%),
  radial-gradient(600px 500px at 10% 90%, var(--lav), transparent 70%), var(--bg); }
.login__card { width: min(400px, 100%); background: var(--surface); border-radius: 28px; padding: 36px 32px 28px; box-shadow: 0 30px 60px -40px rgba(34, 33, 43, .35); }
.login__card h1 { font-size: 30px; letter-spacing: -.035em; margin-top: 22px; }
.login__card .muted { margin: 6px 0 24px; }
.login .err { color: var(--danger); font-size: 13px; font-weight: 700; margin: -4px 0 12px; }
.login .err:empty { display: none; }
.hint { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }
.back { display: block; text-align: center; margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.back:hover { color: var(--ink); }

.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 0; border-radius: 12px; background: var(--bg); padding: 12px 13px; font-weight: 600; font-size: 15px;
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .2s; resize: vertical;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; box-shadow: inset 0 0 0 2px #9d8fe0; }

/* ---------- app ---------- */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 14px clamp(16px, 3vw, 32px); background: rgba(247, 245, 241, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 0 14px; height: 42px; color: var(--muted); }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font-weight: 600; color: var(--ink); }
.bar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu__list { position: absolute; right: 0; top: 46px; background: var(--surface); border-radius: 14px; padding: 6px; min-width: 220px; box-shadow: 0 20px 40px -20px rgba(34, 33, 43, .35); }
.menu__list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 9px; font-weight: 600; cursor: pointer; }
.menu__list button:hover { background: var(--bg); }

.main { padding: 8px clamp(16px, 3vw, 32px) 48px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.4fr); gap: 12px; }
.kpi { border-radius: 20px; padding: 18px 20px; min-width: 0; }
.kpi__t { font-size: 13px; font-weight: 700; color: var(--muted); }
.kpi__v { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__s { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi--src { background: var(--surface); }
.srcbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 12px 0 10px; gap: 2px; }
.srcbar span { display: block; height: 100%; }
.srclegend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.srclegend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; }
.bg-lav { background: var(--lav); } .bg-sky { background: var(--sky); } .bg-butter { background: var(--butter); }
.bg-mint { background: var(--mint); } .bg-rose { background: var(--rose); } .bg-peach { background: var(--peach); }
.c-site { background: #f2b493; } .c-tg { background: #8fc0ee; } .c-call { background: #8fd0ad; } .c-kwork { background: #b3a4ee; } .c-avito { background: #e9cf6c; }

.tools { display: flex; align-items: center; gap: 16px; margin: 22px 0 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: none; padding: 8px 16px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.is-on { background: var(--ink); color: #fff; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { border: 0; background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.fchip.is-on { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.stage { background: rgba(255, 255, 255, .5); border-radius: 20px; padding: 10px; min-height: 60vh; transition: background-color .2s, box-shadow .2s; }
.stage.is-over { background: var(--lav); box-shadow: inset 0 0 0 2px #9d8fe0; }
.stage__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 8px 12px; }
.stage__t { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.stage__t i { width: 10px; height: 10px; border-radius: 4px; }
.stage__n { font-size: 13px; color: var(--muted); font-weight: 700; }
.stage__sum { font-size: 12px; color: var(--muted); font-weight: 700; padding: 0 8px 10px; margin-top: -8px; }
.stage__list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.stage__empty { font-size: 13px; color: var(--muted); text-align: center; padding: 22px 8px; border: 1.5px dashed var(--line); border-radius: 14px; }

.lead {
  background: var(--surface); border-radius: 14px; padding: 12px 13px; cursor: pointer; text-align: left; width: 100%; border: 0;
  box-shadow: 0 1px 0 rgba(34, 33, 43, .04), 0 6px 14px -10px rgba(34, 33, 43, .2);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.lead:hover { transform: translateY(-2px); box-shadow: 0 12px 22px -14px rgba(34, 33, 43, .35); }
.lead.is-drag { opacity: .4; }
.lead.is-flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px #9d8fe0; } 100% { box-shadow: 0 1px 0 rgba(34, 33, 43, .04), 0 6px 14px -10px rgba(34, 33, 43, .2); } }
.lead__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.tag { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 7px; white-space: nowrap; }
.tag--site { background: var(--peach); } .tag--tg { background: var(--sky); } .tag--call { background: var(--mint); } .tag--kwork { background: var(--lav); } .tag--avito { background: var(--butter); }
.lead__ago { font-size: 11px; color: var(--muted); font-weight: 700; }
.lead__name { font-weight: 800; font-size: 15px; line-height: 1.3; }
.lead__type { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 1px; }
.lead__foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.lead__budget { font-weight: 800; font-size: 14px; }
.late { font-size: 11px; font-weight: 800; color: var(--danger); background: var(--rose); padding: 3px 8px; border-radius: 7px; }

/* ---------- list ---------- */
.list { background: var(--surface); border-radius: 20px; overflow-x: auto; }
.list table { width: 100%; border-collapse: collapse; min-width: 820px; }
.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 14px 16px; border-bottom: 1.5px solid var(--line); }
.list td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 600; vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--bg); }
.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 8px; white-space: nowrap; }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer__shade { position: absolute; inset: 0; background: rgba(34, 33, 43, .28); animation: fade .25s both; }
.drawer__panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); display: flex; flex-direction: column; animation: slide .35s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 8px; }
.drawer__head h2 { font-size: 22px; letter-spacing: -.02em; }
.drawer__body { padding: 8px 24px 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.stages button { border: 0; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--bg); color: var(--muted); }
.stages button.is-on { color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.contact-links { display: flex; gap: 6px; flex-wrap: wrap; min-height: 45px; align-items: center; }
.contact-links a { font-size: 13px; font-weight: 700; padding: 8px 12px; border-radius: 10px; background: var(--sky); }
.contact-links a:hover { background: var(--lav-deep); }
.extras { font-size: 13px; color: var(--muted); font-weight: 600; margin: -4px 0 14px; }
.extras:empty { display: none; }
.notes h3 { font-size: 15px; margin: 6px 0 10px; }
.note-add { display: flex; gap: 8px; margin-bottom: 14px; }
.note-add input { flex: 1; min-width: 0; border: 0; border-radius: 11px; background: var(--bg); padding: 0 12px; height: 40px; font-weight: 600; }
.note-add input:focus { outline: none; box-shadow: inset 0 0 0 2px #9d8fe0; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; display: grid; gap: 12px; }
.timeline li { position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--lav-deep); box-shadow: 0 0 0 3px var(--surface); }
.timeline time { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.drawer__foot { position: sticky; bottom: 0; margin-top: auto; background: var(--surface); padding: 16px 0 20px; display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); margin-top: 20px; }

.snack { position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 13px; font-weight: 700; font-size: 14px; transition: opacity .3s var(--ease), transform .3s var(--ease); pointer-events: none; max-width: calc(100% - 32px); }
.snack.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi--src { grid-column: 1 / -1; }
  .board { grid-template-columns: repeat(5, minmax(250px, 1fr)); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
  .stage { scroll-snap-align: start; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .kpi { padding: 14px 16px; }
  .kpi__v { font-size: 22px; }
  .board { grid-template-columns: repeat(5, 82vw); margin: 0 -16px; padding: 0 16px 8px; scroll-padding: 0 16px; }
  .stage { min-height: 50vh; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .drawer__head, .drawer__body { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
