.crm {
  min-width: 0;
}

.crm-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(132px, .6fr) auto auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 15px;
}

.crm select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid #a8b8d1;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.crm-toolbar input {
  min-height: 40px;
}

.crm-result-count,
.crm-muted,
.crm-empty {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}

.crm-result-count {
  margin-bottom: 10px;
}

.crm-status:not(:empty) {
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid #c5d7ee;
  border-radius: 8px;
  background: #ecf5ff;
  color: #204777;
  overflow-wrap: anywhere;
}

.crm-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}

.crm-board[data-filtered='true'] {
  grid-template-columns: minmax(0, 1fr);
}

.crm-column {
  min-width: 0;
  min-height: 130px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eaf0fa;
}

.crm-column[data-dropping] {
  border-color: var(--blue);
  background: #dce8ff;
}

.crm-column h2 {
  min-height: 2.4em;
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid #2a61ca;
  font-size: .9rem;
  line-height: 1.2;
}

.crm-column[data-stage='in_progress'] h2 { border-color: #5363b7; }
.crm-column[data-stage='waiting'] h2 { border-color: #a87520; }
.crm-column[data-stage='done'] h2 { border-color: #2f7b63; }

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

.crm-board[data-filtered='true'] .crm-cards {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
}

.crm-card {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow-wrap: anywhere;
}

.crm-card-title {
  width: fit-content;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: #aac0df;
  text-underline-offset: .19em;
}

.crm-card-title:hover { color: var(--blue); }
.crm-card-company,
.crm-card-contact { color: var(--muted); font-size: .81rem; }

.crm-card select {
  min-height: 33px;
  margin-top: 4px;
  font-size: .76rem;
}

.crm-next-action {
  display: grid;
  gap: 3px;
  margin-block: 4px 2px;
  font-size: .82rem;
}

.crm-next-action time { color: var(--muted); font-size: .76rem; }
.crm-next-action time[data-overdue='true'] { color: #9d2626; font-weight: 700; }
.crm-empty { padding: 8px 0 2px; }

.crm-pager,
.crm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crm-pager:not(:empty) {
  justify-content: center;
  margin: 13px 0;
}

.crm-preferences { margin-top: 18px; }
.crm-preferences summary { font-weight: 700; }
.crm-preferences-body { display: grid; gap: 5px; padding-top: 8px; }

.crm-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid #c4d1e6;
  border-radius: 15px;
  background: #f5f7fb;
  color: var(--ink);
  box-shadow: 0 18px 60px #10244555;
}

.crm-dialog::backdrop { background: #14254482; }

.crm-dialog-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.crm-dialog-header h2 { font-size: 1.3rem; overflow-wrap: anywhere; }
.crm-dialog-header .button { flex-shrink: 0; }
.crm-dialog > .crm-status:not(:empty) { position: sticky; z-index: 1; top: 60px; margin: 0; border-radius: 0; }
.crm-dialog-body { padding: 14px; }
.crm-dialog-body > .panel:last-child { margin-bottom: 0; }
.crm-panel > h3 { font-size: 1.04rem; font-weight: 700; }
.crm-panel > p { margin-top: 5px; }
.crm-form { display: grid; gap: 10px; }
.crm-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.crm-form .field { min-width: 0; }

.crm-event {
  display: grid;
  gap: 4px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.crm-event-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; font-size: .89rem; }
.crm-event-header time { color: var(--muted); font-size: .79rem; }
.crm-event p.crm-event-subject { color: var(--ink); font-weight: 650; }
.crm-event-body { white-space: pre-wrap; }
.crm-more { margin-top: 10px; }

@media (max-width: 1120px) {
  .crm-board:not([data-filtered='true']) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-column h2 { min-height: 0; }
}

@media (max-width: 680px) {
  .crm-toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .crm-toolbar .button { width: 100%; }
}

@media (max-width: 460px) {
  .crm-board:not([data-filtered='true']), .crm-fields { grid-template-columns: minmax(0, 1fr); }
  .crm-toolbar > .field:first-child { grid-column: 1 / -1; }
}
