/* ═══════════════════════════════════════════════════════════════
   LunaSolver — Deep space UI
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-void:     #05080f;
  --bg-deep:     #0a0f1a;
  --bg-card:     #0f1525;
  --bg-card-h:   #141b2d;
  --bg-input:    #111827;
  --border:      #1e293b;
  --border-h:    #334155;
  --text-primary:#e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --accent:      #8b5cf6;
  --accent-glow: rgba(139,92,246,0.15);
  --accent-h:    #a78bfa;
  --success:     #10b981;
  --success-bg:  rgba(16,185,129,0.12);
  --error:       #f43f5e;
  --error-bg:    rgba(244,63,94,0.12);
  --warning:     #f59e0b;
  --warning-bg:  rgba(245,158,11,0.12);
  --info:        #3b82f6;
  --info-bg:     rgba(59,130,246,0.12);
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-h); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-h); border-radius:3px; }

/* ── Navbar ────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}
.navbar-brand .moon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}
.navbar-brand .moon::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--bg-deep);
  border-radius: 50%;
  top: -4px;
  right: -6px;
}
.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--text-muted);
}
.navbar-user {
  color: var(--accent-h);
  font-weight: 500;
}
.navbar-link {
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s;
}
.navbar-link:hover { color: var(--text-primary); }

/* ── Container ─────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-header h1 span { color: var(--accent-h); }
.page-header p {
  color: var(--text-dim);
  font-size: 14px;
}
.btn-sync {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
}
.btn-sync:hover {
  border-color: var(--accent);
  color: var(--accent-h);
}
.btn-sync .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text-muted); }
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ── Tab Content ───────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-h); }
.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}
.stat-card .sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.stat-card .value.green { color: var(--success); }
.stat-card .value.purple { color: var(--accent-h); }
.stat-card .value.blue { color: var(--info); }
.stat-card .value.amber { color: var(--warning); }

/* ── Chart Card ────────────────────────────────────────────── */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.chart-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}
.chart-card canvas {
  width: 100% !important;
  height: 260px !important;
}

/* ── Table / Audit Stream ──────────────────────────────────── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  overflow-x: auto;
}
.table-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-card-h); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);     color: var(--info); }

/* ── Latency highlight ─────────────────────────────────────── */
.latency { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.latency.fast { color: var(--success); }
.latency.mid  { color: var(--warning); }
.latency.slow { color: var(--error); }

/* ── Auth Pages ────────────────────────────────────────────── */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(139,92,246,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.04) 0%, transparent 50%),
    var(--bg-void);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.auth-card .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 32px;
}
.auth-card .logo .moon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}
.auth-card .logo .moon::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  background: var(--bg-card);
  border-radius: 50%;
  top: -5px;
  right: -7px;
}
.auth-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
  text-align: center;
}
.auth-card .subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ── Form Controls ─────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-dim); }

.form-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 6px;
  display: none;
}
.form-error.visible { display: block; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  line-height: 1.4;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-h);
  border-color: var(--accent-h);
}
.btn-full { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--border-h);
  color: var(--text-primary);
}
.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: var(--error);
}
.btn-danger:hover:not(:disabled) {
  background: var(--error-bg);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

/* ── API Key Display ───────────────────────────────────────── */
.key-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
}
.key-display .key-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-display .btn-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  transition: color .15s;
}
.key-display .btn-copy:hover { color: var(--accent-h); }

/* ── Docs Styles ───────────────────────────────────────────── */
.docs-content {
  max-width: 800px;
}
.docs-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 32px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.docs-content h2:first-child { border-top: none; padding-top: 0; }
.docs-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--accent-h);
}
.docs-content p {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 14px;
}
.docs-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent-h);
}
.docs-content pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0 20px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.docs-content pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}
.endpoint-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  margin-right: 8px;
}
.endpoint-badge.post { background: var(--success-bg); color: var(--success); }
.endpoint-badge.get  { background: var(--info-bg);    color: var(--info); }
.endpoint-badge.del  { background: var(--error-bg);   color: var(--error); }

/* ── Admin extras ──────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 768px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.admin-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.visible {
  display: flex;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
}
.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 68px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn .25s ease;
  max-width: 360px;
}
.toast.success { background: #065f46; color: #a7f3d0; }
.toast.error   { background: #7f1d1d; color: #fecaca; }
.toast.info    { background: #1e3a5f; color: #bfdbfe; }

@keyframes toastIn {
  from { opacity:0; transform: translateX(20px); }
  to   { opacity:1; transform: translateX(0); }
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}
.empty-state p { font-size: 14px; }

/* ── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-24 { margin-bottom: 24px; }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .value { font-size: 22px; }
  .container { padding: 20px 16px; }
  .page-header { flex-direction: column; gap: 12px; }
}
