/* ============================================================
   cab-management.css — раздел «Управление» (js/pages/management.js).
   Только свои классы cab-mgmt-*; цвета — токены дизайн-системы, хардкода нет.
   Ничего окружного: оформление отделимо от работы, раздел переносится
   на другую машину вместе с этим файлом.
   ============================================================ */

.cab-mgmt__stack { display: flex; flex-direction: column; gap: 18px; }

.cab-mgmt__source {
  margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--mpr-muted);
  padding: 10px 14px; border: 1px solid var(--mpr-line-soft); border-radius: var(--mpr-r-sm);
  background: var(--mpr-card);
}
.cab-mgmt__source b { color: var(--mpr-forest); font-weight: 600; }

.cab-mgmt__slices { margin: 0; }

/* ---------- Панель ---------- */
.cab-mgmt-panel { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.cab-mgmt-panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cab-mgmt-panel__title { font-size: 15px; font-weight: 600; color: var(--mpr-forest); line-height: 1.3; }
.cab-mgmt-panel__sub { margin-top: 3px; font-size: 12px; color: var(--mpr-muted); line-height: 1.45; max-width: 62ch; }
.cab-mgmt-panel__count {
  font-family: var(--mpr-mono); font-size: 12px; color: var(--mpr-muted);
  border: 1px solid var(--mpr-line-soft); border-radius: var(--mpr-r-pill); padding: 3px 10px; white-space: nowrap;
}

.cab-mgmt-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cab-mgmt-search { max-width: 280px; min-width: 180px; flex: 1 1 200px; }

.cab-mgmt-more { display: flex; justify-content: center; margin-top: 12px; }

.cab-mgmt-note { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: var(--mpr-muted); }
.cab-mgmt-note b { color: var(--mpr-forest); font-weight: 600; }

/* ---------- Общие мелочи ---------- */
.cab-mgmt-chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: var(--mpr-r-pill);
  border: 1px solid var(--mpr-line-soft); background: var(--mpr-card);
  font-size: 11.5px; line-height: 1.5; color: var(--mpr-muted); white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: inline-block;
}
.cab-mgmt-flag {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: var(--mpr-r-pill);
  font-size: 11.5px; line-height: 1.5; white-space: nowrap;
  background: var(--mpr-work-bg); color: var(--mpr-work-fg); border: 1px solid var(--mpr-work-line);
}
.cab-mgmt-flag--late { background: var(--mpr-risk-bg); color: var(--mpr-risk-fg); border-color: var(--mpr-risk-line); }
.cab-mgmt-flag--soon { background: var(--mpr-focus-bg); color: var(--mpr-focus-fg); border-color: var(--mpr-focus-line); }
.cab-mgmt-flag--muted { background: transparent; color: var(--mpr-muted); border-color: var(--mpr-line-soft); }

/* ---------- Карточка проекта ---------- */
.cab-mgmt-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 1100px) { .cab-mgmt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.cab-mgmt-card {
  display: flex; flex-wrap: wrap; gap: 14px; padding: 14px;
  border: 1px solid var(--mpr-line-soft); border-radius: var(--mpr-r-lg);
  background: var(--mpr-card-strong); box-shadow: var(--mpr-shadow-soft);
}
.cab-mgmt-card__cover { position: relative; flex: 0 0 156px; max-width: 100%; align-self: flex-start; }
.cab-mgmt-card__logo {
  position: absolute; left: 8px; top: 8px; width: 34px; height: 34px; object-fit: contain;
  background: rgba(255, 253, 247, .9); border-radius: var(--mpr-r-sm); padding: 3px;
  border: 1px solid var(--mpr-line-soft);
}
.cab-mgmt-card__state {
  position: absolute; right: 8px; bottom: 8px; padding: 3px 9px; border-radius: var(--mpr-r-pill);
  font-size: 11px; line-height: 1.5; background: var(--mpr-card-strong); color: var(--mpr-muted);
  border: 1px solid var(--mpr-line-soft);
}
.cab-mgmt-card__state--risk,
.cab-mgmt-card__state--late { background: var(--mpr-risk-bg); color: var(--mpr-risk-fg); border-color: var(--mpr-risk-line); }
.cab-mgmt-card__state--soon { background: var(--mpr-focus-bg); color: var(--mpr-focus-fg); border-color: var(--mpr-focus-line); }
.cab-mgmt-card__state--work { background: var(--mpr-work-bg); color: var(--mpr-work-fg); border-color: var(--mpr-work-line); }
.cab-mgmt-card__state--done { background: var(--mpr-done-bg); color: var(--mpr-done-fg); border-color: var(--mpr-done-line); }

.cab-mgmt-card__body { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.cab-mgmt-card__chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cab-mgmt-card__title { font-size: 14.5px; font-weight: 600; line-height: 1.35; color: var(--mpr-forest); }
.cab-mgmt-card__title:hover { text-decoration: underline; }
.cab-mgmt-card__sub { margin: 0; font-size: 12px; color: var(--mpr-muted); line-height: 1.45; }
.cab-mgmt-card__facts { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--mpr-muted); }
.cab-mgmt-card__next { margin: 0; font-size: 12px; line-height: 1.45; color: var(--mpr-forest); }

.cab-mgmt-card__ready {
  display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--mpr-line-soft);
}
.cab-mgmt-card__bar { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cab-mgmt-card__pct { font-size: 22px; font-weight: 600; letter-spacing: -.02em; color: var(--mpr-forest); line-height: 1; min-width: 52px; }
.cab-mgmt-card__note { margin: 0; font-size: 11.5px; color: var(--mpr-muted); line-height: 1.4; }
.cab-mgmt-card__open { white-space: nowrap; flex: 0 0 auto; }

@media (max-width: 720px) {
  .cab-mgmt-card__cover { flex: 1 1 100%; }
}

/* ---------- Контрольные точки ---------- */
.cab-mgmt-points { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 900px) { .cab-mgmt-points { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.cab-mgmt-point {
  display: grid; gap: 3px; padding: 10px 12px; border-radius: var(--mpr-r-sm);
  border: 1px solid var(--mpr-line-soft); background: var(--mpr-card); min-height: 44px;
  border-left: 3px solid var(--mpr-line);
}
.cab-mgmt-point:hover { border-color: var(--mpr-line-strong); background: var(--mpr-card-strong); }
.cab-mgmt-point.is-late { border-left-color: var(--mpr-risk-fg); }
.cab-mgmt-point.is-soon { border-left-color: var(--mpr-gold); }
.cab-mgmt-point__kind { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--mpr-muted); }
.cab-mgmt-point.is-late .cab-mgmt-point__kind { color: var(--mpr-risk-fg); }
.cab-mgmt-point__title { font-size: 13.5px; font-weight: 500; color: var(--mpr-forest); line-height: 1.4; }
.cab-mgmt-point__meta { font-size: 12px; color: var(--mpr-forest); font-family: var(--mpr-mono); }
.cab-mgmt-point__proj,
.cab-mgmt-point__who { font-size: 11.5px; color: var(--mpr-muted); line-height: 1.4; }

/* ---------- Ответственные ---------- */
.cab-mgmt-owners { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 1000px) { .cab-mgmt-owners { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.cab-mgmt-owner {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--mpr-line-soft); border-radius: var(--mpr-r); background: var(--mpr-card);
}
.cab-mgmt-owner.is-none { border-style: dashed; }
.cab-mgmt-owner__head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.cab-mgmt-owner__name { font-size: 13.5px; font-weight: 600; color: var(--mpr-forest); line-height: 1.35; }
.cab-mgmt-owner__post { margin-top: 2px; font-size: 11.5px; color: var(--mpr-muted); line-height: 1.4; max-width: 46ch; }
.cab-mgmt-owner__badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cab-mgmt-owner__list { display: flex; flex-direction: column; gap: 6px; }
.cab-mgmt-owner__proj {
  display: grid; gap: 2px; padding: 7px 10px; border-radius: var(--mpr-r-sm);
  border: 1px solid var(--mpr-line-soft); background: var(--mpr-card-strong); min-height: 44px;
}
.cab-mgmt-owner__proj:hover { border-color: var(--mpr-line-strong); }
.cab-mgmt-owner__proj-title { font-size: 12.5px; font-weight: 500; color: var(--mpr-forest); line-height: 1.4; }
.cab-mgmt-owner__proj-meta { font-size: 11.5px; color: var(--mpr-muted); }

/* ---------- Контракты ---------- */
.cab-mgmt-contracts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 900px) { .cab-mgmt-contracts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1300px) { .cab-mgmt-contracts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.cab-mgmt-contract {
  display: flex; flex-direction: column; gap: 7px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--mpr-line-soft); border-radius: var(--mpr-r); background: var(--mpr-card);
}
.cab-mgmt-contract:hover { border-color: var(--mpr-line-strong); background: var(--mpr-card-strong); }
.cab-mgmt-contract:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(143, 149, 80, .28); }
.cab-mgmt-contract__meta { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--mpr-muted); }
.cab-mgmt-contract__title { margin: 0; font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--mpr-forest); }
.cab-mgmt-contract__pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cab-mgmt-contract__proj { font-size: 11.5px; color: var(--mpr-muted); line-height: 1.4; }
.cab-mgmt-contract__how { font-size: 11px; color: var(--mpr-muted); font-style: normal; opacity: .8; }

/* ---------- «Как считаем» ---------- */
.cab-mgmt-how {
  border: 1px solid var(--mpr-line-soft); border-radius: var(--mpr-r-sm);
  background: var(--mpr-card); padding: 10px 14px;
}
.cab-mgmt-how > summary { cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--mpr-forest); min-height: 24px; }
.cab-mgmt-how__body p { margin: 10px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--mpr-muted); max-width: 78ch; }

/* Лента срезов и наборы кнопок на телефоне прокручиваются внутри себя */
@media (max-width: 640px) {
  .cab-mgmt__slices,
  .cab-mgmt-tools .np-seg { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cab-mgmt-tools .np-seg::-webkit-scrollbar,
  .cab-mgmt__slices::-webkit-scrollbar { height: 3px; }
  .cab-mgmt-search { max-width: none; }
  .cab-mgmt-panel { padding: 14px; }
}

/* Длинные названия поставщиков и точек не должны растягивать колонку сетки */
.cab-mgmt-contract, .cab-mgmt-point, .cab-mgmt-owner, .cab-mgmt-card { min-width: 0; }
.cab-mgmt-contract__title, .cab-mgmt-contract__proj,
.cab-mgmt-point__title, .cab-mgmt-point__proj, .cab-mgmt-point__who,
.cab-mgmt-owner__proj-title, .cab-mgmt-card__title { overflow-wrap: anywhere; }
.cab-mgmt-contract__pills .cab-mgmt-chip { max-width: 100%; }
.cab-mgmt__source-note { display: block; margin-top: 4px; }
