.crm-sheet {
  --rf-ink: #102b25;
  --rf-muted: #526b63;
  --rf-border: #d6ded8;
  --rf-surface: #fbfbf7;
  --rf-inset: #f0f4ed;
  --rf-focus: #087b67;
  --rf-pad: clamp(20px, 4vw, 38px);
  position: fixed;
  inset: 0 0 0 auto;
  width: min(100%, 680px);
  height: 100%;
  height: 100dvh;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-left: 1px solid var(--rf-border);
  background: var(--rf-surface);
  color: var(--rf-ink);
  box-shadow: -12px 0 50px #06171420;
  font: inherit;
  line-height: 1.45;
}

.crm-sheet[open] { animation: rf-arrive 180ms ease-out; }
.crm-sheet::backdrop { background: #081d185c; }
.crm-sheet, .crm-sheet *, .crm-sheet *::after, .crm-sheet *::before { box-sizing: border-box; }
.crm-sheet [hidden] { display: none !important; }
.crm-sheet :focus-visible { outline: 2px solid var(--rf-focus); outline-offset: 3px; }
.crm-sheet :is(button, input, select, textarea) { font: inherit; }
.crm-sheet button { cursor: pointer; }
.crm-sheet :disabled { cursor: default; opacity: .58; }
.crm-sheet .rf-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.crm-sheet .rf-form { display: flex; flex-direction: column; min-height: 0; gap: 20px; }
.crm-sheet .rf-panel.rf-form { gap: 0; }
.crm-sheet .rf-panel > .rf-form { flex: 1; gap: 0; }
.crm-sheet .rf-head, .crm-sheet .rf-foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding-inline: var(--rf-pad);
  background: var(--rf-surface);
  z-index: 1;
}
.crm-sheet .rf-head {
  justify-content: space-between;
  padding-block: 25px 20px;
  border-bottom: 1px solid var(--rf-border);
}
.crm-sheet .rf-context {
  display: block;
  margin: 0 0 4px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--rf-muted);
  letter-spacing: .02em;
}
.crm-sheet .rf-head h2 {
  margin: 0;
  color: var(--rf-ink);
  font-size: clamp(1.45rem, 4vw, 1.95rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.04em;
}
.crm-sheet .rf-close {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  color: var(--rf-muted);
  border: 1px solid var(--rf-border);
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
}
.crm-sheet .rf-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 25px var(--rf-pad);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.crm-sheet .rf-body > * + * { margin-top: 20px; }
.crm-sheet .rf-foot {
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-block: 14px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rf-border);
}
.crm-sheet .rf-grid, .crm-sheet .rf-section-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}
.crm-sheet .rf-field { display: flex; flex-direction: column; min-width: 0; gap: 6px; }
.crm-sheet .rf-field, .crm-sheet label { color: var(--rf-ink); font-size: .875rem; font-weight: 550; }
.crm-sheet .rf-wide { grid-column: 1 / -1; }
.crm-sheet :is(input:not([type=checkbox],[type=radio],[type=file],[type=hidden],[type=color]), select, textarea) {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 11px;
  color: var(--rf-ink);
  background: white;
  border: 1px solid #abbdb3;
  border-radius: 7px;
  box-shadow: none;
  font-size: .9375rem;
  font-weight: 400;
}
.crm-sheet input::placeholder, .crm-sheet textarea::placeholder { color: #6b7c75; opacity: 1; }
.crm-sheet textarea { min-height: 90px; resize: vertical; }
.crm-sheet :is(input, select, textarea)[aria-invalid=true] { border-color: #aa4230; }
.crm-sheet input:is([type=checkbox],[type=radio]) { accent-color: #086b60; }
.crm-sheet input[type=color] { width: 45px; height: 42px; border: 1px solid var(--rf-border); border-radius: 6px; }
.crm-sheet .rf-area { display: grid; grid-template-columns: minmax(0,1fr) minmax(64px,auto); gap: 7px; }
.crm-sheet .rf-actions, .crm-sheet .rf-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.crm-sheet .rf-toolbar { justify-content: space-between; }
.crm-sheet .rf-search { flex: 1 1 180px; min-width: 0; }
.crm-sheet :is(.rf-primary,.rf-secondary,.rf-quiet,.rf-danger) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}
.crm-sheet .rf-primary { color: #fff; background: #164b3e; border-color: #164b3e; }
.crm-sheet .rf-primary:hover { background: #0e382e; }
.crm-sheet .rf-secondary { background: white; color: var(--rf-ink); border-color: #b6c6be; }
.crm-sheet .rf-quiet { background: transparent; color: #166552; }
.crm-sheet :is(.rf-secondary,.rf-quiet,.rf-close):hover { background: #eaf1eb; }
.crm-sheet .rf-danger { color: #933e2c; background: transparent; }
.crm-sheet .rf-danger:hover { background: #fae8e3; }
.crm-sheet .rf-hint, .crm-sheet .rf-row-meta {
  color: var(--rf-muted);
  font-size: .8125rem;
  font-weight: 400;
  line-height: 1.5;
}
.crm-sheet .rf-hint, .crm-sheet .rf-error { margin-block: 0; }
.crm-sheet .rf-error { color: #8d3023; font-size: .875rem; font-weight: 550; }
.crm-sheet .rf-section { border-block-start: 1px solid var(--rf-border); }
.crm-sheet .rf-section > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.crm-sheet .rf-section > summary::-webkit-details-marker { display: none; }
.crm-sheet .rf-section > summary::after {
  content: '';
  width: 8px;
  height: 8px;
  margin: 0 5px 3px;
  border: solid var(--rf-muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.crm-sheet .rf-section[open] > summary::after { transform: rotate(225deg); margin-bottom: -4px; }
.crm-sheet .rf-section-content { grid-template-columns: minmax(0,1fr); padding: 3px 0 16px; gap: 12px; }
.crm-sheet .rf-inset, .crm-sheet .rf-figure {
  padding: 15px 17px;
  border: 1px solid var(--rf-border);
  border-radius: 9px;
  background: var(--rf-inset);
}
.crm-sheet .rf-figure { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; background: #e9f2e9; border-color: #c4d8ca; color: #1d493b; }
.crm-sheet .rf-figure :is(small, strong) { display: block; }
.crm-sheet .rf-figure small, .crm-sheet .rf-figure > span { font-size: .8125rem; }
.crm-sheet .rf-figure strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.crm-sheet .rf-list, .crm-sheet .rf-stages { display: grid; gap: 7px; margin-inline: 0; padding: 0; list-style: none; }
.crm-sheet .rf-row, .crm-sheet .rf-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--rf-border);
  border-radius: 8px;
  background: white;
}
.crm-sheet .rf-row-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.crm-sheet .rf-row-title { display: block; color: var(--rf-ink); font-size: .9375rem; font-weight: 600; }
.crm-sheet .rf-row-meta { display: block; }
.crm-sheet .rf-stage { flex-wrap: wrap; gap: 8px; }
.crm-sheet .rf-stage .rf-field { flex: 1 1 140px; }
.crm-sheet .rf-empty {
  padding: 23px 16px;
  border: 1px dashed #bacbc1;
  border-radius: 8px;
  color: var(--rf-muted);
  text-align: center;
  font-size: .875rem;
}
.crm-sheet .rf-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e5eee6;
  color: #335b47;
  font-size: .75rem;
  font-weight: 600;
}
.crm-sheet .rf-thumb {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--rf-border);
  border-radius: 8px;
  background: var(--rf-inset);
  object-fit: contain;
}
.crm-sheet .rf-thumb img { width: 100%; height: 100%; object-fit: contain; }
.crm-sheet .rf-file, .crm-sheet input[type=file] {
  max-width: 100%;
  color: var(--rf-muted);
  font-size: .8125rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.crm-sheet .rf-file > .rf-grid { margin: 10px 0 6px; }
.crm-sheet input[type=file]::file-selector-button {
  min-height: 42px;
  margin-right: 9px;
  padding: 8px 12px;
  border: 1px solid #b6c6be;
  border-radius: 6px;
  background: white;
  color: var(--rf-ink);
  font: inherit;
  cursor: pointer;
}
@keyframes rf-arrive { from { transform: translateX(30px); opacity: .55; } to { transform: translateX(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .crm-sheet[open] { animation: none; } }
@media (max-width: 540px) {
  .crm-sheet { width: 100%; border-left: none; --rf-pad: 18px; }
  .crm-sheet .rf-head { padding-block: 17px 15px; }
  .crm-sheet .rf-body { padding-block: 18px; }
  .crm-sheet .rf-grid, .crm-sheet .rf-section-content { grid-template-columns: minmax(0,1fr); gap: 14px; }
  .crm-sheet .rf-row { flex-wrap: wrap; }
  .crm-sheet .rf-row-main { min-width: 125px; }
  .crm-sheet :is(.rf-primary,.rf-secondary,.rf-quiet,.rf-danger) { min-height: 44px; }
  .crm-sheet :is(input,select,textarea):not([type=file]) { font-size: 16px; }
}
