:root {
  --bg: #0e2029;
  --panel: #142c37;
  --card: #1a3642;
  --line: #24424f;
  --text: #e6eef2;
  --muted: #8ba3ae;
  --accent: #f5c518;        /* жёлтый IMUN PHARM */
  --accent-ink: #1a1a1a;
  --link: #5fb4ff;
  --ok: #3ccf8e;
  --bad: #ff6b6b;
  --side: 76px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%; overflow-x: hidden; }
#root { min-height: 100%; }
a { color: var(--link); text-decoration: none; }
button, input, select, textarea { font: inherit; font-size: 16px; color: inherit; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.btn { border: 0; border-radius: 8px; padding: 10px 16px; cursor: pointer; background: var(--card); color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.4em; }
.okmsg { color: var(--ok); }

/* ---------- вход ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 360px; background: var(--panel); padding: 28px; border-radius: 14px; display: grid; gap: 12px; }
.brand { font-weight: 800; letter-spacing: .5px; color: var(--accent); font-size: 22px; text-align: center; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; letter-spacing: 0; }
.langs { display: flex; justify-content: center; gap: 8px; }
.langs button { background: none; border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; cursor: pointer; color: var(--muted); }
.langs button.on { border-color: var(--accent); color: var(--accent); }

/* ---------- каркас как в amoCRM ---------- */
.shell { display: flex; min-height: 100%; }
.side { width: var(--side); background: var(--panel); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column;
  align-items: stretch; padding: 10px 0; z-index: 5; }
.side .logo { color: var(--accent); font-weight: 800; text-align: center; font-size: 13px; padding: 4px 0 12px; line-height: 1.1; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; color: var(--muted); font-size: 11px; text-align: center; }
.nav a .ic { font-size: 22px; line-height: 1; }
.nav a.on, .nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav a.on .ic { color: var(--accent); }
.side .spacer { flex: 1; }
.main { margin-left: var(--side); flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 3; }
.top h1 { font-size: 18px; margin: 0; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.top .grow { flex: 1; }
.content { padding: 20px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 20px; background: var(--card); color: var(--muted); }
.tabs a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th { color: var(--muted); font-weight: 500; font-size: 13px; }
.grid tr.row { cursor: pointer; }
.grid tr.row:hover td { background: rgba(255,255,255,.03); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; background: var(--card); }
.tag.off { color: var(--bad); }
.stage { display: inline-block; padding: 4px 10px; border-radius: 6px; color: #111; font-size: 13px; margin: 3px; }

/* ---------- модальное окно ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px; display: grid; gap: 12px; }
.modal h2 { margin: 0; font-size: 18px; }
.form-row { display: grid; gap: 6px; }
.form-row label { color: var(--muted); font-size: 13px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.perms { display: grid; gap: 4px; }
.perm { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.perm input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.perm .src { margin-left: auto; font-size: 12px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card); padding: 10px 16px; border-radius: 8px; z-index: 30; }

/* ---------- телефон: нижняя панель как в приложении ---------- */
@media (max-width: 760px) {
  .side { inset: auto 0 0 0; width: 100%; height: calc(62px + env(safe-area-inset-bottom)); flex-direction: row; padding: 0 0 env(safe-area-inset-bottom); border-top: 1px solid var(--line); }
  .side .logo, .side .spacer, .nav a.desk-only { display: none; }
  .nav { display: flex; width: 100%; }
  .nav a { flex: 1; padding: 8px 0; }
  .main { margin-left: 0; padding-bottom: 76px; }
  .content { padding: 14px; }
  .top { padding: 12px 14px; }
  .two { grid-template-columns: 1fr; }
  .grid .hide-m { display: none; }
  .top .btn { padding: 8px 12px; font-size: 14px; }
  .top .btn .lbl { display: none; }
}

/* ---------- карточка сделки ---------- */
.tabs.small a { padding: 5px 12px; font-size: 13px; }
.small { font-size: 12px; }
.lead-card { display: grid; grid-template-columns: 400px 1fr; gap: 0; margin: -20px; min-height: calc(100vh - 57px); }
.lead-left { background: var(--panel); padding: 16px 18px; border-right: 1px solid var(--line); overflow: auto; }
.lead-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.lead-head .back { color: var(--muted); font-size: 26px; line-height: 1; padding: 0 4px; }
.lead-title { font-size: 20px; font-weight: 700; background: transparent; border-color: transparent; padding: 4px 6px; }
.lead-title:hover:not(:disabled) { border-color: var(--line); }
.stage-box { margin-bottom: 12px; }
.stage-select { width: auto; max-width: 70%; padding: 4px 8px; font-weight: 600; background: transparent; border-color: transparent; }
.stagebar { display: flex; gap: 2px; margin-top: 6px; }
.stagebar span { flex: 1; height: 4px; border-radius: 2px; }
.contact-mini { margin: 6px 0 12px; }
.fields { display: grid; gap: 2px; }
.frow { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 8px; padding: 3px 0; }
.frow.col { grid-template-columns: 1fr; justify-items: stretch; }
.frow.col > label { text-align: left; }
.frow label { color: var(--muted); font-size: 13px; }
.frow input, .frow select, .frow textarea { padding: 6px 8px; background: transparent; border-color: transparent; }
.frow input:hover:not(:disabled), .frow select:hover:not(:disabled), .frow textarea:hover:not(:disabled),
.frow input:focus, .frow select:focus, .frow textarea:focus { border-color: var(--line); background: var(--bg); }
.frow :disabled { opacity: .85; }
.quick { display: flex; gap: 8px; }
.quick .btn { padding: 6px 12px; font-size: 14px; }
.other { display: flex; align-items: center; gap: 6px; padding: 4px 0; color: var(--text); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.lead-right { display: flex; flex-direction: column; min-width: 0; height: calc(100vh - 57px); position: sticky; top: 57px; }
.feed { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px; display: grid; align-content: start; gap: 8px; }
.lead-tasks { max-height: 30vh; overflow: auto; }
.ev-line { font-size: 13px; color: var(--text); }
.ev-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.ev-call { border-left: 3px solid var(--ok); }
.ev-message { border-left: 3px solid var(--link); }
.ev-head { font-size: 12px; margin-bottom: 4px; }
.ev-body { white-space: pre-wrap; word-break: break-word; }
.composer { border-top: 1px solid var(--line); padding: 12px 20px; display: grid; gap: 8px; background: var(--bg); position: sticky; bottom: 0; }
.kinds { display: flex; gap: 6px; }
.kinds button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 16px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.kinds button.on { border-color: var(--accent); color: var(--accent); }
.composer .btn { justify-self: end; }
@media (max-width: 760px) {
  .lead-card { grid-template-columns: 1fr; margin: -14px; }
  .lead-left { border-right: 0; }
  .frow { grid-template-columns: 120px 1fr; }
  .lead-right { height: auto; position: static; }
  .feed { max-height: none; }
  .composer { bottom: calc(62px + env(safe-area-inset-bottom)); }
}

/* ---------- фильтры и доска ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { width: auto; max-width: 220px; padding: 8px 10px; }
.filters .chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.filters .chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.filters .reset { color: var(--muted); font-size: 14px; }
.filters .ftoggle { display: none; padding: 8px 12px; }
.viewtoggle { display: flex; background: var(--card); border-radius: 8px; overflow: hidden; }
.viewtoggle a { padding: 8px 12px; color: var(--muted); font-size: 16px; }
.viewtoggle a.on { background: var(--accent); color: var(--accent-ink); }
.board-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.board-sum { font-size: 14px; }
.stage-picker { display: none; margin-bottom: 10px; }
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.col { flex: 0 0 270px; background: var(--panel); border-radius: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.col.over { outline: 2px dashed var(--accent); }
.col.closed { opacity: .8; }
.col-head { padding: 10px 12px 8px; border-bottom: 3px solid; text-align: center; }
.col-name { font-weight: 700; text-transform: uppercase; font-size: 13px; letter-spacing: .3px; }
.col-meta { font-size: 12px; margin-top: 2px; }
.col-list { overflow-y: auto; padding: 8px; display: grid; gap: 6px; align-content: start; }
.bcard { display: grid; gap: 4px; background: var(--card); border-radius: 8px; padding: 9px 10px; color: var(--text); border: 1px solid transparent; }
.bcard:hover { border-color: var(--line); }
.bcard.dragging { opacity: .4; }
.bc-top { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
.bc-contact { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-name { color: var(--link); font-size: 14px; }
.bc-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.bc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.bc-dot.red { background: var(--accent); }
.btn.more { margin: 0 8px 8px; padding: 6px; font-size: 13px; }
@media (max-width: 760px) {
  .filters select { flex: 1 1 45%; max-width: none; }
  .filters input[type=search] { flex: 1 1 60%; }
  .filters .ftoggle { display: block; }
  .filters:not(.open) .fx { display: none; }
  .board-tools .btn .lbl { display: none; }
  .stage-picker { display: block; }
  .board { display: block; overflow: visible; min-height: 0; }
  .col { display: none; max-height: none; }
  .col.m-active { display: flex; }
  .col-head { display: none; }
}

/* ---------- задачи и «Сегодня» ---------- */
.nav a .ic { position: relative; }
.badge { position: absolute; top: -6px; right: -12px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; }
.task { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task-cb input { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 2px; }
.task-main { display: grid; gap: 2px; min-width: 0; }
.task-due { font-weight: 600; }
.task.overdue .task-due { color: var(--bad); }
.task.done { opacity: .6; }
.task.done .task-main > div:nth-child(2) { text-decoration: line-through; }
.task-form { display: grid; gap: 8px; }
.tf-row { display: grid; grid-template-columns: 1.3fr 1fr 1.3fr; gap: 8px; }
.lead-right .task-form { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--bg); }
.lead-tasks { padding: 4px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.no-task { margin: 8px 20px; padding: 8px 12px; border-radius: 8px; background: #3a3214; color: #f5d76e; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border-radius: 10px; padding: 14px; color: var(--muted); font-size: 13px; display: grid; gap: 2px; }
.stat b { font-size: 26px; color: var(--text); }
.stat.bad b { color: var(--bad); }
.stat.ok b { color: var(--ok); }
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.today-block h3 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; }
.today-block h3 .count { color: var(--muted); font-weight: 500; }
.today-block.bad h3 { color: var(--bad); }
.fresh { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--text); }
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .today-grid { grid-template-columns: 1fr; }
  .tf-row { grid-template-columns: 1fr 1fr; }
  .tf-row select:last-child { grid-column: span 2; }
}

/* ---------- заказ, финансы, логистика ---------- */
.olines { display: grid; gap: 4px; }
.oline { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: 14px; }
.oline.total { border-top: 1px solid var(--line); padding-top: 4px; }
.section-title { margin: 14px 0 4px; font-weight: 700; font-size: 14px; }
.bad-text { color: var(--bad); }
.ships { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.ship { display: grid; gap: 6px; margin: 0; }
.ship-head { display: flex; align-items: center; gap: 8px; }
.ship-head .stage { margin-left: auto; }
.ship-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.filters label.small { align-self: center; }
.filters input[type=date], .filters input[type=month] { width: auto; }
@media (max-width: 760px) { .ships { grid-template-columns: 1fr; } }

/* ---------- аналитика ---------- */
.hbar { background: var(--bg); border-radius: 4px; height: 8px; overflow: hidden; min-width: 40px; }
.hbar span { display: block; height: 100%; border-radius: 4px; }
.brow { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 50px; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.brow b { text-align: right; }
.stats.two { grid-template-columns: 1fr 1fr; margin: 0; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.ok-text { color: var(--ok); }
.plan-input { max-width: 160px; padding: 6px 8px; }
tr.plan-total td { font-weight: 700; }
tr.plan-dept td:first-child { padding-left: 16px; }
tr.plan-user td:first-child { padding-left: 32px; color: var(--muted); }
.top a.btn { display: inline-flex; align-items: center; }

/* ---------- интеграции: чаты, переписка в ленте ---------- */
.tag.ok { color: var(--ok); }
.kinds { flex-wrap: wrap; }
.kinds button.send-kind { color: var(--text); }
.ev-in { margin-right: 14%; }
.ev-out { margin-left: 14%; background: rgba(245,197,24,.06); border-color: rgba(245,197,24,.25); }
.ev-extra { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ev-extra.reply { flex-direction: column; align-items: stretch; }
.ev-extra.reply > .btn { align-self: flex-start; }
.ev-extra.reply:not(:has(textarea)) { flex-direction: row; align-items: center; }
.ev-extra audio { width: 100%; max-width: 360px; height: 36px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.call-mini { margin-left: 8px; }
.chat-list { padding: 0; overflow: hidden; }
.chat-row { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); }
.chat-row:hover { background: rgba(255,255,255,.03); }
.chat-row.waiting .chat-top b { color: var(--accent); }
.chat-ic { font-size: 22px; width: 28px; text-align: center; }
.chat-main { flex: 1; min-width: 0; }
.chat-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; margin-top: 2px; }
.chat-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dot-new { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.int-card h3 { margin: 0 0 10px; }
.env { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--accent); overflow-x: auto; }
.copy { display: flex; gap: 6px; align-items: center; min-width: 0; }
.copy code { background: var(--bg); padding: 6px 8px; border-radius: 6px; font-size: 12px; overflow-x: auto; white-space: nowrap; max-width: 100%; }
.warn { border-left: 3px solid var(--accent); padding: 8px 12px; background: rgba(245,197,24,.06); border-radius: 6px; }
.steps { padding-left: 18px; color: var(--muted); }
.steps li { margin: 4px 0; }
@media (max-width: 760px) { .ev-in { margin-right: 6%; } .ev-out { margin-left: 6%; } }
