/* ─── Reset & Variables ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #111827;
  --bg-2: #1f2937;
  --bg-card: #1f2937;
  --border: #374151;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --indigo: #6366f1;
  --indigo-light: #818cf8;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --font: 'Inter', sans-serif;
  --sidebar-w: 240px;
  --radius: 8px;
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }

/* ─── Pages ────────────────────────────────────────────────────────────── */
.page { display: none; height: 100vh; }
.page.active { display: block; }

/* ─── Login ────────────────────────────────────────────────────────────── */
.login-container {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.15) 0%, transparent 70%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}
.logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 10px var(--indigo);
}
.login-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.login-header p { color: var(--text-muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 20px; }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--indigo); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-light); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--indigo); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.btn-icon:hover { background: var(--bg-2); color: var(--text); }
.btn-logout {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ─── Error ────────────────────────────────────────────────────────────── */
.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  color: var(--red);
  padding: 10px 14px;
  font-size: 13px;
}

/* ─── App layout ───────────────────────────────────────────────────────── */
#page-app { display: none; }
#page-app.active { display: block; }
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand { font-size: 16px; font-weight: 700; flex: 1; }
.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,0.15); color: var(--indigo-light); }
.nav-icon { font-size: 16px; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 100px;
  min-width: 18px;
  text-align: center;
}
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.admin-info { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

/* ─── Main content ─────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.topbar h2 { font-size: 16px; font-weight: 600; flex: 1; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; }

/* ─── Content sections ─────────────────────────────────────────────────── */
.content { display: none; flex: 1; overflow-y: auto; padding: 24px; }
.content.active { display: block; }

/* ─── Stats Grid ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.stat-card.loading .skeleton {
  height: 60px;
  background: linear-gradient(90deg, var(--border) 25%, #2d3748 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── Panel ────────────────────────────────────────────────────────────── */
.content-grid { display: grid; gap: 20px; }
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 { font-size: 15px; font-weight: 600; }
.panel-actions { display: flex; gap: 8px; align-items: center; }

/* ─── Tables ───────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(55,65,81,0.5);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.loading-row { text-align: center; color: var(--text-muted); padding: 32px !important; }

/* ─── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.badge-active { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-suspended { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-funded { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-released { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-disputed { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-draft { background: rgba(156,163,175,0.15); color: var(--text-muted); }
.badge-open { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-resolved { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-enterprise { background: rgba(99,102,241,0.15); color: var(--indigo-light); }
.badge-creator { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-admin { background: rgba(239,68,68,0.15); color: var(--red); }

/* ─── Search & Filters ─────────────────────────────────────────────────── */
.search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 12px;
  outline: none;
  width: 220px;
}
.search-input:focus { border-color: var(--indigo); }
.filter-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 12px;
  outline: none;
  cursor: pointer;
}

/* ─── Activity ─────────────────────────────────────────────────────────── */
.activity-list { padding: 8px 0; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(55,65,81,0.3);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 18px; flex-shrink: 0; }
.activity-content { flex: 1; }
.activity-title { font-size: 13px; font-weight: 500; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px; font-size: 14px; }

/* ─── Pagination ───────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.pagination button {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.pagination button.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.pagination button:hover:not(.active) { border-color: var(--indigo); color: var(--text); }

/* ─── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.radio-group { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s;
}
.radio-option:has(input:checked) { border-color: var(--indigo); }
.radio-option input { accent-color: var(--indigo); }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
