/* Доски с перетаскиванием (kanban.js): проекты на компьютере и доска сделок. */

/* --- Перетаскивание --- */
.kk-card, .sq-kc { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.kk-press { transform: scale(.97); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
body > .kk-ghost {
  position: fixed; left: 0; top: 0; margin: 0; z-index: 9999; pointer-events: none; box-sizing: border-box;
  will-change: translate, rotate; cursor: grabbing;
  transition: rotate .15s ease-out, scale .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
body > .kk-ghost.lift { scale: 1.04; box-shadow: 0 18px 40px -8px rgba(15,20,30,.28), 0 4px 12px rgba(15,20,30,.12); }
.kk-ph {
  background: transparent !important; box-shadow: none !important;
  outline: 2px dashed color-mix(in srgb, var(--ink) 18%, transparent); outline-offset: -2px;
  border-radius: 18px;
}
.kk-ph > * { visibility: hidden; }
.kk-gone { display: none !important; }
html.kk-grabbing, html.kk-grabbing * { cursor: grabbing !important; }
.kk-drop { animation: kkDrop .42s cubic-bezier(.2,.8,.2,1); }
@keyframes kkDrop { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #3b82f6) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.kk-shake { animation: kkShake .42s; }
@keyframes kkShake { 20%, 60% { translate: -5px 0; } 40%, 80% { translate: 5px 0; } }
.kk-over { background: color-mix(in srgb, var(--accent, #3b82f6) 7%, var(--sq-soft, transparent)) !important; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent, #3b82f6) 35%, transparent) !important; }
.kk-deny { opacity: .55; }
[data-col] { transition: background .2s, box-shadow .2s, opacity .2s; }

/* Каскадное появление карточек при открытии доски */
.kk-in { animation: kkIn .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--kk-i, 0) * 40ms); }
@keyframes kkIn { from { opacity: 0; transform: translateY(10px) scale(.98); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }

@media (prefers-reduced-motion: reduce) {
  .kk-in, .kk-drop, .kk-shake { animation: none; }
  .kk-ghost, .kk-press { transition: none; }
}

/* --- Общие кусочки карточек --- */
.kk-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; margin-top: 2px; }
.kk-owner { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font: inherit; font-size: 12px; font-weight: 500; color: var(--ink-2, var(--ink)); background: none; border: 0; padding: 0; text-align: left; }
.kk-owner > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kk-owner > svg { width: 12px; height: 12px; flex: none; color: var(--muted); }
button.kk-owner { cursor: pointer; border-radius: 999px; padding: 2px 8px 2px 2px; margin: -2px 0 -2px -2px; }
button.kk-owner:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.kk-owner.free { color: var(--muted); }
.ava.kk-ava { width: 22px; height: 22px; font-size: 10px; flex: none; }
.kk-dash { width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed color-mix(in srgb, var(--ink) 30%, transparent); display: inline-flex; align-items: center; justify-content: center; flex: none; box-sizing: border-box; }
.kk-dash svg { width: 12px; height: 12px; }
.kk-team .ava { width: 22px; height: 22px; font-size: 10px; margin-left: -7px; border-width: 2px; border-color: var(--card); }
.kk-team .ava:first-child { margin-left: 0; }
.kk-noteam { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* --- Доска сделок --- */
.kk-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
.kk-chips::-webkit-scrollbar { display: none; }
.kk-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--chip, var(--card)); color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
.kk-chip .ava { margin-left: -6px; }
.kk-chip i { font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kk-chip.on { background: var(--dark, var(--ink)); color: var(--on-dark, #fff); box-shadow: none; }
.kk-chip.on i { color: inherit; opacity: .7; }

.kk-board { display: grid; grid-auto-flow: column; grid-auto-columns: 100%; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 6px; scroll-padding: 0 16px; scrollbar-width: none; overscroll-behavior-x: contain; }
.kk-board::-webkit-scrollbar { display: none; }
html.kk-grabbing .kk-board { scroll-snap-type: none; }
.kk-col { scroll-snap-align: start; scroll-snap-stop: always; background: color-mix(in srgb, var(--card) 55%, transparent); border-radius: 22px; padding: 8px; box-shadow: inset 0 0 0 1px var(--line); min-height: 260px; display: flex; flex-direction: column; min-width: 0; }
.kk-colh { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px 8px; }
.kk-colh b { font-size: 15px; font-weight: 600; }
.kk-cnt { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kk-colsum { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--ink-2, var(--ink)); font-variant-numeric: tabular-nums; }
.kk-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 60px; }
.kk-empty { display: grid; place-items: center; min-height: 80px; font-size: 13px; color: var(--muted); border-radius: 16px; border: 1.5px dashed var(--line); }
.kk-list:has(.kk-card) .kk-empty { display: none; }

.kk-card { position: relative; background: var(--card); border-radius: 18px; padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--line), var(--card-shadow, 0 1px 2px rgba(0,0,0,.04)); display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: grab; min-width: 0; }
.kk-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.kk-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 20px; }
.kk-src { font-size: 11px; font-weight: 600; letter-spacing: .01em; padding: 3px 8px; border-radius: 999px; background: var(--st-blue-bg, var(--chip)); color: var(--ink-2, var(--ink)); white-space: nowrap; }
.kk-sum { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kk-name { font-size: 15px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kk-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kk-age { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kk-age svg { width: 13px; height: 13px; }
.kk-age.hot { color: var(--hot, #d9480f); font-weight: 600; }
.kk-pay { display: flex; flex-direction: column; gap: 4px; }
.kk-pay span { font-size: 12px; color: var(--muted); }
.kk-bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; }
.kk-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green, #2f9e44); transition: width .4s; }

.kk-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.kk-paid { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--dark, var(--ink)); color: var(--on-dark, #fff); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.kk-paid svg { width: 13px; height: 13px; }
.kk-paid:active { transform: scale(.96); }
/* Оплачено полностью: зелёная вспышка и карточка улетает с доски продаж */
.kk-fly { animation: kkFly .55s cubic-bezier(.55,0,.75,.2) forwards; pointer-events: none; }
@keyframes kkFly {
  0% { box-shadow: inset 0 0 0 2px var(--green, #2f9e44); }
  35% { transform: scale(1.03); box-shadow: inset 0 0 0 2px var(--green, #2f9e44), 0 10px 30px -10px rgba(47,158,68,.5); }
  100% { transform: translate(40%, -12px) scale(.85) rotate(4deg); opacity: 0; }
}
.kk-paylink { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--st-green-bg, var(--chip)); color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.kk-paylink svg { width: 13px; height: 13px; }
.kk-paylink:active { transform: scale(.96); }

/* Зона «Отказ» появляется снизу, пока карточку держат */
.kk-zone { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 9998; translate: -50% 140%; opacity: 0; display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-radius: 999px; background: var(--rose-bg, #fde8e8); color: var(--rose, #c92a2a); font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0,0,0,.3); transition: translate .3s cubic-bezier(.2,.8,.2,1), opacity .2s, scale .2s; pointer-events: none; }
.kk-zone svg { width: 16px; height: 16px; }
.kk-dragging .kk-zone { translate: -50% 0; opacity: 1; pointer-events: auto; }
.kk-zone.kk-over { scale: 1.08; background: var(--rose, #c92a2a) !important; color: #fff; box-shadow: 0 12px 34px -8px rgba(201,42,42,.5) !important; }
.kk-hint { margin: 12px 4px 0; font-size: 13px; color: var(--muted); }

/* Компьютер: три колонки во всю ширину */
body.desk .kk-chips { margin: 0 0 14px; padding: 0; }
body.desk .kk-board { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(240px, 1fr)); grid-auto-columns: auto; margin: 0; padding: 0 0 6px; scroll-snap-type: none; }
body.desk .kk-col { border-radius: 24px; padding: 10px; min-height: 420px; box-shadow: inset 0 0 0 1px var(--sq-line-in, var(--line)); }
body.desk .kk-card { box-shadow: inset 0 0 0 1px var(--sq-line-in, var(--line)), var(--sq-shadow, none); transition: box-shadow .2s, transform .2s; }
body.desk .kk-card:hover { box-shadow: inset 0 0 0 1px var(--sq-line-in, var(--line)), 0 6px 18px -8px rgba(15,20,30,.18); }
body.desk .sq-kc .kk-foot { padding-top: 6px; border-top: 1px solid var(--sq-line-in, var(--line)); margin-top: 4px; }
body.desk .sq-kc:hover { box-shadow: inset 0 0 0 1px var(--sq-line-in), 0 6px 18px -8px rgba(15,20,30,.18); }

/* Кнопка «Диалог» на карточке сделки — маленькое окно переписки (компьютер) или «Чаты» (телефон) */
.kk-sp { flex: 1; }
.kk-chatb { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 10px; background: var(--chip, rgba(0, 0, 0, 0.05)); color: var(--ink); cursor: pointer; transition: background 0.15s, transform 0.15s; }
.kk-chatb svg { width: 15px; height: 15px; }
.kk-chatb:hover { background: var(--ink); color: var(--card, #fff); }
.kk-chatb:active { transform: scale(0.92); }

/* Телефон: на экране ровно одна колонка, свайп — следующая; точки показывают, где вы */
.kk-dots { display: flex; justify-content: center; gap: 6px; margin: 10px 0 2px; }
.kk-dots button { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 4px; background: var(--line); cursor: pointer; transition: width 0.25s, background 0.25s; }
.kk-dots button.on { width: 20px; background: var(--ink); }
body.desk .kk-dots { display: none; }
