/* T2 Falcon Admin — Contact Groups */

/* Reuse .templates-page grid (clients tree + main) — extra rules below.   */

.cg-page .tpl-main {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ============================================================================
   Contracts-style chrome for the Contact Groups LIST + DETAILS
   The page reuses Hierarchy/Contracts global classes (.content-panel /
   .content-body / .node-header / .table-panel / .users-table / TablePagination /
   .info-panel) so it matches the "Contracts & Cost" screen — same header, table
   and behavior. The rules below are the few Contact-Groups-specific touches on
   top of that shared chrome.
   ============================================================================ */

/* Tree only in Falcon view; Client view is full-width (mirrors Contracts) */
.templates-page.cg-page.with-tree { grid-template-columns: var(--clients-w) minmax(0, 1fr); }
.templates-page.cg-page.no-tree   { grid-template-columns: minmax(0, 1fr); }

/* List rows are not clickable — details open only from the "More Details" action,
   so no pointer cursor and no hover/zebra background. */
.cg-users-table tbody tr { cursor: default; }

/* Keep list rows at the standard ~60px height. The two-line creator/date cells
   would otherwise push rows to ~67px, so trim the vertical padding a touch. */
.cg-users-table tbody td { padding-top: 12px; padding-bottom: 12px; }

/* Deleted contact group (Falcon view only) — greyed-out row with a thin red accent bar
   on the trailing edge, matching the reference. The Status badge keeps its real
   Completed / In-Progress colour. */
.cg-users-table tbody tr.deleted td { color: #9aa1a9; background: #f6f7f8; }
.cg-users-table tbody tr.deleted .cg-creator .nm,
.cg-users-table tbody tr.deleted .cg-creator .em { color: #9aa1a9; }
.cg-users-table tbody tr.deleted .tpl-shared-pill { opacity: 0.55; }
.cg-users-table tbody tr.deleted td:last-child { position: relative; }
.cg-users-table tbody tr.deleted td:last-child::after {
  content: ''; position: absolute; top: 10px; bottom: 10px; inset-inline-end: 4px;
  width: 3px; border-radius: 2px; background: var(--red, #e5484d);
}

/* Created column — two stacked lines (date / time) */
.cg-users-table td.cg-multi div { line-height: 1.35; }
.cg-users-table td.cg-multi div + div { color: var(--text-muted); font-size: 12px; }

/* "#" column in the contacts table */
.cg-contacts-table th.cg-num,
.cg-contacts-table td.cg-num { width: 44px; color: var(--text-muted); }

/* Header role chip ("VIEWING AS …") — subtle separator before the buttons */
.cg-viewing-as {
  border-inline-end: 1px solid var(--border);
  padding-inline-end: 16px;
  margin-inline-end: 4px;
}

/* Details — group info panel */
.cg-info-panel { margin-bottom: 18px; }
.cg-info-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}
.cg-danger { color: #C92A2A; }
.cg-field-shared { grid-column: 1 / -1; }

/* Details — contacts table download buttons */
.cg-th-actions { display: inline-flex; align-items: center; gap: 12px; }
/* Download buttons: "Original File" = teal outline, "Contact Group" = filled teal. */
.cg-th-btn {
  height: 40px;
  padding: 0 18px;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--teal);
  color: var(--teal);
}
.cg-th-btn:hover { background: rgba(13, 63, 68, 0.05); }
.cg-th-btn.is-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.cg-th-btn.is-primary:hover { background: var(--teal-hover, #0b3539); }

/* Creator column (Created-by cell in the list) */
.cg-creator { display: flex; flex-direction: column; line-height: 1.3; }
.cg-creator .nm { font-size: 12.5px; color: var(--text); }
.cg-creator .em { font-size: 11.5px; color: var(--text-muted); }

/* Shared-with chips (light gray pills) */
.cg-shared-chips { display: inline-flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.cg-shared-chip {
  display: inline-block;
  flex-shrink: 0;
  height: 36px;
  line-height: 36px;
  padding: 0 18px;
  background: #ECEFF1;
  color: var(--text);
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}
.cg-shared-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--teal);
  color: white;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.cg-shared-more:hover,
.cg-shared-more.on { background: var(--teal-dark); }

/* "Shared with more" popup — opens on clicking the +N chip (fixed-positioned so
   it is never clipped by the table's horizontal scroll). */
.cg-shared-pop {
  z-index: 1000;
  width: 300px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16), 0 0 0 1px var(--border-2, #e3e9ea);
  padding: 14px 6px 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: menuIn 0.12s ease;
}
.cg-shared-pop-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border-2, #e3e9ea);
}
.cg-shared-pop-list {
  overflow-y: auto;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
}
.cg-shared-pop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}
.cg-shared-pop-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============== Add/Edit Contact Group wizard ============== */
.acg-drop {
  margin-top: 18px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: #fafbfc;
  padding: 44px 24px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.acg-drop:hover, .acg-drop.drag-over {
  border-color: var(--teal);
  background: rgba(13, 63, 68, 0.03);
}
.acg-drop.has-file {
  cursor: default;
  padding: 48px 24px;
  background: white;
}
.acg-drop-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #edf1f0;
  color: #1f2a37;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.acg-drop-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}
.acg-drop-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.acg-sample-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--teal);
  font-weight: 500;
  text-decoration: none;
}
.acg-sample-link:hover { text-decoration: underline; }

/* "Contact File *" field — label above the dropzone (mirrors the other fields) */
.acg-file-field {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acg-file-field .acg-drop { margin-top: 0; }
.acg-drop.error { border-color: #dc2626; background: #fef5f5; }

/* Uploaded-file card — green spreadsheet icon + bold name + size + × (centered) */
.acg-file-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 6px 8px;
  max-width: 100%;
}
.acg-file-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: rgba(13, 63, 68, 0.08);
  color: var(--teal);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.acg-file-icon.sheet { background: transparent; width: 52px; height: 52px; }
.acg-file-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  max-width: 100%;
}
.acg-file-meta strong {
  font-size: 16px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.acg-file-meta span { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.acg-file-remove {
  width: 30px; height: 30px;
  margin-top: 8px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.acg-file-remove:hover { background: #fdecec; color: #dc2626; }

.acg-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.acg-hint svg { color: var(--teal); }

.acg-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 4px 0 14px;
  gap: 12px;
}
.acg-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.acg-section-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.acg-count-pill {
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
}
.acg-count-pill.teal {
  background: var(--teal);
  color: white;
}

/* Column edit grid */
.acg-col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 20px;
}
.acg-col-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.acg-col-input-wrap { position: relative; }
.acg-col-input-wrap .ac-input { padding-inline-end: 30px; }
.acg-col-ok {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #1F8A5B;
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
}
.acg-col-tooltip {
  position: absolute;
  inset-inline-end: 0;
  bottom: calc(100% + 6px);
  background: #2a1416;
  color: #ffd5d5;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.15s, transform 0.15s;
}
.acg-col-tooltip svg { color: #ff8a8a; flex-shrink: 0; }
.acg-col-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  inset-inline-end: 12px;
  border: 4px solid transparent;
  border-top-color: #2a1416;
}
.acg-col-field.invalid .acg-col-tooltip { opacity: 1; transform: translateY(0); }

/* Preview table inside wizard */
.acg-preview-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: white;
}
.acg-preview-wrap {
  overflow: auto;
  background: #F8F8F8;
}
.acg-preview-wrap .cg-table th.col-invalid {
  background: #fef0f0;
  color: #c5302d;
}

/* Empty state */
.acg-empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 50px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.acg-empty.small { padding: 30px; }

/* Share step */
.acg-share-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.acg-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--text-muted);
  max-width: 360px;
}
.acg-search:focus-within { border-color: var(--teal); }
.acg-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.acg-link-btn {
  background: transparent;
  border: none;
  color: var(--teal);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.acg-link-btn:hover { text-decoration: underline; }

.acg-user-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: white;
  max-height: 380px;
  overflow-y: auto;
}
.acg-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.acg-user-row:last-child { border-bottom: none; }
.acg-user-row:hover { background: #fafbfc; }
.acg-user-row.on { background: rgba(13, 63, 68, 0.04); }
.acg-user-row input[type="checkbox"] { display: none; }
.acg-user-check {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid #c4c9cf;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  flex-shrink: 0;
  transition: all 0.15s;
}
.acg-user-row.on .acg-user-check {
  background: var(--teal);
  border-color: var(--teal);
}
.acg-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.acg-user-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.acg-user-meta strong { font-size: 13px; font-weight: 600; color: var(--text); }
.acg-user-meta span   { font-size: 11.5px; color: var(--text-muted); }
.acg-user-role {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Review step */
.acg-review { display: flex; flex-direction: column; gap: 16px; }
.acg-review-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  overflow: hidden;
}
.acg-review-card-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
}
.acg-review-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 24px;
  padding: 18px;
}
.acg-review-grid label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.acg-review-grid .val { font-size: 13px; color: var(--text); font-weight: 600; word-break: break-word; }

.acg-review-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 18px;
}
.acg-col-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
}

.acg-review-users {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px 18px;
}
.acg-review-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
}
.acg-review-empty { padding: 22px 18px; font-size: 12.5px; color: var(--text-muted); }

.acg-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.acg-confirm input { display: none; }
.acg-confirm-mark {
  width: 18px; height: 18px;
  border: 1.5px solid #c4c9cf;
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
}
.acg-confirm input:checked ~ .acg-confirm-mark { background: var(--teal); border-color: var(--teal); }
.acg-confirm:has(input:checked) .acg-confirm-mark { background: var(--teal); border-color: var(--teal); }

@media (max-width: 1100px) {
  .acg-col-grid { grid-template-columns: repeat(2, 1fr); }
  .acg-review-grid { grid-template-columns: repeat(2, 1fr); }
  .acg-review-users { grid-template-columns: 1fr; }
}

/* ============== Wizard layout (matches templates-page grid) ============== */
/* The wizard reuses .templates-page so the org tree column has the same
   width (var(--clients-w)) as Hierarchy / Wallet / Templates. The main
   panel is a single .tpl-main card with action bar + step bar inside. */
.acg-wizard-shell .tpl-main.acg-wizard-main {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.acg-wizard-topbar.tpl-main-head {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.acg-wizard-brand { display: flex; align-items: center; gap: 10px; }
.acg-wizard-brand-fallback {
  width: 28px; height: 28px; border-radius: 50%;
  background: #cfe9ec; color: var(--teal);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
}
.acg-wizard-actions { display: flex; align-items: center; gap: 12px; }
.acg-wizard-cancel {
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text-muted);
  padding: 6px 10px;
}
.acg-wizard-cancel:hover { color: var(--text); }
.acg-wizard-prev {
  height: 34px; padding: 0 18px;
  border: 1px solid var(--border); background: white;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--text);
}
.acg-wizard-prev:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.acg-wizard-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.acg-wizard-next {
  height: 34px; padding: 0 22px;
  border: none; background: var(--teal); color: white;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500;
}
.acg-wizard-next:hover { background: #0a323a; }

.acg-wizard-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 8px;
}
.acg-wizard-card-title { font-size: 17px; font-weight: 700; color: var(--text); }
.acg-wizard-step-counter { font-size: 12px; color: var(--text-muted); font-style: italic; }
.acg-wizard-step-counter strong { color: var(--text); font-weight: 600; font-style: normal; }
.acg-wizard-body { padding: 8px 24px 24px; flex: 1; overflow-y: auto; min-height: 0; }

/* ============== Step 2 — column header inputs + popover ============== */
.acg-first-row-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
  margin: 8px 0 18px;
}
.acg-first-row-toggle input { display: none; }
.acg-cb-mark {
  width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid #c4c9cf; background: white;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.acg-first-row-toggle input:checked + .acg-cb-mark,
.acg-col-chip-tog.on .acg-cb-mark,
.acg-combo-row.on .acg-cb-mark {
  background: var(--teal); border-color: var(--teal);
}

.acg-cols-section { margin-bottom: 22px; }
.acg-cols-section-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.acg-cols-title { font-size: 13px; font-weight: 600; color: var(--text); }
.acg-cols-hint { font-size: 12px; color: var(--text-muted); }
.acg-spaces-note {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-muted);
}

.acg-col-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 32px; }
.acg-cols-none { font-size: 13px; color: var(--text-muted); }
.acg-col-chip-tog {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 12.5px; color: var(--text);
  cursor: pointer; user-select: none;
  font-family: inherit;
}
.acg-col-chip-tog input { display: none; }
.acg-col-chip-tog.off { color: var(--text-muted); background: #fafbfc; }
.acg-col-chip-tog.off span:last-child { text-decoration: line-through; }
.acg-col-chip-tog.on { border-color: var(--teal); }
.acg-col-chip-eye {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--teal);
}
.acg-col-chip-tog.off .acg-col-chip-eye { color: #d97706; }

/* ============== Step 4 — review pane ============== */
.acg-r4 { display: flex; flex-direction: column; gap: 22px; }
.acg-r4-confirm {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: #f3faf5;
  border: 1px solid #c7e9d2;
  border-radius: 10px;
  font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
  align-self: flex-start;
}
.acg-r4-confirm input { display: none; }
.acg-r4-confirm input:checked + .acg-cb-mark {
  background: var(--teal); border-color: var(--teal);
}
.acg-r4-grid {
  display: grid; grid-template-columns: 1.9fr 1fr 3fr 2.2fr; gap: 28px 16px;
}
/* Review summary: all four identifiers sit on row 1
   (Name | Reference ID | Original file | Number of contacts),
   and "Shared with" spans the full width of row 2. */
.acg-r4-pos-name   { grid-area: 1 / 1; }
.acg-r4-pos-ref    { grid-area: 1 / 2; }
.acg-r4-pos-file   { grid-area: 1 / 3; }
.acg-r4-pos-num    { grid-area: 1 / 4; }
.acg-r4-pos-shared { grid-area: 2 / 1 / 3 / 5; }
/* Shared-with chips wrap within their cell instead of overflowing the card edge;
   the table-cell variants keep their single line. */
.acg-r4-shared-cell .cg-shared-chips { display: flex; flex-wrap: wrap; gap: 8px 10px; max-width: 100%; }

/* Internal-page topbar scope logo — client brand image or node initial avatar. */
.cg-scope-logo { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; box-sizing: border-box; overflow: hidden; }
.cg-scope-node { background: #0d3f44; color: #fff; }
.cg-scope-falcon { background: #fff; border: 1px solid var(--border); color: var(--teal); }
.acg-r4-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.acg-r4-field label {
  font-size: 12px; color: var(--teal); font-weight: 500;
}
.acg-r4-field .val { font-size: 14px; color: var(--text); font-weight: 500; }
.acg-r4-file {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.acg-r4-file-icon { flex-shrink: 0; }
.acg-r4-file-meta { display: flex; flex-direction: column; min-width: 0; }
.acg-r4-file-meta strong { font-size: 13px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.acg-r4-file-meta span { font-size: 11.5px; color: var(--text-muted); }
.acg-r4-shared { display: flex; flex-wrap: wrap; gap: 6px; }
.acg-r4-share-chip {
  display: inline-flex; align-items: center;
  background: #1a3a3f; color: white;
  font-size: 12px; font-weight: 500;
  padding: 5px 12px; border-radius: 999px;
}
.acg-r4-share-chip.more { background: #f0f1f3; color: var(--text-muted); }

.acg-r4-preview-head { display: flex; align-items: baseline; gap: 10px; }
.acg-r4-preview {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: #F8F8F8;
  padding-bottom: 16px;
}
.acg-preview-tbl.r4 thead th.r4-h {
  background: #F8F8F8;
  color: var(--text); font-weight: 600; font-size: 12.5px;
  padding: 20px 8px;
}
.acg-preview-tbl.r4 tbody tr:nth-child(even) { background: #fafbfc; }

.acg-preview-tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.acg-preview-tbl th, .acg-preview-tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: start;
  white-space: nowrap;
}
.acg-preview-tbl thead th {
  background: #F8F8F8;
  position: sticky; top: 0; z-index: 2;
  padding: 10px 8px;
}
.acg-preview-tbl th.num, .acg-preview-tbl td.num {
  width: 40px; color: var(--text-muted); font-weight: 500;
  text-align: center;
}
.acg-preview-tbl tbody td { color: var(--text); background: #fff; padding: 20px 14px; }
.acg-preview-tbl tbody td.muted { color: var(--text-muted); }
.acg-preview-tbl tbody tr:last-child td { border-bottom: 1px solid var(--border); }

.acg-hdr-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  min-width: 140px;
}
.acg-hdr-cell.is-invalid { border-color: #c5302d; background: #fef0f0; }
.acg-hdr-cell.is-hidden { background: #f5f6f7; opacity: 0.65; }
.acg-hdr-input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text);
}
.acg-hdr-input:disabled { color: var(--text-muted); cursor: not-allowed; }
.acg-hdr-cell.is-invalid .acg-hdr-input { color: #c5302d; }
.acg-hdr-eye {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.acg-hdr-eye:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.acg-hdr-eye.off { color: var(--text-muted); }

/* Validation popover (rendered via portal — fixed positioning) */
.acg-rule-pop {
  position: fixed;
  z-index: 1000;
  min-width: 280px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  padding: 8px;
  display: flex; flex-direction: column;
  gap: 2px;
}
.acg-rule {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  font-size: 12.5px;
  border-radius: 6px;
  position: relative;
}
.acg-rule.ok { color: var(--text-muted); text-decoration: line-through; }
.acg-rule.fail { color: #c5302d; font-weight: 600; }
.acg-rule-ic {
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.acg-rule-ic.ok { background: #1F8A5B; }
.acg-rule-ic.warn { background: transparent; color: #c5302d; }
.acg-rule-label { flex: 1; min-width: 0; }
.acg-rule-x {
  width: 18px; height: 18px;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.acg-rule:hover .acg-rule-x { opacity: 1; }
.acg-rule-x:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.acg-rule-disabled-wrap {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.acg-rule-disabled-label { font-size: 11px; color: var(--text-muted); margin-inline-end: 4px; }
.acg-rule-restore {
  font-size: 11.5px; padding: 3px 8px;
  border: 1px dashed var(--border); background: #f7f8f9;
  border-radius: 6px; cursor: pointer; font-family: inherit;
  color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.acg-rule-restore:hover { color: var(--teal); border-color: var(--teal); }
.acg-rule-restore .plus { font-weight: 700; color: var(--teal); }

/* ============== Step 3 — share grid ============== */
.acg-share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: flex-start;
}
.acg-share-label { font-size: 13px; font-weight: 600; color: var(--text); }
.acg-share-label .muted { font-weight: 400; color: var(--text-muted); margin-inline-start: 6px; }

.acg-combo { position: relative; margin-top: 10px; }
.acg-combo-control {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 6px 10px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-family: inherit;
  text-align: start;
}
.acg-combo.open .acg-combo-control { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,63,68,0.08); }
.acg-combo-chips { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.acg-combo-placeholder { color: var(--text-muted); font-size: 13px; }
.acg-combo-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #e8f0f1; color: var(--teal);
  font-size: 12px; font-weight: 500;
  padding: 3px 8px; border-radius: 5px;
  cursor: pointer;
}
.acg-combo-chip.more { background: #f0f1f3; color: var(--text-muted); }
.acg-combo-chip svg { opacity: 0.7; }
.acg-combo-chip:hover svg { opacity: 1; }
.acg-combo-caret { color: var(--text-muted); flex-shrink: 0; }

.acg-combo-pop {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  z-index: 10;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.10);
  padding: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.acg-combo-search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: white; color: var(--text-muted);
  margin-bottom: 6px;
}
.acg-combo-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--text);
}
.acg-combo-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
}
.acg-combo-row input { display: none; }
.acg-combo-row.on { background: #F3F8F5; }
.acg-combo-row.all { background: #F3F8F5; font-weight: 600; }
.acg-combo-row.all.on { background: #E8F2EC; }
.acg-combo-row:hover { background: #f3f5f7; }
.acg-combo-row.on:hover { background: #E8F2EC; }
.acg-combo-row-meta { display: flex; flex-direction: column; min-width: 0; }
.acg-combo-row-name { color: var(--text); font-weight: 500; }
.acg-combo-row.all .acg-combo-row-name { font-weight: 600; }
.acg-combo-row-sub { font-size: 11px; color: var(--text-muted); }
.acg-combo-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* Right panel — Selected Users */
.acg-share-right-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.acg-unselect {
  background: transparent; border: none;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 12.5px;
  color: var(--text-muted); cursor: pointer;
}
.acg-unselect:hover { color: var(--text); }
.acg-share-right-empty {
  border: 1px dashed var(--border); border-radius: 10px;
  padding: 32px; text-align: center;
  font-size: 12.5px; color: var(--text-muted);
}
.acg-share-right-list { display: flex; flex-direction: column; gap: 8px; }
.acg-share-right-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: #F3F8F5;
  border-radius: 8px;
}
.acg-share-right-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acg-share-right-meta strong { font-size: 13px; color: var(--text); font-weight: 600; }
.acg-share-right-meta span { font-size: 11.5px; color: var(--text-muted); }
.acg-share-right-x {
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.acg-share-right-x:hover { background: rgba(0,0,0,0.06); color: var(--text); }

@media (max-width: 1100px) {
  .acg-share-grid { grid-template-columns: 1fr; }
}

/* "+ Create Contact Group" header button on Client view */
.cg-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.cg-create-btn:hover { background: var(--teal-dark); }

/* "Edit" action in row menu */
.cg-row-menu .menu-item.edit { color: var(--text); }
.cg-row-menu .menu-item.edit:hover { background: rgba(13, 63, 68, 0.06); }

/* ============== Reuse picker styles from templates.css ============== */

/* ====== Role-based Client view: tabs, share editor, delete dialog ====== */
.cg-tabs.tabs-bar { padding: 0 4px; margin-bottom: 16px; }

/* Destructive (Delete) row-menu item — red text/icon, red fill on hover
   (overrides the generic dark-teal .row-menu-item:hover so red never sits on teal). */
.row-menu-item.cg-danger-item { color: var(--red, #e5484d); }
.row-menu-item.cg-danger-item svg { color: var(--red, #e5484d); }
.row-menu-item.cg-danger-item:hover { background: #104C54; color: #ffffff; }
.row-menu-item.cg-danger-item:hover svg { color: #ffffff; }

/* Editable "Shared with" picker (Share action) — matches the Template share field:
   a "N Items Selected" trigger + checkbox dropdown (CgShareCombo / TplShareMulti). */
.cg-d-share-edit .tpl-share-multi-wrap { margin-top: 6px; max-width: 640px; }
.cg-d-share-edit .lab .opt { color: var(--text-muted); font-weight: 400; font-size: 11px; }
.cg-share-edit { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.cg-share-edit-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 32px; }
.cg-share-edit-empty { font-size: 13px; color: var(--text-muted); }
.cg-share-edit-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 6px 0 14px;
  background: #ECEFF1; color: var(--text); border-radius: 999px; font-size: 13px;
}
.cg-share-edit-chip .x {
  width: 20px; height: 20px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer;
}
.cg-share-edit-chip .x:hover { background: #fdecec; color: #dc2626; }
.cg-share-edit-combo { position: relative; align-self: flex-start; }
.cg-share-edit-add {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px;
  background: white; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--teal); font-weight: 500; cursor: pointer; font-family: inherit;
}
.cg-share-edit-add:hover { border-color: var(--teal); }
.cg-share-edit-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  width: 280px; max-height: 300px; overflow: hidden;
  background: white; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.16), 0 0 0 1px var(--border-2, #e3e9ea);
  display: flex; flex-direction: column;
}
.cg-share-edit-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-2, #e3e9ea); color: var(--text-muted);
}
.cg-share-edit-search input { flex: 1; border: none; outline: none; font-family: inherit; font-size: 13px; color: var(--text); background: transparent; }
.cg-share-edit-list { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; }
.cg-share-edit-opt {
  text-align: start; padding: 9px 12px; border: none; background: transparent;
  font-family: inherit; font-size: 13px; color: var(--text); cursor: pointer; border-radius: 8px;
}
.cg-share-edit-opt:hover { background: rgba(13,63,68,0.06); }
.cg-share-edit-noopt { padding: 14px 12px; font-size: 12.5px; color: var(--text-muted); text-align: center; }

/* Delete confirmation dialog */
.cg-confirm-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15,20,25,0.45);
  display: flex; align-items: center; justify-content: center;
  animation: menuIn 0.12s ease;
}
.cg-confirm {
  width: 380px; max-width: calc(100vw - 32px);
  background: white; border-radius: 16px; padding: 26px 26px 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25); text-align: center;
}
.cg-confirm-icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  border-radius: 50%; background: #fdecec; color: #dc2626;
  display: flex; align-items: center; justify-content: center;
}
.cg-confirm-title { font-size: 16px; font-weight: 700; color: var(--text); }
.cg-confirm-body { margin-top: 8px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.cg-confirm-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; }
.cg-confirm-actions .btn { min-width: 110px; justify-content: center; }
.cg-confirm-del { background: #dc2626; color: white; border: none; }
.cg-confirm-del:hover { background: #b91c1c; }

/* ====== Edit Contact Group (single-screen form) ====== */
.ac-input.is-locked { background: #f1f3f4; color: var(--text-muted); cursor: not-allowed; }
.ac-input.is-locked:hover { border-color: var(--border); }
.cg-edit-shared-field { margin-top: 6px; }
.cg-edit-shared-field .opt { color: var(--text-muted); font-weight: 400; font-size: 11.5px; }
.cg-edit-contacts { margin-top: 26px; }

/* Shared With combo — chips inside a scrollable box + portaled add dropdown */
.cg-share-combo { position: relative; max-width: 520px; }
.cg-share-combo-control {
  display: flex; align-items: flex-start; gap: 8px;
  min-height: 46px; max-height: 104px; overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: white; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.cg-share-combo-control.open { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,63,68,0.08); }
.cg-share-combo-chips { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.cg-share-combo-ph { color: var(--text-faint); font-size: 13px; }
.cg-share-combo-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 6px 0 12px;
  background: #ECEFF1; color: var(--text); border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.cg-share-combo-chip button {
  width: 18px; height: 18px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer;
}
.cg-share-combo-chip button:hover { background: #fdecec; color: #dc2626; }
.cg-share-combo-caret { color: var(--text-muted); flex-shrink: 0; margin-top: 7px; }
.cg-share-combo-pop {
  z-index: 1000; background: white; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.16), 0 0 0 1px var(--border-2, #e3e9ea);
  display: flex; flex-direction: column; overflow: hidden;
}
.cg-share-combo-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-2, #e3e9ea); color: var(--text-muted); }
.cg-share-combo-search input { flex: 1; border: none; outline: none; font-family: inherit; font-size: 13px; color: var(--text); background: transparent; }
.cg-share-combo-list { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; }
.cg-share-combo-opt { text-align: start; padding: 9px 12px; border: none; background: transparent; font-family: inherit; font-size: 13px; color: var(--text); cursor: pointer; border-radius: 8px; }
.cg-share-combo-opt:hover { background: rgba(13,63,68,0.06); }
.cg-share-combo-empty { padding: 14px 12px; font-size: 12.5px; color: var(--text-muted); text-align: center; }

/* ============== Responsive ============== */
@media (max-width: 1100px) {
  .cg-details-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
