/* Интерфейс в стиле amoCRM. Работает только при html.ui-amo (?ui=amo).
   Структура и плотность как в amo, цвета и шрифт — наши (bop-workspace.css). */

/* ---------- Верхняя строка воронки ---------- */
html.ui-amo #view-pipeline { gap: 0; }
html.ui-amo .amo-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 0 12px; border-bottom: 1px solid var(--rule); margin-bottom: 0;
}
html.ui-amo .amo-pipes { display: flex; gap: 2px; padding: 2px; background: var(--inset); border-radius: var(--r-md); flex-shrink: 0; }
html.ui-amo .amo-pipes button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-secondary); cursor: pointer;
}
html.ui-amo .amo-pipes button.on { background: var(--paper); color: var(--ink); }

html.ui-amo .amo-filter {
  position: relative; flex: 1; min-width: 200px; max-width: 640px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  min-height: 36px; padding: 4px 6px 4px 34px;
  background: var(--paper); border: 1px solid var(--control-rule); border-radius: var(--r-md);
}
html.ui-amo .amo-filter:focus-within { border-color: var(--rule-focus); box-shadow: var(--ring); }
html.ui-amo .amo-filter > .ic { position: absolute; left: 11px; top: 10px; color: var(--ink-meta); }
html.ui-amo .amo-filter input {
  flex: 1; min-width: 120px; border: 0; outline: 0; background: transparent; padding: 4px 2px; font-size: 13px; color: var(--ink);
}
html.ui-amo .amo-filter input::placeholder { color: var(--ink-meta); }
html.ui-amo .amo-filter-btn {
  border: 0; background: transparent; color: var(--ink-secondary); width: 28px; height: 26px;
  border-radius: var(--r-sm); display: grid; place-items: center; cursor: pointer;
}
html.ui-amo .amo-filter-btn:hover { background: var(--inset); color: var(--ink); }
html.ui-amo .amo-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 8px;
  background: var(--action-wash); color: var(--action); border-radius: var(--r-sm); font-size: 12px; font-weight: 600;
}
html.ui-amo .amo-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }

html.ui-amo .amo-filter-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: min(560px, calc(100vw - 32px));
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--sh-pop);
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
html.ui-amo .amo-fp-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
html.ui-amo .amo-fp-row > span:first-child {
  width: 96px; flex-shrink: 0; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-meta);
}
html.ui-amo .amo-filter-panel .chips .av { display: none !important; }
html.ui-amo .amo-fp-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--rule-soft); }

html.ui-amo .amo-total { margin-left: auto; font-size: 13px; color: var(--ink-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
html.ui-amo .amo-bar .pipeline-view-toggle { margin-left: 0; }

/* ---------- Колонки ---------- */
html.ui-amo .amo-kanban {
  grid-auto-columns: 280px; gap: 8px; margin-top: 0; padding-top: 0; align-items: start;
}
html.ui-amo .amo-col { background: transparent; border: 0; max-height: calc(100dvh - 150px); display: flex; flex-direction: column; }
html.ui-amo .amo-col-head {
  position: sticky; top: 0; z-index: 2; background: var(--workbench);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 8px 10px; border-bottom: 2px solid var(--stage, var(--rule)); margin-bottom: 8px;
}
html.ui-amo .amo-col-head b {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html.ui-amo .amo-col-head span { font-size: 12px; color: var(--ink-secondary); font-variant-numeric: tabular-nums; }
html.ui-amo .amo-col .col-body { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; padding: 0 0 12px; min-height: 80px; }
html.ui-amo .amo-col.drag-over .col-body { background: var(--action-wash); border-radius: var(--r-md); }

html.ui-amo .amo-quick-add {
  flex-shrink: 0;
  border: 1px dashed var(--control-rule); background: transparent; border-radius: var(--r-sm);
  padding: 10px; font-size: 13px; color: var(--ink-secondary); cursor: pointer; margin-bottom: 4px;
}
html.ui-amo .amo-quick-add:hover { border-color: var(--action); color: var(--action); background: var(--paper); }

/* ---------- Карточка сделки ---------- */
html.ui-amo .deal-card.amo-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 7px 9px 7px 10px; min-height: 0; flex-shrink: 0; height: auto; overflow: visible;
  background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--stage, var(--rule));
  border-radius: var(--r-sm); box-shadow: none; cursor: pointer;
}
html.ui-amo .deal-card.amo-card:hover { border-color: var(--control-rule); border-left-color: var(--stage, var(--rule)); background: #fff; }
html.ui-amo .deal-card.amo-card.is-selected { outline: 2px solid var(--rule-focus); outline-offset: -1px; }
html.ui-amo .deal-card.amo-card.dragging { opacity: .45; }
html.ui-amo .ac-top { display: flex; align-items: baseline; gap: 8px; }
html.ui-amo .ac-name {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html.ui-amo .ac-top time { flex-shrink: 0; font-size: 11px; color: var(--ink-meta); font-variant-numeric: tabular-nums; }
html.ui-amo .ac-sub { display: flex; gap: 6px; font-size: 12px; color: var(--ink-secondary); min-width: 0; }
html.ui-amo .ac-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.ui-amo .ac-sub span + span::before { content: "·"; margin-right: 6px; color: var(--ink-disabled); }
html.ui-amo .ac-mgr { color: var(--info); font-weight: 600; }
html.ui-amo .ac-bot { display: flex; align-items: center; gap: 6px; min-height: 18px; }
html.ui-amo .ac-tag {
  font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 4px;
  background: var(--inset); color: var(--ink-secondary); white-space: nowrap;
}
html.ui-amo .ac-price { font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
html.ui-amo .ac-wait { font-size: 11px; font-weight: 600; color: var(--info); white-space: nowrap; }
html.ui-amo .ac-task { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; white-space: nowrap; }
html.ui-amo .ac-task i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-disabled); }
html.ui-amo .ac-task.none i { background: var(--warn); }
html.ui-amo .ac-task.today { color: var(--ok); }
html.ui-amo .ac-task.today i { background: var(--ok); }
html.ui-amo .ac-task.over { color: var(--danger); }
html.ui-amo .ac-task.over i { background: var(--danger); }
html.ui-amo .ac-task.later i { background: var(--ok); opacity: .5; }
html.ui-amo .deal-card.amo-card .repeat-badge { font-size: 11px; margin-left: 4px; }

@media (max-width: 760px) {
  html.ui-amo .amo-bar { flex-wrap: wrap; }
  html.ui-amo .amo-filter { order: 3; flex-basis: 100%; max-width: none; }
  html.ui-amo .amo-total { margin-left: 0; }
  html.ui-amo .amo-kanban { grid-auto-columns: min(280px, 84vw); }
  html.ui-amo .amo-col { max-height: none; }
}

/* ================= Карточка сделки ================= */
html.ui-amo .amo-deal {
  position: fixed; top: 0; bottom: 0; right: 0; left: var(--bop-sidebar); z-index: 55;
  display: grid; grid-template-columns: 380px minmax(0, 1fr);
  background: var(--workbench);
}
html.ui-amo .amo-deal-left {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--paper); border-right: 1px solid var(--rule);
}
html.ui-amo .amo-deal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 4px 10px; }
html.ui-amo .amo-deal-head h2 {
  flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html.ui-amo .amo-deal-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 16px 12px 52px; font-size: 12px; color: var(--ink-meta); }
html.ui-amo .amo-return { border: 0; background: var(--info-soft); color: var(--info); border-radius: 4px; font-size: 11px; font-weight: 600; padding: 1px 6px; cursor: pointer; }

html.ui-amo .amo-stage { padding: 0 16px 14px; border-bottom: 1px solid var(--rule); }
html.ui-amo .amo-stage-pipe { font-size: 11px; color: var(--ink-meta); }
html.ui-amo .amo-stage-row { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
html.ui-amo .amo-stage-select {
  flex: 1; min-width: 0; appearance: none; -webkit-appearance: none;
  border: 1px solid transparent; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' fill='none' stroke='%2361655e' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M3 4.5L5.5 7 8 4.5'/%3E%3C/svg%3E") no-repeat right 6px center;
  font: 700 15px/1.3 var(--f-body); color: var(--ink); padding: 4px 24px 4px 6px; margin-left: -6px; border-radius: var(--r-sm); cursor: pointer;
}
html.ui-amo .amo-stage-select:hover { border-color: var(--control-rule); }
html.ui-amo .amo-stage-row small { font-size: 12px; color: var(--ink-meta); white-space: nowrap; }
html.ui-amo .amo-progress { display: flex; gap: 3px; }
html.ui-amo .amo-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--inset); }
html.ui-amo .amo-progress i.on { background: var(--seg); }

html.ui-amo .amo-deal-fields { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 24px; }
html.ui-amo .amo-fgroup { padding: 12px 0 4px; }
html.ui-amo .amo-fgroup + .amo-fgroup { border-top: 1px solid var(--rule-soft); }
html.ui-amo .amo-fgroup h4 { margin: 0 0 4px; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-meta); }
html.ui-amo .amo-fgroup .info-row {
  display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 10px; align-items: baseline;
  padding: 5px 0; border: 0; min-height: 0;
}
html.ui-amo .amo-fgroup .info-row .k { font-size: 13px; color: var(--ink-secondary); }
html.ui-amo .amo-fgroup .info-row .v { font-size: 13px; color: var(--ink); text-align: left; word-break: break-word; }
html.ui-amo .amo-fgroup .info-row .v.editable { border-radius: 4px; padding: 1px 4px; margin: -1px -4px; }
html.ui-amo .amo-fgroup .info-row .v.editable:hover { background: var(--inset); }

html.ui-amo .amo-contact {
  display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-md);
}
html.ui-amo .amo-contact > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
html.ui-amo .amo-contact b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.ui-amo .amo-contact span:not(.av) { font-size: 12px; color: var(--ink-secondary); }

html.ui-amo .amo-deal-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
html.ui-amo .amo-feed.deal-unified-feed { flex: 1; min-height: 0; max-height: none; padding: 16px 12px 12px; }
html.ui-amo .amo-feed .deal-feed-event {
  display: flex; align-items: baseline; gap: 8px; margin: 2px 14px; padding: 2px 0;
  border: 0; background: transparent; border-radius: 0;
}
html.ui-amo .amo-feed .deal-feed-event-icon { display: none; }
html.ui-amo .amo-feed .deal-feed-event > div { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px; }
html.ui-amo .amo-feed .deal-feed-event small { order: -1; font-size: 11px; color: var(--ink-meta); }
html.ui-amo .amo-feed .deal-feed-event b { font-size: 12px; font-weight: 600; }
html.ui-amo .amo-feed .deal-feed-event p { font-size: 12px; }
html.ui-amo .amo-feed .deal-feed-event.dp-event-paid b { color: var(--ok); }

html.ui-amo .amo-deal-bottom { flex-shrink: 0; border-top: 1px solid var(--rule); background: var(--paper); }
html.ui-amo .amo-pinned-tasks { max-height: 132px; overflow-y: auto; padding: 6px 16px; border-bottom: 1px solid var(--rule-soft); }
html.ui-amo .amo-pinned-tasks.empty { font-size: 12px; color: var(--ink-meta); padding: 8px 16px; }
html.ui-amo .amo-pinned-tasks.empty button { border: 0; background: none; color: var(--info); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
html.ui-amo .amo-ptask { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: 13px; }
html.ui-amo .amo-ptask-check {
  flex-shrink: 0; width: 16px; height: 16px; border: 1.5px solid var(--control-rule); border-radius: 50%; background: var(--paper); cursor: pointer; align-self: center;
}
html.ui-amo .amo-ptask-check:hover { border-color: var(--ok); background: var(--ok-soft); }
html.ui-amo .amo-ptask-when { font-size: 12px; color: var(--ok); white-space: nowrap; font-weight: 600; }
html.ui-amo .amo-ptask.over .amo-ptask-when { color: var(--danger); }
html.ui-amo .amo-ptask b { font-weight: 600; }
html.ui-amo .amo-ptask-note { color: var(--ink-secondary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

html.ui-amo .amo-composer { padding: 8px 16px 12px; }
html.ui-amo .amo-cmp-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
html.ui-amo .amo-cmp-tabs button {
  border: 0; background: transparent; padding: 4px 10px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; color: var(--ink-secondary); cursor: pointer;
}
html.ui-amo .amo-cmp-tabs button.on { background: var(--action-wash); color: var(--action); }
html.ui-amo .amo-cmp-tabs button:disabled { opacity: .45; }
html.ui-amo .amo-cmp-to { margin-left: auto; font-size: 12px; color: var(--ink-meta); }
html.ui-amo .amo-cmp-chat { display: none; align-items: center; gap: 6px; padding: 0; border: 0; background: transparent; }
html.ui-amo .amo-cmp-chat #dp-chat-text { flex: 1; min-width: 0; }
html.ui-amo .amo-cmp-note { display: none; flex-direction: column; gap: 8px; }
html.ui-amo .amo-composer[data-cmode="chat"] .amo-cmp-chat { display: flex; }
html.ui-amo .amo-composer[data-cmode="note"] .amo-cmp-note,
html.ui-amo .amo-composer[data-cmode="task"] .amo-cmp-note { display: flex; }
html.ui-amo .amo-cmp-note textarea { resize: vertical; min-height: 44px; }
html.ui-amo .amo-cmp-note .dp-action-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
html.ui-amo .amo-cmp-note .dp-action-due-wrap { align-items: center; gap: 6px; margin-right: auto; font-size: 12px; color: var(--ink-secondary); }

@media (max-width: 900px) {
  html.ui-amo .amo-deal { left: 0; display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  html.ui-amo .amo-deal-left { border-right: 0; border-bottom: 1px solid var(--rule); min-height: 0; }
  html.ui-amo .amo-deal-fields { overflow: visible; flex: none; }
  html.ui-amo .amo-deal-main { display: block; min-height: 0; }
  html.ui-amo .amo-feed.deal-unified-feed { overflow: visible; max-height: none; min-height: 40dvh; }
  html.ui-amo .amo-deal-bottom { position: sticky; bottom: 0; z-index: 3; box-shadow: 0 -6px 16px #2527240d; }
  html.ui-amo .amo-composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  html.ui-amo .amo-cmp-tabs { flex-wrap: wrap; }
  html.ui-amo .amo-cmp-to { flex-basis: 100%; margin-left: 0; order: 5; }
  html.ui-amo .amo-cmp-chat .dp-chat-send { padding-inline: 10px; }
  html.ui-amo .amo-deal-meta { padding-left: 16px; }
}

/* ================= Задачи ================= */
html.ui-amo .amo-tasks { grid-auto-columns: minmax(220px, 1fr); }
html.ui-amo .amo-col-empty { font-size: 12px; color: var(--ink-disabled); text-align: center; padding: 16px 0; }
html.ui-amo .amo-task-card {
  display: flex; gap: 10px; align-items: flex-start; flex-shrink: 0;
  padding: 9px 10px; background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--stage);
  border-radius: var(--r-sm); cursor: pointer;
}
html.ui-amo .amo-task-card:hover { border-color: var(--control-rule); border-left-color: var(--stage); }
html.ui-amo .amo-task-card .amo-ptask-check { margin-top: 2px; }
html.ui-amo .amo-task-card > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
html.ui-amo .amo-task-card time { font-size: 11px; font-weight: 600; color: var(--stage); }
html.ui-amo .amo-task-deal { font-size: 12px; color: var(--info); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.ui-amo a.amo-task-deal:hover { text-decoration: underline; }
html.ui-amo .amo-task-card b { font-size: 13px; font-weight: 600; color: var(--ink); }
html.ui-amo .amo-task-card p { margin: 0; font-size: 12px; color: var(--ink-secondary); }
html.ui-amo .amo-total b.t-danger { color: var(--danger); font-weight: 600; }

/* ================= Клиенты ================= */
html.ui-amo #view-customers .cust-newbtn { display: none !important; }
html.ui-amo #view-customers > .workspace-toolbar {
  display: flex; align-items: center; gap: 12px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--rule);
}
html.ui-amo #view-customers > .workspace-toolbar .input { flex: 1; max-width: 640px; height: 36px; background: var(--paper); }
html.ui-amo #view-customers > .workspace-toolbar > span { margin-left: auto; font-size: 13px; color: var(--ink-secondary); white-space: nowrap; }
html.ui-amo #view-customers table.data td { padding-top: 7px; padding-bottom: 7px; }
