.crm-dialog {
  --form-text: #181f2c;
  --form-subtle: #535a66;
  --form-green: #182f56;
  --form-line: #dcdfe3;
  inset: 0;
  box-sizing: border-box;
  width: min(560px, calc(100% - 32px));
  max-width: none;
  max-height: min(90vh, 860px);
  max-height: min(90dvh, 860px);
  margin: auto;
  padding: 0;
  color: var(--form-text);
  background: #fff;
  border: 1px solid var(--form-line);
  border-radius: 6px;
  box-shadow: 0 15px 52px #131b2a29;
  overflow: hidden;
  font: inherit;
}
.crm-dialog::backdrop { background: #11192670; }
html:has(.crm-dialog[open]) { overflow: hidden; }
.crm-dialog [hidden] { display: none !important; }
.crm-dialog *, .crm-dialog *::before, .crm-dialog *::after { box-sizing: border-box; }
.crm-dialog :where(button, input, select, textarea) { font: inherit; }
.crm-dialog button, .crm-dialog select, .crm-dialog summary { cursor: pointer; }
.crm-dialog :focus-visible { outline: 3px solid #3b588b; outline-offset: 2px; }
.crm-dialog-frame {
  display: flex;
  flex-direction: column;
  max-height: min(calc(90vh - 2px), 858px);
  max-height: min(calc(90dvh - 2px), 858px);
}
.crm-dialog-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px 19px;
  border-bottom: 1px solid var(--form-line);
  flex: none;
}
.crm-dialog-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  color: var(--form-green);
}
.crm-dialog-mark svg { width: 24px; height: 24px; }
.crm-dialog-heading { flex: 1; min-width: 0; }
.crm-customer-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; margin-top: 5px;
  color: var(--form-subtle); font-size: .84rem; line-height: 1.45;
}
.crm-summary-region, .crm-summary-owner {
  max-width: min(18em, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crm-high-intent { font-weight: 700; color: #8a3e20; }
.crm-dialog-heading h2 {
  margin: 0;
  max-height: 3.1em;
  overflow: auto;
  color: var(--form-text);
  font-size: 1.35rem;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.crm-dialog-heading p, .crm-hint, .crm-empty {
  margin: 3px 0 0;
  color: var(--form-subtle);
  font-size: .875rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.crm-dialog-close {
  display: grid;
  place-items: center;
  align-self: flex-start;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 4px;
  border: 0;
  padding: 0;
  color: #515863;
  background: transparent;
}
.crm-dialog-close:hover, .crm-btn-muted:hover, .crm-dialog .crm-basic summary:hover { background: #eff1f4; }
.crm-dialog-scroll { min-height: 0; overflow-y: auto; padding: 22px 24px; overscroll-behavior: contain; }
.crm-entry-form, .crm-basic > div { display: grid; gap: 16px; margin: 0; }
.crm-fields-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.crm-trade-fields { display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 14px; align-items: start; }
.crm-source-field { display: grid; gap: 9px; min-width: 0; }
.crm-fields-two:has(.crm-source-field) { align-items: start; }
.crm-field { display: grid; min-width: 0; gap: 7px; margin: 0; color: var(--form-text); }
.crm-field > span { display: flex; align-items: center; gap: 7px; font-size: .9rem; line-height: 1.5; font-weight: 600; }
.crm-field small { color: var(--form-subtle); font-weight: 400; font-size: .75rem; }
.crm-field input, .crm-field textarea, .crm-field select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--form-line);
  border-radius: 6px;
  background: #fff;
  color: var(--form-text);
  line-height: 1.45;
  font-size: 1rem;
}
.crm-field input:focus, .crm-field textarea:focus, .crm-field select:focus { border-color: var(--form-green); }
.crm-field input::placeholder, .crm-field textarea::placeholder { color: #646973; opacity: 1; }
.crm-field textarea { min-height: 82px; resize: vertical; }
.crm-field select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m3 6 5 5 5-5' fill='none' stroke='%2352695e' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
}
.crm-field input[type=date] { appearance: none; font-variant-numeric: tabular-nums; }
.crm-stage-date { align-items: start; }
.crm-date-picker { display: grid; gap: 6px; min-width: 0; }
.crm-date-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-date-shortcuts button {
  min-height: 32px;
  min-width: 44px;
  padding: 3px 8px;
  border: 1px solid var(--form-line);
  border-radius: 6px;
  background: #fff;
  color: var(--form-green);
  font-size: .875rem;
}
.crm-date-shortcuts button:hover { background: #e6eaf1; border-color: #929cad; }
.crm-date-status { color: var(--form-subtle); font-size: .82rem; line-height: 1.5; }
.crm-date-status:empty { display: none; }
@media (pointer: coarse) { .crm-date-shortcuts button { min-height: 44px; } }
.crm-checkbox {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  gap: 8px;
  margin: -8px 0;
  color: var(--form-subtle);
  font-size: .875rem;
  cursor: pointer;
}
.crm-checkbox input { width: 16px; height: 16px; margin: 0; accent-color: var(--form-green); }
.crm-form-error {
  padding: 10px 12px;
  background: #fff2e9;
  border: 1px solid #eccbb6;
  border-radius: 4px;
  color: #7f381b;
  overflow-wrap: anywhere;
  font-size: .9rem;
  line-height: 1.55;
}
.crm-duplicate {
  display: grid;
  justify-items: start;
  gap: 9px;
  padding: 12px 14px;
  border-left: 3px solid #aa752b;
  background: #fcf4e7;
  color: #6d4c1f;
}
.crm-duplicate p, .crm-action-note { margin: 0; font-size: .95rem; line-height: 1.65; overflow-wrap: anywhere; }
.crm-inline-actions, .crm-import-template { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.crm-import-template { flex-direction: column; gap: 10px; }
.crm-section-title { margin: 22px 0 14px; font-size: 1rem; }
.crm-facts { display: grid; margin: 0; }
.crm-facts > div { display: grid; grid-template-columns: minmax(5em, 25%) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--form-line); }
.crm-facts dt { color: var(--form-subtle); }
.crm-facts dd { margin: 0; overflow-wrap: anywhere; }
.crm-field input[type="file"] { padding: 6px; font-size: .9rem; }
.crm-field input::file-selector-button { min-height: 38px; margin-right: 7px; border: 1px solid var(--form-line); border-radius: 3px; background: white; color: var(--form-text); }
.crm-results-filter { margin: 0 0 9px; }
.crm-import-results { padding: 0; margin: 0; list-style: none; }
.crm-import-results li { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--form-line); font-size: .9rem; line-height: 1.5; }
.crm-import-results li b { font-weight: 550; color: var(--form-subtle); }
.crm-import-results li span { overflow-wrap: anywhere; }
.crm-row-ok { color: var(--form-text); }
.crm-row-error { color: #8a391f; }
.crm-dialog-footer {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 15px 24px;
  background: #fff;
  border-top: 1px solid var(--form-line);
}
.crm-btn {
  min-height: 44px;
  min-width: 73px;
  padding: 8px 16px;
  border-radius: 6px;
  line-height: 1.5;
  font-size: .9rem;
  font-weight: 600;
}
.crm-btn-primary { color: #fff; background: var(--form-green); border: 1px solid var(--form-green); }
.crm-btn-primary:hover { background: #122442; }
.crm-btn:disabled { opacity: .7; cursor: wait; }
.crm-btn-muted { color: var(--form-text); background: #fff; border: 1px solid var(--form-line); }
.crm-tabbar {
  display: flex;
  gap: 20px;
  padding: 0 24px;
  border-bottom: 1px solid var(--form-line);
  flex: none;
}
.crm-tabbar button {
  position: relative;
  min-height: 46px;
  padding: 6px 2px;
  border: 0;
  border-radius: 0;
  color: var(--form-subtle);
  background: transparent;
  font-weight: 600;
  font-size: .9rem;
}
.crm-tabbar button[aria-selected=true] { color: var(--form-green); }
.crm-tabbar button[aria-selected=true]::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 3px;
  background: var(--form-green);
}
.crm-tabbar button span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 5px;
  background: #eceef2;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.crm-last-note {
  margin: 0 0 18px;
  padding: 0 0 15px;
  border-bottom: 1px solid var(--form-line);
}
.crm-last-note > div, .crm-history-head, .crm-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}
.crm-last-note strong, .crm-history-head strong { color: var(--form-text); font-size: .9rem; overflow-wrap: anywhere; }
.crm-last-note time, .crm-history-head time { color: var(--form-subtle); font-size: .8rem; font-variant-numeric: tabular-nums; }
.crm-last-note p, .crm-history p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #323b4a;
  line-height: 1.6;
  font-size: .95rem;
}
.crm-last-note p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.crm-basic { border-top: 1px solid var(--form-line); }
.crm-basic summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 9px 0;
  list-style: none;
  border-radius: inherit;
  color: var(--form-text);
  font-size: .9rem;
  font-weight: 600;
}
.crm-basic summary::-webkit-details-marker { display: none; }
.crm-basic summary svg { width: 15px; height: 15px; }
.crm-basic[open] summary svg { transform: rotate(90deg); }
.crm-basic summary span { margin-left: auto; color: var(--form-subtle); font-size: .8rem; font-weight: 400; }
.crm-basic > div { padding: 8px 0 0; }
.crm-history {
  display: grid;
  gap: 0;
  list-style: none;
  padding: 0 0 0 5px;
  margin: 0;
}
.crm-history li { position: relative; min-width: 0; padding: 0 0 23px 19px; }
.crm-history li:last-child { padding-bottom: 0; }
.crm-history li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid #8c97a9;
  border-radius: 50%;
  background: #fff;
}
.crm-history li:first-child::before { border-color: var(--form-green); background: var(--form-green); }
.crm-history li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  left: -1px;
  bottom: -4px;
  width: 2px;
  background: var(--form-line);
}
.crm-history-meta { margin-top: 8px; justify-content: flex-start; color: var(--form-subtle); font-size: .8rem; }
.crm-stage { padding: 2px 8px; color: #364154; background: #e9ecf2; border-radius: 4px; }
@media (max-width: 520px) {
  .crm-trade-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .crm-trade-fields > :last-child { grid-column: 1 / -1; }
  .crm-dialog { width: calc(100% - 16px); border-radius: 4px; max-height: 95vh; max-height: 95dvh; }
  .crm-dialog-frame { max-height: calc(95vh - 2px); max-height: calc(95dvh - 2px); }
  .crm-dialog-header { padding: 15px; gap: 9px; }
  .crm-dialog-mark { height: 28px; width: 28px; }
  .crm-dialog-scroll { padding: 18px 15px; }
  .crm-tabbar { padding: 0 15px; }
  .crm-dialog-footer { padding: 12px 15px max(12px, env(safe-area-inset-bottom)); }
  .crm-date-shortcuts button { min-height: 44px; }
}
@media (max-width: 400px) {
  .crm-fields-two { grid-template-columns: 1fr; }
}
@media (min-width: 370px) and (max-width: 400px) {
  .crm-entry-form:has(.crm-trade-fields) .crm-fields-two:not(.crm-stage-date) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-stage-date { grid-template-columns: 2fr 3fr; }
}
