/* Tour Lead Hub — стиль Apple + Notion + Monday: белый фон, светло-синий, бирюза, минимализм. */
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #16202b;
  --muted: #6b7a8d;
  --line: #e6edf4;
  --blue: #2f6bff;
  --blue-soft: #e9f0ff;
  --teal: #14b8a6;
  --teal-soft: #e2f7f4;
  --hot: #ff5a5f;
  --warm: #f5a623;
  --cold: #9aa7b4;
  --overdue: #e11d48;
  --green: #18b368;
  --shadow: 0 1px 2px rgba(16, 32, 43, .04), 0 6px 20px rgba(16, 32, 43, .06);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 14px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
.logo span { opacity: .8; font-weight: 600; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 12px; color: var(--muted); }
.controls { display: flex; align-items: center; gap: 14px; }
.ctrl { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.ctrl select {
  font-size: 13px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer;
}
.btn-ghost {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); }
.live { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--green); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---- KPI ---- */
.kpis {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; padding: 18px 24px;
}
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.kpi.accent .value { color: var(--blue); }
.kpi.hot .value { color: var(--hot); }
.kpi.green .value { color: var(--green); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 8px; padding: 0 24px; }
.tab {
  border: none; background: transparent; padding: 10px 16px; border-radius: 10px 10px 0 0;
  font-size: 14px; color: var(--muted); cursor: pointer; font-weight: 600;
}
.tab.active { color: var(--blue); background: var(--card); border: 1px solid var(--line); border-bottom: none; }

.view { padding: 18px 24px 40px; }

/* ---- Lead board ---- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.lead {
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--cold);
  border-radius: 14px; padding: 14px; box-shadow: var(--shadow); position: relative;
}
.lead.hot { border-left-color: var(--hot); }
.lead.warm { border-left-color: var(--warm); }
.lead.cold { border-left-color: var(--cold); }
.lead.overdue { border-left-color: var(--overdue); box-shadow: 0 0 0 2px rgba(225,29,72,.15), var(--shadow); }
.lead.sold { opacity: .72; border-left-color: var(--green); }
.lead.lost { opacity: .55; border-left-color: #b9c2cc; }
.lead.ready { border-left-color: #e11d48; box-shadow: 0 0 0 2px rgba(225,29,72,.25), var(--shadow); }
.ready-call { background: #e11d48; color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .4px; text-align: center; padding: 7px; border-radius: 9px; margin-bottom: 10px; animation: readyPulse 1.6s ease-in-out infinite; }
@keyframes readyPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(225,29,72,.5); } 50% { box-shadow: 0 0 0 6px rgba(225,29,72,0); } }
.lead-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.lead-name { font-weight: 700; font-size: 15px; }
.lead-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.score {
  min-width: 40px; text-align: center; font-weight: 800; font-size: 16px; border-radius: 10px;
  padding: 4px 8px; background: var(--blue-soft); color: var(--blue);
}
.score.hot { background: #ffe9ea; color: var(--hot); }
.score.warm { background: #fff2dc; color: #c9810a; }
.lead-row { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; font-size: 13px; }
.lead-row b { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.seg { background: var(--teal-soft); color: #0f766e; border-color: #c7eee9; }
.chip.vip { background: #fff0c7; color: #9a6700; border-color: #ffe08a; }
.chip.src { background: var(--blue-soft); color: var(--blue); border-color: #d6e4ff; }
.lead-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.state { font-weight: 700; }
.state.waiting { color: var(--warm); }
.state.work { color: var(--blue); }
.state.sold { color: var(--green); }
.state.lost { color: #9aa7b4; }
.wait.alarm { color: var(--overdue); font-weight: 700; }
.assigned { display: flex; align-items: center; gap: 6px; }
.ava { width: 20px; height: 20px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 700; }
.reassign-flag { color: var(--overdue); font-size: 11px; }

/* ---- Tables / managers ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 4px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--teal)); }
.rank { font-weight: 800; color: var(--muted); width: 28px; }

.section-title { font-size: 13px; color: var(--muted); margin: 4px 2px 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.top-card { background: linear-gradient(135deg, var(--blue), var(--teal)); color: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.top-card .crown { font-size: 13px; opacity: .9; }
.top-card .tname { font-size: 26px; font-weight: 800; margin: 6px 0 12px; }
.top-card .tstats { display: flex; gap: 22px; }
.top-card .tstats div span { display: block; font-size: 12px; opacity: .85; }
.top-card .tstats div b { font-size: 20px; }

.src-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.src-row .name { width: 90px; font-size: 13px; }
.src-row .pct { width: 44px; text-align: right; font-size: 13px; color: var(--muted); }

.foot { padding: 18px 24px 30px; color: var(--muted); font-size: 12px; }

/* ---- Toolbar / filters ---- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.fbtn { border: 1px solid var(--line); background: #fff; color: var(--muted); padding: 7px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.fbtn.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary { border: none; background: var(--blue); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { border: 1px solid #ffd0d3; background: #fff5f5; color: var(--hot); padding: 9px 14px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.lead { cursor: pointer; transition: transform .08s, box-shadow .12s; }
.lead:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(16,32,43,.12); }
.empty { color: var(--muted); padding: 40px; text-align: center; grid-column: 1 / -1; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,32,43,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(16,32,43,.3); overflow: hidden; animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head .score { font-size: 13px; vertical-align: middle; }
.x { border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.modal-body { padding: 16px 20px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv span { color: var(--muted); }
.modal-actions { padding: 16px 20px; display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--bg); }
.sell-row { display: flex; align-items: center; gap: 6px; }
.sell-row input { width: 90px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.closed-note { font-weight: 700; color: var(--ink); }

/* ---- Form ---- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form input, .form select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; color: var(--ink); }
.form .chk { flex-direction: row; align-items: center; gap: 8px; grid-column: 1 / -1; font-size: 14px; color: var(--ink); }

/* ---- Settings ---- */
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: none; }
.hint2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.set-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.thr { display: flex; gap: 6px; }
.thr input { width: 60px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd8e3; border-radius: 999px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---- Воронка этапов / заметка в карточке ---- */
.pipe { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 12px; }
.pstep { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pstep.done { background: var(--teal-soft); color: #0f766e; border-color: #c7eee9; font-weight: 600; }
.parr { color: var(--muted); font-size: 11px; }
.kv select { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.note-wrap { margin-top: 12px; }
.note-wrap textarea { width: 100%; min-height: 62px; border: 1px solid var(--line); border-radius: 9px; padding: 9px; font: inherit; font-size: 13px; resize: vertical; box-sizing: border-box; }
.note-wrap .btn-ghost { margin-top: 6px; }
.cinfo { background: linear-gradient(135deg, var(--blue-soft), var(--teal-soft)); border: 1px solid #d6e4ff; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; color: var(--ink); }

/* ---- Быстрые ссылки и оценка тура ---- */
.links-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn { display: inline-block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--blue-soft); color: var(--blue); text-decoration: none; font-size: 13px; font-weight: 600; }
.link-btn:hover { background: var(--blue); color: #fff; }
.estimate { background: var(--teal-soft); border: 1px solid #c7eee9; border-radius: 10px; padding: 12px; font-size: 13px; margin-top: 10px; }
.estimate-box:empty { display: none; }

/* ---- Инструменты ---- */
.tools-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.tool { padding: 16px; }
.tool .section-title { margin: 0 0 12px; }
.tool select, .tool input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.trow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.trow input { width: 100px; }
.trow select { flex: 1; min-width: 90px; }
.tool-result { margin-top: 12px; font-size: 20px; color: var(--ink); }
.calc-out { width: 100%; box-sizing: border-box; text-align: right; font-size: 22px; padding: 10px 12px; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-btn { padding: 14px 0; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 16px; cursor: pointer; }
.calc-btn:hover { background: var(--bg); }
.calc-btn.eq { background: var(--blue); color: #fff; border-color: var(--blue); }
@media (max-width: 600px) { .tools-grid { grid-template-columns: 1fr; } }
.toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; min-width: 200px; }
.chip.rem { background: #fff2dc; color: #c9810a; border-color: #ffe08a; }
.chip.rem-over { background: #ffe9ea; color: var(--hot); border-color: #ffd0d3; }
.rem-wrap { margin-top: 12px; }
.rem-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rem-item.over { color: var(--overdue); font-weight: 600; }
.rem-wrap .trow { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.rem-wrap input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.rem-wrap #rem-text { flex: 1; min-width: 140px; }
.pay-wrap { margin-top: 12px; }
.pay-wrap .trow { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pay-wrap input, .pay-wrap select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.pay-wrap input[type=number] { width: 130px; }
.pay-sum { margin: 8px 0; font-size: 14px; background: var(--bg); padding: 8px 10px; border-radius: 9px; }
.msg-wrap { margin-top: 12px; }
.msg-wrap select, .msg-wrap textarea { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; margin-bottom: 8px; }
.msg-wrap textarea { min-height: 70px; resize: vertical; }
.msg-wrap .trow { display: flex; gap: 8px; flex-wrap: wrap; }
.task-row.over { color: var(--overdue); }
.task-row:hover { background: var(--bg); }
.chk-wrap { margin-top: 6px; }
.chk-item { font-size: 14px; padding: 4px 0; color: var(--muted); }
.chk-item.done { color: var(--ink); }
.docs { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.help-row { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.help-row > :first-child { flex-shrink: 0; }
.history { margin-top: 6px; }
.hrow { display: flex; gap: 8px; font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.hrow:last-child { border-bottom: none; }
.htime { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hby { color: var(--blue); font-weight: 600; white-space: nowrap; }
.htext { color: var(--ink); }

/* ---- Login ---- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.login-card { background: #fff; padding: 30px; border-radius: 18px; box-shadow: var(--shadow); width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-logo { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, var(--blue), var(--teal)); color: #fff; font-weight: 800; }
.login-logo span { opacity: .8; }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.login-card .btn-primary { padding: 11px; font-size: 15px; }
.login-err { background: #fff5f5; color: var(--hot); padding: 9px 11px; border-radius: 9px; font-size: 13px; }
.login-hint { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ---- Адаптив: телефоны, планшеты, разные экраны ---- */
.panel { overflow-x: auto; }            /* широкие таблицы скроллятся вбок, не ломая вёрстку */
.panel table { min-width: 560px; }      /* колонки не схлопываются */
.tabs { overflow-x: auto; }
.topbar { flex-wrap: wrap; }
.modal { max-height: 90vh; overflow-y: auto; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px 14px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 22px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .controls { gap: 8px; flex-wrap: wrap; }
  .view { padding: 14px; }
  .tabs { padding: 0 14px; }
  .board { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn-primary { width: 100%; }
  .filters { overflow-x: auto; }
  .form { grid-template-columns: 1fr; }   /* формы в один столбец */
  .modal { max-width: 100%; }
}
