/* ==========================================================================
   SceneComp Admin Console — extends /assets/styles.css without modifying it.
   Inherits exact obsidian palette, hairline surfaces, typography & motion.
   ========================================================================== */

.admin-loading {
  max-width: 440px;
  margin: 56px auto;
  padding: 40px 32px;
  text-align: center;
}
.admin-loading h2 {
  margin: 18px 0 6px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.admin-loading p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.icon-tile.warn {
  color: var(--warn);
  background: linear-gradient(180deg, rgba(245, 181, 70, 0.16), rgba(245, 181, 70, 0.05));
  border-color: rgba(245, 181, 70, 0.34);
}
.icon-tile.danger {
  color: var(--danger);
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.16), rgba(248, 113, 113, 0.05));
  border-color: rgba(248, 113, 113, 0.34);
}

.pill-danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.38);
  color: #fca5a5;
}

.admin-header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.admin-security-chip {
  height: 22px;
  padding: 0 9px;
  font-size: 11px;
}

/* ---------- KPI Strip ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0;
  overflow: hidden;
  margin-bottom: 18px;
}
.kpi-cell {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi-cell + .kpi-cell {
  border-left: 1px solid var(--line);
}
.kpi-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.kpi-val {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #fff;
  margin-top: 2px;
}
.kpi-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-sub strong {
  color: var(--text-2);
  font-weight: 600;
}

/* ---------- Toolbar (Search + Segmented Filter) ---------- */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}
.search-wrap .input {
  height: 36px;
  padding-left: 36px;
  font-size: 13.5px;
}

.seg-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: #0e0e11;
  border: 1px solid var(--line-2);
}
.seg-tab {
  height: 28px;
  padding: 0 11px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 560;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg-tab:hover { color: var(--text); }
.seg-tab.active {
  background: var(--panel-3);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 3px rgba(0, 0, 0, 0.5);
}
.seg-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
}
.seg-tab.active .seg-count {
  color: var(--accent-ink);
}

/* ---------- Data Table ---------- */
.table-card {
  padding: 0;
  overflow: hidden;
}
.table-card-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.admin-table thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.admin-table thead th:first-child { padding-left: 22px; }
.admin-table thead th:last-child { padding-right: 22px; text-align: right; }

.admin-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.14s ease;
}
.admin-table tbody tr:last-child { border-bottom: 0; }
.admin-table tbody tr.is-clickable { cursor: pointer; }
.admin-table tbody tr.is-clickable:hover { background: rgba(255, 255, 255, 0.025); }
.admin-table tbody tr.is-selected {
  background: rgba(75, 139, 245, 0.08);
}

.admin-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--text-2);
}
.admin-table tbody td:first-child { padding-left: 22px; }
.admin-table tbody td:last-child { padding-right: 22px; text-align: right; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 210px;
}
.user-cell .user-avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
  border-radius: 9px;
}
.user-cell .user-avatar.is-admin {
  background: linear-gradient(145deg, #3ddc97, #1c9a66);
}
.user-cell-text {
  min-width: 0;
}
.user-cell-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.user-cell-email {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--ok-soft);
  border: 1px solid var(--ok-line);
  color: #7ff0bd;
}
.you-chip {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-2);
  color: var(--muted);
}

.plan-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.plan-stack .pill {
  height: 23px;
  padding: 0 9px;
  font-size: 11.5px;
}
.plan-source {
  font-size: 11.5px;
  color: var(--muted-2);
}

.seat-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 78px;
}
.seat-mini-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}
.seat-mini-bar {
  height: 4px;
  width: 68px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.seat-mini-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3a74e8, var(--cyan));
}
.seat-mini-bar.full i {
  background: linear-gradient(90deg, #e59a2f, var(--warn));
}

.date-cell {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.table-empty {
  padding: 36px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.012);
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------- Audit Feed ---------- */
.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.audit-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
}
.audit-row:last-child { border-bottom: 0; }
.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--muted-2);
}
.audit-dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(61, 220, 151, 0.45); }
.audit-dot.warn { background: var(--warn); box-shadow: 0 0 8px rgba(245, 181, 70, 0.45); }
.audit-dot.accent { background: var(--accent); box-shadow: 0 0 8px rgba(75, 139, 245, 0.5); }

.audit-main {
  min-width: 0;
}
.audit-line {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.45;
}
.audit-line strong {
  color: var(--text);
}
.audit-detail {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.audit-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
}

/* ---------- Slide-Over User Inspector Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(6, 6, 9, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: flex-end;
}
.admin-drawer {
  width: min(500px, 100vw);
  height: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 28%), #121216;
  border-left: 1px solid var(--line-2);
  box-shadow: -24px 0 64px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-in 0.2s var(--ease);
}
@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}
.drawer-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.drawer-id .user-avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
  border-radius: 11px;
}
.drawer-id h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-email {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.drawer-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f0f12;
  padding: 16px;
}
.drawer-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.drawer-block-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--text);
}

.drawer-kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.kv-box {
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}
.kv-k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-2);
  font-weight: 600;
}
.kv-v {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  margin-top: 2px;
}

.inline-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.select-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239d9da8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
  cursor: pointer;
  color-scheme: dark;
}
.select-input option {
  background: #151518;
  color: var(--text);
}
.admin-drawer .input,
.admin-modal .input {
  color-scheme: dark;
}
.input-sm {
  height: 34px;
  font-size: 13px;
}

.seat-limit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}
.seat-limit-row label {
  font-size: 12.5px;
  color: var(--muted);
  margin-right: auto;
}
.side-help code {
  white-space: nowrap;
}

.seat-limit-row .input {
  width: 64px;
  height: 30px;
  text-align: center;
  font-family: var(--mono);
  padding: 0 8px;
  -moz-appearance: textfield;
}
.seat-limit-row .input::-webkit-outer-spin-button,
.seat-limit-row .input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.grant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 8px;
}
.grant-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.seat-row.is-revoked {
  opacity: 0.58;
  border-style: dashed;
}

.admin-role-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin-role-copy {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- Grant Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 6, 9, 0.76);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.admin-modal {
  width: min(460px, 100%);
  padding: 26px;
  box-shadow: var(--shadow-lg);
}
.admin-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.admin-modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.toggle-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle-check input {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
  flex-shrink: 0;
  margin: 0;
}
.toggle-check input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.16s var(--ease), background 0.16s ease;
}
.toggle-check input:checked {
  background: var(--accent);
  border-color: rgba(120, 170, 255, 0.7);
}
.toggle-check input:checked::after {
  transform: translateX(13px);
  background: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-cell:nth-child(3) { border-left: 0; }
  .kpi-cell:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .kpi-cell { padding: 16px; }
  .kpi-val { font-size: 24px; }
  .table-card-head { padding: 16px; }
  .admin-table thead th:first-child,
  .admin-table tbody td:first-child { padding-left: 16px; }
  .admin-table thead th:last-child,
  .admin-table tbody td:last-child { padding-right: 16px; }
  .inline-form-row,
  .drawer-kv { grid-template-columns: minmax(0, 1fr); }
  .audit-row { padding: 12px 16px; }
}
