/* МАЯК · экран «Доступы» — группы и гранты. Префиксы .access- / .acc- .
   Тема наследуется через CSS-переменные из tokens.css. */

.access-admin {
  grid-column: 1 / -1;        /* растянуть на всю область .main (grid 380px 1fr) */
  min-width: 0;
  background: var(--bg);
  overflow: auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 24px;
  gap: 18px;
  overflow: auto;
}

/* ── шапка ── */
.access-header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.access-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.access-title p { margin: 2px 0 0; font-size: 13px; }
.access-sections { margin-left: auto; }
.access-sections .seg-item { display: inline-flex; align-items: center; gap: 6px; height: 30px; }

.access-body { flex: 1; min-height: 0; overflow-y: auto; }

/* ── общие мелочи ── */
.acc-count {
  margin-left: 4px;
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-sub);
  color: var(--muted);
}
.seg-item.active .acc-count { background: var(--accent-bg); color: var(--accent); }

.acc-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}
.acc-empty.sm { padding: 16px; font-size: 12.5px; }

/* ─────────────────────────────────────────────────────────────
   Раздел «Группы»
   ───────────────────────────────────────────────────────────── */
.acc-groups { display: flex; flex-direction: column; gap: 14px; }
.acc-groups-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.acc-groups-bar .seg-item { display: inline-flex; align-items: center; gap: 6px; }
.acc-typetag {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: var(--bg-sub); border: 1px solid var(--line); border-radius: var(--r-2);
  font-size: 13px; font-weight: 600; color: var(--fg);
}

.acc-groups-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  align-items: start;
}

/* список групп */
.acc-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 6px;
}
.acc-group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  cursor: pointer;
  text-align: left;
  color: var(--fg);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.acc-group-row:hover { background: var(--bg-sub); }
.acc-group-row.active { background: var(--accent-bg); border-color: var(--accent-line); }
.acc-group-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: none;
  border-radius: var(--r-2);
  background: var(--bg-sub); color: var(--accent);
}
.acc-group-ic.lg { width: 40px; height: 40px; }
.acc-group-row.active .acc-group-ic { background: var(--paper); }
.acc-group-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acc-group-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-group-id { font-size: 10.5px; }

/* поиск групп над сеткой */
.acc-group-search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; max-width: 420px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-2); color: var(--muted);
}
.acc-group-search svg { flex: none; }
.acc-group-search input {
  border: none; background: transparent; outline: none;
  font: inherit; color: var(--fg); width: 100%;
}

/* сетка групп: до 4 в ряд, прокрутка вниз */
.acc-group-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}
@media (max-width: 1240px) { .acc-group-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .acc-group-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px)  { .acc-group-grid { grid-template-columns: 1fr; } }

.acc-group-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; text-align: left;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-2); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.acc-group-card:hover { background: var(--bg-sub); }
.acc-group-card.active { background: var(--accent-bg); border-color: var(--accent-line); }
.acc-group-card.active .acc-group-ic { background: var(--paper); }

/* прокрутка таблицы грантов и списка участников */
.acc-table-wrap.scroll { max-height: 340px; overflow-y: auto; }
.acc-member-list { max-height: 320px; overflow-y: auto; }

/* детали группы */
.acc-group-detail {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 18px;
  min-height: 220px;
}
.acc-detail-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; height: 200px; color: var(--muted-2); text-align: center;
}
.acc-detail-empty p { margin: 0; font-size: 13px; }

.acc-detail-head { display: flex; align-items: flex-start; gap: 12px; }
.acc-detail-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.acc-detail-title h3 { margin: 0; font-size: 17px; font-weight: 600; }
.acc-detail-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 2px; }
.acc-detail-desc { margin: 12px 0 0; font-size: 12.5px; }

.acc-member-toolbar { display: flex; align-items: center; gap: 8px; margin: 18px 0 10px; }

.acc-member-list { display: flex; flex-direction: column; gap: 4px; }
.acc-member {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--paper-2);
}
.acc-member-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: none;
  border-radius: var(--r-1);
  background: var(--bg-sub); color: var(--muted);
}
.acc-member-text { flex: 1; min-width: 0; }
.acc-member-name { font-size: 13px; font-weight: 500; }
.acc-member-id { font-size: 10.5px; }

/* ─────────────────────────────────────────────────────────────
   Раздел «Права доступа»
   ───────────────────────────────────────────────────────────── */
.acc-grants { display: flex; flex-direction: column; gap: 18px; }

.acc-grant-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 16px 18px;
}
.acc-grant-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.acc-grant-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.acc-grant-sub { margin: 2px 0 0; font-size: 12px; }
.acc-grant-head .btn { margin-left: auto; flex: none; }

.acc-table-wrap { overflow-x: auto; }
.acc-table { width: 100%; border-collapse: collapse; }
.acc-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.acc-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.acc-table tbody tr:last-child td { border-bottom: 0; }
.acc-table tbody tr:hover td { background: var(--bg-sub); }
.acc-arrow-col { width: 28px; color: var(--muted-2); text-align: center; }

.acc-target { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acc-target-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: none;
  border-radius: var(--r-2);
  background: var(--bg-sub); color: var(--muted);
}
.acc-target-icon.group { background: var(--accent-bg); color: var(--accent); }
.acc-target-text { min-width: 0; }
.acc-target-name { font-size: 13px; font-weight: 500; }
.acc-target-sub { font-size: 10px; }

/* ─────────────────────────────────────────────────────────────
   Грант-мастер (модалка)
   ───────────────────────────────────────────────────────────── */
.access-modal-overlay {
  position: fixed; inset: 0;
  z-index: var(--z-modal, 200);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(10, 14, 24, 0.5);
  backdrop-filter: blur(2px);
}
.access-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.access-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.access-modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.access-modal-body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.access-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.acc-wiz-section {
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 12px 14px;
  background: var(--paper-2);
  display: flex; flex-direction: column; gap: 10px;
}
.acc-wiz-arrow { text-align: center; color: var(--muted-2); margin: -6px 0; }

.acc-seg-row { display: flex; width: 100%; }
.acc-seg-row .seg-item { flex: 1; justify-content: center; }

.acc-field { display: flex; flex-direction: column; gap: 5px; }
.acc-field label {
  font-size: 11px; font-weight: 500;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}
.acc-field select { width: 100%; }
.acc-level-field { padding-top: 2px; }

.acc-empty-select {
  padding: 8px 10px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-2);
  font-size: 12px;
  color: var(--muted-2);
}

/* ── адаптив ── */
@media (max-width: 900px) {
  .acc-groups-grid { grid-template-columns: 1fr; }
  .access-sections { margin-left: 0; }
}
@media (max-width: 560px) {
  .access-admin { padding: 16px; }
  .acc-grant-head { flex-wrap: wrap; }
  .acc-grant-head .btn { margin-left: 0; }
}
