:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d4d7dd;
  --ink: #16181d;
  --muted: #6b7280;
  --muted-2: #9aa0ab;
  --brand: #e8a417;      /* золото «Едем завтра» */
  --brand-ink: #7a5600;
  --brand-soft: #fdf5e2;
  --accent: #2563eb;
  --green: #10a760;
  --green-soft: #e7f6ee;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #f59e0b;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Топбар ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: 58px; padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand .pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 2px;
  background: linear-gradient(150deg, var(--brand), #d68f0c);
  transform: rotate(-45deg); position: relative; flex: 0 0 auto;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.35);
}
.brand .pin::after { content:""; position:absolute; inset:8px; border-radius:50%; background:#fff; }
.brand small { color: var(--muted); font-weight: 500; margin-left: 2px; }

.nav { display: flex; gap: 2px; margin-left: 4px; }
.nav button {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 13px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px;
}
.nav button:hover { background: var(--bg); color: var(--ink); }
.nav button.active { background: var(--brand-soft); color: var(--brand-ink); }

.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.user-chip .av {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.btn-logout { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 7px 11px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.btn-logout:hover { border-color: var(--border-strong); color: var(--ink); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px;
}
.btn:hover { border-color: var(--border-strong); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #3a2900; }
.btn-primary:hover { background: #d68f0c; border-color: #d68f0c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn.block { width: 100%; }

/* ---------- Раскладка ---------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px 18px 60px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }

/* ---------- Панель фильтров ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text], .toolbar select {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 11px; color: var(--ink); outline: none; min-width: 0;
}
.toolbar input[type=text]:focus, .toolbar select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.toolbar .search { flex: 1 1 220px; min-width: 160px; }

/* ---------- Канбан ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(248px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col {
  background: #eef0f3; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; min-height: 200px;
}
.col.dragover { outline: 2px dashed var(--brand); outline-offset: -3px; background: var(--brand-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.col-head .title { font-weight: 700; font-size: 13px; }
.col-head .cnt { margin-left: auto; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; border-radius: 20px; padding: 1px 8px; }
.dot-new { background: #64748b; } .dot-call { background: #3b82f6; } .dot-qual { background: #8b5cf6; }
.dot-docs { background: #e8a417; } .dot-working { background: #10a760; } .dot-reject { background: #e5484d; }

.cards { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px;
  box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card.dragging { opacity: .5; }
.card .c-name { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.card .c-prof { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card .c-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.tag.city::before { content: "📍 "; }
.tag.src { text-transform: capitalize; }
.tag.warn { background: var(--red-soft); color: var(--red); border-color: transparent; }
.tag.due { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.card .c-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; }
.mini-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 7px; width: 30px; height: 28px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.mini-btn:hover { border-color: var(--border-strong); color: var(--ink); }

/* мобильный селект статуса на карточке */
.card .m-status { display: none; }

/* ---------- Дашборд ---------- */
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-top: 4px; }
.kpi .value.green { color: var(--green); } .kpi .value.brand { color: var(--brand-ink); }
.kpi .hint { color: var(--muted-2); font-size: 11.5px; margin-top: 2px; }

.panels { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 12px; font-size: 14px; letter-spacing: -.01em; }
.panel h3 .cnt { color: var(--muted); font-weight: 500; }

/* воронка */
.funnel-row { display: grid; grid-template-columns: 130px 1fr 42px; align-items: center; gap: 10px; margin-bottom: 9px; }
.funnel-row .fl { font-size: 12.5px; color: var(--ink); font-weight: 600; }
.funnel-bar { height: 22px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #d68f0c); min-width: 2px; }
.funnel-row .fn { text-align: right; font-weight: 700; font-size: 13px; }

/* источники */
.src-row { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 8px; }
.src-row .sl { font-size: 12.5px; font-weight: 600; text-transform: capitalize; }
.src-bar { height: 18px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.src-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.src-row .sn { text-align: right; font-weight: 700; font-size: 12.5px; }

/* задачи на дашборде */
.task-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: none; }
.task-item .tcheck { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-radius: 5px; flex: 0 0 auto; cursor: pointer; }
.task-item .tcheck:hover { border-color: var(--green); }
.task-item .tbody { flex: 1; min-width: 0; }
.task-item .tt { font-weight: 600; font-size: 13px; }
.task-item .tm { color: var(--muted); font-size: 12px; }
.task-item .tdue { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.tdue.overdue { background: var(--red-soft); color: var(--red); }
.tdue.today { background: var(--brand-soft); color: var(--brand-ink); }
.tdue.up { background: var(--bg); color: var(--muted); }
.empty { color: var(--muted-2); font-size: 13px; padding: 8px 0; }

/* ---------- Модалка карточки ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16,18,24,.5); z-index: 60; display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 720px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .14s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head .mh-main { flex: 1; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.modal-head .mh-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.modal-close { border: none; background: var(--bg); border-radius: 8px; width: 32px; height: 32px; font-size: 18px; color: var(--muted); }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }

.quick-contacts { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.qc { display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border-radius: 9px; font-weight: 700; font-size: 13px; border: 1px solid transparent; }
.qc.call { background: var(--green-soft); color: #0a7a44; }
.qc.wa { background: #e6f8ee; color: #128c4b; }
.qc.tg { background: #e6f2fb; color: #1d78c2; }
.qc:hover { filter: brightness(.97); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.field .val { font-size: 13.5px; font-weight: 500; }
.field input, .field select { border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }

.sec-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 10px; }
.note-form { display: flex; gap: 8px; margin-bottom: 12px; }
.note-form input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; outline: none; }
.note-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-item { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 8px 0; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); margin-top: 5px; }
.tl-dot.touch { background: var(--accent); } .tl-dot.system { background: var(--brand); } .tl-dot.note { background: var(--green); }
.tl-body .tl-text { font-size: 13px; }
.tl-body .tl-meta { color: var(--muted-2); font-size: 11.5px; margin-top: 2px; }

.task-form { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.task-form input[type=text] { flex: 1 1 180px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none; }
.task-form input[type=date] { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.task-list-m { display: flex; flex-direction: column; gap: 6px; }
.tlm { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: var(--bg); border-radius: 8px; }
.tlm.done { opacity: .55; }
.tlm .tlm-t { flex: 1; font-size: 13px; }
.tlm.done .tlm-t { text-decoration: line-through; }

/* ---------- Логин ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #fbf6e9, #f3f4f6); padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; font-size: 18px; margin-bottom: 4px; }
.login-card .lc-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 12px; }
.login-card input { border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-err { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 12px; display: none; }
.login-err.show { display: block; }
.login-hint { text-align: center; color: var(--muted-2); font-size: 11.5px; margin-top: 16px; line-height: 1.6; }

/* тосты */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: slidein .2s; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.hidden { display: none !important; }

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
  .panels { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding: 14px 12px 80px; }
  .topbar { height: 54px; padding: 0 12px; gap: 8px; }
  .nav { display: none; }
  .user-chip .un { display: none; }
  .brand small { display: none; }
  /* канбан → вертикальные секции */
  .board { display: flex; flex-direction: column; overflow-x: visible; gap: 14px; }
  .col { min-height: auto; }
  .card { cursor: default; }
  .card .c-foot { display: none; }
  .card .m-status { display: block; margin-top: 9px; }
  .card .m-status select { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: var(--surface); }
  /* нижняя мобильная навигация */
  .mobile-nav { display: flex; }
  .overlay { padding: 0; align-items: stretch; }
  .modal { max-width: none; border-radius: 0; min-height: 100vh; }
  .modal-body { max-height: none; }
  .quick-contacts .qc { flex: 1; justify-content: center; }
}
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; background: var(--surface); border-top: 1px solid var(--border); padding: 6px; }
.mobile-nav button { flex: 1; border: none; background: transparent; color: var(--muted); padding: 8px 4px; border-radius: 8px; font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mobile-nav button .ic { font-size: 17px; }
.mobile-nav button.active { color: var(--brand-ink); background: var(--brand-soft); }
