/* Оформление в духе Битрикс24: левое меню, светлый фон, цветные этапы воронки */
:root {
  --bg: #eef2f4; --card: #fff; --text: #333; --muted: #828b95; --line: #e1e5e9;
  --side: #1d2e44; --side2: #2b4059; --sidetext: #c3ccd6;
  --blue: #2fc6f6; --blue2: #2067b0; --link: #2067b0;
  --green: #bbed21; --greentext: #535c69;
  --ok: #7bd500; --bad: #ff5752; --warn: #ffa900;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
  /* цвета этапов */
  --c-new: #39a8ef; --c-qual: #2fc6f6; --c-calc: #55d0e0; --c-kp: #ffa900; --c-nego: #9dcf00; --c-won: #7bd500; --c-think: #ffcd00; --c-lost: #ff5752;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Open Sans", "Helvetica Neue", "Segoe UI", Arial, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ===== каркас ===== */
.shell { display: flex; min-height: 100vh; }
aside.side { width: 230px; flex: 0 0 230px; background: linear-gradient(180deg, var(--side) 0%, #16243a 100%); color: var(--sidetext); position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.side .brand .dot { width: 30px; height: 30px; border-radius: 8px; background: var(--blue); display: grid; place-items: center; color: #fff; font-size: 16px; }
.side .brand small { display: block; font-weight: 400; font-size: 11px; color: #8fa0b3; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--sidetext); padding: 9px 18px; font-size: 14px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side nav a.on { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--blue); font-weight: 600; }
.side nav .ico { width: 20px; text-align: center; opacity: .9; }
.side nav .grp { padding: 14px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #6f8197; }
.side .badge { margin-left: auto; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

header.bar { background: #fff; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar .burger { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; padding: 4px 8px; color: var(--greentext); }
.bar .search { flex: 1; max-width: 420px; position: relative; }
.bar .search input { width: 100%; border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px 7px 34px; background: #f5f7f8; }
.bar .search::before { content: "⌕"; position: absolute; left: 13px; top: 5px; color: var(--muted); font-size: 17px; }
.bar select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; max-width: 170px; }
.bar .user { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--greentext); white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; }

main { padding: 18px 20px 40px; width: 100%; max-width: 1500px; }
.page-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
h1 { font-size: 24px; font-weight: 300; margin: 0; color: #333; }
h2 { font-size: 16px; font-weight: 600; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }

/* ===== кнопки ===== */
.btn { border: 1px solid #c6cdd3; background: #fff; border-radius: 4px; padding: 0 16px; height: 36px; line-height: 34px; cursor: pointer; white-space: nowrap; color: var(--greentext); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; display: inline-block; text-decoration: none !important; }
.btn:hover { background: #f3f5f7; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #3eddff; }
.btn.create { background: var(--green); border-color: var(--green); color: var(--greentext); }
.btn.create:hover { background: #d2f95f; }
.btn.danger { color: #e0322c; border-color: #f2b5b2; }
.btn.small { height: 28px; line-height: 26px; padding: 0 10px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ===== поля ===== */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  border: 1px solid #c6cdd3; border-radius: 2px; padding: 7px 10px; background: #fff; width: 100%; min-width: 0; height: 38px;
}
textarea { min-height: 76px; height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47,198,246,.2); }
label.f { display: block; font-size: 12px; color: var(--muted); }
label.f > span { display: block; margin-bottom: 4px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 16px; }
.form .wide { grid-column: 1 / -1; }
fieldset { border: 0; border-radius: var(--radius); padding: 14px 18px 16px; margin: 0 0 14px; background: #fff; box-shadow: var(--shadow); }
legend { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--greentext); padding: 0; float: left; width: 100%; margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
legend + * { clear: both; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; background: #fff; padding: 12px; border-radius: var(--radius); box-shadow: var(--shadow); }

/* ===== статусы ===== */
.st { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; color: #fff; background: #a8adb4; }
.st-new { background: var(--c-new); } .st-qual { background: var(--c-qual); } .st-calc { background: var(--c-calc); }
.st-kp { background: var(--c-kp); } .st-nego { background: var(--c-nego); } .st-won { background: var(--c-won); }
.st-lost { background: var(--c-lost); } .st-think { background: var(--c-think); color: #5b4b00; }
.overdue { color: #e0322c; font-weight: 600; }
.today { color: #d68a00; font-weight: 600; }

/* ===== таблицы ===== */
.tablewrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 9px 10px; border-bottom: 1px solid #edf0f2; text-align: left; vertical-align: top; }
.t th { background: #fff; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0; border-bottom: 1px solid var(--line); }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: #f1fbfe; }
.t td.num, .t th.num { text-align: right; white-space: nowrap; }

/* ===== «Сегодня» ===== */
.lead-item { display: block; background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 11px 14px; margin-bottom: 8px; color: inherit; border-left: 4px solid var(--c-new); text-decoration: none !important; }
.lead-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.lead-item .l1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 600; color: var(--link); }
.lead-item .l2 { font-size: 12px; color: var(--muted); margin-top: 4px; }
.lead-item.od { border-left-color: var(--c-lost); } .lead-item.td { border-left-color: var(--c-kp); } .lead-item.th { border-left-color: var(--c-think); }
.section-h { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; font-weight: 600; font-size: 15px; }
.section-h .cnt { background: #dfe5ea; border-radius: 10px; padding: 0 9px; font-size: 12px; }
.section-h .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ===== канбан в духе Битрикс24 ===== */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { min-width: 260px; width: 260px; flex: 0 0 auto; }
.col .stage { position: relative; height: 38px; color: #fff; font-weight: 600; font-size: 13px; display: flex; align-items: center; padding: 0 22px 0 12px; border-radius: 4px 0 0 4px; margin-right: 12px; }
.col .stage::after { content: ""; position: absolute; right: -12px; top: 0; border-left: 12px solid var(--sc); border-top: 19px solid transparent; border-bottom: 19px solid transparent; }
.col .stage .n { margin-left: auto; background: rgba(255,255,255,.3); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.col .sum { font-size: 13px; color: var(--greentext); margin: 6px 2px 8px; font-weight: 600; }
.col .cards { min-height: 120px; max-height: calc(100vh - 230px); overflow-y: auto; padding: 2px; border-radius: 6px; }
.col.drop .cards { background: rgba(47,198,246,.12); outline: 2px dashed var(--blue); }
.kcard { background: #fff; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.08); cursor: pointer; font-size: 12px; color: var(--greentext); border-left: 3px solid var(--sc); }
.kcard:hover { box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.kcard b { display: block; font-size: 14px; color: var(--link); font-weight: 600; margin-bottom: 3px; }
.kcard .amt { font-weight: 600; color: #333; font-size: 13px; }
.kcard[draggable=true] { cursor: grab; }
.col .more { display: block; text-align: center; font-size: 12px; padding: 6px; }

/* ===== карточка обращения ===== */
.lead-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.status-bar { display: flex; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.status-bar button { position: relative; border: 0; background: #e3e8ec; color: var(--greentext); height: 34px; padding: 0 14px 0 22px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; flex: 1 0 auto; margin-right: 3px;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); }
.status-bar button:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); padding-left: 14px; border-radius: 4px 0 0 4px; }
.status-bar button.past, .status-bar button.on { background: var(--sc); color: #fff; }
.status-bar button.on { box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.status-bar button:disabled { cursor: default; }
.touch { border-left: 2px solid #dfe5ea; padding: 6px 0 10px 14px; margin-left: 6px; position: relative; }
.touch::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.touch.system::before, .touch.status::before { background: #c6cdd3; }
.touch .meta { font-size: 11px; color: var(--muted); }
.touch .txt { white-space: pre-wrap; }
.touch.system { opacity: .75; } .touch.status .txt { color: var(--muted); font-size: 13px; }
.quick { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.quick button { font-size: 12px; padding: 3px 8px; border-radius: 12px; border: 1px solid #c6cdd3; background: #fff; cursor: pointer; color: var(--greentext); }
.quick button:hover { border-color: var(--blue); }
.layout2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .layout2 { grid-template-columns: 1fr; } .layout2 > :last-child { order: -1; } }
details.filt > summary { cursor: pointer; font-weight: 600; color: var(--link); margin-bottom: 10px; list-style: none; }
details.filt > summary::before { content: "▸ "; } details.filt[open] > summary::before { content: "▾ "; }

/* ===== отчёты ===== */
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--blue); }
.kpi .v { font-size: clamp(18px, 1.9vw, 24px); font-weight: 300; color: #333; white-space: nowrap; }
.kpi .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.funnel .row { display: grid; grid-template-columns: 160px 1fr 120px; gap: 10px; align-items: center; margin: 5px 0; }
.funnel .bar { height: 26px; border-radius: 3px; min-width: 3px; }
@media (max-width: 600px) { .funnel .row { grid-template-columns: 110px 1fr 80px; font-size: 12px; } }

.tpl { white-space: pre-wrap; background: #f5f7f8; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }

/* ===== вход ===== */
.login-bg { min-height: 100vh; background: linear-gradient(135deg, #1d2e44 0%, #2067b0 60%, #2fc6f6 100%); display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: #fff; padding: 28px; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login h1 { text-align: center; margin-bottom: 4px; }
.login .form { grid-template-columns: 1fr; }
.login .btn { width: 100%; height: 42px; }
.err { color: #e0322c; font-size: 13px; min-height: 1.2em; }
.note { background: #fff8e1; border: 1px solid #ffe08a; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }
.note.red { background: #ffeceb; border-color: #ffbab8; }
.note.blue { background: #e5f8fe; border-color: #a6e6fb; }
.code { font-family: Consolas, monospace; background: #f0f3f5; padding: 2px 6px; border-radius: 3px; word-break: break-all; }

/* ===== окно ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(29,46,68,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 10px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; padding: 18px 20px; width: 100%; max-width: 660px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }

.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; text-align: center; font-weight: 700; line-height: 18px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2b3a4d; color: #fff; padding: 10px 18px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: #e0322c; }

/* ===== телефон ===== */
.side-close { display: none; }
@media (max-width: 860px) {
  aside.side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .shell.menu-open aside.side { transform: none; }
  .shell.menu-open .side-close { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .bar .burger { display: block; }
  header.bar { padding: 0 10px; gap: 8px; }
  .bar .user .nm { display: none; }
  .bar .search { display: none; }
  .bar select { margin-left: auto; }
  .bar select { max-width: 110px; }
  main { padding: 12px 10px 40px; }
  h1 { font-size: 20px; }
  .t th, .t td { padding: 7px 6px; font-size: 13px; }
  .hide-m { display: none; }
  .col { min-width: 80vw; width: 80vw; }
}
