*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #09090b; color: #e4e4e7;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

.admin-shell { display: grid; grid-template-columns: 200px 1fr; height: 100dvh; }

/* Sidebar */
.admin-sidebar {
  background: #0c0c0f; border-right: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; padding: 14px 10px;
}
.admin-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; padding: 0 6px; }
.ab-mark {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 6px; background: #7c3aed;
  font-weight: 600; font-size: 12px; color: #fff;
}
.admin-brand span { font-weight: 600; font-size: 14px; }
.admin-nav { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.an-item {
  text-align: left; padding: 8px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: #71717a;
}
.an-item:hover { background: rgba(255,255,255,.04); color: #a1a1aa; }
.an-item.active { background: rgba(255,255,255,.06); color: #fafafa; }
.admin-back {
  display: block; text-decoration: none; color: #3f3f46; font-size: 12px;
  padding: 8px 10px; border-top: 1px solid rgba(255,255,255,.06); margin-top: 8px;
}
.admin-back:hover { color: #71717a; }

/* Main */
.admin-main { overflow-y: auto; padding: 20px 24px; }
.section { display: none; }
.section.active { display: block; }
h1 { font-size: 20px; font-weight: 600; margin-bottom: 16px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card {
  background: #18181b; border: 1px solid rgba(255,255,255,.06); border-radius: 8px;
  padding: 16px; text-align: center;
}
.sc-value { font-size: 24px; font-weight: 600; color: #fafafa; }
.sc-label { font-size: 11px; color: #52525b; margin-top: 4px; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.tb-input {
  flex: 1; padding: 7px 10px; border-radius: 6px;
  background: #18181b; border: 1px solid rgba(255,255,255,.06); outline: none; font-size: 13px;
}
.tb-input:focus { border-color: rgba(124,58,237,.3); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 8px 10px; color: #52525b; font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,.06); font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: top; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }

/* Forms */
.form-card {
  background: #18181b; border: 1px solid rgba(255,255,255,.06); border-radius: 8px;
  padding: 16px; margin-bottom: 12px;
}
.form-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 11px; color: #71717a; margin-bottom: 3px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 7px 10px; border-radius: 6px;
  background: #09090b; border: 1px solid rgba(255,255,255,.06); outline: none; font-size: 13px;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: rgba(124,58,237,.3); }
.form-row input[type="checkbox"] { width: auto; margin-right: 4px; }
.form-actions { display: flex; gap: 6px; margin-top: 12px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mode-preview-section {
  border-top: 1px solid #27272a; margin-top: 16px; padding-top: 16px;
}
.mode-preview-section h4 { margin: 0 0 12px; color: #e4e4e7; font-size: 14px; }
.preview-upload-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.preview-upload {
  min-height: 120px; border: 1px dashed #3f3f46; border-radius: 8px;
  background: #09090b; display: grid; place-items: center; color: #71717a;
  cursor: pointer; overflow: hidden; margin-bottom: 8px;
}
.preview-upload.small { min-height: 88px; }
.preview-upload.has-img { border-style: solid; }
.preview-upload img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stat-grid-edit { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stat-grid-edit input[type="range"] { padding: 0; accent-color: #7c3aed; }

/* Buttons */
.btn-primary {
  padding: 7px 14px; border-radius: 6px;
  background: #7c3aed; color: #fff; font-weight: 600; font-size: 13px;
}
.btn-primary:hover { background: #6d28d9; }
.btn-sm {
  padding: 7px 12px; border-radius: 6px;
  background: #27272a; color: #e4e4e7; font-size: 13px; font-weight: 500;
}
.btn-sm:hover { background: #3f3f46; }
.btn-ghost { padding: 7px 12px; font-size: 13px; color: #52525b; }
.btn-ghost:hover { color: #a1a1aa; }
.btn-danger { padding: 5px 8px; border-radius: 4px; background: #7f1d1d; color: #fca5a5; font-size: 12px; }
.btn-danger:hover { background: #991b1b; }
.btn-xs { padding: 4px 8px; border-radius: 4px; background: #27272a; color: #a1a1aa; font-size: 12px; }
.btn-xs:hover { background: #3f3f46; }

/* Badges */
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-admin { background: rgba(124,58,237,.12); color: #a78bfa; }
.badge-user { background: #27272a; color: #52525b; }
.badge-mod { background: rgba(59,130,246,.12); color: #60a5fa; }
.badge-active { background: rgba(34,197,94,.12); color: #4ade80; }
.badge-inactive { background: rgba(239,68,68,.12); color: #f87171; }
.badge-banned { background: #7f1d1d; color: #fca5a5; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 10px 16px; border-radius: 8px;
  background: #18181b; border: 1px solid rgba(255,255,255,.06);
  font-size: 13px; color: #fafafa;
  transform: translateY(60px); opacity: 0;
  transition: all .2s ease; z-index: 100;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Prompt entry editor */
.prompt-entry {
  background: #18181b;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.prompt-entry.is-marker { border-color: rgba(124,58,237,.3); }
.prompt-entry.drop-target { border-color: #7c3aed; }
.pe-head { display: flex; align-items: flex-start; gap: 12px; }
.drag-handle {
  width: 32px; flex: 0 0 32px; padding-top: 4px;
  color: #52525b; font-size: 11px; cursor: grab;
  text-transform: uppercase;
}
.pe-main { flex: 1; min-width: 0; }
.pe-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pe-title-row strong { font-size: 13px; font-weight: 600; color: #fafafa; }
.pe-sub { margin-top: 4px; color: #52525b; font-size: 12px; }
.pe-badge {
  display: inline-flex; align-items: center; min-height: 18px;
  padding: 2px 6px; border-radius: 4px;
  background: rgba(124,58,237,.12); color: #a78bfa;
  font-size: 11px; font-weight: 500;
}
.pe-badge.muted { background: #27272a; color: #a1a1aa; }
.pe-badge.off { background: #7f1d1d; color: #fca5a5; }
.pe-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-tight { padding: 4px 8px; font-size: 12px; }
.pe-editor {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.pe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pe-check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-check {
  display: inline-flex !important; align-items: center; gap: 4px;
  margin: 0 !important; color: #a1a1aa !important; font-size: 12px !important;
}
.field-hint { display: block; margin-top: 4px; color: #52525b; font-size: 12px; }
.pe-marker-note {
  padding: 12px; border-radius: 8px;
  background: #09090b; border: 1px solid rgba(255,255,255,.06);
  color: #a1a1aa; font-size: 13px; line-height: 1.55;
}

@media (max-width: 768px) {
  .admin-shell { grid-template-columns: 1fr; }
  html, body { overflow: hidden; }
  .admin-sidebar {
    display: block; border-right: none; border-bottom: 1px solid rgba(255,255,255,.06);
    padding: 10px; overflow-x: auto;
  }
  .admin-shell { display: flex; flex-direction: column; }
  .admin-brand { margin-bottom: 8px; }
  .admin-nav { flex-direction: row; gap: 6px; }
  .an-item { white-space: nowrap; }
  .admin-back { display: none; }
  .admin-main { padding: 14px; overflow-x: hidden; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-4, .preview-upload-grid, .stat-grid-edit, .pe-grid {
    grid-template-columns: 1fr !important;
  }
  .toolbar { flex-direction: column; }
  .data-table, .data-table thead, .data-table tbody, .data-table tr, .data-table th, .data-table td {
    display: block;
  }
  .data-table thead { display: none; }
  .data-table tr {
    background: #18181b; border: 1px solid rgba(255,255,255,.06);
    border-radius: 8px; margin-bottom: 10px; padding: 8px;
  }
  .data-table td {
    border-bottom: 1px solid rgba(255,255,255,.04);
    padding: 7px 4px; overflow-wrap: anywhere;
  }
  .data-table td:last-child { border-bottom: 0; }
  .pe-head { flex-direction: column; }
  .pe-actions { width: 100%; }
}
