.sg-container {
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

// ── Stats Row ─────────────────────────────────────────
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px 16px 0;
  flex-shrink: 0;

  @media (max-width: 900px) { grid-template-columns: repeat(2, 1fr); }
  @media (max-width: 500px) { grid-template-columns: 1fr; }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  border: 1px solid var(--border-subtle);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;

  mat-icon { font-size: 22px; width: 22px; height: 22px; }

  &--group  { background: #eef2ff; mat-icon { color: #4f6fd4; } }
  &--active { background: #f0fdf4; mat-icon { color: #22c55e; } }
  &--domain { background: #fff7ed; mat-icon { color: #f97316; } }
  &--skill  { background: #f5f3ff; mat-icon { color: #7c3aed; } }
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-number {
  font-size: 26px;
  font-weight: 700;
  color: var(--action-primary-default, #7068b1);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

// ── Filter Bar ────────────────────────────────────────
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;

  .filter-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .filter-right {
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

.filter-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;

  .filter-select {
    appearance: none;
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    min-width: 140px;
    transition: border-color 0.2s ease;

    &:focus { border-color: var(--action-primary-default, #7068b1); }
  }

  .select-arrow {
    position: absolute;
    right: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    pointer-events: none;
  }
}

.filter-search-wrapper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-surface);
  padding: 0 10px;
  gap: 6px;
  transition: border-color 0.2s ease;

  &:focus-within { border-color: var(--action-primary-default, #7068b1); }

  .searchIcon { font-size: 18px; width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }

  .filter-search {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    padding: 6px 0;
    width: 180px;

    &::placeholder { color: var(--text-secondary); }
  }
}

.showing-label {
  font-size: 13px;
  color: var(--text-secondary);

  strong { color: var(--action-primary-default, #7068b1); }
}

// ── View Toggle ───────────────────────────────────────
.view-toggle {
  display: flex;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  background: var(--bg-surface);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;

  mat-icon { font-size: 18px; width: 18px; height: 18px; color: var(--text-secondary); }

  &.active {
    background: var(--action-primary-default, #7068b1);
    mat-icon { color: #fff; }
  }

  &:not(.active):hover { background: var(--bg-subtle); }
}

// ── Add Button ────────────────────────────────────────
.btn-add {
  padding: 8px 18px;
  background: var(--action-primary-default, #7068b1);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s ease;

  &:hover { opacity: 0.9; }
}

// ── Card Grid ─────────────────────────────────────────
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 16px;

  @media (max-width: 600px) { grid-template-columns: 1fr; }
}

.group-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;

  &:hover {
    border-color: var(--action-primary-default, #7068b1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4f6fd4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.identity-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.group-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-code {
  font-size: 12px;
  color: var(--text-secondary);
}

.status-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  color: #e53935;
  background: #fff5f5;
  border: 1px solid #e53935;

  &.is-active {
    color: #2e7d32;
    background: #f1fdf3;
    border-color: #2e7d32;
  }
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;

  span { display: flex; align-items: center; gap: 5px; }
  mat-icon { font-size: 15px; width: 15px; height: 15px; }
}

.card-footer {
  display: flex;
  gap: 8px;
}

.btn-edit {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { font-size: 16px; width: 16px; height: 16px; }

  &:hover {
    border-color: var(--action-primary-default, #7068b1);
    background: var(--action-primary-default, #7068b1);
    color: #fff;
  }
}

.btn-delete {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fca5a5;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { font-size: 16px; width: 16px; height: 16px; color: #e53935; }

  &:hover {
    border-color: #e53935;
    background: #e53935;
    mat-icon { color: #fff; }
  }
}

// ── Table View ────────────────────────────────────────
.table-container {
  background: var(--bg-surface);
  border-radius: 8px;
  margin: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.group-table {
  width: 100%;
  border-collapse: collapse;

  thead tr {
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-subtle);

    th {
      position: sticky;
      top: 0;
      z-index: 1;
      background: var(--bg-subtle);
      padding: 12px 16px;
      text-align: left;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
      letter-spacing: 0.5px;
      white-space: nowrap;
    }
  }

  tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;

    &:last-child { border-bottom: none; }
    &:hover { background: var(--bg-muted); }
    &.row-alternate { background: var(--bg-subtle); }
    &.row-alternate:hover { background: var(--bg-muted); }

    td {
      padding: 12px 16px;
      font-size: 13px;
      color: var(--text-primary);
      vertical-align: middle;

      strong { font-weight: 600; }
    }
  }
}

.code-badge-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--action-primary-default, #7068b1);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.status-active {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #2e7d32;
  color: #2e7d32;
  background: #f1fdf3;
}

.status-inactive {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #e53935;
  color: #e53935;
  background: #fff5f5;
}

// ── Table Action Buttons ──────────────────────────────
.action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-edit-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { font-size: 16px; width: 16px; height: 16px; color: var(--text-secondary); }

  &:hover {
    border-color: var(--action-primary-default, #7068b1);
    background: var(--action-primary-default, #7068b1);
    mat-icon { color: #fff; }
  }
}

.btn-delete-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #fca5a5;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { font-size: 16px; width: 16px; height: 16px; color: #e53935; }

  &:hover {
    border-color: #e53935;
    background: #e53935;
    mat-icon { color: #fff; }
  }
}

// ── Card Grid View ────────────────────────────────────
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.group-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s, transform 0.15s;

  &:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
  }

  .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .card-group-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
  }

  .card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);

    .meta-icon {
      font-size: 15px !important;
      width: 15px !important;
      height: 15px !important;
      color: var(--action-primary-default, #7068b1);
    }
  }

  .card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }
}

// ── Empty State ───────────────────────────────────────
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;

  .empty-icon {
    font-size: 56px;
    width: 56px;
    height: 56px;
    color: var(--text-secondary);
    margin-bottom: 16px;
  }

  h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0 0 8px; }
  p  { font-size: 14px; color: var(--text-secondary); margin: 0 0 24px; }
}

// ── Modal ─────────────────────────────────────────────
.modal {
  display: none;
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
  padding-top: 80px;
}

.modal-content-wrapper {
  display: flex;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-surface, #fefefe);
  padding: 24px;
  border: 1px solid var(--border-subtle, #888);
  width: min(680px, 95vw);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.titlecontainer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary, #333);
  margin: 0;
}

.icons {
  display: flex;
  gap: 24px;
  align-items: center;
}

.action {
  display: flex;
  gap: 12px;
  align-items: center;
}

.save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  height: 38px;
  border-radius: 8px;
  background: #1EAE8A;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { color: #fff; font-size: 18px; width: 18px; height: 18px; }

  .save-label { color: #fff; font-size: 13px; font-weight: 600; }

  &:hover { background: #189b7a; transform: translateY(-1px); }
  &:active { transform: translateY(0); }
}

.delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid #E63946;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { color: #E63946; font-size: 18px; width: 18px; height: 18px; }

  &:hover { background: rgba(230,57,70,0.1); transform: translateY(-1px); }
  &:active { transform: translateY(0); }
}

.add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid #818181;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;

  mat-icon { color: #818181; font-size: 18px; width: 18px; height: 18px; }

  &:hover { background: rgba(129,129,129,0.1); transform: translateY(-1px); }
  &:active { transform: translateY(0); }
}

.closeicon {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;

  mat-icon { width: 26px; height: 26px; font-size: 26px; color: #666; }

  &:hover { transform: scale(1.1); mat-icon { color: #333; } }
}

.modal-form-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

// .form-row {
//   display: flex;
//   gap: 16px;
//   flex-wrap: wrap;
// }

.domain-hint {
  font-size: 11px;
  color: #c88ef8;
  margin: 4px 0 0;
  line-height: 1.3;
}

.picklist-stack {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-width: 200px;

  gb-newpicklist {
    width: 100%;
    margin-bottom: 0;   // kill any default field spacing before the code text
  }
}

/* ---- Sort Indicators ---- */
.sortable-col {
  cursor: pointer;
  user-select: none;

  &:hover {
    color: var(--text-primary);
  }
}

.sort-indicator {
  display: inline-flex;
  flex-direction: column;
  margin-left: 5px;
  gap: 1px;
  vertical-align: middle;
  line-height: 1;
}

.sort-arrow-up,
.sort-arrow-down {
  font-size: 8px;
  color: var(--border-subtle);
  line-height: 1;
  display: block;

  &.sort-active {
    color: var(--text-primary);
  }
}
