/* CRM workspace: dense enough for operations, calm enough for daily use. */
.crm-shell {
  --crm-ink: #172b4d;
  --crm-muted: #6b7a90;
  --crm-line: #e2e8f0;
  --crm-blue: #2455a5;
  --crm-blue-dark: #163d79;
  color: var(--crm-ink);
}

.crm-shell > .mb-5 {
  margin-bottom: 18px;
}

.crm-shell > .mb-5 h2 {
  color: var(--crm-ink);
  font-size: clamp(24px, 2.4vw, 31px);
  letter-spacing: -0.025em;
}

.crm-shell > .mb-5 p {
  max-width: 760px;
  margin-top: 7px;
  color: var(--crm-muted);
  line-height: 1.55;
}

.crm-shell > .flex.border-b {
  gap: 4px;
  margin-bottom: 20px;
  border-color: var(--crm-line);
}

.crm-shell > .flex.border-b .tabbtn {
  min-height: 40px;
  border-radius: 8px 8px 0 0;
  padding: 9px 13px;
  color: #66758b;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.crm-shell > .flex.border-b .tabbtn:hover {
  background: #f2f6fc;
  color: var(--crm-blue);
}

.crm-shell > .flex.border-b .tabbtn.border-blue-600 {
  border-color: var(--crm-blue);
  background: #edf3fd;
  color: var(--crm-blue);
}

.crm-lead-workspace {
  min-width: 0;
}

.crm-lead-actions,
.crm-filter-bar,
.crm-customer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.crm-lead-actions {
  margin-bottom: 16px;
}

.crm-action-group,
.crm-view-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.crm-action,
.crm-filter-bar button,
.crm-filter-bar select,
.crm-filter-bar input,
.crm-customer-toolbar input,
.crm-customer-toolbar select {
  min-height: 40px;
  border: 1px solid #d7e0ec;
  border-radius: 8px;
  background: #fff;
  color: #35465f;
  font: inherit;
  font-size: 13px;
}

.crm-filter-bar > button {
  padding: 8px 11px;
  color: #66758b;
  cursor: pointer;
  font-weight: 650;
}

.crm-filter-bar > button:hover {
  border-color: #b2c3da;
  background: #fff;
  color: var(--crm-blue);
}

.crm-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 650;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.crm-action:hover {
  border-color: #a9bedc;
  background: #f4f7fc;
}

.crm-action:active {
  transform: translateY(1px);
}

.crm-action-primary {
  border-color: var(--crm-blue);
  background: var(--crm-blue);
  color: #fff;
  box-shadow: 0 3px 7px rgb(30 78 140 / 14%);
}

.crm-action-primary:hover {
  border-color: var(--crm-blue-dark);
  background: var(--crm-blue-dark);
  color: #fff;
}

.crm-action-soft {
  border-color: #cbdcf4;
  background: #eef4fd;
  color: var(--crm-blue);
}

.crm-filter-bar {
  align-items: stretch;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  background: #f8fafc;
}

.crm-filter-search {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
}

.crm-filter-search i {
  position: absolute;
  top: 12px;
  left: 13px;
  color: #8b9ab0;
  pointer-events: none;
}

.crm-filter-search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  outline: 0;
}

.crm-filter-bar select {
  min-width: 145px;
  padding: 8px 30px 8px 11px;
  cursor: pointer;
  outline: 0;
}

.crm-filter-bar input:focus,
.crm-filter-bar select:focus,
.crm-customer-toolbar input:focus,
.crm-customer-toolbar select:focus {
  border-color: #7297ce;
  box-shadow: 0 0 0 3px rgb(71 122 196 / 12%);
}

.crm-filter-count {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 3px;
  color: var(--crm-muted);
  font-size: 12px;
  white-space: nowrap;
}

.crm-view-toggle {
  gap: 0;
  overflow: hidden;
  border: 1px solid #d7e0ec;
  border-radius: 8px;
  background: #fff;
}

.crm-view-toggle button {
  min-height: 38px;
  padding: 8px 11px;
  border: 0;
  border-right: 1px solid #e2e8f0;
  background: #fff;
  color: #738198;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
}

.crm-view-toggle button:last-child { border-right: 0; }
.crm-view-toggle button:hover { background: #f2f6fc; color: var(--crm-blue); }
.crm-view-toggle button[aria-pressed="true"] { background: #eaf1fc; color: var(--crm-blue); }

.crm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.crm-kpi {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 15px rgb(38 65 103 / 5%);
}

.crm-kpi::after {
  position: absolute;
  right: -18px;
  bottom: -26px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--crm-kpi-tint, #eaf1fc);
  content: '';
  opacity: .72;
}

.crm-kpi-label {
  position: relative;
  z-index: 1;
  color: #728097;
  font-size: 12px;
  font-weight: 650;
}

.crm-kpi-value {
  position: relative;
  z-index: 1;
  margin-top: 5px;
  color: var(--crm-ink);
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.crm-kpi-note {
  position: relative;
  z-index: 1;
  margin-top: 5px;
  color: #8a98ac;
  font-size: 11px;
}

.crm-pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(185px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 6px;
}

.crm-stage {
  min-width: 185px;
  min-height: 180px;
  padding: 10px;
  border: 1px solid #e1e8f2;
  border-radius: 12px;
  background: #f8fafc;
}

.crm-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 29px;
  margin-bottom: 8px;
  color: #52627a;
  font-size: 12px;
  font-weight: 700;
}

.crm-stage-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  height: 23px;
  border-radius: 7px;
  background: #e7edf6;
  color: #62748c;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.crm-stage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-lead-card {
  position: relative;
  padding: 11px 11px 10px 13px;
  border: 1px solid #e4eaf2;
  border-left: 3px solid var(--crm-card-accent, #0ea5e9);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 2px 5px rgb(43 69 104 / 5%);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.crm-lead-card:hover,
.crm-lead-card:focus-visible {
  border-color: #b7c9e2;
  box-shadow: 0 7px 18px rgb(43 69 104 / 11%);
  outline: 0;
  transform: translateY(-1px);
}

.crm-lead-card-name {
  overflow: hidden;
  color: #263b5b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-lead-card-meta {
  margin-top: 4px;
  overflow: hidden;
  color: #78879b;
  font-size: 11px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-lead-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
}

.crm-lead-card-source {
  overflow: hidden;
  color: #93a0b1;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-empty {
  grid-column: 1 / -1;
  padding: 38px 18px;
  border: 1px dashed #d5deeb;
  border-radius: 11px;
  background: #fbfcfe;
  color: #8492a7;
  text-align: center;
}

.crm-table-shell,
.crm-customer-shell {
  overflow: hidden;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 15px rgb(38 65 103 / 4%);
}

.crm-table,
.crm-customer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.crm-table th,
.crm-customer-table th {
  padding: 13px 15px;
  border-bottom: 1px solid var(--crm-line);
  background: #f8fafc;
  color: #718099;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.crm-table td,
.crm-customer-table td {
  padding: 13px 15px;
  border-bottom: 1px solid #edf1f6;
  color: #41526b;
  vertical-align: middle;
}

.crm-table tbody tr:hover td,
.crm-customer-table tbody tr:hover td { background: #f8fafd; }
.crm-table tbody tr:last-child td,
.crm-customer-table tbody tr:last-child td { border-bottom: 0; }

.crm-table-name,
.crm-customer-name {
  color: #263b5b;
  font-weight: 700;
}

.crm-table-sub,
.crm-customer-sub {
  margin-top: 3px;
  color: #8693a6;
  font-size: 11px;
}

.crm-table-actions {
  text-align: right;
  white-space: nowrap;
}

.crm-select-cell {
  width: 42px;
  padding-right: 4px !important;
  padding-left: 12px !important;
  text-align: center !important;
}

.crm-select-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--crm-blue);
  cursor: pointer;
  vertical-align: middle;
}

.crm-select-checkbox:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
.crm-table tbody .crm-row-selected td,
.crm-customer-table tbody .crm-row-selected td { background: #edf4ff; }

.crm-table-actions button,
.crm-customer-table button {
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid #d7e1ef;
  border-radius: 7px;
  background: #fff;
  color: var(--crm-blue);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
}

.crm-table-actions button:hover,
.crm-customer-table button:hover { border-color: #aac0df; background: #eef4fd; }

.crm-table-actions .crm-delete-button,
.crm-customer-table .crm-delete-button {
  min-width: 31px;
  margin-left: 5px;
  border-color: #fecaca;
  color: #b42318;
}

.crm-table-actions .crm-delete-button:hover,
.crm-customer-table .crm-delete-button:hover {
  border-color: #fca5a5;
  background: #fff1f2;
  color: #991b1b;
}

.crm-action-danger {
  border-color: #fecaca;
  background: #fff7f7;
  color: #b42318;
}

.crm-action-danger:hover:not(:disabled) {
  border-color: #fca5a5;
  background: #fff1f2;
  color: #991b1b;
}

.crm-action:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.crm-customer-toolbar {
  align-items: stretch;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  background: #f8fafc;
}

.crm-customer-toolbar input {
  flex: 1 1 300px;
  min-width: 220px;
  padding: 9px 12px;
  outline: 0;
}

.crm-customer-summary {
  align-self: center;
  color: var(--crm-muted);
  font-size: 12px;
  white-space: nowrap;
}

.crm-customer-table { min-width: 1180px; }
.crm-customer-table th:first-child { width: 56px; text-align: center; }
.crm-customer-table th:nth-child(2) { width: 22%; }
.crm-customer-table th:nth-child(3) { width: 16%; }
.crm-customer-table th:nth-child(4) { width: 18%; }
.crm-customer-table th:nth-child(5) { width: 12%; }
.crm-customer-table th:nth-child(6) { width: 12%; }
.crm-customer-table th:nth-child(7) { width: 12%; }
.crm-customer-table th:last-child { width: 132px; text-align: right; }
.crm-customer-table td:first-child { color: #7a8ba3; text-align: center; font-variant-numeric: tabular-nums; }
.crm-customer-table td:last-child { text-align: right; }
.crm-customer-selectable th:first-child { width: 42px; }
.crm-customer-selectable th:nth-child(2) { width: 56px; text-align: center; }
.crm-customer-selectable th:nth-child(3) { width: 22%; }
.crm-customer-selectable th:nth-child(4) { width: 16%; }
.crm-customer-selectable th:nth-child(5) { width: 18%; }
.crm-customer-selectable th:nth-child(8) { width: 12%; }
.crm-customer-selectable td:nth-child(2) { color: #7a8ba3; text-align: center; font-variant-numeric: tabular-nums; }
.crm-customer-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #edf7f0;
  color: #277c4f;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.crm-customer-empty {
  padding: 40px 20px;
  color: #8492a7;
  text-align: center;
}

.crm-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--crm-muted);
  font-size: 12px;
}

.crm-pagination button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #d7e0ec;
  border-radius: 7px;
  background: #fff;
  color: #52647c;
  cursor: pointer;
  font: inherit;
}

.crm-pagination button:disabled { cursor: not-allowed; opacity: .45; }
.crm-pagination button:not(:disabled):hover { border-color: #aac0df; background: #eef4fd; color: var(--crm-blue); }

@media (max-width: 1080px) {
  .crm-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-pipeline { grid-template-columns: repeat(6, minmax(205px, 1fr)); }
}

@media (max-width: 680px) {
  .crm-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .crm-kpi { padding: 12px; }
  .crm-kpi-value { font-size: 21px; }
  .crm-filter-bar { padding: 11px; }
  .crm-filter-search { flex-basis: 100%; }
  .crm-filter-bar select { flex: 1 1 130px; min-width: 0; }
  .crm-filter-count { width: 100%; }
  .crm-table-shell,
  .crm-customer-shell { overflow-x: auto; }
  .crm-table,
  .crm-customer-table { min-width: 730px; }
  .crm-customer-toolbar input { flex-basis: 100%; }
  .crm-customer-summary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .crm-action,
  .crm-lead-card,
  .crm-shell > .flex.border-b .tabbtn { transition: none; }
}
