/* ---------- Nível 1: Cockpit Executivo ---------- */

.cx-hero {
  display: flex;
  align-items: stretch;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--peers-white);
  border-bottom: 1px solid var(--grey-300);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.cx-hero__block {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cx-hero__progress {
  flex: 1 1 240px;
  min-width: 220px;
}

.cx-hero__progress-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.cx-hero__progress-pct {
  font-family: var(--font-secondary);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--peers-blue);
  line-height: 1;
}

.cx-hero__progress-sub {
  font-size: 0.78rem;
  color: var(--grey-600);
}

.cx-progress-bar {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--grey-200);
  overflow: hidden;
}

.cx-progress-bar--sm {
  height: 6px;
  flex: 1;
}

.cx-progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--peers-blue), var(--info-main));
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

.cx-rag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.85rem;
}

.cx-rag__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cx-rag[data-rag="green"] { background: #e3faea; color: #0f7a3d; }
.cx-rag[data-rag="green"] .cx-rag__dot { background: var(--success-main); }
.cx-rag[data-rag="yellow"] { background: #fff5df; color: #8a5b00; }
.cx-rag[data-rag="yellow"] .cx-rag__dot { background: var(--warning-main); }
.cx-rag[data-rag="red"] { background: #ffe6df; color: #a3230f; }
.cx-rag[data-rag="red"] .cx-rag__dot { background: var(--error-main); }

.cx-hero__milestone {
  padding-left: var(--space-4);
  border-left: 1px solid var(--grey-300);
  min-width: 220px;
}

.cx-hero__milestone-eyebrow {
  font-family: var(--font-secondary);
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--info-main);
  margin-bottom: 3px;
}

.cx-hero__milestone-title {
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--peers-blue);
  line-height: 1.3;
}

.cx-hero__updated {
  font-size: 0.72rem;
  color: var(--grey-500);
  text-align: right;
  align-items: flex-end;
  min-width: 140px;
}

/* ---------- Filtros ---------- */

.cx-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--space-4);
  background: var(--grey-50);
  border-bottom: 1px solid var(--grey-300);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.cx-filter-btn {
  font-family: var(--font-secondary);
  font-weight: 600;
  font-size: 0.76rem;
  color: var(--peers-blue);
  background: var(--peers-white);
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cx-filter-btn:hover {
  background: var(--peers-serene-02);
  border-color: var(--peers-serene);
}

.cx-filter-btn[data-active="true"] {
  background: var(--peers-blue);
  border-color: var(--peers-blue);
  color: var(--peers-lime);
}

.cx-filters__hint {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--grey-500);
}

/* ---------- Nível 2: Esteira Tática (acordeon vertical) ---------- */

.cx-track {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-3) var(--space-4) var(--space-6);
  background: var(--grey-100);
}

.cx-track__loading {
  padding: var(--space-4);
  color: var(--grey-600);
}

.cx-row {
  display: flex;
  flex-direction: column;
  background: var(--peers-white);
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.cx-row__accent {
  height: 5px;
  flex-shrink: 0;
}

.cx-row--dimmed {
  opacity: 0.45;
}

/* --- Linha colapsada --- */

.cx-row--collapsed {
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.cx-row--collapsed:hover {
  background: var(--grey-50);
}

.cx-row__collapsed-body {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px var(--space-4);
  min-width: 0;
}

.cx-row__title {
  flex-shrink: 0;
  width: 280px;
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--peers-blue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cx-row__mini-bar {
  position: relative;
  flex: 1;
  max-width: 320px;
  height: 6px;
  background: var(--grey-200);
  border-radius: 3px;
  overflow: hidden;
}

.cx-row__mini-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 3px;
}

.cx-row__pct {
  flex-shrink: 0;
  width: 38px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--grey-600);
}

.cx-row__pulse {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-main);
  animation: cx-pulse 1.8s ease-in-out infinite;
  margin-left: auto;
}

@keyframes cx-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  50% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
}

/* --- Linha expandida --- */

.cx-row__header {
  width: 100%;
  border: none;
  background: none;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--grey-200);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.cx-row__header:hover {
  background: var(--grey-50);
}

.cx-row__header-main {
  flex: 1 1 260px;
  min-width: 0;
}

.cx-row__title--expanded {
  width: auto;
  white-space: normal;
  font-size: 1.05rem;
}

.cx-row__progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 260px;
}

.cx-row__progress-row span {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--grey-700);
  white-space: nowrap;
}

.cx-row__body {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.cx-group {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
}

.cx-group__header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--grey-100);
  border: none;
  cursor: pointer;
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--peers-blue);
  text-align: left;
}

.cx-group__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cx-group__count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--grey-500);
  flex-shrink: 0;
}

.cx-group__add-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--success-main);
  color: var(--peers-white);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.cx-group__header:hover .cx-group__add-btn {
  opacity: 1;
}

.cx-group__add-btn:hover {
  background: #118d57;
}

.cx-toggle {
  flex-shrink: 0;
  font-size: 0.7rem;
  width: 12px;
}

.cx-group__body {
  display: flex;
  flex-direction: column;
}

.cx-group.is-collapsed .cx-group__body {
  display: none;
}

.cx-task {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-top: 1px solid var(--grey-200);
  background: var(--peers-white);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-primary);
}

.cx-task:hover {
  background: var(--peers-serene-02);
}

.cx-task.is-pending {
  box-shadow: inset 3px 0 0 var(--info-main);
}

.cx-task__id {
  flex-shrink: 0;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--grey-500);
  min-width: 48px;
}

.cx-task__name {
  flex: 1;
  font-size: 0.8rem;
  color: var(--grey-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cx-task__duration {
  flex-shrink: 0;
  font-size: 0.68rem;
  color: var(--grey-500);
}

.cx-pill {
  flex-shrink: 0;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.cx-pill--green { background: #e3faea; color: #0f7a3d; }
.cx-pill--yellow { background: #fff5df; color: #8a5b00; }
.cx-pill--red { background: #ffe6df; color: #a3230f; }
.cx-pill--neutral { background: var(--grey-200); color: var(--grey-700); }

.cx-task__remove {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: var(--grey-300);
  color: var(--grey-700);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cx-task:hover .cx-task__remove {
  opacity: 1;
}

.cx-task__remove:hover {
  background: var(--error-main);
  color: var(--peers-white);
}

/* ---------- Nível 3: Drawer ---------- */

.cx-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 19, 52, 0.45);
  z-index: 1000;
  display: none;
}

.cx-drawer-backdrop.is-open {
  display: block;
}

.cx-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background: var(--peers-white);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: var(--space-4);
  box-sizing: border-box;
}

.cx-drawer-backdrop.is-open .cx-drawer {
  transform: translateX(0);
}

.cx-drawer__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--grey-200);
  color: var(--grey-700);
  cursor: pointer;
}

.cx-drawer__close:hover {
  background: var(--grey-300);
}

.cx-drawer__eyebrow {
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--info-main);
  margin: 0 var(--space-6) 4px 0;
}

.cx-drawer__title {
  font-family: var(--font-secondary);
  font-size: 1.2rem;
  color: var(--peers-blue);
  margin: 0 var(--space-6) var(--space-3) 0;
}

.cx-field {
  margin-bottom: var(--space-3);
}

.cx-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--grey-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.cx-field select,
.cx-field input[type="text"],
.cx-field input[type="date"],
.cx-field input[type="number"],
.cx-field textarea {
  width: 100%;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  color: var(--grey-800);
}

.cx-field textarea {
  resize: vertical;
}

.cx-field select[disabled],
.cx-field input[disabled] {
  background: var(--grey-100);
  color: var(--grey-500);
}

.cx-field__hint {
  font-size: 0.72rem;
  color: var(--grey-500);
  margin: 6px 0 0;
}

.cx-field p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--grey-800);
}

.cx-drawer__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.cx-drawer__grid > div {
  min-width: 0;
}

.cx-drawer__grid > div label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.cx-drawer__grid input,
.cx-drawer__grid select {
  width: 100%;
  font-family: var(--font-primary);
  font-size: 0.85rem;
  padding: 6px 8px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  color: var(--grey-800);
}

.cx-empty {
  font-size: 0.8rem;
  color: var(--grey-500);
  font-style: italic;
}

.cx-row__empty-msg {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-size: 0.95rem;
}

.cx-rollout-btn {
  display: block;
  width: fit-content;
  margin: 0 auto var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--peers-blue);
  color: var(--peers-white);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.cx-rollout-btn:hover {
  opacity: 0.85;
}

.cx-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.cx-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--grey-100);
  border-radius: var(--radius-md);
  padding: 6px 8px;
}

.cx-checklist-item__check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--grey-300);
  background: var(--peers-white);
  color: var(--grey-400);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cx-checklist-item--ok .cx-checklist-item__check:not(.cx-checklist-item__check--warn) {
  background: var(--success-main);
  border-color: var(--success-main);
  color: var(--peers-white);
}

.cx-checklist-item--restricao .cx-checklist-item__check--warn {
  background: var(--warning-main);
  border-color: var(--warning-main);
  color: var(--peers-white);
}

.cx-checklist-item__text {
  flex: 1;
  font-size: 0.82rem;
  color: var(--grey-800);
}

.cx-checklist-item--ok .cx-checklist-item__text,
.cx-checklist-item--restricao .cx-checklist-item__text {
  color: var(--grey-500);
  text-decoration: line-through;
}

.cx-checklist-item__remove {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--grey-300);
  color: var(--grey-700);
  font-size: 0.74rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cx-checklist-item__remove:hover {
  background: var(--error-main);
  color: var(--peers-white);
}

.cx-checklist-add {
  display: flex;
  gap: 6px;
}

.cx-checklist-add input {
  flex: 1;
}

.cx-checklist-add button {
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--peers-lime);
  background: var(--peers-blue);
  border: none;
  border-radius: var(--radius-md);
  padding: 0 14px;
  cursor: pointer;
}

.cx-checklist-add button:hover {
  background: #133061;
}

/* ---------- Modal "Adicionar atividade" ---------- */

.cx-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 19, 52, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: var(--space-3);
}

.cx-modal {
  background: var(--peers-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-4);
}

.cx-modal__eyebrow {
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--info-main);
  margin: 0 0 4px;
}

.cx-modal h2 {
  font-family: var(--font-secondary);
  font-size: 1.15rem;
  color: var(--peers-blue);
  margin: 0 0 var(--space-3);
}

.cx-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--space-3);
}

.cx-modal__btn {
  font-family: var(--font-secondary);
  font-weight: 700;
  font-size: 0.82rem;
  border-radius: var(--radius-full);
  padding: 9px 18px;
  cursor: pointer;
  border: 1px solid transparent;
}

.cx-modal__btn--cancel {
  background: var(--peers-white);
  border-color: var(--grey-300);
  color: var(--grey-700);
}

.cx-modal__btn--save {
  background: var(--peers-blue);
  color: var(--peers-lime);
}

.cx-modal__btn--save:hover {
  background: #133061;
}

@media (max-width: 860px) {
  .cx-row__title {
    width: auto;
    max-width: 160px;
  }

  .cx-row__mini-bar {
    max-width: 120px;
  }

  .cx-hero__milestone {
    border-left: none;
    padding-left: 0;
  }
}
