/* ResourceEditor — F7.W2 split-layout (Cal.com canon: list 280px + detail right) */

/* F43.W1 — root override для HTML [hidden] attribute.
 * Браузерный default `[hidden] { display: none }` имеет specificity (0,1,0),
 * равной любому class-selector. Наши `.ref-skeleton { display: flex }`,
 * `.ref-grid { display: grid }`, `.ref-error { display: flex }`, `.ref-toast`
 * объявлены позже в файле — побеждают по cascade order, [hidden] игнорируется.
 *
 * Симптомы до fix: серые skeleton-полосы остаются видимыми поверх grid после
 * `_show('grid')`; error/toast могут показываться одновременно со skeleton.
 *
 * Canon Stripe/Linear/services-products.css:350 (.sp-view [hidden]):
 * scoped override с !important в начале файла как base reset. */
.ref-wrap [hidden],
.re-root [hidden] { display: none !important; }

.re-root {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - 56px);
  min-height: 600px;
  background: #f9fafb;
}

/* F20.W9.W1 — 3-pane layout: sidebar (groups) | list (resources) | detail */
.re-root-3pane {
  grid-template-columns: 244px 320px 1fr;
}

@media (max-width: 1100px) {
  .re-root-3pane {
    grid-template-columns: 220px 280px 1fr;
  }
}

.re-sidebar {
  border-right: 1px solid #e5e7eb;
  background: #fafbfc;
  overflow-y: auto;
}

.rg-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.rg-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #eef0f3;
}

.rg-sidebar-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.rg-sidebar-add {
  border: 0;
  background: transparent;
  color: var(--brand-accent-hover);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease-out;
}
.rg-sidebar-add:hover { background: color-mix(in srgb, var(--brand-accent) 10%, transparent); }

.rg-list {
  list-style: none;
  margin: 0;
  padding: 6px 6px 12px;
  flex: 1;
}

.rg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  color: #1f2937;
  position: relative;
  transition: background 120ms ease-out;
}
.rg-item:hover { background: #f1f5f9; }
.rg-item.is-active {
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  color: var(--brand-accent-deep);
  font-weight: 500;
}
.rg-item.is-active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--brand-accent-hover);
}

.rg-item-marker {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
}
.rg-item-marker[style*="background"] { color: rgba(255,255,255,0.92); }

.rg-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rg-item-count {
  font-size: 11.5px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 22px;
  text-align: center;
}
.rg-item.is-active .rg-item-count {
  background: color-mix(in srgb, var(--brand-accent) 18%, transparent);
  color: var(--brand-accent-deep);
}

.rg-item-actions {
  display: none;
  gap: 2px;
  margin-left: 4px;
}
.rg-item:hover .rg-item-actions {
  display: inline-flex;
}
.rg-item-act {
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 5px;
  display: inline-flex;
}
.rg-item-act:hover { background: #e2e8f0; color: #1f2937; }

.rg-divider {
  height: 1px;
  background: #eef0f3;
  margin: 8px 8px;
  list-style: none;
}

.rg-state {
  padding: 12px 14px;
  font-size: 12.5px;
  color: #94a3b8;
  font-style: italic;
}
.rg-state.is-error { color: #dc2626; font-style: normal; }

/* F26.W1 — ResourceGroupChipsBar (top-bar chips canonical Notion/Linear). */
.rg-chips-wrap {
  position: relative;
  width: 100%;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}
.rg-chips-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.rg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.rg-chip:hover { background: #f1f5f9; border-color: #cbd5e1; }
.rg-chip.is-active {
  background: var(--brand-accent-soft);
  border-color: var(--brand-accent);
  color: var(--brand-accent-deep);
}
.rg-chip.is-drag-over {
  background: #ddd6fe;
  border-color: #7c3aed;
  border-style: dashed;
}
.rg-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.rg-chip-name { line-height: 1; }
.rg-chip-count {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.rg-chip.is-active .rg-chip-count { color: var(--brand-accent-deep); background: color-mix(in srgb, var(--brand-accent) 15%, transparent); }

.rg-chip-add, .rg-chip-manage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px dashed #cbd5e1;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 150ms ease-out;
}
.rg-chip-add:hover, .rg-chip-manage:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  background: color-mix(in srgb, var(--brand-accent) 5%, transparent);
}

.rg-chips-loading, .rg-chips-error {
  font-size: 12.5px;
  color: #94a3b8;
  font-style: italic;
  padding: 4px 8px;
}
.rg-chips-error { color: #dc2626; font-style: normal; }

/* Inline popover «New group» (Notion New Tag pattern). */
.rg-chips-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 16px;
  z-index: 10;
  width: 280px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rg-popover-title { font-size: 13px; font-weight: 600; color: #0f172a; }
.rg-popover-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 150ms ease-out;
}
.rg-popover-input:focus { border-color: var(--brand-accent); }
.rg-popover-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rg-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 150ms ease-out, border-color 150ms ease-out;
}
.rg-color-swatch:hover { transform: scale(1.1); }
.rg-color-swatch.is-selected { border-color: #0f172a; }
.rg-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.rg-popover-cancel, .rg-popover-save {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}
.rg-popover-save {
  background: var(--brand-accent);
  color: #ffffff;
  border-color: var(--brand-accent);
}
.rg-popover-save:hover { background: var(--brand-accent-hover); border-color: var(--brand-accent-hover); }
.rg-popover-cancel:hover { background: #f1f5f9; }

.re-list-item-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11.5px;
  color: #64748b;
}
.re-list-item-group-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.re-list {
  border-right: 1px solid #e5e7eb;
  background: #ffffff;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.re-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
}

.re-list-title {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.re-btn-icon {
  background: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  transition: all 0.15s;
}
.re-btn-icon:hover { background: #f3f4f6; color: #111827; }

.re-list-items {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.re-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
.re-list-item:hover { background: #f9fafb; }
.re-list-item.is-selected {
  background: #eff6ff;
  border-left-color: var(--brand-primary);
}

.re-list-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.re-list-item-name {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.re-list-item-type {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.re-list-empty,
.re-list-error {
  padding: 24px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}
.re-list-error { color: #b91c1c; background: #fef2f2; }

.re-list-empty-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
}

.re-detail {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.re-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px;
  color: #6b7280;
}

.re-detail-empty-icon {
  font-size: 64px;
  color: #d1d5db;
  margin-bottom: 16px;
}

.re-detail-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.re-detail-empty-hint {
  font-size: 14px;
  color: #9ca3af;
  max-width: 360px;
  line-height: 1.5;
}

.re-detail-hint {
  padding: 8px 16px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  font-style: italic;
}

.re-detail-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #ffffff;
}

/* Mobile responsive — stack list above detail (W7 polish wave will refine) */
@media (max-width: 768px) {
  .re-root {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .re-list {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    max-height: 200px;
  }
}

/* ─── F7.W3 ResourceEditForm inline styles ───────────────────────────── */

.ref-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #f9fafb;
  overflow-y: auto;
}

.ref-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 2;
}

.ref-title-block {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ref-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-id-badge {
  font-size: 11px;
  color: #6b7280;
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.ref-dirty-badge {
  font-size: 11px;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.ref-btn {
  padding: 8px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.ref-btn:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; }
.ref-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent);
  outline-offset: 2px;
}
.ref-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ref-btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}
.ref-btn-primary:hover:not(:disabled) { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.ref-btn-ghost { background: transparent; border-color: transparent; }
.ref-btn-ghost:hover:not(:disabled) { background: #f3f4f6; }

.ref-skeleton {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ref-skeleton-block {
  height: 80px;
  background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
  background-size: 200% 100%;
  animation: ref-skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes ref-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ref-error {
  padding: 32px;
  text-align: center;
  color: #b91c1c;
}
.ref-error-detail {
  margin: 12px 0;
  font-size: 13px;
  color: #6b7280;
  font-family: ui-monospace, monospace;
}

/* F586 — карточка ресурса = премиум-вкладки (канон Cal.com EventType editor).
   .ref-grid = вертикальный контейнер: панель вкладок + тело (форма + превью). */
.ref-grid {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Панель вкладок — заметная: крупный текст, активная подчёркнута брендом.
   ⛔ flex: 0 0 auto ОБЯЗАТЕЛЕН: .ref-grid — flex-column фикс. высоты; без
   flex-shrink:0 эта панель (с overflow-x:auto → min-height спека = 0) схлопывается
   в 0 при переполнении контента и overflow клипает кнопки = вкладки исчезают
   (root-fix F586.W2, verified L1). */
.ref-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
}
.ref-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: #64748b;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 15px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out;
}
.ref-tab:hover { color: #0f172a; background: #f8fafc; }
.ref-tab.is-active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}
.ref-tab:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent);
  outline-offset: -4px;
  border-radius: 6px;
}

/* Тело вкладки: форма в ограниченной колонке + sticky-превью справа. */
.ref-tab-body {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  padding: 24px;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.ref-tab-main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 680px;
}
.ref-tab-panel { display: none; }
.ref-tab-panel.is-active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Атомарные суб-компоненты (schedule/closedDates/payment/B8) уже рисуют свою
   .ref-section карточку; убираем их внешний padding внутри панели вкладки. */
.ref-tab-panel .ref-ext-b8-wrap { padding: 0; }

/* Живое превью — sticky-rail справа, видно на любой вкладке. */
.ref-preview-rail {
  flex: 0 0 340px;
  position: sticky;
  top: 24px;
  align-self: flex-start;
}
.ref-preview-rail .ref-section { margin: 0; }

.ref-section-divider {
  height: 1px;
  background: #eef0f3;
  margin: 14px 0 2px;
}

/* Узкие экраны (drawer / mobile): превью наверх, одна колонка. */
@media (max-width: 1100px) {
  .ref-tab-body { flex-direction: column; gap: 16px; max-width: 760px; }
  .ref-tab-main { max-width: none; width: 100%; order: 2; }
  .ref-preview-rail { position: static; flex: none; width: 100%; order: 1; }
}

.ref-section {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
}

.ref-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}
.ref-section-title-2 { margin-top: 16px; }

.ref-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 12px;
  margin-bottom: 4px;
  font-weight: 500;
}

.ref-input, .ref-select, .ref-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #111827;
  background: #ffffff;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.ref-textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.4;
}
.ref-textarea-small { min-height: 68px; }
.ref-input:focus, .ref-select:focus, .ref-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 10%, transparent);
}
.ref-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.ref-field { display: block; min-width: 0; }

.ref-preview-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.ref-preview-hero {
  height: 160px;
  background-color: #f3f4f6;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ref-preview-hero-placeholder {
  color: #9ca3af;
  font-size: 13px;
}
.ref-preview-body { padding: 14px; }
.ref-preview-name { font-weight: 600; font-size: 15px; color: #111827; }
.ref-preview-type { font-size: 12px; color: #6b7280; margin-top: 2px; }
.ref-preview-desc { font-size: 13px; color: #374151; margin-top: 8px; line-height: 1.5; }
.ref-preview-price { font-weight: 600; color: #059669; margin-top: 8px; }
.ref-preview-duration, .ref-preview-hours { font-size: 12px; color: #6b7280; margin-top: 4px; }

.ref-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #1f2937;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: all 0.3s;
  z-index: 9999;
}
.ref-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ref-toast.success { background: #059669; }
.ref-toast.error { background: #dc2626; }

.ref-empty {
  padding: 48px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

/* Mobile: tighter tab-body padding (F586 — секции уже стек, не колонки) */
@media (max-width: 1024px) {
  .ref-tab-body { padding: 12px 14px 24px; }
  .ref-tabs { padding: 0 14px; }
}

/* ─── F7.W6 AiAssistant section ─────────────────────────────────────── */
.re-detail-empty-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px;
  max-width: 720px;
  margin: 0 auto;
}
.re-ai-mount { width: 100%; margin-top: 24px; }

.ai-wrap {
  background: linear-gradient(135deg, #f0f9ff 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  padding: 20px;
}
.ai-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ai-icon { font-size: 22px; }
.ai-title { margin: 0; font-size: 16px; font-weight: 700; color: #4c1d95; }
.ai-subtitle { font-size: 12px; color: #6b7280; }

.ai-brief {
  width: 100%;
  padding: 12px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
  box-sizing: border-box;
  background: #ffffff;
}
.ai-brief:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15); }

.ai-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.ai-char-count { font-size: 11px; color: #9ca3af; }
.ai-btn-primary {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c3aed 0%, var(--brand-primary) 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.ai-btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.ai-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.ai-status.ai-loading { background: #eff6ff; color: #1e40af; }
.ai-status.ai-error { background: #fef2f2; color: #b91c1c; }
.ai-status.ai-success { background: #f0fdf4; color: #166534; }

.ai-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
}
.ai-meta-text { font-size: 12px; color: #374151; }
.ai-warn { color: #b45309; }
.ai-usage { color: #6b7280; }
.ai-btn-accept-all {
  padding: 6px 12px;
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ai-btn-accept-all:hover { background: #047857; }

.ai-followups {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
}
.ai-followups-title {
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 6px;
}
.ai-followups-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-followup-chip {
  padding: 4px 10px;
  background: #ffffff;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  font-size: 12px;
  color: #78350f;
}

.ai-suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.ai-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s;
}
.ai-card.is-accepted { border-color: #10b981; background: #f0fdf4; opacity: 0.85; }
.ai-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.ai-card-name { font-weight: 600; font-size: 14px; color: #111827; }
.ai-card-conf { font-size: 11px; font-weight: 700; }
.ai-card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-card-type { font-size: 11px; color: #6b7280; padding: 2px 6px; background: #f3f4f6; border-radius: 4px; }
.ai-card-adapter { font-size: 11px; color: var(--brand-accent-hover); padding: 2px 6px; background: var(--brand-accent-soft); border-radius: 4px; font-weight: 600; }
.ai-card-summary { font-size: 12px; color: #6b7280; min-height: 14px; }
.ai-card-accept {
  margin-top: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--brand-primary);
  color: var(--brand-primary);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ai-card-accept:hover:not(:disabled) { background: #eff6ff; }
.ai-card-accept:disabled { opacity: 0.6; cursor: default; }
.ai-card.is-accepted .ai-card-accept { background: #10b981; color: #ffffff; border-color: #10b981; }

/* ─── F8.W3 ResourceEditFormExtensions — B24-parity секции ──────────── */

.ref-bitrix-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ref-bitrix-checkbox {
  margin-top: 2px;
}

.ref-bitrix-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ref-bitrix-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #475569;
  font-size: 13px;
}

.ref-bitrix-subtitle {
  margin: 6px 0 0;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
}

.ref-bitrix-status {
  min-height: 18px;
  color: #64748b;
  font-size: 13px;
}

.ref-bitrix-status.is-error {
  color: #b91c1c;
}

.ref-bitrix-stage-map {
  display: grid;
  gap: 8px;
}

.ref-bitrix-multiselect {
  min-height: 132px;
  padding: 6px;
}

.ref-bitrix-stage-row {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
}

.ref-bitrix-stage-row span {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .ref-bitrix-grid,
  .ref-bitrix-stage-row {
    grid-template-columns: 1fr;
  }
}

.ref-ext-b8-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 20px 16px;
}

.ref-ext-section {
  /* inherits .ref-section base styles */
}

.ref-ext-hint {
  font-size: 12px;
  color: #6b7280;
  margin: 4px 0 0;
  line-height: 1.5;
}

/* F86.W6 — баннер «ресурс без услуги = не продаётся» над секцией привязки.
   Премиум amber-tone, Lucide-иконка, без эмодзи. */
.ref-ext-no-service-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fffbeb;
}
.ref-ext-no-service-banner svg {
  flex-shrink: 0;
  color: #b45309;
  margin-top: 1px;
}
.ref-ext-no-service-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ref-ext-no-service-text strong {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
}
.ref-ext-no-service-text span {
  font-size: 12px;
  color: #92704e;
  line-height: 1.45;
}

.ref-ext-error {
  font-size: 12px;
  color: #b91c1c;
}

/* B. Display mode radio cards */
.ref-ext-radio-cards {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.ref-ext-radio-card {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: #ffffff;
}
.ref-ext-radio-card:hover { border-color: var(--brand-primary-soft); background: #eff6ff; }
.ref-ext-radio-input { display: none; }
.ref-ext-radio-card:has(.ref-ext-radio-input:checked) {
  border-color: var(--brand-primary);
  background: #eff6ff;
}

.ref-ext-radio-icon { font-size: 20px; color: #6b7280; }
.ref-ext-radio-label { font-size: 13px; font-weight: 600; color: #111827; }
.ref-ext-radio-hint { font-size: 11px; color: #9ca3af; line-height: 1.4; }

/* C. Toggle row */
.ref-ext-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
}
.ref-ext-toggle-check {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.ref-ext-toggle-label {
  font-size: 14px;
  color: #111827;
  font-weight: 500;
}

/* D. Duration preset buttons */
.ref-ext-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.ref-ext-preset-btn {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  background: #ffffff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.ref-ext-preset-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.ref-ext-preset-btn.is-active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.ref-ext-custom-duration {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ref-ext-custom-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}
.ref-ext-custom-input {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #111827;
  text-align: center;
  box-sizing: border-box;
}
.ref-ext-custom-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 10%, transparent);
}

/* A. Services chips */
.ref-ext-services-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-height: 32px;
}

.ref-ext-chip {
  padding: 5px 12px;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  background: #ffffff;
  color: #374151;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.ref-ext-chip:hover { border-color: #60a5fa; background: #eff6ff; }
.ref-ext-chip.is-selected {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.ref-ext-refresh-btn {
  margin-top: 8px;
  font-size: 12px;
  padding: 5px 10px;
}

/* E. Working hours custom mount */
.ref-ext-workhours-company,
.ref-ext-workhours-custom-mount {
  margin-top: 6px;
}

/* Mobile */
@media (max-width: 768px) {
  .ref-ext-b8-wrap { padding: 0 12px 12px; }
  .ref-ext-radio-cards { flex-direction: column; }
  .ref-ext-custom-duration { flex-wrap: nowrap; }
}

/* Calendar resource drawer: the same editor, tuned for a Bitrix iframe side panel. */
#cv2ResourceDrawerHost .dialog.cv2-resource-dialog {
  width: min(840px, calc(100vw - 56px));
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  background: #f6f8fb;
}

#cv2ResourceDrawerHost .ref-wrap {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #f6f8fb;
}

#cv2ResourceDrawerHost .ref-header {
  position: relative;
  top: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "cancel title book save";
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #dfe5ee;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

#cv2ResourceDrawerHost .ref-header > .ref-btn-ghost {
  grid-area: cancel;
}

#cv2ResourceDrawerHost .ref-title-block {
  grid-area: title;
  min-width: 0;
}

#cv2ResourceDrawerHost .ref-btn-book {
  grid-area: book;
  white-space: nowrap;
}

#cv2ResourceDrawerHost .ref-btn-primary {
  grid-area: save;
  white-space: nowrap;
}

#cv2ResourceDrawerHost .ref-title {
  font-size: 17px;
  line-height: 1.25;
}

#cv2ResourceDrawerHost .ref-id-badge {
  display: none !important;
}

#cv2ResourceDrawerHost .ref-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
/* F586 — в drawer прокрутка живёт на .ref-grid → панель вкладок sticky к её
   верху (header отдельный, выше grid). */
#cv2ResourceDrawerHost .ref-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0 18px;
  background: #f6f8fb;
}
#cv2ResourceDrawerHost .ref-tab-body {
  padding: 14px 18px 20px;
  max-width: none;
}

#cv2ResourceDrawerHost .ref-section,
#cv2ResourceDrawerHost .ref-ext-section {
  border-color: #dfe5ee;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#cv2ResourceDrawerHost .ref-ext-b8-wrap {
  padding: 0;
  gap: 12px;
}

#cv2ResourceDrawerHost .ref-section-title {
  color: #111827;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 14px;
}

#cv2ResourceDrawerHost .ref-label {
  color: #475569;
  font-size: 13px;
  margin-top: 14px;
  margin-bottom: 6px;
}

#cv2ResourceDrawerHost .ref-input,
#cv2ResourceDrawerHost .ref-select {
  min-height: 40px;
  border-color: #cfd7e3;
  border-radius: 7px;
}

#cv2ResourceDrawerHost .ref-label--checkbox {
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  margin-top: 14px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #172554;
}

#cv2ResourceDrawerHost .ref-field-hint {
  margin-top: 6px;
}

#cv2ResourceDrawerHost .photo-uploader-drop {
  padding: 18px;
  border-radius: 8px;
  background: #f8fafc;
}

#cv2ResourceDrawerHost .photo-uploader-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

#cv2ResourceDrawerHost .photo-tile img,
#cv2ResourceDrawerHost .photo-tile .tile-progress {
  height: 104px;
}

#cv2ResourceDrawerHost .ref-preview-card {
  border-radius: 8px;
  background: #ffffff;
}

#cv2ResourceDrawerHost .ref-preview-hero {
  height: 132px;
}

@media (max-width: 760px) {
  #cv2ResourceDrawerHost .dialog.cv2-resource-dialog {
    width: 100vw;
    max-width: 100vw;
    border-left: 0;
  }

  #cv2ResourceDrawerHost .ref-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "cancel save"
      "title title"
      "book book";
    align-items: stretch;
    padding: 12px;
  }

  #cv2ResourceDrawerHost .ref-header > .ref-btn-ghost {
    justify-self: start;
  }

  #cv2ResourceDrawerHost .ref-btn-primary {
    justify-self: end;
  }

  #cv2ResourceDrawerHost .ref-btn-book {
    width: 100%;
  }

  #cv2ResourceDrawerHost .ref-tab-body {
    padding: 12px;
  }
  #cv2ResourceDrawerHost .ref-tabs {
    padding: 0 12px;
  }
}

/* F575 — структурные атрибуты ресурса: тип кровати / класс / галочки удобств */
.ref-structured { margin-top: 4px; }
.ref-amenities { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.ref-amenity-cat {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: #64748b; margin-bottom: 8px;
}
.ref-amenity-items {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
}
.ref-amenity {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid #e2e8f0; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: #1e293b; background: #fff;
  transition: border-color .15s ease, background .15s ease;
}
.ref-amenity:hover { border-color: #cbd5e1; background: #f8fafc; }
.ref-amenity input { accent-color: #2563eb; width: 16px; height: 16px; flex: none; }
.ref-amenity:has(input:checked) { border-color: #2563eb; background: #eff6ff; }

