.crm-approval-summary {
  min-width: 132px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.crm-approval-summary strong,
.crm-approval-summary span {
  display: block;
}

.crm-approval-summary strong {
  color: var(--brand-dark);
  font-family: Manrope, sans-serif;
  font-size: 28px;
}

.crm-approval-summary span {
  color: var(--muted);
  font-size: 12px;
}

.crm-project-approval-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -4px 0 18px;
  padding: 14px 16px;
  border: 1px solid #e8cf9d;
  border-left: 4px solid #c78d25;
  border-radius: 8px;
  background: #fff9e9;
}

.crm-project-approval-copy {
  min-width: 0;
}

.crm-project-approval-kicker {
  display: block;
  margin-bottom: 3px;
  color: #805a0e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.crm-project-approval-copy h2 {
  margin: 0;
  color: var(--ink);
  font-family: Manrope, sans-serif;
  font-size: 16px;
}

.crm-project-approval-copy p {
  margin: 3px 0 0;
  color: #795510;
  font-size: 12px;
}

.crm-project-approval-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex: 0 0 auto;
}

.crm-project-approval-actions .btn {
  white-space: nowrap;
}

.crm-approval-filter {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  align-items: end;
  justify-content: start;
  gap: 8px 12px;
}

.crm-approval-filter label {
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.crm-approval-table table {
  min-width: 980px;
}

.crm-approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crm-reject-panel,
.crm-approve-panel {
  width: 300px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #f1c8c8;
  border-radius: 7px;
  background: #fff8f8;
}

.crm-approve-panel {
  border-color: #b9ddca;
  background: #f2fbf6;
}

.crm-reject-panel label,
.crm-approve-panel label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.crm-reject-panel textarea,
.crm-approve-panel textarea {
  margin-bottom: 8px;
}

.crm-discount-cell {
  max-width: 250px;
  color: #795510;
  font-size: 12px;
  line-height: 1.5;
}

.crm-approval-empty {
  padding: 52px 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--paper);
  text-align: center;
}

.crm-approval-empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-family: Manrope, sans-serif;
}

.crm-approval-empty p {
  margin: 0;
}

.crm-view-root .alert-success {
  border-color: #b9ddca;
  color: #146b43;
  background: #f2fbf6;
}

.crm-workflow-card-head {
  justify-content: space-between;
  gap: 18px;
}

.crm-workflow-card-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.crm-completion-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #b9ddca;
  border-radius: 7px;
  color: #146b43;
  background: #f2fbf6;
}

.crm-completion-banner strong,
.crm-completion-banner span {
  display: block;
}

.crm-completion-banner span {
  color: #477665;
  font-size: 12px;
}

.crm-workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.crm-workflow-grid.technical-only {
  grid-template-columns: minmax(0, 1fr);
}

.crm-workflow-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.crm-workflow-section + .crm-workflow-section {
  border-left: 1px solid var(--line);
}

.crm-workflow-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.crm-workflow-section-head h6 {
  margin: 2px 0 0;
  color: var(--ink);
  font-family: Manrope, sans-serif;
  font-size: 16px;
}

.crm-workflow-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.crm-workflow-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.crm-workflow-steps li {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.crm-workflow-step-number {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--paper);
  font-weight: 800;
}

.crm-workflow-steps li.complete,
.crm-workflow-steps li.current {
  color: var(--brand-dark);
  font-weight: 700;
}

.crm-workflow-steps li.complete .crm-workflow-step-number,
.crm-workflow-steps li.current .crm-workflow-step-number {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.crm-payment-summary {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  margin: 12px 0 18px;
  padding: 12px;
  border-left: 3px solid var(--brand);
  background: var(--canvas);
}

.crm-payment-summary strong,
.crm-payment-summary span {
  display: block;
}

.crm-payment-summary span,
.crm-workflow-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.crm-payment-ledger {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.crm-payment-ledger > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.crm-payment-ledger dt {
  color: var(--muted);
  font-size: 11px;
}

.crm-payment-ledger dd {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.crm-payment-ledger .is-emphasis {
  margin-top: 3px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.crm-payment-ledger .is-emphasis dt,
.crm-payment-ledger .is-emphasis dd {
  color: var(--brand-dark);
  font-weight: 800;
}

.crm-workflow-hint {
  margin: 12px 0 0;
}

.crm-workflow-section > .crm-workflow-hint {
  margin-top: auto;
  padding-top: 12px;
}

.crm-workflow-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-content: start;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.crm-workflow-form label {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
}

.crm-workflow-form select,
.crm-workflow-form textarea,
.crm-workflow-form input[type="file"] {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.crm-workflow-form textarea {
  min-height: 80px;
  resize: vertical;
}

.crm-workflow-form .form-text {
  margin-top: -8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--muted);
}

.crm-workflow-file-list {
  display: grid;
  gap: 6px;
  margin-top: -4px;
}

.crm-workflow-file {
  min-width: 0;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 26px;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
  font-size: 11px;
}

.crm-workflow-file > i {
  color: var(--brand);
  text-align: center;
}

.crm-workflow-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-workflow-file-size {
  color: var(--muted);
  white-space: nowrap;
}

.crm-workflow-file-remove {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.crm-workflow-file-remove:hover,
.crm-workflow-file-remove:focus-visible {
  color: var(--red);
  background: #fff1f1;
  outline: none;
}

.crm-workflow-form button {
  justify-self: start;
  white-space: nowrap;
  margin-top: 4px;
}

.crm-workflow-history-button {
  align-self: flex-start;
  margin-top: 12px;
}

/* Workflow history styles */
.crm-history-item {
  padding: 16px 0;
}

.crm-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.crm-history-header strong {
  font-size: 14px;
  color: var(--brand-dark);
}

.crm-history-notes {
  padding: 12px;
  background: var(--canvas);
  border-left: 3px solid var(--brand);
  margin: 12px 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.6;
}

.crm-history-image {
  margin-top: 12px;
  text-align: center;
  padding: 12px;
  background: var(--canvas);
  border-radius: 6px;
}

.crm-attachment-list,
.crm-deliverable-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.crm-attachment-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.crm-attachment-list i {
  color: var(--brand);
}

.crm-deliverable-list li {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 3px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.crm-deliverable-list li:last-child {
  border-bottom: 0;
}

.crm-deliverable-list small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.crm-empty-note {
  margin: 0;
  color: var(--muted);
}

.crm-project-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  gap: 10px;
}

.crm-project-filter-grid .crm-filter-field {
  min-width: 0;
}

.crm-project-filter-grid label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.crm-project-table table {
  min-width: 1080px;
}

.crm-project-table .project-row {
  cursor: pointer;
}

.crm-project-table .project-row:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.crm-table-subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.crm-project-empty {
  min-height: 220px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--paper);
  text-align: center;
}

.crm-project-empty strong {
  color: var(--ink);
  font-family: Manrope, sans-serif;
}

.crm-project-empty p {
  max-width: 520px;
  margin: 0 0 8px;
}

.crm-notification-slot,
.crm-notification-control {
  position: relative;
}

.crm-notification-trigger {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.crm-notification-trigger:hover,
.crm-notification-trigger:focus-visible,
.crm-notification-trigger.active {
  border-color: var(--brand);
  background: var(--canvas);
  outline: none;
}

.crm-notification-trigger:focus-visible {
  box-shadow: 0 0 0 3px rgba(8, 127, 149, .16);
}

.crm-notification-trigger:active:not(:disabled) {
  transform: translateY(1px);
}

.crm-notification-trigger:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.crm-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--crm-icon) center / contain no-repeat;
  mask: var(--crm-icon) center / contain no-repeat;
}

.crm-icon-bell {
  --crm-icon: url('/static/icons/bell.svg');
}

.crm-notification-count {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border: 2px solid var(--paper);
  border-radius: 10px;
  color: #fff;
  background: var(--red);
  font-size: 10px;
  font-weight: 800;
}

.crm-notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: min(380px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(15, 45, 42, .18);
}

.crm-notification-panel[hidden] {
  display: none;
}

.crm-notification-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.crm-notification-head strong,
.crm-notification-head span {
  display: block;
}

.crm-notification-head strong {
  font-family: Manrope, sans-serif;
}

.crm-notification-head span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.crm-notification-head button,
.crm-notification-state button {
  border: 0;
  color: var(--brand-dark);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.crm-notification-list {
  max-height: min(430px, 62vh);
  overflow-y: auto;
}

.crm-notification-item {
  width: 100%;
  display: block;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.crm-notification-item:last-child {
  border-bottom: 0;
}

.crm-notification-item:hover,
.crm-notification-item:focus-visible {
  background: var(--canvas);
  outline: none;
}

.crm-notification-item.unread {
  border-left: 3px solid var(--brand);
  background: #f1faf9;
}

.crm-notification-message {
  display: block;
  line-height: 1.45;
}

.crm-notification-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.crm-notification-state {
  min-height: 120px;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.crm-notification-state strong {
  color: var(--ink);
}

.crm-notification-state.error {
  color: var(--red);
}

@media (max-width: 640px) {
  .crm-project-approval-callout {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .crm-project-approval-actions {
    justify-content: space-between;
  }

  .crm-approval-summary {
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
    text-align: left;
  }

  .crm-approval-filter {
    grid-template-columns: 1fr;
  }

  .crm-approval-filter label {
    grid-column: auto;
  }

  .crm-notification-panel {
    position: fixed;
    top: 64px;
    right: 8px;
    left: 8px;
    width: auto;
  }

  .crm-workflow-grid {
    grid-template-columns: 1fr;
  }

  .crm-workflow-section + .crm-workflow-section {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .crm-workflow-form {
    grid-template-columns: 1fr;
  }

  .crm-workflow-form label,
  .crm-workflow-form select,
  .crm-workflow-form textarea,
  .crm-workflow-form button {
    grid-column: 1;
    grid-row: auto;
  }

  .crm-project-filter-grid {
    grid-template-columns: 1fr;
  }
}

/* Project detail tabs */
.crm-project-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}

.crm-project-tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.crm-project-tab:hover { color: var(--ink); }

.crm-project-tab.active {
  border-bottom-color: var(--brand);
  color: var(--brand-dark);
}

.crm-project-tab:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* Summary: project / payment / deployment progress tracks */
.crm-progress-card .card-body {
  display: grid;
  gap: 22px;
}

.crm-progress-track__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 10px;
}

.crm-progress-track__head span { color: var(--muted); }
.crm-progress-track__head em { color: var(--amber); font-style: normal; font-weight: 700; }

.crm-progress-track__steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--steps), minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Rail runs between the first and last dot centers. */
.crm-progress-track__steps::before,
.crm-progress-track__steps::after {
  content: "";
  position: absolute;
  top: 7px;
  left: calc(50% / var(--steps));
  height: 4px;
  border-radius: 2px;
}

.crm-progress-track__steps::before {
  right: calc(50% / var(--steps));
  background: var(--line);
}

.crm-progress-track__steps::after {
  width: calc((100% - 100% / var(--steps)) * var(--progress) / 100%);
  background: var(--brand);
}

.crm-progress-track__steps li {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.crm-progress-track__dot {
  width: 18px;
  height: 18px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
}

.crm-progress-track__steps li.complete .crm-progress-track__dot {
  border-color: var(--brand);
  background: var(--brand);
}

.crm-progress-track__steps li.current { color: var(--brand-dark); font-weight: 700; }
.crm-progress-track__steps li.current .crm-progress-track__dot {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-pale);
}

.crm-progress-track.is-done .crm-progress-track__steps li.current .crm-progress-track__dot { background: var(--brand); }
.crm-progress-track.is-warn .crm-progress-track__steps li.current { color: var(--amber); }
.crm-progress-track.is-warn .crm-progress-track__steps li.current .crm-progress-track__dot {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(216, 148, 20, .18);
}

.crm-progress-track__label { overflow-wrap: anywhere; }

/* Activity tab */
.crm-activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.crm-activity-next {
  display: grid;
  gap: 6px;
}

.crm-activity-next span { color: var(--muted); }

.crm-activity-form { display: grid; gap: 10px; }

.crm-activity-form__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.crm-activity-previews,
.crm-activity-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crm-activity-preview {
  position: relative;
  width: 84px;
  height: 84px;
}

.crm-activity-preview img,
.crm-activity-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.crm-activity-preview button {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

.crm-activity-image {
  display: grid;
  width: 110px;
  height: 110px;
  margin: 4px 0 8px;
}

.crm-activity-image__placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.crm-activity-image.is-broken .crm-activity-image__placeholder { color: var(--red); }

.crm-activity-entry__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.crm-activity-entry__text {
  margin: 0 0 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .crm-project-tab { padding: 9px 12px; font-size: 14px; }
  .crm-progress-track__steps li { font-size: 11px; }
  .crm-activity-form__row .ml-auto { margin-left: 0 !important; width: 100%; }
}

/* Project header: title row with the actions menu on the right */
.crm-project-detail-titlebar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.crm-project-detail-titlebar .crm-project-detail-title {
  flex: 1 1 auto;
  min-width: 0;
}

.crm-project-menu {
  position: relative;
  flex: 0 0 auto;
}

.crm-project-menu__toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.crm-project-menu__toggle svg { fill: currentColor; }
.crm-project-menu__toggle:hover,
.crm-project-menu__toggle[aria-expanded="true"] { background: var(--canvas); }
.crm-project-menu__toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.crm-project-menu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(16, 42, 67, .16);
}

.crm-project-menu__list[hidden] { display: none; }

.crm-project-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.crm-project-menu__item i { width: 16px; color: var(--muted); text-align: center; }
.crm-project-menu__item:hover,
.crm-project-menu__item:focus-visible { background: var(--canvas); outline: none; }
.crm-project-menu__item:disabled { opacity: .5; cursor: not-allowed; }
.crm-project-menu__item.is-success,
.crm-project-menu__item.is-success i { color: var(--brand-dark); }
.crm-project-menu__item.is-warning,
.crm-project-menu__item.is-warning i { color: var(--amber); }
.crm-project-menu__item.is-danger,
.crm-project-menu__item.is-danger i { color: var(--red); }

.crm-project-menu__separator {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}

/* Overview progress sits between the header and the tabs. */
.crm-project-detail-header + .crm-progress-card { margin-top: 18px; }

.crm-project-tab__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
}

.crm-project-tab.active .crm-project-tab__count {
  background: var(--brand-pale);
  color: var(--brand-dark);
}

/* Project form: deployment start / end */
.crm-event-window legend { font-size: inherit; font-weight: 700; padding: 0; margin-bottom: 6px; }
.crm-event-window__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.crm-event-window__fields label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
@media (max-width: 520px) {
  .crm-event-window__fields { grid-template-columns: 1fr; }
}

/* Deployment calendar */
.crm-calendar {
  --cal-rent: var(--brand);
  --cal-rent-bg: var(--brand-pale);
  --cal-sale: #b76e00;
  --cal-sale-bg: #fff1d6;
}

.crm-calendar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 14px;
}

.crm-calendar-head h1 { margin: 0; font-size: 28px; }
.crm-calendar-head p { margin: 4px 0 0; color: var(--muted); }

.crm-calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-calendar-nav h2 {
  min-width: 150px;
  margin: 0 0 0 8px;
  font-size: 20px;
}

.crm-calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.crm-calendar-filters { display: flex; flex-wrap: wrap; gap: 8px; }

.crm-calendar-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 600;
  cursor: pointer;
}

.crm-calendar-filter input { margin: 0; }
.crm-calendar-filter__swatch { width: 12px; height: 12px; border-radius: 3px; }
.crm-calendar-filter.is-rent .crm-calendar-filter__swatch { background: var(--cal-rent); }
.crm-calendar-filter.is-sale .crm-calendar-filter__swatch { background: var(--cal-sale); }
.crm-calendar-count { color: var(--muted); font-size: 14px; }

.crm-calendar-grid {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.crm-calendar-grid[aria-busy="true"] { opacity: .6; }

.crm-calendar-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.crm-calendar-row + .crm-calendar-row { border-top: 1px solid var(--line); }

.crm-calendar-weekday {
  padding: 8px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.crm-calendar-day {
  min-width: 0;
  min-height: 118px;
  padding: 6px;
}

.crm-calendar-day + .crm-calendar-day { border-left: 1px solid var(--line); }
.crm-calendar-day.is-outside { background: var(--canvas); }
.crm-calendar-day.is-outside .crm-calendar-day__number { color: var(--muted); opacity: .7; }
.crm-calendar-day.is-selected { box-shadow: inset 0 0 0 2px var(--brand); }

.crm-calendar-day__number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.crm-calendar-day__number:hover { background: var(--canvas); }
.crm-calendar-day.is-today .crm-calendar-day__number { background: var(--brand); color: #fff; }
.crm-calendar-day__number:focus-visible,
.crm-calendar-more:focus-visible,
.crm-calendar-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.crm-calendar-day__events { display: grid; gap: 3px; }

.crm-calendar-chip {
  display: flex;
  gap: 5px;
  min-width: 0;
  padding: 3px 6px;
  border-left: 3px solid var(--cal-rent);
  border-radius: 4px;
  background: var(--cal-rent-bg);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
}

.crm-calendar-chip:hover { text-decoration: none; filter: brightness(.97); }
.crm-calendar-chip.is-sale { border-left-color: var(--cal-sale); background: var(--cal-sale-bg); }
.crm-calendar-chip.is-both { border-left-style: double; border-left-width: 4px; }
.crm-calendar-chip__time { flex: 0 0 auto; font-weight: 800; }
.crm-calendar-chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.crm-calendar-more {
  padding: 2px 6px;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.crm-calendar-agenda {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.crm-calendar-agenda__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.crm-calendar-agenda__head h3 { margin: 0; font-size: 18px; }
.crm-calendar-agenda__day + .crm-calendar-agenda__day { margin-top: 14px; }
.crm-calendar-agenda__day h4 { margin: 0 0 6px; color: var(--muted); font-size: 14px; }

.crm-calendar-agenda__item {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--cal-rent);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

.crm-calendar-agenda__item + .crm-calendar-agenda__item { margin-top: 6px; }
.crm-calendar-agenda__item:hover { background: var(--canvas); text-decoration: none; }
.crm-calendar-agenda__item.is-sale { border-left-color: var(--cal-sale); }
.crm-calendar-agenda__time { font-weight: 800; font-size: 14px; }
.crm-calendar-agenda__body { display: grid; min-width: 0; }
.crm-calendar-agenda__body strong,
.crm-calendar-agenda__body small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-calendar-agenda__body small { color: var(--muted); }
.crm-calendar-agenda__tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }

.crm-calendar-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.crm-calendar-tag.is-rent { background: var(--cal-rent-bg); color: var(--brand-dark); }
.crm-calendar-tag.is-sale { background: var(--cal-sale-bg); color: var(--cal-sale); }

/* Phones: compact grid with dots; the agenda carries the detail. */
@media (max-width: 760px) {
  .crm-calendar-day { min-height: 58px; padding: 3px; }
  .crm-calendar-day__events { display: flex; flex-wrap: wrap; gap: 2px; }
  .crm-calendar-chip {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cal-rent);
  }
  .crm-calendar-chip.is-sale { background: var(--cal-sale); }
  .crm-calendar-chip__time,
  .crm-calendar-chip__text { display: none; }
  .crm-calendar-more { padding: 0; font-size: 10px; }
  .crm-calendar-agenda__item { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .crm-calendar-agenda__tags { justify-content: flex-start; }
}

/* Activity tab: chat window */
.crm-chat {
  display: flex;
  flex-direction: column;
  height: min(70vh, 680px);
  min-height: 420px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.crm-chat__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.crm-chat__head h5 { margin: 0; }
.crm-chat__hint { color: var(--muted); font-size: 13px; }

.crm-chat__log {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  overflow-y: auto;
  background: var(--canvas);
  overscroll-behavior: contain;
}

.crm-chat__log:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.crm-chat__empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.crm-chat__day {
  display: flex;
  justify-content: center;
  margin: 10px 0 4px;
}

.crm-chat__day span {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.crm-chat__msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 78%;
}

.crm-chat__msg:not(.is-continued) { margin-top: 6px; }

.crm-chat__avatar {
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.crm-chat__msg.is-continued .crm-chat__avatar { background: transparent; }

.crm-chat__bubble {
  min-width: 0;
  padding: 8px 12px 6px;
  border-radius: 14px 14px 14px 4px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(16, 42, 67, .08);
}

.crm-chat__msg.is-mine .crm-chat__bubble {
  background: var(--brand);
  color: #fff;
}

.crm-chat__author {
  display: block;
  margin-bottom: 2px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.crm-chat__text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.crm-chat__images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.crm-chat__images .crm-activity-image { width: 140px; height: 140px; margin: 0; }
.crm-chat__msg.is-mine .crm-chat__author { color: #fff; }
.crm-chat__msg.is-mine .crm-activity-image__placeholder { border-color: rgba(255, 255, 255, .5); color: #fff; }

.crm-chat__time {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  text-align: right;
  opacity: .7;
}

.crm-chat__event {
  align-self: flex-start;
  display: grid;
  gap: 2px;
  max-width: min(520px, 92%);
  margin: 8px 0 8px 40px; /* line up with the message bubbles, past the avatar */
  padding: 8px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.crm-chat__event-label {
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.crm-chat__event.is-done .crm-chat__event-label { color: var(--muted); }
.crm-chat__event.is-done strong { color: var(--muted); }
.crm-chat__event small { color: var(--muted); }

.crm-chat__composer {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.crm-chat__previews { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-chat__previews:not(:empty) { padding: 6px 4px 10px; }
.crm-chat__error { color: var(--red); font-size: 13px; }
.crm-chat__error:not(:empty) { padding: 0 4px 6px; }

.crm-chat__bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.crm-chat__attach,
.crm-chat__send {
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.crm-chat__attach { background: var(--canvas); color: var(--muted); }
.crm-chat__attach:hover { color: var(--brand-dark); }
.crm-chat__send { background: var(--brand); color: #fff; }
.crm-chat__send:hover:not(:disabled) { background: var(--brand-dark); }
.crm-chat__send:disabled { opacity: .5; cursor: progress; }

.crm-chat__bar:has(#activityNoteImages:focus-visible) .crm-chat__attach,
.crm-chat__send:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.crm-chat__input {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 160px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.4;
  resize: none;
}

.crm-chat__input:focus { outline: none; border-color: var(--brand); background: var(--paper); }

@media (max-width: 640px) {
  .crm-chat { height: 75vh; min-height: 360px; }
  .crm-chat__log { padding: 12px 8px; }
  .crm-chat__msg { max-width: 92%; }
  .crm-chat__images .crm-activity-image { width: 104px; height: 104px; }
}

/* Visually hidden but available to screen readers and keyboard focus. */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.crm-event-window__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 6px;
}

.crm-event-window__head legend { margin: 0; }

.crm-event-window__allday {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 600;
  cursor: pointer;
}

/* Calendar step ribbons, filter chips and config (colours come from --st). */
.crm-calendar-chip { position: relative; overflow: hidden; }
.crm-calendar-chip:has(.crm-calendar-chip__ribbons) { padding-right: 18px; }

.crm-calendar-chip__ribbons {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 1px;
}

.crm-calendar-chip__ribbons span {
  width: 5px;
  background: var(--st);
}

.crm-calendar-statuses {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: -2px 0 12px;
}

.crm-calendar-statuses__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.crm-calendar-statuses__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.crm-calendar-status-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.crm-calendar-status-filter[aria-pressed="true"] {
  border-color: var(--st);
  box-shadow: inset 0 0 0 1px var(--st);
  background: color-mix(in srgb, var(--st) 12%, var(--paper));
}

.crm-calendar-status-filter:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.crm-calendar-status-filter.is-empty { opacity: .6; }

.crm-calendar-status-filter__swatch {
  width: 5px;
  height: 14px;
  border-radius: 2px;
  background: var(--st);
}

.crm-calendar-status-filter__count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.crm-calendar-statuses__actions { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }

.crm-calendar-status {
  padding: 2px 8px;
  border: 1px solid var(--st, var(--line));
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.crm-calendar-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--st);
}

.crm-calendar-status.is-plain { color: var(--muted); font-weight: 600; }
.crm-calendar-status.is-plain::before { display: none; }

.crm-calendar-config__group {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crm-calendar-config__group legend {
  width: auto;
  margin: 0;
  padding: 0 6px;
  font-size: 14px;
  font-weight: 800;
}

.crm-calendar-config__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}

.crm-calendar-config__row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
}

.crm-calendar-config__row input[type="color"] {
  width: 36px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

@media (max-width: 760px) {
  .crm-calendar-chip { padding-right: 0 !important; overflow: visible; margin: 3px; }
  .crm-calendar-chip[style*="--st"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--st); }
  .crm-calendar-chip__ribbons { display: none; }
  .crm-calendar-statuses__actions { margin-left: 0; }
}

/* Việc của tôi: tasks as rows */
.crm-task-table {
  --task-cols: 34px minmax(180px, 2fr) minmax(110px, 1.2fr) minmax(100px, .9fr) minmax(130px, 1.3fr) minmax(120px, 1fr);
  --task-min: 674px; /* sum of the column minimums */
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.crm-task-table.is-followup {
  --task-cols: 34px minmax(170px, 1.7fr) minmax(100px, 1fr) minmax(180px, 2fr) minmax(120px, 1.1fr) minmax(110px, .9fr) 112px;
  --task-min: 826px;
}

.crm-task-table__head,
.crm-task-row {
  display: grid;
  min-width: var(--task-min);
  grid-template-columns: var(--task-cols);
  align-items: center;
}

.crm-task-table__head {
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.crm-task-row {
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.crm-task-row:hover { background: #f7fafc; }
.crm-task-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.crm-task-cell,
.crm-task-row > .bulk-row-checkbox {
  min-width: 0;
  padding: 10px 12px;
}

.crm-task-row > .bulk-row-checkbox { display: flex; align-items: center; justify-content: center; padding-right: 0; }
.crm-task-cell--check { padding-right: 0; }

.crm-task-cell--project {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.crm-task-cell--project strong { color: var(--brand-dark); font-size: 13px; }
.crm-task-row__name { flex-basis: 100%; font-weight: 600; overflow-wrap: anywhere; }
.crm-task-cell--project .badge { order: 1; }

.crm-task-cell--badges { display: flex; flex-wrap: wrap; gap: 4px; }

.crm-task-cell--owners {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
}

.crm-task-cell--action { text-align: right; }

.crm-task-followup {
  display: grid;
  gap: 2px;
  padding-left: 8px;
  border-left: 3px solid var(--amber);
}

.crm-task-followup.is-missing { border-left-color: var(--red); }
.crm-task-followup.is-upcoming { border-left-color: var(--blue); }
.crm-task-followup__text { font-weight: 700; overflow-wrap: anywhere; }
.crm-task-followup small { color: var(--muted); }
.crm-task-followup__late { color: var(--red); font-weight: 800; }
.crm-task-followup__today { color: var(--amber); font-weight: 800; }
.crm-task-followup__soon { color: var(--blue); font-weight: 800; }

/* Narrow screens: each row stacks into a compact block. */
@media (max-width: 900px) {
  .crm-task-table__head { display: none; }
  .crm-task-row {
    min-width: 0;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
    padding: 6px 0;
  }
  .crm-task-row > .bulk-row-checkbox { grid-row: span 6; padding-top: 12px; }
  .crm-task-cell { padding: 3px 12px; }
  .crm-task-cell[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
  .crm-task-cell--badges[data-label]::before,
  .crm-task-cell--owners[data-label]::before { width: 100%; }
  .crm-task-cell--owners { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .crm-task-cell--action { text-align: left; padding-bottom: 8px; }
}

/* Follow-up groups inside "Đến hạn hành động". */
.crm-task-bucket + .crm-task-bucket { margin-top: 18px; }

.crm-task-bucket__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding-left: 10px;
  border-left: 4px solid var(--bucket);
  font-size: 15px;
  font-weight: 800;
}

.crm-task-bucket__count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bucket);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

.crm-task-bucket.is-overdue { --bucket: var(--red); }
.crm-task-bucket.is-today { --bucket: var(--amber); }
.crm-task-bucket.is-week { --bucket: var(--blue); }
.crm-task-bucket.is-month { --bucket: var(--muted); }
.crm-task-bucket.is-later { --bucket: #94a3b8; }

/* Next-action dialog: earlier versions */
.crm-action-versions__wrap {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.crm-action-versions__wrap h6 { margin: 0 0 8px; font-weight: 800; }

.crm-action-versions {
  display: grid;
  gap: 8px;
  max-height: 260px;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  list-style: none;
}

.crm-action-versions li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  background: var(--canvas);
}

.crm-action-versions li.is-replaced { border-left-color: var(--line); }
.crm-action-versions li.is-replaced strong { color: var(--muted); }
.crm-action-versions li small { color: var(--muted); }

.crm-action-versions__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Sortable list headers */
.crm-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.crm-sort-button i { color: var(--muted); font-size: 12px; }
.crm-sort-button.is-active i { color: var(--brand); }
.crm-sort-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
th.text-right .crm-sort-button { justify-content: flex-end; width: 100%; }
.crm-table-nowrap { white-space: nowrap; }

/* Status buttons on the progress tracks */
.crm-progress-track__head { align-items: center; }
.crm-progress-track__head > span { margin-left: auto; }
.crm-progress-track__action { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.crm-progress-track__action:disabled { opacity: .55; cursor: not-allowed; }

.crm-status-actions { display: grid; gap: 8px; }
.crm-status-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.crm-status-action:hover { border-color: var(--brand); background: var(--canvas); }
.crm-status-action.is-success i { color: #2f7d4a; }
.crm-status-action.is-danger { color: #b42318; }
.crm-status-action.is-warning i { color: var(--amber); }

/* Calendar view switch and Gantt chart */
.crm-calendar-views { display: flex; gap: 6px; }
.crm-gantt-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.crm-gantt { min-width: calc(220px + var(--days) * 30px); }
.crm-gantt__row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) repeat(var(--days), minmax(28px, 1fr));
  align-items: stretch;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}
.crm-gantt__row:last-child { border-bottom: 0; }
.crm-gantt__row > * { grid-row: 1; }
.crm-gantt__row--head { min-height: 40px; background: var(--canvas); font-size: 12px; font-weight: 700; }
.crm-gantt__label {
  grid-column: 1;
  position: sticky;
  left: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 6px 10px;
  border-right: 1px solid var(--line);
  background: inherit;
  background-color: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
.crm-gantt__row--head .crm-gantt__label { background-color: var(--canvas); }
.crm-gantt__label strong,
.crm-gantt__label small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-gantt__label small { color: var(--muted); }
a.crm-gantt__label:hover strong { color: var(--brand); }
.crm-gantt__day {
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.15;
  border-left: 1px solid var(--line);
}
.crm-gantt__day small { color: var(--muted); font-weight: 600; font-size: 10px; }
.crm-gantt__cell { border-left: 1px solid var(--line); }
.crm-gantt__cell.is-weekend,
.crm-gantt__day.is-weekend { background: rgba(101, 117, 139, .07); }
.crm-gantt__cell.is-today,
.crm-gantt__day.is-today { background: rgba(8, 127, 149, .12); }
.crm-gantt__day.is-today { color: var(--brand-dark); }
.crm-gantt__bar {
  z-index: 1;
  align-self: center;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 26px;
  margin: 0 2px;
  padding: 0 8px;
  overflow: hidden;
  border-left: 4px solid var(--st, var(--cal-rent));
  border-radius: 6px;
  background: var(--cal-rent-bg);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.crm-gantt__bar.is-sale { background: var(--cal-sale-bg); border-left-color: var(--st, var(--cal-sale)); }
.crm-gantt__bar.is-cut-start { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.crm-gantt__bar.is-cut-end { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.crm-gantt__bar span { overflow: hidden; text-overflow: ellipsis; }
.crm-gantt__bar:hover { filter: brightness(.96); }
.crm-gantt__bar:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.crm-gantt__empty { padding: 16px; }

/* Locale-independent dd/mm/yyyy date + HH:MM time field */
.crm-dt { display: flex; gap: 6px; min-width: 0; }
.crm-dt__date { position: relative; flex: 1 1 auto; min-width: 0; }
.crm-dt__date .form-control { width: 100%; padding-right: 38px; }
.crm-dt__pick {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--muted);
  transform: translateY(-50%);
  cursor: pointer;
}
.crm-dt__pick:hover { color: var(--brand); background: var(--canvas); }
.crm-dt__pick:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.crm-dt__native {
  position: absolute;
  right: 4px;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.crm-dt__time { flex: 0 0 82px; width: 82px; text-align: center; }

/* Sort direction symbol (text glyph; no icon font is loaded) */
.crm-sort-indicator { color: var(--muted); font-size: 11px; line-height: 1; opacity: .7; }
.crm-sort-button.is-active .crm-sort-indicator { color: var(--brand); opacity: 1; }
.crm-sort-button:hover .crm-sort-indicator { opacity: 1; }

/* Approval queue embedded in Việc của tôi */
.crm-approval-list.is-embedded > .page-header h2 { margin: 0; font-size: 20px; }

/* Points to "Lưu & gửi duyệt" when the form opens from "Nhập báo giá & gửi duyệt" */
#submitProjectBtn.is-highlighted { box-shadow: 0 0 0 3px rgba(8, 127, 149, .35); }

.crm-pending-payments {
  display: grid;
  gap: 6px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid #d97706;
  border-radius: 8px;
}

.crm-pending-payments > span {
  color: var(--muted);
  font-size: 12px;
}

.crm-pending-payments ul {
  display: grid;
  gap: 8px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.crm-pending-payments li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.crm-pending-payments li > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.crm-pending-payments small {
  color: var(--muted);
}

.crm-pending-payment-actions {
  display: flex;
  gap: 6px;
}

.crm-history-review {
  color: var(--muted);
  font-size: 12px;
}

.crm-approval-section-title {
  margin: 24px 0 10px;
  font-size: 15px;
  font-weight: 800;
}

/* Deployment list: project-type tabs and schedule groups */
.crm-deploy-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  /* overflow-x alone makes the y axis scroll too. */
  overflow-y: hidden;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}
.crm-deploy-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.crm-deploy-tab::after {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  background: transparent;
  content: '';
}
.crm-deploy-tab:hover,
.crm-deploy-tab:focus-visible { color: var(--ink); }
.crm-deploy-tab.is-active { color: var(--ink); }
.crm-deploy-tab.is-active::after { background: var(--brand); }
.crm-deploy-tab__badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
}
.crm-deploy-tab__badge[hidden] { display: none; }

.crm-project-table tr.crm-schedule-group > td {
  padding: 10px 14px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.crm-project-table tr.crm-schedule-group--overdue > td {
  background: #fdecec;
  color: var(--red);
}
.crm-schedule-group__count {
  margin-left: 8px;
  color: var(--muted);
  font-weight: 700;
}
.crm-schedule-group--overdue .crm-schedule-group__count { color: inherit; }

/* Deployment preparation check sheet */
.crm-prep-checklist {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--canvas);
}

.crm-prep-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.crm-prep-head h6 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 14px;
}

.crm-prep-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-prep-progress {
  height: 6px;
  margin: 12px 0;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
}

.crm-prep-progress span {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width .2s ease;
}

.crm-prep-steps,
.crm-prep-config-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.crm-prep-step,
.crm-prep-config-item {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.crm-prep-step-mark {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.crm-prep-step.is-done .crm-prep-step-mark {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.crm-prep-step-body {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 13px;
}

.crm-prep-step-body small,
.crm-prep-step-pending,
.crm-prep-check-meta {
  color: var(--muted);
  font-size: 12px;
}

.crm-prep-check-meta {
  display: grid;
  gap: 3px;
}

.crm-prep-check-notes {
  color: var(--ink);
  white-space: pre-wrap;
}

.crm-prep-check-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.crm-prep-check-files a {
  overflow-wrap: anywhere;
}

.crm-prep-config-fields {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.crm-prep-config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.crm-prep-config-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 640px) {
  .crm-prep-step,
  .crm-prep-config-item {
    grid-template-columns: 25px minmax(0, 1fr);
  }

  .crm-prep-step-actions,
  .crm-prep-config-actions {
    grid-column: 2;
  }

  .crm-prep-config-add {
    grid-template-columns: minmax(0, 1fr);
  }
}

.crm-prep-guide {
  margin: 2px 0;
  font-size: 12px;
}

.crm-prep-guide summary {
  color: var(--brand-dark);
  font-weight: 700;
  cursor: pointer;
}

.crm-prep-guide-text {
  margin-top: 4px;
  padding: 8px 10px;
  border-left: 3px solid var(--brand);
  color: var(--ink);
  background: var(--canvas);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.crm-prep-guide.is-static {
  margin-bottom: 12px;
}

.crm-prep-config-add {
  align-items: start;
}
