.crm-shell { max-width: 1440px; }
.crm-shell [hidden],
.crm-dialog [hidden] { display: none !important; }
.crm-task-complete { margin-top: 8px; }
.crm-close-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.crm-outcome-note { margin-top: 14px; color: var(--ink-dim); }
.crm-truncation { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--warning); border-radius: 10px; background: #fff8e7; color: #6f4b00; font-size: 11px; }
.crm-brand-link { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.crm-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--acc-deep);
  font: 600 10px/1.2 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.crm-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
.crm-header p { max-width: 680px; }
.crm-header-actions { display: flex; gap: 9px; flex: 0 0 auto; }
.crm-workspace-switch {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.crm-workspace-switch button {
  min-height: 37px;
  padding: 7px 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font: 600 11px/1 inherit;
  cursor: pointer;
}
.crm-workspace-switch button[aria-selected="true"] { background: var(--ink); color: #fff; }
.crm-workspace-switch button:focus-visible,
.crm-template-list button:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }
.crm-section-heading,
.crm-workspace-top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}
.crm-section-heading h2,
.crm-workspace-top h2 {
  font: 600 18px/1.2 'Space Grotesk', sans-serif;
  letter-spacing: -.025em;
}
.crm-section-heading > p { color: var(--ink-soft); font-size: 11px; }
.crm-today { margin-bottom: 24px; }
.crm-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  margin-top: 13px;
}
.crm-summary-card {
  appearance: none;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.crm-summary-card:hover { border-color: var(--acc-dim); box-shadow: 0 10px 24px -18px rgba(13, 16, 24, .38); transform: translateY(-1px); }
.crm-summary-card:focus-visible,
.crm-view-switch button:focus-visible,
.crm-record-button:focus-visible,
.crm-icon-button:focus-visible,
.crm-kanban-card:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
}
.crm-summary-card.is-active { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.crm-summary-card strong,
.crm-summary-card span,
.crm-summary-card small { display: block; }
.crm-summary-card strong { font: 600 25px/1 'Space Grotesk', sans-serif; }
.crm-summary-card span { margin-top: 9px; font-size: 12px; font-weight: 650; }
.crm-summary-card small { margin-top: 4px; color: var(--ink-soft); font-size: 10px; line-height: 1.45; }
.crm-summary-card[data-summary="overdue"] strong { color: var(--negative); }
.crm-summary-card[data-summary="due_today"] strong { color: var(--warning); }
.crm-summary-skeleton {
  min-height: 103px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(100deg, var(--surface) 25%, var(--line-soft) 38%, var(--surface) 52%);
  background-size: 200% 100%;
  animation: crm-shimmer 1.2s linear infinite;
}
@keyframes crm-shimmer { to { background-position-x: -200%; } }

.crm-workspace {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.crm-view-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--line-soft);
}
.crm-view-switch button {
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-dim);
  font: 600 11px/1 inherit;
  cursor: pointer;
}
.crm-view-switch button.active { background: var(--surface); color: var(--acc-deep); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.crm-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) repeat(3, minmax(130px, .7fr)) auto;
  gap: 10px;
  align-items: end;
  margin-top: 18px;
  padding: 13px;
  border-radius: 12px;
  background: var(--line-soft);
}
.crm-filters .field { gap: 4px; }
.crm-filters .field label { font-size: 9px; }
.crm-filters input,
.crm-filters select { min-height: 38px; }
.crm-clear-filters { min-height: 38px; }
.crm-state,
.crm-detail-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 28px;
  color: var(--ink-dim);
  font-size: 12px;
  text-align: center;
}
.crm-state.is-error,
.crm-detail-state.is-error { flex-direction: column; color: var(--negative); }
.crm-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: crm-spin .7s linear infinite;
}
@keyframes crm-spin { to { transform: rotate(360deg); } }
.crm-empty { padding: 48px 20px; text-align: center; }
.crm-empty h3 { font: 600 16px/1.2 'Space Grotesk', sans-serif; }
.crm-empty p { max-width: 420px; margin: 7px auto 0; color: var(--ink-dim); font-size: 12px; line-height: 1.55; }

.crm-pipeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 11px;
  margin-top: 16px;
  padding: 2px 2px 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}
.crm-column {
  min-height: 330px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--line-soft);
}
.crm-column-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 3px 10px; }
.crm-column-header h3 { font-size: 11px; font-weight: 650; }
.crm-column-header span {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 10px;
}
.crm-column-cards { display: grid; gap: 8px; }
.crm-kanban-card {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
}
.crm-kanban-card:hover { border-color: var(--acc-dim); }
.crm-kanban-card strong,
.crm-kanban-card span,
.crm-kanban-card small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crm-kanban-card strong { font-size: 12px; white-space: nowrap; }
.crm-kanban-card .crm-opportunity-name { margin-top: 5px; color: var(--ink-dim); font-size: 11px; white-space: nowrap; }
.crm-card-meta { display: flex; justify-content: space-between; gap: 7px; margin-top: 11px; }
.crm-card-meta small { color: var(--ink-soft); font-size: 9px; white-space: nowrap; }
.crm-card-action { margin-top: 8px; color: var(--warning); font-size: 9px; line-height: 1.35; }
.crm-column-empty { padding: 30px 8px; color: var(--ink-soft); font-size: 10px; text-align: center; }

.crm-list-wrap { margin-top: 16px; overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 9px;
  letter-spacing: .05em;
  text-align: left;
  text-transform: uppercase;
}
.crm-table td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); font-size: 11px; vertical-align: middle; }
.crm-table tr:last-child td { border-bottom: 0; }
.crm-record-button { border: 0; background: transparent; color: var(--ink); font: 650 12px/1.25 inherit; cursor: pointer; text-align: left; }
.crm-record-button:hover { color: var(--acc-deep); }
.crm-contact-secondary { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 9px; }
.crm-stage-badge,
.crm-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  font-size: 9px;
  font-weight: 650;
}
.crm-status-badge.is-complete { background: var(--positive-soft); color: var(--positive); }
.crm-status-badge.is-attention { background: var(--warning-soft); color: var(--warning); }

.crm-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(880px, calc(100dvh - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
}
.crm-detail-dialog { width: min(1040px, calc(100vw - 32px)); }
.crm-dialog::backdrop { background: rgba(13, 15, 20, .48); backdrop-filter: blur(3px); }
.crm-dialog > form,
.crm-dialog > .crm-dialog-header,
.crm-dialog > .crm-detail-state,
.crm-dialog > #contactDetail { padding: 22px 24px; }
.crm-dialog > form > .crm-dialog-header { margin: -22px -24px 19px; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); }
.crm-dialog > .crm-dialog-header { position: sticky; z-index: 3; top: 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(14px); }
.crm-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.crm-dialog-header h2 { font: 600 21px/1.15 'Space Grotesk', sans-serif; letter-spacing: -.025em; }
.crm-dialog-header p { margin-top: 6px; color: var(--ink-dim); font-size: 11px; line-height: 1.45; }
.crm-icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-dim);
  font: 400 23px/1 sans-serif;
  cursor: pointer;
}
.crm-icon-button:hover { border-color: var(--ink-soft); color: var(--ink); }
.crm-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--line-soft);
  cursor: pointer;
}
.crm-check-row input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--acc); }
.crm-check-row strong,
.crm-check-row small { display: block; }
.crm-check-row strong { font-size: 12px; }
.crm-check-row small { margin-top: 3px; color: var(--ink-dim); font-size: 10px; line-height: 1.45; }
.crm-fieldset {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.crm-fieldset:disabled { opacity: .55; }
.crm-fieldset legend { padding: 0 6px; color: var(--ink-dim); font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.crm-contact-picker { margin-bottom: 18px; }
.crm-form-status { min-height: 18px; margin-top: 12px; color: var(--ink-dim); font-size: 11px; }
.crm-form-status.is-error { color: var(--negative); }
.crm-form-status.is-success { color: var(--positive); }

.crm-detail-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .85fr); gap: 14px; align-items: start; }
.crm-detail-main,
.crm-detail-side { display: grid; gap: 12px; min-width: 0; }
.crm-detail-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.crm-detail-card h3 { margin-bottom: 11px; font: 600 14px/1.2 'Space Grotesk', sans-serif; }
.crm-detail-card .hint { margin: -5px 0 12px; color: var(--ink-dim); font-size: 10px; line-height: 1.45; }
.crm-inline-form { display: grid; gap: 10px; }
.crm-inline-form .grid { gap: 9px; }
.crm-inline-form .field input,
.crm-inline-form .field select,
.crm-inline-form .field textarea { padding: 8px 10px; }
.crm-inline-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.crm-inline-actions .btn-primary,
.crm-inline-actions .btn-secondary { padding: 8px 12px; font-size: 11px; }
.crm-action-status { flex: 1; min-height: 16px; color: var(--ink-soft); font-size: 9px; line-height: 1.35; }
.crm-timeline { position: relative; display: grid; gap: 0; list-style: none; }
.crm-timeline::before { content: ''; position: absolute; top: 7px; bottom: 7px; left: 5px; width: 1px; background: var(--line); }
.crm-timeline li { position: relative; padding: 0 0 16px 21px; }
.crm-timeline li:last-child { padding-bottom: 0; }
.crm-timeline li::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 1px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 0 1px var(--acc-dim);
}
.crm-timeline strong { display: block; font-size: 11px; }
.crm-timeline p { margin-top: 3px; color: var(--ink-dim); font-size: 10px; line-height: 1.45; white-space: pre-wrap; }
.crm-timeline time { display: block; margin-top: 4px; color: var(--ink-soft); font-size: 9px; }
.crm-mini-list { display: grid; gap: 7px; list-style: none; }
.crm-mini-list li { padding: 10px; border-radius: 9px; background: var(--line-soft); }
.crm-mini-list strong,
.crm-mini-list span,
.crm-mini-list small { display: block; }
.crm-mini-list strong { font-size: 11px; }
.crm-mini-list span { margin-top: 4px; color: var(--ink-dim); font-size: 10px; }
.crm-mini-list small { margin-top: 4px; color: var(--ink-soft); font-size: 9px; }
.crm-empty-inline { padding: 13px; border: 1px dashed var(--line); border-radius: 9px; color: var(--ink-soft); font-size: 10px; text-align: center; }
.crm-client-link {
  padding: 12px;
  border-radius: 10px;
  background: var(--line-soft);
}
.crm-client-link strong,
.crm-client-link span { display: block; }
.crm-client-link strong { font-size: 11px; }
.crm-client-link span { margin-top: 4px; color: var(--ink-dim); font-size: 10px; line-height: 1.45; }
.crm-client-link.is-linked { background: var(--positive-soft); }
.crm-client-link.is-linked strong { color: var(--positive); }

.crm-templates-workspace {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.crm-workspace-description { max-width: 650px; margin-top: 6px; color: var(--ink-dim); font-size: 11px; line-height: 1.5; }
.crm-template-filters {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 17px;
  padding: 12px;
  border-radius: 12px;
  background: var(--line-soft);
}
.crm-template-filters .field { min-width: 190px; }
.crm-template-layout {
  display: grid;
  grid-template-columns: minmax(230px, .7fr) minmax(0, 1.7fr);
  gap: 13px;
  margin-top: 13px;
}
.crm-template-list-panel {
  min-width: 0;
  max-height: 720px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--line-soft);
}
.crm-template-list { display: grid; gap: 5px; padding: 7px; }
.crm-template-list > button {
  width: 100%;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.crm-template-list > button:hover { border-color: var(--line); background: var(--surface); }
.crm-template-list > button.is-active { border-color: var(--acc-dim); background: var(--acc-soft); }
.crm-template-list strong,
.crm-template-list span { display: block; }
.crm-template-list strong { font-size: 11px; }
.crm-template-list span { margin-top: 4px; color: var(--ink-soft); font-size: 9px; }
.crm-template-editor {
  min-width: 0;
  min-height: 400px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.crm-template-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.crm-template-editor-header h3 { font: 600 18px/1.2 'Space Grotesk', sans-serif; }
.crm-template-editor-header p { margin-top: 5px; color: var(--ink-soft); font: 400 9px/1.4 'JetBrains Mono', monospace; overflow-wrap: anywhere; }
.crm-template-channel { flex: 0 0 auto; }
.crm-template-editor textarea { min-height: 190px; font-family: 'JetBrains Mono', ui-monospace, monospace; line-height: 1.55; }
.crm-variable-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.crm-variable-chip {
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--acc-soft);
  color: var(--acc-deep);
  font: 500 9px/1.2 'JetBrains Mono', monospace;
}
.crm-preview {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--line-soft);
}
.crm-preview > span { display: block; margin-bottom: 9px; color: var(--ink-soft); font-size: 9px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.crm-preview-subject { margin-bottom: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 650; }
.crm-preview-body { color: var(--ink-dim); font-size: 11px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-template-actions { display: flex; align-items: center; gap: 8px; margin-top: 15px; }
.crm-template-actions .crm-action-status { margin-right: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
@media (max-width: 1000px) {
  .crm-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-search-field { grid-column: 1 / -1; }
  .crm-clear-filters { justify-self: start; }
  .crm-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .crm-template-layout { grid-template-columns: minmax(200px, .65fr) minmax(0, 1.35fr); }
}
@media (max-width: 620px) {
  .crm-header,
  .crm-section-heading,
  .crm-workspace-top { align-items: stretch; flex-direction: column; }
  .crm-header-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .crm-header-actions button { min-height: 44px; padding-inline: 10px; }
  .crm-section-heading > p { margin-top: -8px; }
  .crm-workspace { margin-inline: -2px; padding: 15px 12px; border-radius: 14px; }
  .crm-view-switch { width: 100%; }
  .crm-view-switch button { flex: 1; min-height: 42px; }
  .crm-filters { grid-template-columns: minmax(0, 1fr); }
  .crm-search-field { grid-column: auto; }
  .crm-clear-filters { justify-self: stretch; min-height: 44px; }
  .crm-summary-grid { gap: 8px; }
  .crm-summary-card { min-height: 108px; padding: 13px; }
  .crm-pipeline { grid-auto-columns: minmax(82vw, 1fr); }
  .crm-list-wrap { overflow: visible; }
  .crm-table,
  .crm-table tbody,
  .crm-table tr,
  .crm-table td { display: block; width: 100%; }
  .crm-table thead { display: none; }
  .crm-table tr { padding: 13px; border: 1px solid var(--line); border-radius: 11px; }
  .crm-table tr + tr { margin-top: 8px; }
  .crm-table td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .crm-table td::before { content: attr(data-label); flex: 0 0 auto; color: var(--ink-soft); font-size: 9px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
  .crm-table td:first-child { display: block; padding-bottom: 10px; text-align: left; }
  .crm-table td:first-child::before { display: none; }
  .crm-dialog,
  .crm-detail-dialog {
    width: 100vw;
    max-width: none;
    max-height: calc(100dvh - 10px);
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }
  .crm-dialog > form,
  .crm-dialog > .crm-dialog-header,
  .crm-dialog > .crm-detail-state,
  .crm-dialog > #contactDetail { padding: 18px 15px; }
  .crm-dialog > form > .crm-dialog-header { margin: -18px -15px 17px; padding: 18px 15px 14px; }
  .crm-dialog .field input,
  .crm-dialog .field select,
  .crm-dialog .field textarea { min-height: 44px; font-size: 16px; }
  .crm-inline-actions { align-items: stretch; flex-direction: column; }
  .crm-inline-actions button { min-height: 44px; width: 100%; }
  .crm-workspace-switch { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .crm-workspace-switch button { min-height: 44px; padding-inline: 8px; }
  .crm-templates-workspace { padding: 15px 12px; border-radius: 14px; }
  .crm-template-filters { align-items: stretch; flex-direction: column; }
  .crm-template-filters .field,
  .crm-template-filters .crm-view-switch { width: 100%; }
  .crm-template-layout { grid-template-columns: minmax(0, 1fr); }
  .crm-template-list-panel { max-height: 260px; }
  .crm-template-editor { padding: 14px 12px; }
  .crm-template-actions { align-items: stretch; flex-direction: column; }
  .crm-template-actions button { min-height: 44px; width: 100%; }
}
