.admin-page {
  padding: 110px 24px 80px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
}

.admin-hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 28px 28px 24px;
  margin-bottom: 22px;
  background:
    radial-gradient(900px 280px at 10% -20%, rgba(255, 77, 106, 0.28), transparent 55%),
    radial-gradient(700px 240px at 90% 0%, rgba(255, 122, 143, 0.14), transparent 50%),
    linear-gradient(180deg, rgba(28, 28, 34, 0.95), rgba(18, 18, 22, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.admin-hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-hero h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.admin-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 520px;
  line-height: 1.45;
}

.admin-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.admin-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.2s, transform 0.2s;
}

.admin-stat-card:hover {
  border-color: rgba(255, 77, 106, 0.35);
  transform: translateY(-1px);
}

.admin-stat-card span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-stat-card strong {
  font-size: 26px;
  color: #fff;
  font-weight: 700;
  line-height: 1;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}

.admin-nav {
  position: sticky;
  top: 96px;
  background: rgba(21, 21, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 12px;
  backdrop-filter: blur(14px);
}

.admin-nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 10px 10px;
}

.admin-tab {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s ease;
  font-family: inherit;
  text-align: left;
  margin-bottom: 4px;
}

.admin-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.admin-tab.active {
  background: linear-gradient(135deg, rgba(255, 77, 106, 0.22), rgba(255, 77, 106, 0.08));
  border-color: rgba(255, 77, 106, 0.35);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 77, 106, 0.08);
}

.admin-tab .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.admin-tab.active .dot {
  background: var(--primary-color);
  box-shadow: 0 0 10px rgba(255, 77, 106, 0.7);
}

.admin-content {
  min-width: 0;
}

.admin-panel {
  display: none;
  background: rgba(21, 21, 25, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  padding: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.admin-panel.active {
  display: block;
  animation: adminFade 0.2s ease;
}

@keyframes adminFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.admin-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.admin-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.admin-panel .panel-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
  max-width: 640px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 16px;
}

.admin-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-form.cols-1 {
  grid-template-columns: 1fr;
}

.admin-form.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-field.full {
  grid-column: 1 / -1;
}

.admin-field label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-field input,
.admin-field select,
.admin-field textarea {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  color: var(--text-color);
  padding: 11px 12px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
  border-color: rgba(255, 77, 106, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 77, 106, 0.12);
}

.admin-field textarea {
  min-height: 76px;
  resize: vertical;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.admin-btn.primary {
  background: linear-gradient(135deg, #FF4D6A, #FF7A8F);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 77, 106, 0.28);
}

.admin-btn.primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.admin-btn.soft {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-btn.soft:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-btn.danger {
  background: rgba(255, 59, 48, 0.14);
  color: #ff8f86;
  border: 1px solid rgba(255, 59, 48, 0.3);
}

.admin-btn.danger:hover {
  background: rgba(255, 59, 48, 0.22);
}

.admin-btn.sm {
  padding: 6px 11px;
  font-size: 12px;
}

.admin-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.14);
}

/* Allow dropdowns to escape table clipping */
.admin-panel:has(.admin-more-menu.open),
.admin-content:has(.admin-more-menu.open),
.admin-table-wrap:has(.admin-more-menu.open) {
  overflow: visible;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.admin-table td {
  color: var(--text-secondary);
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  white-space: nowrap;
}

.admin-badge.online {
  background: rgba(52, 199, 89, 0.15);
  color: #78f0a6;
}

.admin-badge.ban {
  background: rgba(255, 59, 48, 0.15);
  color: #ff8f86;
}

.admin-badge.hwid {
  background: rgba(255, 149, 0, 0.15);
  color: #ffc078;
}

.admin-badge.mute {
  background: rgba(90, 140, 255, 0.15);
  color: #9cbcff;
}

.admin-badge.role {
  background: rgba(255, 77, 106, 0.14);
  color: #ffb0bc;
}

.admin-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.admin-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-user-chip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.admin-detail-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
}

.admin-detail-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-detail-item strong {
  color: #fff;
  font-size: 14px;
  word-break: break-word;
}

.admin-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  background: #16161b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  max-width: 380px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s ease;
}

.admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.admin-toast.error {
  border-color: rgba(255, 59, 48, 0.45);
}

.admin-toast.ok {
  border-color: rgba(52, 199, 89, 0.45);
}

.admin-denied {
  max-width: 480px;
  margin: 140px auto;
  text-align: center;
  padding: 36px 28px;
  background: rgba(21, 21, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.admin-denied h1 {
  margin: 0 0 10px;
  font-size: 22px;
}

.admin-denied p {
  color: var(--text-secondary);
  margin: 0 0 18px;
}

.admin-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}

.admin-toolbar input {
  flex: 1;
  min-width: 180px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  color: #fff;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.admin-toolbar input:focus {
  border-color: rgba(255, 77, 106, 0.5);
}

.admin-actions-cell {
  white-space: nowrap;
  position: relative;
  overflow: visible;
}

.admin-more {
  display: inline-block;
  position: relative;
  vertical-align: middle;
}

/* Fixed portal menu — not clipped by table overflow */
.admin-more-menu,
#admin-effects-portal {
  display: none;
  position: fixed;
  z-index: 9999;
  min-width: 250px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: min(360px, calc(100vh - 24px));
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  background: #16161c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.admin-more-menu.open,
#admin-effects-portal.open {
  display: block;
}

.admin-more-menu button,
#admin-effects-portal button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #e8e8ee;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.3;
}

.admin-more-menu button:hover,
#admin-effects-portal button:hover {
  background: rgba(255, 77, 106, 0.18);
  color: #fff;
}

.admin-more-sep {
  margin: 8px 10px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.admin-memas-dur {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 6px 10px;
  align-items: center;
}

.admin-memas-dur .dur-btn {
  width: auto !important;
  padding: 6px 10px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  font-size: 11px !important;
}

.admin-memas-dur .dur-btn.active {
  background: rgba(255, 77, 106, 0.22) !important;
  border-color: rgba(255, 77, 106, 0.45) !important;
  color: #fff !important;
}

.admin-memas-dur input {
  width: 72px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
}

.admin-memas-file {
  display: block;
  margin: 4px 8px 8px;
  padding: 10px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.admin-memas-file input {
  display: none;
}

.admin-memas-file:hover {
  border-color: rgba(255, 77, 106, 0.4);
  color: #fff;
}

.admin-memas-text {
  width: calc(100% - 16px);
  margin: 4px 8px 8px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.admin-memas-text:focus {
  border-color: rgba(255, 77, 106, 0.5);
}

.module-policy-status {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.module-policy-status.ok { color: #77d9a1; }
.module-policy-status.error { color: #ff8095; }
.module-policy-status.loading { color: #f0c87a; }

.module-policy-grid {
  align-items: stretch;
  margin-bottom: 18px;
}

.module-policy-label {
  display: block;
  margin: 16px 0 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.module-policy-textarea,
.module-rule-row input,
.module-rule-row select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.module-policy-textarea {
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

.module-policy-textarea:focus,
.module-rule-row input:focus,
.module-rule-row select:focus {
  border-color: rgba(255, 77, 106, 0.55);
  box-shadow: 0 6px 20px rgba(255, 77, 106, 0.08);
}

.module-policy-guide code,
.module-policy-guide strong {
  color: #8de3b0;
}

.module-policy-example {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 16px 0 9px;
  padding: 11px 12px;
  border: 1px solid rgba(119, 217, 161, 0.22);
  border-radius: 10px;
  background: rgba(119, 217, 161, 0.07);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.module-policy-example.denied {
  border-color: rgba(255, 128, 149, 0.22);
  background: rgba(255, 128, 149, 0.07);
}

.module-policy-example.denied strong { color: #ff8095; }

.module-rules-card { margin-bottom: 18px; }

.module-rules-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.module-rules-labels,
.module-rule-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(140px, 1fr) minmax(145px, 0.75fr) auto;
  gap: 10px;
  align-items: center;
}

.module-rules-labels {
  padding: 0 2px 7px;
  color: var(--text-muted);
  font-size: 11px;
}

.module-rule-row + .module-rule-row { margin-top: 9px; }
.module-rule-row input,
.module-rule-row select { min-height: 40px; padding: 9px 11px; }
.module-rule-row select { cursor: pointer; }
.module-rules-empty { margin: 0; }

.module-policy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-btn:disabled {
  cursor: wait;
  opacity: 0.58;
}

.ai-settings-card { margin-bottom: 18px; }
.ai-prompt-field textarea {
  min-height: 320px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}
.admin-field small {
  display: block;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}
.ai-key-clear {
  display: flex;
  align-items: flex-end;
  padding-bottom: 10px;
}
.ai-key-clear label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.ai-key-clear input { width: auto; }
.admin-field small code {
  color: var(--text-color);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.ai-test-diagnostics {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--background-secondary);
}
.ai-test-diagnostics[data-state="ok"] { border-color: rgba(74, 222, 128, 0.34); }
.ai-test-diagnostics[data-state="error"] { border-color: rgba(248, 113, 113, 0.42); }
.ai-test-diagnostics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.ai-test-diagnostics-head span {
  color: var(--text-muted);
  font-size: 11px;
}
.ai-test-diagnostics-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-test-diagnostics-controls button {
  padding: 5px 9px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}
.ai-test-diagnostics-controls button:hover {
  color: var(--text-color);
  border-color: var(--border-color-active);
}
.ai-test-diagnostics pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 980px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-nav {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .admin-nav-title {
    width: 100%;
  }
  .admin-tab {
    width: auto;
    margin: 0;
  }
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-grid-2,
  .admin-form,
  .admin-form.cols-3,
  .admin-detail {
    grid-template-columns: 1fr;
  }
  .module-rules-labels { display: none; }
  .module-rule-row { grid-template-columns: 1fr; }
  .module-rule-row .module-rule-remove { justify-self: start; }
  .module-rules-head { align-items: stretch; flex-direction: column; }
}
