:root {
  --bg: #050505;
  --card: #0f0f0f;
  --card2: #141414;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --text2: rgba(255, 255, 255, 0.62);
  --text3: rgba(255, 255, 255, 0.3);
  --accent: #f65b97;
  --purple: #9b51e0;
  --green: #6fcf97;
  --grad: linear-gradient(90deg, #9b51e0, #f65b97);
  --sidebar-w: 246px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

.admin-body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* Auth layer */
.auth-layer {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--border2);
  border-radius: 24px;
  background: var(--card);
  overflow: hidden;
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, 0.95);
}

.auth-head {
  padding: 24px;
  background: linear-gradient(135deg, #9b51e0 0%, #f65b97 100%);
  position: relative;
}

.auth-back-link {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  transition:
    transform 0.22s ease,
    background-color 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease;
}

.auth-back-link:hover {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.36);
  color: #ffffff;
}

.auth-back-link svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.auth-head::after {
  content: 'ADMIN';
  position: absolute;
  right: -8px;
  bottom: -12px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  width: 17px;
  height: 17px;
  fill: #fff;
}

.auth-head h1 {
  margin: 12px 0 4px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.auth-head p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.76);
}

.auth-form {
  padding: 22px;
  display: grid;
  gap: 12px;
}

.auth-form label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
}

.auth-note {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text3);
}

.auth-note code {
  color: rgba(255, 255, 255, 0.82);
}

@media (max-width: 560px) {
  .auth-back-link {
    top: 14px;
    right: 14px;
    padding: 8px 11px;
    font-size: 10px;
  }

  .auth-head {
    padding-top: 58px;
  }
}

/* Core shell */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.66);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.sidebar-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.logo-text span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text2);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
}

.nav-section {
  margin-bottom: 22px;
}

.nav-section-label {
  padding: 0 8px;
  margin-bottom: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text3);
}

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item.is-active {
  background: rgba(155, 81, 224, 0.14);
  border-color: rgba(155, 81, 224, 0.25);
  color: var(--text);
}

.nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.72;
  flex-shrink: 0;
}

.nav-item.is-active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

.nav-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--grad);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 12px;
  flex-shrink: 0;
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.main {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.82);
  backdrop-filter: blur(12px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger {
  display: none;
}

.page-title {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.page-sub {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  padding: 24px;
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.status-line {
  min-height: 20px;
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}

.status-line.is-error {
  color: #ff8ca8;
}

.status-line.is-success {
  color: var(--green);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
}

.stat-card.c1::before {
  background: var(--grad);
}

.stat-card.c2::before {
  background: linear-gradient(90deg, #2d9cdb, #56ccf2);
}

.stat-card.c3::before {
  background: linear-gradient(90deg, #27ae60, #6fcf97);
}

.stat-card.c4::before {
  background: linear-gradient(90deg, #f2994a, #f2c94c);
}

.stat-label {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}

.stat-value {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-delta {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text3);
}

.stat-delta.up {
  color: var(--green);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 14px;
}

.section-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.section-head--stack {
  align-items: flex-end;
}

.section-title {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.btn {
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: transparent;
  color: var(--text2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  cursor: pointer;
  padding: 9px 13px;
  transition: all 0.18s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn-primary {
  border-color: transparent;
  background: var(--grad);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
}

.form-stack {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.form-stack label > span,
.messages-controls label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.48);
}

.form-input {
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: rgba(246, 91, 151, 0.5);
}

.form-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

textarea.form-input {
  resize: vertical;
}

.form-input option {
  background: #111;
}

.subhead {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
}

.metrics-rows {
  display: grid;
  gap: 8px;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.items-list {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--card2);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.item-meta {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text2);
}

.tags-row,
.metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip,
.metric-chip {
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  color: var(--text2);
  background: rgba(255, 255, 255, 0.04);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-form {
  display: grid;
  gap: 8px;
}

.upload-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.45);
}

.media-list {
  display: grid;
  gap: 6px;
}

.media-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

.media-preview {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.media-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border2);
  background: rgba(255, 255, 255, 0.04);
}

.media-meta-block {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.media-path {
  font-size: 11px;
  color: var(--text2);
  word-break: break-all;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text2);
}

tbody tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-green {
  border: 1px solid rgba(111, 207, 151, 0.3);
  background: rgba(111, 207, 151, 0.12);
  color: var(--green);
}

.badge-blue {
  border: 1px solid rgba(86, 204, 242, 0.3);
  background: rgba(86, 204, 242, 0.12);
  color: #56ccf2;
}

.messages-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.messages-controls label {
  min-width: 160px;
}

.message-card {
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--card2);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.message-from {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.message-body {
  margin: 0;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

.message-time {
  margin: 0;
  font-size: 10px;
  color: var(--text3);
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-actions .form-input {
  width: 160px;
}

.user-card {
  gap: 12px;
}

.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.user-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.user-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.user-meta-pill {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text2);
  background: rgba(255, 255, 255, 0.03);
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-role-select {
  max-width: 180px;
}

.badge-current {
  border: 1px solid rgba(242, 153, 74, 0.35);
  background: rgba(242, 153, 74, 0.12);
  color: #f2c94c;
}

.settings-layout {
  align-items: start;
}

.settings-summary {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.settings-item {
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: var(--card2);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.settings-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}

.settings-value {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.settings-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text2);
}

.activity-list {
  padding: 8px 0;
}

.activity-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
}

.activity-dot.success {
  background: var(--green);
}

.activity-dot.info {
  background: #56ccf2;
}

.activity-text {
  margin: 0;
  font-size: 12px;
  color: var(--text2);
}

.activity-time {
  margin: 2px 0 0;
  font-size: 10px;
  color: var(--text3);
}

.placeholder-card {
  padding: 18px;
  display: grid;
  gap: 10px;
}

.placeholder-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

.placeholder-badge {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(246, 91, 151, 0.32);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  color: rgba(246, 91, 151, 0.92);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transform: translateY(70px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: rgba(246, 91, 151, 0.5);
}

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.toast.is-error .toast-dot {
  background: var(--accent);
}

@media (max-width: 1080px) {
  .layout-two {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .hamburger {
    display: inline-flex;
  }

  .topbar {
    padding: 12px 14px;
  }

  .content {
    padding: 14px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .messages-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .messages-controls label,
  .message-actions .form-input,
  .user-role-select {
    width: 100%;
    max-width: none;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    gap: 6px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 10px;
  }
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}
