/* ================================================================
   CRM Module — assets/css/crm.css
   Канбан-доска, список задач, модальное окно задачи
   ================================================================ */

/* ── Page layout ── */
.is-hidden { display: none !important; }

/* CRM page: hide footer, remove empty space below kanban */
.aidc-crm-page .footer { display: none !important; }
.aidc-crm-page { min-height: auto !important; }
.aidc-crm-page #app { min-height: auto !important; display: flex; flex-direction: column; }
.aidc-crm-page .shell { flex: 1 0 auto; padding: 16px 24px 0; display: flex; flex-direction: column; }
.aidc-crm-page #crmRoot { flex: 1 0 auto; display: flex; flex-direction: column; }

/* WebApp CRM: tighter padding on mobile, generous on desktop-webapp */
body.aidc-tg.aidc-crm-page .tg-page {
  padding: 10px 16px calc(var(--tg-nav-h, 56px) + var(--tg-safe-bottom, 0px) + 10px) !important;
}
@media (min-width: 600px) {
  body.aidc-tg.aidc-crm-page .tg-page {
    padding: 16px 24px calc(var(--tg-nav-h, 56px) + var(--tg-safe-bottom, 0px) + 16px) !important;
  }
}

.crm-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.crm-page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #f5f5f5;
  margin: 0;
}
.crm-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.crm-toolbar .crm-view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  overflow: hidden;
}
.crm-view-toggle .crm-view-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.crm-view-toggle .crm-view-btn.is-active {
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
}
.crm-view-toggle .crm-view-btn:hover:not(.is-active) {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.8);
}

/* ── Filters bar ── */
.crm-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.crm-filters select,
.crm-filters input[type="text"] {
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #e0e0e0;
  outline: none;
  min-width: 120px;
  transition: border-color .15s;
}
.crm-filters select:focus,
.crm-filters input[type="text"]:focus {
  border-color: rgba(83,255,153,0.4);
}

/* Override core.css .aidc-select { width:100% } inside CRM toolbar */
.crm-filters .aidc-select,
.crm-toolbar .aidc-select {
  width: auto;
  min-width: 120px;
  max-width: 220px;
}
.crm-form-group .aidc-select {
  width: 100%;
}

/* CRM-specific .aidc-select styling (match dark CRM theme) */
.crm-filters .aidc-select__btn,
.crm-toolbar .aidc-select__btn {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #e0e0e0;
}
.crm-filters .aidc-select.is-open .aidc-select__btn,
.crm-toolbar .aidc-select.is-open .aidc-select__btn {
  border-color: rgba(83,255,153,0.4);
  box-shadow: 0 0 0 2px rgba(83,255,153,0.1);
}
.crm-form-group .aidc-select__btn {
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #e0e0e0;
}
.crm-form-group .aidc-select.is-open .aidc-select__btn {
  border-color: rgba(83,255,153,0.4);
  box-shadow: 0 0 0 2px rgba(83,255,153,0.1);
}

/* CRM select menus — portaled to #aidc-dialog-root, scope via body class */
.aidc-crm-page .aidc-select__menu,
.aidc-crm-page #aidc-dialog-root .aidc-select__menu {
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: #0e0e14;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  padding: 4px;
}
.aidc-crm-page .aidc-select__option,
.aidc-crm-page #aidc-dialog-root .aidc-select__option {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #e0e0e0;
}
.aidc-crm-page .aidc-select__option:hover,
.aidc-crm-page #aidc-dialog-root .aidc-select__option:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
}
.aidc-crm-page .aidc-select__option.is-selected,
.aidc-crm-page #aidc-dialog-root .aidc-select__option.is-selected {
  background: rgba(83,255,153,0.1);
  border-color: rgba(83,255,153,0.25);
  color: #53ff99;
}
/* Priority-specific colours for selected option */
.aidc-crm-page .aidc-select__option.is-selected[data-value="urgent"] {
  background: rgba(255,68,68,0.12); border-color: rgba(255,68,68,0.3); color: #FF4444;
}
.aidc-crm-page .aidc-select__option.is-selected[data-value="high"] {
  background: rgba(255,140,0,0.12); border-color: rgba(255,140,0,0.3); color: #FF8C00;
}
.aidc-crm-page .aidc-select__option.is-selected[data-value="medium"] {
  background: rgba(255,215,0,0.12); border-color: rgba(255,215,0,0.3); color: #FFD700;
}
.aidc-crm-page .aidc-select__option.is-selected[data-value="low"] {
  background: rgba(76,175,80,0.12); border-color: rgba(76,175,80,0.3); color: #4CAF50;
}
/* Priority button text colour (reflects current value) */
.aidc-crm-page .aidc-select[data-aidc-value="urgent"] .aidc-select__btn { color: #FF4444; }
.aidc-crm-page .aidc-select[data-aidc-value="high"]   .aidc-select__btn { color: #FF8C00; }
.aidc-crm-page .aidc-select[data-aidc-value="medium"] .aidc-select__btn { color: #FFD700; }
.aidc-crm-page .aidc-select[data-aidc-value="low"]    .aidc-select__btn { color: #4CAF50; }

.crm-search {
  flex: 1;
  min-width: 140px;
  max-width: 260px;
}

/* ── New task button ── */
.crm-btn-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #120914;
  background: linear-gradient(135deg, #53ff99 0%, #36d98a 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(83,255,153,0.2);
  transition: transform .12s, box-shadow .12s;
  white-space: nowrap;
}
.crm-btn-new:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(83,255,153,0.3);
}
.crm-btn-new svg { width: 16px; height: 16px; stroke: #120914; fill: none; }

/* ── Kanban board ── */
.crm-kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  flex: 0 0 auto;
  align-items: stretch;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.crm-kanban::-webkit-scrollbar { height: 6px; }
.crm-kanban::-webkit-scrollbar-track { background: transparent; }
.crm-kanban::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.crm-column {
  flex: 1 1 0;
  min-width: 200px;
  min-height: 0;          /* prevent intrinsic sizing — let stretch work */
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 10px;
  /* align-self: stretch is default for align-items: stretch parent */
}
.crm-column[data-status="overdue"] {
  background: rgba(255,68,68,0.03);
  border-color: rgba(255,68,68,0.12);
}
.crm-column[data-status="overdue"] .crm-column-title {
  color: #FF4444;
}
.crm-column[data-status="cancelled"] {
  background: rgba(248,113,113,0.03);
  border-color: rgba(248,113,113,0.10);
}
.crm-column[data-status="cancelled"] .crm-column-title {
  color: #fca5a5;
}
.crm-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 8px;
}
.crm-column-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.crm-column-count {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.04);
  padding: 2px 8px;
  border-radius: 10px;
}
.crm-column-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
  transition: background .15s;
}
.crm-column-body.drag-over {
  background: rgba(83,255,153,0.04);
  border-radius: 8px;
}

/* ── Task card ── */
.crm-task-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: grab;
  transition: transform .12s, box-shadow .12s, border-color .15s;
  user-select: none;
}
.crm-task-card:hover {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.crm-task-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}
.crm-task-card__priority {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.crm-task-card__priority--urgent { color: #FF4444; }
.crm-task-card__priority--high { color: #FF8C00; }
.crm-task-card__priority--medium { color: #FFD700; }
.crm-task-card__priority--low { color: #4CAF50; }
.crm-task-card__priority svg { width: 10px; height: 10px; }
.crm-task-card__priority--urgent svg { stroke: #FF4444; }
.crm-task-card__priority--high svg { stroke: #FF8C00; }
.crm-task-card__priority--medium svg { stroke: #FFD700; }
.crm-task-card__priority--low svg { stroke: #4CAF50; }

.crm-task-card__title {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 8px;
  line-height: 1.3;
  word-break: break-word;
}
.crm-task-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
}
.crm-task-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crm-task-card__meta-item svg {
  width: 13px;
  height: 13px;
  stroke: rgba(255,255,255,0.35);
  fill: none;
}
.crm-task-card__overdue {
  color: #FF4444;
}

/* ── List view ── */
.crm-list {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.crm-list th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.crm-list th:hover { color: rgba(255,255,255,0.7); }
.crm-list td {
  padding: 10px 12px;
  font-size: 13px;
  color: #e0e0e0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.crm-list tr:hover td {
  background: rgba(255,255,255,0.02);
}
.crm-list .crm-status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.crm-status-badge--todo       { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.6); }
.crm-status-badge--in_progress { background: rgba(59,130,246,0.15); color: #60a5fa; }
.crm-status-badge--review      { background: rgba(250,204,21,0.12); color: #fde68a; }
.crm-status-badge--done        { background: rgba(83,255,153,0.12); color: #53ff99; }
.crm-status-badge--cancelled   { background: rgba(248,113,113,0.1); color: #fca5a5; }

.crm-priority-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.crm-priority-dot--urgent { background: #FF4444; }
.crm-priority-dot--high   { background: #FF8C00; }
.crm-priority-dot--medium { background: #FFD700; }
.crm-priority-dot--low    { background: #4CAF50; }

/* ── Empty state ── */
.crm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: rgba(255,255,255,0.35);
  font-size: 15px;
  text-align: center;
}
.crm-empty svg {
  width: 48px;
  height: 48px;
  stroke: rgba(255,255,255,0.15);
  fill: none;
  margin-bottom: 16px;
}

/* ── Task modal ── */
.crm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: crmFadeIn .15s ease;
}
@keyframes crmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.crm-modal {
  background: #0e0e14;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: crmSlideUp .2s ease;
}
/* Non-wide (single column) — allow body scrolling */
.crm-modal:not(.crm-modal--wide) .crm-modal__body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
/* ═══ Wide modal — ALWAYS 3 equal columns: form | checklists | comments ═══ */
.crm-modal--wide {
  max-width: 1340px;
}
.crm-modal--wide .crm-modal__columns {
  display: grid;
  grid-template-columns: 4fr 3fr 3fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}
.crm-modal--wide .crm-modal__columns > .crm-modal__body {
  min-width: 0;
  box-sizing: border-box;
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.crm-modal--wide .crm-modal__columns > .crm-modal__body::-webkit-scrollbar { width: 5px; }
.crm-modal--wide .crm-modal__columns > .crm-modal__body::-webkit-scrollbar-track { background: transparent; }
.crm-modal--wide .crm-modal__columns > .crm-modal__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.crm-modal--wide .crm-modal__columns > .crm-checklists-section {
  min-width: 0;
  box-sizing: border-box;
  overflow-y: auto;
  padding: 16px;
  border-right: 1px solid rgba(255,255,255,0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.crm-modal--wide .crm-modal__columns > .crm-checklists-section::-webkit-scrollbar { width: 5px; }
.crm-modal--wide .crm-modal__columns > .crm-checklists-section::-webkit-scrollbar-track { background: transparent; }
.crm-modal--wide .crm-modal__columns > .crm-checklists-section::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.crm-modal--wide .crm-modal__columns > .crm-comments {
  min-width: 0;
  box-sizing: border-box;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.crm-modal--wide .crm-modal__columns > .crm-comments::-webkit-scrollbar { width: 5px; }
.crm-modal--wide .crm-modal__columns > .crm-comments::-webkit-scrollbar-track { background: transparent; }
.crm-modal--wide .crm-modal__columns > .crm-comments::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ═══ Dark-themed checklist inputs ═══ */
.checklist-add-item__input {
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.10) !important;
  color: #f5f5f5 !important;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s;
}
.checklist-add-item__input::placeholder {
  color: rgba(255,255,255,0.3);
}
.checklist-add-item__input:focus {
  border-color: rgba(99,102,241,0.5) !important;
}

/* ═══ Center "+ New checklist" button ═══ */
.checklist-new {
  text-align: center;
  justify-content: center;
}

/* ═══ Center checklists inside column ═══ */
.crm-checklists-root {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ═══ Create-mode comments placeholder ═══ */
.crm-comments--placeholder {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  color: rgba(255,255,255,0.3);
  font-size: 13px;
}

/* ═══ Responsive ═══ */
@media (max-width: 1100px) {
  .crm-modal--wide { max-width: 95vw; }
  .crm-modal--wide .crm-modal__columns {
    grid-template-columns: 1fr;
  }
  .crm-modal--wide .crm-modal__columns > .crm-modal__body {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .crm-modal--wide .crm-modal__columns > .crm-checklists-section {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    max-height: 50vh;
  }
  .crm-modal--wide .crm-modal__columns > .crm-comments {
    max-height: 50vh;
  }
}
@media (max-width: 800px) {
  .crm-modal--wide { max-width: 95vw; }
  .crm-modal--wide .crm-modal__columns > .crm-checklists-section {
    max-height: none;
  }
  .crm-modal--wide .crm-modal__columns > .crm-comments {
    max-height: none;
  }
}
@keyframes crmSlideUp {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.crm-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.crm-modal__title {
  font-size: 18px;
  font-weight: 700;
  color: #f5f5f5;
}
.crm-modal__close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  transition: background .12s, color .12s;
}
.crm-modal__close:hover {
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
}
.crm-modal__close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.crm-modal__body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}
.crm-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-form-group label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.crm-form-group input:not([type="radio"]):not([type="checkbox"]),
.crm-form-group select,
.crm-form-group textarea {
  padding: 10px 12px;
  font-size: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #e0e0e0;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.crm-form-group input:not([type="radio"]):not([type="checkbox"]):focus,
.crm-form-group select:focus,
.crm-form-group textarea:focus {
  border-color: rgba(83,255,153,0.4);
}
.crm-form-group textarea {
  min-height: 80px;
  resize: vertical;
}
/* Project select optgroup styling */
.crm-form-group select optgroup {
  font-style: normal;
  font-weight: 700;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  background: #15151e;
}
.crm-form-group select optgroup option {
  font-weight: 400;
  font-size: 14px;
  color: #e0e0e0;
  padding-left: 12px;
}
.crm-form-row {
  display: flex;
  gap: 12px;
}
.crm-form-row > .crm-form-group {
  flex: 1;
}

/* ── Create project link ── */
.crm-create-project-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(83,255,153,0.7);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.crm-create-project-link:hover {
  color: #53ff99;
}

/* ── Inline create-project form ── */
.crm-create-project-inline {
  margin-top: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.crm-create-project-inline.is-hidden { display: none; }
.crm-create-project-input,
.crm-create-project-folder,
.crm-create-project-type {
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #e0e0e0;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.crm-create-project-input:focus,
.crm-create-project-folder:focus,
.crm-create-project-type:focus {
  border-color: rgba(83,255,153,0.4);
}
.crm-create-project-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.crm-btn-sm {
  padding: 5px 12px !important;
  font-size: 12px !important;
}

.crm-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.crm-btn-cancel {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.crm-btn-cancel:hover {
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
}
.crm-btn-submit {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 700;
  color: #120914;
  background: linear-gradient(135deg, #53ff99 0%, #36d98a 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s;
}
.crm-btn-submit:hover { transform: translateY(-1px); }
.crm-btn-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Comments section inside modal ── */
.crm-comments {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 16px;
}
.crm-comments__title {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
}
.crm-comment {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.crm-comment__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.crm-comment__body { flex: 1; }
.crm-comment__author {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin-bottom: 2px;
}
.crm-comment__text {
  font-size: 13px;
  color: #e0e0e0;
  line-height: 1.4;
}
.crm-comment__time {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 4px;
}
.crm-comment-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.crm-comment-form input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #e0e0e0;
  outline: none;
}
.crm-comment-form button {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(83,255,153,0.15);
  color: #53ff99;
  border: 1px solid rgba(83,255,153,0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
}
.crm-comment-form button:hover { background: rgba(83,255,153,0.25); }

/* ── Plan required overlay ── */
.crm-plan-required {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: rgba(255,255,255,0.45);
}
.crm-plan-required svg { width: 56px; height: 56px; stroke: rgba(255,255,255,0.15); fill: none; margin-bottom: 20px; }
.crm-plan-required h2 { font-size: 20px; color: #f5f5f5; margin: 0 0 8px; }
.crm-plan-required p { font-size: 14px; margin: 0 0 20px; }
.crm-plan-required a {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  color: #120914;
  background: linear-gradient(135deg, #53ff99, #36d98a);
  border-radius: 12px;
  text-decoration: none;
}

/* ── Sticky footer for CRM page ── */
.aidc-crm-page #app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.aidc-crm-page #app > .shell {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.aidc-crm-page #crmRoot {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.aidc-crm-page footer,
.aidc-crm-page [data-include*="footer"] + footer {
  flex-shrink: 0;
  margin-top: auto;
}

/* ── Search wrap ── */
.crm-search-wrap {
  position: relative;
  flex: 1;
  min-width: 140px;
  max-width: 260px;
  z-index: 0;
}
.crm-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: rgba(255,255,255,0.35);
  fill: none;
  pointer-events: none;
  z-index: 1;
}
.crm-search-wrap .crm-search {
  padding-left: 30px;
  width: 100%;
  box-sizing: border-box;
}

/* ── Deadline row: date + time — equal halves ── */
.crm-deadline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: flex-start;
  gap: 10px;
}
.crm-date-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
}
.crm-date-display {
  flex: 1;
  padding: 10px 40px 10px 12px;
  font-size: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #e0e0e0;
  outline: none;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s;
}
.crm-date-display:focus {
  border-color: rgba(83,255,153,0.4);
}
.crm-date-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.crm-date-btn:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
}
.crm-date-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}
.crm-time-input {
  width: 100%;
  padding: 10px 8px;
  font-size: 14px;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #e0e0e0;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
  box-sizing: border-box;
}
.crm-time-input:focus {
  border-color: rgba(83,255,153,0.4);
}

/* ── Custom calendar panel ── */
.crm-calendar-panel {
  display: none;
  margin-top: 8px;
  background: #15151f;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.crm-calendar-panel.open {
  display: block;
}
.crm-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.crm-cal-title {
  font-size: 14px;
  font-weight: 700;
  color: #f0f0f0;
}
.crm-cal-nav {
  display: flex;
  gap: 4px;
}
.crm-cal-nav-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  transition: background .12s, color .12s;
}
.crm-cal-nav-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
}
.crm-cal-nav-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
}
.crm-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.crm-cal-dow {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  padding: 4px 0;
}
.crm-cal-day {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.crm-cal-day:hover {
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
}
.crm-cal-day.muted {
  color: rgba(255,255,255,0.2);
}
.crm-cal-day.today {
  background: rgba(83,255,153,0.08);
  color: #53ff99;
  font-weight: 700;
}
.crm-cal-day.selected {
  background: rgba(83,255,153,0.2);
  color: #53ff99;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(83,255,153,0.4);
}
.crm-cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.crm-cal-clear,
.crm-cal-today {
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.crm-cal-clear {
  color: rgba(255,255,255,0.45);
}
.crm-cal-clear:hover {
  color: #FF4444;
  background: rgba(255,68,68,0.08);
}
.crm-cal-today {
  color: #53ff99;
}
.crm-cal-today:hover {
  background: rgba(83,255,153,0.1);
}

/* ── Delete button in modal footer ── */
.crm-btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #FF4444;
  background: rgba(255,68,68,0.06);
  border: 1px solid rgba(255,68,68,0.2);
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.crm-btn-delete:hover {
  background: rgba(255,68,68,0.12);
  border-color: rgba(255,68,68,0.35);
}
.crm-btn-delete svg {
  width: 14px;
  height: 14px;
  stroke: #FF4444;
  fill: none;
}

/* ── Modal footer layout (delete left, actions right) ── */
.crm-modal__footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Comments empty state ── */
.crm-comments__empty {
  font-size: 13px;
  color: rgba(255,255,255,0.3);
  padding: 12px 0;
  text-align: center;
}

/* ── Comment send button ── */
.crm-comment-send {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(83,255,153,0.15);
  color: #53ff99;
  border: 1px solid rgba(83,255,153,0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
}
.crm-comment-send:hover {
  background: rgba(83,255,153,0.25);
}

/* ── Comment header (author + actions) ── */
.crm-comment__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.crm-comment__actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.crm-comment:hover .crm-comment__actions {
  opacity: 1;
}
.crm-comment__action-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  transition: background .12s, color .12s, border-color .12s;
}
.crm-comment__action-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.15);
}
.crm-comment__action-btn--danger:hover {
  background: rgba(255,68,68,0.1);
  color: #FF4444;
  border-color: rgba(255,68,68,0.25);
}
.crm-comment__action-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
}

/* ── Edited label ── */
.crm-comment__edited {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  font-style: italic;
  margin-left: 6px;
}
.crm-comment__edited--clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  transition: color .12s;
}
.crm-comment__edited--clickable:hover {
  color: rgba(83,255,153,0.6);
}

/* ── Edit history popup ── */
.crm-edit-history-popup {
  background: #15151e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  padding: 12px 14px;
  min-width: 240px;
  max-width: 380px;
  max-height: 280px;
  overflow-y: auto;
  animation: crmFadeIn .12s ease;
}
.crm-edit-history-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.crm-edit-history-item {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.crm-edit-history-item:last-child { border-bottom: none; }
.crm-edit-history-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 3px;
}
.crm-edit-history-text {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  white-space: pre-wrap;
  word-break: break-word;
}
.crm-edit-history-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}

/* ── System comment ── */
.crm-comment--system {
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  padding: 8px 10px;
  border-bottom: none;
}
.crm-comment__system-icon {
  font-size: 14px;
  color: rgba(255,255,255,0.3);
  line-height: 1;
}
.crm-comment--system .crm-comment__text {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  font-style: italic;
}

/* ── Comment inline edit form ── */
.crm-comment__edit-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.crm-comment__original {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  padding: 4px 8px;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid rgba(255,255,255,0.1);
  border-radius: 0 4px 4px 0;
  line-height: 1.4;
}
.crm-comment__edit-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(83,255,153,0.25);
  border-radius: 6px;
  color: #e0e0e0;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}
.crm-comment__edit-input:focus {
  border-color: rgba(83,255,153,0.5);
}
.crm-comment__edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.crm-comment__edit-actions button {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.crm-comment__edit-save {
  background: rgba(83,255,153,0.15);
  color: #53ff99;
  border: 1px solid rgba(83,255,153,0.25);
}
.crm-comment__edit-save:hover {
  background: rgba(83,255,153,0.25);
}
.crm-comment__edit-cancel {
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}
.crm-comment__edit-cancel:hover {
  background: rgba(255,255,255,0.08);
}

/* ── Loading state ── */
.crm-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  font-size: 14px;
  color: rgba(255,255,255,0.4);
  gap: 10px;
}
.crm-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.6);
  border-radius: 50%;
  animation: crmSpin .7s linear infinite;
}
@keyframes crmSpin {
  to { transform: rotate(360deg); }
}

/* ── CRM content container — prevent blank flash on boot ── */
#crmRoot {
  min-height: 200px;             /* prevent layout collapse before JS renders */
}
/* Kanban container smooth transition — no abrupt content pop-in */
#crmKanbanContainer {
  min-height: 120px;             /* reserve space while loading */
}

/* ── Inline editable cells (list view) ── */
.crm-inline-editable {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .12s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crm-inline-editable:hover {
  background: rgba(255,255,255,0.08);
}
.crm-list__cell-title {
  cursor: pointer;
}
.crm-list__cell-title:hover {
  color: #53ff99;
}

/* ── Inline dropdown (portaled to body) ── */
.crm-inline-dropdown {
  background: #15151e;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  padding: 4px;
  min-width: 140px;
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
  -ms-overflow-style: auto;
  animation: crmFadeIn .12s ease;
}
.crm-inline-dropdown::-webkit-scrollbar {
  width: 5px;
}
.crm-inline-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.crm-inline-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
}
.crm-inline-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.22);
}
.crm-inline-option {
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  color: #e0e0e0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .1s;
}
.crm-inline-option:hover {
  background: rgba(255,255,255,0.07);
}
.crm-inline-option.is-selected {
  background: rgba(83,255,153,0.1);
  color: #53ff99;
}
/* Folder group label in inline dropdown */
.crm-inline-group-label {
  padding: 6px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  pointer-events: none;
}
.crm-inline-option--nested {
  padding-left: 20px;
}
.crm-inline-option__icon {
  display: inline-flex;
  align-items: center;
  opacity: 0.55;
  flex-shrink: 0;
}
.crm-inline-date {
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #e0e0e0;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 4px;
  color-scheme: dark;
}
.crm-inline-date-clear {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.crm-inline-date-clear:hover {
  color: #ff4444;
  border-color: rgba(255,68,68,0.3);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .crm-page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .crm-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .crm-kanban {
    /* Horizontal scroll on mobile */
    padding-bottom: 16px;
  }
  .crm-column {
    min-width: 280px;
  }
  .crm-modal {
    max-width: 100%;
    margin: 0 10px;
    max-height: 95vh;
  }
  .crm-form-row {
    flex-direction: column;
  }
  .crm-deadline-row {
    flex-direction: column;
  }
  .crm-search-wrap {
    max-width: 100%;
  }
}

/* ── Kanban card description snippet ── */
.crm-task-card__desc {
  font-size: 11.5px;
  line-height: 1.4;
  color: rgba(255,255,255,0.42);
  margin: 4px 0 2px;
  max-height: 4.2em;          /* ~3 lines */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* ── Comment avatar image ── */
.crm-comment__avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* ── Inline calendar dropdown ── */
.crm-inline-calendar-dropdown {
  min-width: 260px;
  padding: 10px;
  max-height: none;
  overflow: visible;
}
.crm-cal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.crm-cal__month-label {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
}
.crm-cal__nav {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.crm-cal__nav:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.crm-cal__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  margin-bottom: 4px;
}
.crm-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.crm-cal__empty {
  display: block;
}
.crm-cal__day {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border-radius: 50%;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.15s;
}
.crm-cal__day:hover {
  background: rgba(255,255,255,0.10);
}
.crm-cal__day--today {
  border: 1px solid rgba(99,102,241,0.5);
  color: #818cf8;
}
.crm-cal__day--selected {
  background: #6366f1;
  color: #fff;
  font-weight: 600;
}
.crm-cal__clear {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.crm-cal__clear:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}

/* Calendar time input */
.crm-cal__time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0 2px;
}
.crm-cal__time-label {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}
.crm-cal__time-input {
  flex: 1;
  padding: 5px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  text-align: center;
}
.crm-cal__time-input:focus {
  border-color: rgba(99,102,241,0.5);
}
.crm-cal__time-apply {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(83,255,153,0.08);
  border: 1px solid rgba(83,255,153,0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.crm-cal__time-apply:hover {
  background: rgba(83,255,153,0.18);
  border-color: rgba(83,255,153,0.4);
}

/* ── Inline project dropdown extras ── */
.crm-inline-create-link {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(83,255,153,0.7);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: color .15s, background .12s;
}
.crm-inline-create-link:hover {
  color: #53ff99;
  background: rgba(83,255,153,0.06);
}
.crm-inline-group-label--collapsible {
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
}
.crm-inline-group-arrow {
  display: inline-block;
  width: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}
.crm-inline-group-items.is-collapsed {
  display: none;
}

/* ── Inline create-project form inside dropdown ── */
.crm-inline-create-form {
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-inline-create-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #e0e0e0;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.crm-inline-create-input:focus {
  border-color: rgba(83,255,153,0.4);
}
.crm-inline-create-folder,
.crm-inline-create-type {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #e0e0e0;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

/* Compact aidc-select inside inline create-project form */
.crm-inline-create-form .aidc-select__btn {
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 6px;
  min-height: 0;
}
.crm-inline-create-form .aidc-select__option {
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 6px;
}
.crm-inline-create-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ── Create folder link inside create-project form ── */
.crm-create-folder-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(83,255,153,0.7);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.crm-create-folder-link:hover {
  color: #53ff99;
}
.crm-create-folder-inline {
  padding: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-create-folder-inline.is-hidden { display: none; }

/* ================================================================
   CRM — адаптация для мобильного WebApp / TG
   ================================================================ */

/* Общий контейнер страницы CRM в TG */
body.aidc-tg .aidc-crm-page .main,
body.aidc-tg .aidc-crm-page #crmRoot {
  padding-left: 12px;
  padding-right: 12px;
}
/* Убираем избыточный нижний отступ под канбаном в TG */
body.aidc-tg.aidc-crm-page .tg-page,
body.aidc-tg .aidc-crm-page .tg-page {
  padding-bottom: calc(var(--tg-nav-h, 56px) + var(--tg-safe-bottom, 0px) + 8px);
}
body.aidc-tg.aidc-crm-page .shell,
body.aidc-tg .aidc-crm-page .shell {
  padding-bottom: 64px !important;
}

/* Заголовок страницы — меньше отступ на мобильном */
body.aidc-tg .crm-page-header {
  margin-bottom: 12px;
  gap: 8px;
}
body.aidc-tg .crm-page-header h1 {
  font-size: 19px;
}

/* Кнопка «Новая задача» — чуть компактнее */
body.aidc-tg .crm-add-btn {
  padding: 9px 16px;
  font-size: 13px;
  border-radius: 10px;
}

/* Тулбар фильтров — столбцом на узком экране */
@media (max-width: 480px) {
  body.aidc-tg .crm-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 10px;
  }
  body.aidc-tg .crm-toolbar .crm-view-toggle {
    width: 100%;
  }
  body.aidc-tg .crm-toolbar .crm-view-btn {
    flex: 1;
    text-align: center;
  }
  body.aidc-tg .crm-filters {
    width: 100%;
  }
  body.aidc-tg .crm-filters .aidc-select,
  body.aidc-tg .crm-toolbar .aidc-select {
    width: 100%;
    max-width: 100%;
  }
  body.aidc-tg .crm-filters input[type="text"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}

/* Канбан на мобильном — фиксированная ширина колонок, горизонтальный скролл */
body.aidc-tg .crm-kanban {
  gap: 10px;
  padding-bottom: 16px;
  /* Чуть легче скроллится на тачскрине */
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
body.aidc-tg .crm-kanban-column {
  min-width: 240px;
  max-width: 240px;
  scroll-snap-align: start;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
}
@media (max-width: 360px) {
  body.aidc-tg .crm-kanban-column {
    min-width: 210px;
    max-width: 210px;
  }
}

/* Карточки задач — немного крупнее для тач */
body.aidc-tg .crm-task-card {
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(12,14,24,0.9);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  /* Активная область тач */
  -webkit-tap-highlight-color: transparent;
}
body.aidc-tg .crm-task-card:active {
  border-color: rgba(255,0,140,0.4);
  box-shadow: 0 0 0 1px rgba(255,0,140,0.2);
}
body.aidc-tg .crm-task-card__title {
  font-size: 14px;
  line-height: 1.4;
}

/* Список задач — строки крупнее, удобнее для тача */
body.aidc-tg .crm-list-row {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(12,14,24,0.85);
  margin-bottom: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s;
}
body.aidc-tg .crm-list-row:active {
  border-color: rgba(255,0,140,0.35);
}

/* Заголовок колонки — акцент */
body.aidc-tg .crm-column-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 8px;
}
body.aidc-tg .crm-column-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(200,204,240,0.7);
}

/* Модальное окно задачи — на весь экран на мобильном */
@media (max-width: 600px) {
  body.aidc-tg .crm-task-modal {
    border-radius: 20px 20px 0 0;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    transform: none;
    max-height: 92vh;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  body.aidc-tg .crm-task-modal__header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  body.aidc-tg .crm-task-modal__body {
    padding: 14px 16px;
  }
}

/* Кнопки в модальном окне — крупнее на тач */
body.aidc-tg .crm-task-modal__action-btn {
  min-height: 40px;
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 10px;
}

/* Бейдж статуса задачи */
body.aidc-tg .crm-status-badge {
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Приоритет — точка с цветом */
body.aidc-tg .crm-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════
   Recurrence (повторяемость)
   ══════════════════════════════════════════ */

/* Config panel inside task modal form */
.crm-recurrence-config {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 14px 16px;
}
.crm-recurrence-label {
  font-size: 0.85em;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 10px;
}
.crm-recurrence-select {
  width: 100%;
  padding: 7px 10px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  font-size: 0.82em;
  outline: none;
  cursor: pointer;
}
.crm-recurrence-select:focus {
  border-color: rgba(99,102,241,0.5);
}
.crm-recurrence-select--unit {
  width: auto;
  min-width: 100px;
}

/* Options block */
.crm-recurrence-options {
  margin-top: 10px;
}

/* Weekday toggles */
.crm-weekday-toggles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.crm-weekday-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.78em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.crm-weekday-btn:hover {
  border-color: rgba(99,102,241,0.4);
  color: #e2e8f0;
}
.crm-weekday-btn.active {
  background: rgba(99,102,241,0.25);
  border-color: rgba(99,102,241,0.5);
  color: #fff;
}

/* Month days, custom interval */
.crm-recurrence-month-days,
.crm-recurrence-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crm-recurrence-hint {
  font-size: 0.78em;
  color: #94a3b8;
  white-space: nowrap;
}
.crm-recurrence-input {
  padding: 5px 8px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  font-size: 0.82em;
  outline: none;
  width: auto;
}
.crm-recurrence-input:focus {
  border-color: rgba(99,102,241,0.5);
}
.crm-recurrence-input--num {
  width: 60px;
  text-align: center;
}
.crm-recurrence-input--date {
  width: 140px;
}
.crm-recurrence-input--inline {
  display: inline-block;
  margin: 0 4px;
}

/* End conditions */
.crm-recurrence-end {
  margin-top: 4px;
}
.crm-recurrence-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 0.8em;
  color: #cbd5e1;
  cursor: pointer;
  flex-wrap: wrap;
}
.crm-recurrence-radio input[type="radio"] {
  accent-color: #6366f1;
  margin: 0;
  width: auto;
  cursor: pointer;
}

/* Date picker inside recurrence end-condition */
.crm-recurrence-date-wrap {
  position: relative;
  flex: 1;
  min-width: 120px;
  max-width: 170px;
}
.crm-recurrence-date-wrap .crm-date-display {
  font-size: 0.82em;
  padding: 5px 30px 5px 8px;
}
/* Calendar popup for recurrence — full-width under the config block */
.crm-recurrence-cal-panel {
  width: 100%;
  min-width: 280px;
  margin-top: 8px;
}

/* Badge on kanban card */
.crm-recurrence-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  margin-top: 6px;
  background: rgba(99,102,241,0.12);
  color: #a5b4fc;
  border-radius: 10px;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

