/* Модуль «Заказчики»: список через объекты (сделка → договор) и досье.
   Язык — как у «Сделок» и карточки договора: плитки денег, сегменты,
   плотная таблица в карточке. Цвет, кегль, отступы и радиусы — только
   токенами (docs/ОБЛИК-И-ШКАЛЫ.md); текст статуса — ступенями --*-fg. */

/* ── Шапка: заголовок, поиск, «+ Заказчик» ── */
.cl__head { flex-wrap: wrap; gap: var(--s-3); }
.cl__search { width: 340px; max-width: 100%; height: 36px; border-radius: var(--radius-full); padding: 0 var(--s-4); font-size: var(--t-base); }
.cl__add { border-radius: var(--radius-full); }

/* ── Плитки ── */
.cl__kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.cl__kpis > .card + .card { margin-top: 0; }
.cl__kpi { padding: var(--s-3) var(--s-4); display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; text-align: left; border: 0; font: inherit; color: inherit; }
.cl__kpi--act { cursor: pointer; transition: box-shadow var(--fast); }
.cl__kpi--act:hover:where([data-hover="mouse"] *) { box-shadow: var(--shadow-md); }
.cl__kpi-l { font: 500 var(--t-xs)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.cl__kpi-v { font-family: var(--mono); font-size: var(--t-xl); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl__kpi-n { font-size: var(--t-sm); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cl__kpi--late .cl__kpi-l, .cl__kpi--late .cl__kpi-v { color: var(--late-fg); }
.cl__kpi--ok .cl__kpi-v { color: var(--ok-fg); }

/* ── Отборы ── */
.cl__bar-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-3); }
.cl__seg { flex-wrap: wrap; }
.cl__aside { margin-left: auto; font-size: var(--t-sm); color: var(--text-dim); }
.cl__aside b { font-family: var(--mono); font-weight: 600; color: var(--text); }

/* ── Таблица: строка — объект, заказчик слева на все свои строки ── */
.cl__card { padding: var(--s-4); margin-bottom: var(--s-3); }
.cl__card > .card__head { display: flex; align-items: center; gap: var(--s-2); padding: 0; margin-bottom: var(--s-3); min-height: 30px; }
.cl__card > .card__head h2 { margin: 0; font-size: var(--t-md); }
.cl__wide { padding: 0; overflow: hidden; }
.cl__wide .table--wide { overflow-x: auto; }
.cl__table { width: 100%; font-size: var(--t-sm); border-collapse: collapse; }
.cl__table th { text-align: left; padding: var(--s-3) var(--s-3); font: 500 var(--t-xs)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.cl__table th.num, .cl__table td.num { text-align: right; }
.cl__table td { padding: var(--s-2) var(--s-3); vertical-align: top; border-top: 1px solid var(--line); }
.cl__table tr:not(.cl__tr--first) td { border-top-color: transparent; }
.cl__table tr:not(.cl__tr--first) td.cl__obj, .cl__table tr:not(.cl__tr--first) td.cl__stage, .cl__table tr:not(.cl__tr--first) td.cl__sum, .cl__table tr:not(.cl__tr--first) td.cl__money { border-top: 1px dashed var(--line); }
.cl__table tfoot td { border-top: 1px solid var(--line); background: var(--sunken); color: var(--text-dim); padding: var(--s-2) var(--s-3); font-family: var(--mono); }
.cl__who, .cl__next { cursor: pointer; }
.cl__who { width: 26%; min-width: 240px; }
.cl__who:hover:where([data-hover="mouse"] *) .cl__name { color: var(--accent-fg); }
.cl__who-in { display: flex; gap: var(--s-3); align-items: flex-start; }
.cl__who-t { display: flex; flex-direction: column; gap: var(--s-05); min-width: 0; }
.cl__name { font-size: var(--t-base); font-weight: 600; color: var(--text); text-decoration: none; }
.cl__sub { font-size: var(--t-sm); color: var(--text-dim); font-weight: 400; }
/* A long unbroken name must wrap, not stretch the card past the screen (found by demo-obem prochnost, audit У-4) */
.cl__name, .cl__sub { min-width: 0; overflow-wrap: anywhere; }
.cl__state { margin-top: var(--s-1); }
.cl__ava {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-fg); font-size: var(--t-sm); font-weight: 600;
}
.cl__ava--big { width: 56px; height: 56px; border-radius: var(--radius-lg); font-size: var(--t-lg); }
.cl__obj { min-width: 200px; }
.cl__obj.is-link { cursor: pointer; }
.cl__obj.is-link:hover:where([data-hover="mouse"] *) .cl__obj-n { color: var(--accent-fg); text-decoration: underline; }
.cl__obj-n { font-weight: 500; color: var(--text); }
.cl__stage .chip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.cl__sum { font-family: var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cl__money { min-width: 180px; }
.cl__none { color: var(--text-dim); }
.cl__none .btn { margin-left: var(--s-2); }
.cl__next { width: 22%; min-width: 200px; }
.cl__muted { color: var(--text-faint); }

/* Полоса оплаты: зелёное — получено, красное — просрочено, жёлтое — ждём */
.cl__bar { display: flex; height: 6px; margin: var(--s-1) 0; border-radius: var(--radius-full); background: var(--sunken); overflow: hidden; }
.cl__bar i { display: block; height: 100%; }
.cl__bar-ok { background: var(--ok); }
.cl__bar-late { background: var(--late); }
.cl__bar-wait { background: var(--warn); }
.cl__pay { display: block; font-size: var(--t-sm); color: var(--text-dim); }
.cl__pay.is-late { color: var(--late-fg); font-weight: 500; }
.cl__pay.is-wait { color: var(--warn-fg); }
.cl__pay.is-ok { color: var(--ok-fg); }

.cl__step { display: flex; gap: var(--s-2); align-items: baseline; justify-content: space-between; }
.cl__step-t { min-width: 0; }
.cl__step-d { flex: none; font-family: var(--mono); font-size: var(--t-sm); color: var(--text-dim); }
.cl__step.is-auto .cl__step-t { color: var(--text-dim); }
.cl__step.is-late .cl__step-t, .cl__step.is-late .cl__step-d { color: var(--late-fg); }

.cl__empty { padding: var(--s-5); }
.cl__empty h2 { margin: 0 0 var(--s-2); font-size: var(--t-md); }
.cl__empty-acts { display: flex; gap: var(--s-2); margin-top: var(--s-3); }

/* Узкий экран — карточками (рисуются всегда, видны только там) */
.cl__cards { display: none; }

/* ── Окна: новый заказчик, контакт, реквизиты ── */
.cl__form { display: grid; gap: var(--s-2); min-width: 0; }
.cl__fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-3); }
.cl__fgrid[hidden] { display: none; }
.cl__f { margin-bottom: var(--s-3); }
.cl__f--wide { grid-column: 1 / -1; }
.cl__dups { padding: var(--s-3); border-radius: var(--radius); background: var(--warn-soft); display: grid; gap: var(--s-2); }
.cl__dups[hidden] { display: none; }
.cl__dups-t { font-weight: 600; color: var(--warn-fg); font-size: var(--t-sm); }
.cl__dup { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); justify-content: space-between; }
.cl__dup-n { min-width: 0; font-weight: 500; }
.cl__force { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); }

/* ── Досье ── */
.cl__crumbs { margin-bottom: var(--s-2); }
.cl__dhead { align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.cl__dtitle { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; flex: 1 1 320px; }
.cl__dtitle h1 { margin: 0; }
.cl__dmeta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); font-size: var(--t-sm); color: var(--text-dim); }
.cl__dacts { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.cl__dacts .btn { border-radius: var(--radius-full); }

.cl__grid {
  display: grid; gap: var(--s-3); align-items: start;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .85fr);
  grid-template-areas: "main hist side";
}
.cl__col { min-width: 0; display: flex; flex-direction: column; }
.cl__col .card + .card { margin-top: 0; }
.cl__col--main { grid-area: main; }
.cl__col--hist { grid-area: hist; }
.cl__col--side { grid-area: side; }
.cl__count { font-family: var(--mono); font-size: var(--t-sm); color: var(--text-dim); }

/* Поле на месте: сохраняется, когда из него уходишь */
.cl__in {
  min-width: 0; height: 32px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  padding: 0 var(--s-2); font: inherit; color: var(--text);
}
.cl__in:hover:where([data-hover="mouse"] *):not(:disabled) { border-color: var(--border); }
.cl__in:focus { outline: 0; border-color: var(--accent); background: var(--surface); }
.cl__in:disabled { color: var(--text); opacity: 1; }
select.cl__in { cursor: pointer; }
.cl__area { height: auto; width: 100%; padding: var(--s-1) var(--s-2); resize: vertical; line-height: 1.45; }
.cl__box { border-color: var(--border); background: var(--surface); }

.cl__nextbox {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-1) var(--s-2); margin-bottom: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--radius-lg); background: var(--accent-soft);
}
.cl__nextbox.is-late { background: var(--late-soft); }
.cl__nextbox-l { grid-column: 1 / -1; display: flex; gap: var(--s-2); align-items: baseline; padding-left: var(--s-2); font: 500 var(--t-xs)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.cl__nextbox.is-late .cl__nextbox-l { color: var(--late-fg); }
.cl__step-in { width: 100%; font-weight: 500; }
.cl__step-in::placeholder { color: var(--text-dim); font-weight: 400; }
.cl__step-date { width: 150px; font-family: var(--mono); }
.cl__nextbox-auto { font-family: var(--font, inherit); text-transform: none; letter-spacing: 0; font-weight: 400; }

/* Объекты в досье */
.cl__o { padding: var(--s-3) 0; border-top: 1px solid var(--line); display: grid; gap: var(--s-1); }
.card__head + .cl__o { border-top: 0; padding-top: 0; }
.cl__o.is-link { cursor: pointer; }
.cl__o.is-link:hover:where([data-hover="mouse"] *) .cl__obj-n { color: var(--accent-fg); text-decoration: underline; }
.cl__o-top, .cl__o-mid { display: flex; align-items: center; gap: var(--s-2); min-width: 0; flex-wrap: wrap; }
.cl__o-sum { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.cl__o-sum.is-late { color: var(--late-fg); }
.cl__code { flex: none; padding: 0 var(--s-2); border-radius: var(--radius-full); font-family: var(--mono); font-size: var(--t-xs); background: var(--sunken); color: var(--text-dim); }
.cl__todo { margin: var(--s-1) 0 0; padding-left: var(--s-4); font-size: var(--t-sm); color: var(--warn-fg); }
.cl__todo li.is-late { color: var(--late-fg); }

/* Платежи */
.cl__ptable { width: 100%; font-size: var(--t-sm); }
.cl__ptable th { text-align: left; font: 500 var(--t-xs)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); padding: var(--s-2); }
.cl__ptable td { padding: var(--s-2); vertical-align: top; border-top: 1px solid var(--line); }
.cl__ptable td:first-child { width: 44%; }
.cl__ptable .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.cl__date { font-family: var(--mono); white-space: nowrap; }
.cl__date.is-late { color: var(--late-fg); }
.cl__fc td { color: var(--text-dim); }

/* История */
.cl__rec { display: grid; gap: var(--s-2); margin-bottom: var(--s-3); padding-bottom: var(--s-3); border-bottom: 1px solid var(--line); }
.cl__rec-row { display: flex; gap: var(--s-2); align-items: center; }
.cl__rec-row select { flex: none; }
.cl__rec-row input[type="date"] { width: 150px; font-family: var(--mono); }
.cl__time { width: 100px; font-family: var(--mono); }
.cl__time[hidden] { display: none; }
.cl__rec-t { flex: 1; }
.cl__grp { margin: var(--s-2) 0 var(--s-1); font: 500 var(--t-xs)/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.cl__evs { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.cl__ev { display: grid; grid-template-columns: 64px 24px minmax(0, 1fr) auto; gap: var(--s-2); align-items: start; padding: var(--s-1) 0; font-size: var(--t-sm); }
.cl__ev-d { font-family: var(--mono); color: var(--text-dim); white-space: nowrap; display: flex; flex-direction: column; }
.cl__ev-d small { font-size: var(--t-xs); }
.cl__ev-ic { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--radius-full); background: var(--sunken); color: var(--text-dim); }
.cl__ev.is-ok .cl__ev-ic { background: var(--ok-soft); color: var(--ok-fg); }
.cl__ev.is-late .cl__ev-ic { background: var(--late-soft); color: var(--late-fg); }
.cl__ev.is-late .cl__ev-t { color: var(--late-fg); }
.cl__ev.is-quiet .cl__ev-t { color: var(--text-dim); }
.cl__ev-t { line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.cl__ev-acts { display: flex; gap: var(--s-05); opacity: 0; transition: opacity var(--fast); }
.cl__ev:hover .cl__ev-acts, .cl__ev:focus-within .cl__ev-acts { opacity: 1; }
@media (hover: none) { .cl__ev-acts { opacity: 1; } }
.cl__x { border: 0; background: none; color: var(--text-faint); cursor: pointer; padding: var(--s-05); border-radius: var(--radius-sm); display: inline-flex; }
.cl__x:hover:where([data-hover="mouse"] *) { color: var(--text); background: var(--hover); }

/* Люди */
.cl__person { padding: var(--s-2) 0; border-top: 1px solid var(--line); display: grid; gap: var(--s-1); }
.card__head + .cl__person { border-top: 0; padding-top: 0; }
.cl__person-n { display: flex; align-items: flex-start; gap: var(--s-2); }
.cl__person-who { flex: 1; min-width: 0; font-weight: 600; }
.cl__person-acts { flex: none; display: flex; gap: var(--s-05); }
.cl__links { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); font-size: var(--t-sm); }
.cl__link { display: inline-flex; align-items: center; gap: var(--s-05); }
.cl__link a { color: var(--accent-fg); text-decoration: none; font-family: var(--mono); }
.cl__link a:hover:where([data-hover="mouse"] *) { text-decoration: underline; }
.cl__main { margin-left: var(--s-1); }

/* Реквизиты */
.cl__check { display: flex; gap: var(--s-2); align-items: flex-start; padding: var(--s-2) var(--s-3); border-radius: var(--radius); font-size: var(--t-sm); margin-bottom: var(--s-3); }
.cl__check.is-ok { background: var(--ok-soft); color: var(--ok-fg); }
.cl__check.is-warn { background: var(--warn-soft); color: var(--warn-fg); }
.cl__req { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-1) var(--s-3); margin: 0; font-size: var(--t-sm); }
.cl__req dt { color: var(--text-dim); }
.cl__req dd { margin: 0; overflow-wrap: anywhere; }

/* О заказчике */
.cl__about { display: grid; gap: var(--s-2); }
.cl__lf { display: grid; gap: var(--s-05); }
.cl__lf > span { font-size: var(--t-xs); color: var(--text-dim); padding-left: var(--s-2); }
.cl__lf .cl__in { width: 100%; }

/* ── Ширина ── */
@media (max-width: 1500px) {
  .cl__grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-areas: "main side" "hist side"; }
}
@media (max-width: 1100px) {
  .cl__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .cl__grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "hist" "side"; }
}
@media (max-width: 760px) {
  .cl__head .cl__search { flex: 1 0 100%; order: 3; width: auto; }
  .cl__head .page__head-right { margin-left: auto; }
  .cl__add { width: 36px; padding: 0; justify-content: center; }
  .cl__add-t { display: none; }
  .cl__kpis { gap: var(--s-2); }
  .cl__kpi { padding: var(--s-2) var(--s-3); }
  .cl__kpi-v { font-size: var(--t-lg); white-space: normal; }
  .cl__seg { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .cl__aside { margin-left: 0; }
  .cl__wide { display: none; }
  .cl__cards { display: grid; gap: var(--s-2); }
  .cl__mcard { padding: var(--s-3); display: grid; gap: var(--s-2); }
  .cl__mcard + .cl__mcard { margin-top: 0; }
  .cl__mhead, .cl__mobj { display: flex; align-items: center; gap: var(--s-2); width: 100%; border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
  .cl__mhead .cl__who-t { flex: 1; }
  .cl__mobj { flex-direction: column; align-items: stretch; gap: var(--s-1); padding-top: var(--s-2); border-top: 1px solid var(--line); }
  .cl__mobj-top { display: flex; justify-content: space-between; gap: var(--s-2); }
  .cl__msum { font-family: var(--mono); white-space: nowrap; }
  .cl__mobj-mid .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .cl__mnext { padding-top: var(--s-2); border-top: 1px solid var(--line); font-size: var(--t-sm); }
  .cl__fgrid { grid-template-columns: minmax(0, 1fr); }
  .cl__dacts { width: 100%; }
  .cl__rec-row { flex-wrap: wrap; }
  .cl__rec-t { flex: 1 0 100%; }
  .cl__ev { grid-template-columns: 52px 24px minmax(0, 1fr) auto; }
  .cl__nextbox { grid-template-columns: minmax(0, 1fr); }
  /* Payments: two lines per payment instead of four columns */
  .cl__ptable thead { display: none; }
  .cl__ptable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-top: 1px solid var(--line); padding: var(--s-2) 0; }
  .cl__ptable td { border: 0; padding: 0 var(--s-1); width: auto !important; }
  .cl__ptable td.num, .cl__ptable td:last-child { text-align: right; }
}
