﻿:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-alt: #1f2937;
  --surface-hover: #263346;
  --border: #2d3748;
  --border-light: #374151;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-subtle: rgba(59, 130, 246, 0.15);
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --surface-hover: #e2e8f0;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: rgba(37, 99, 235, 0.1);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2rem;
  text-decoration: none;
}
.brand-icon {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
}
.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item a:hover, .nav-item.active a {
  background-color: var(--primary-subtle);
  color: var(--primary);
}
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: 64px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.content-area {
  padding: 2rem;
  flex: 1;
}

/* UI Cards and Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.4rem 0;
  color: var(--text);
}
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 1.15rem;
  font-weight: 600;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table th {
  background-color: var(--surface-alt);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.table tr:hover td {
  background-color: var(--surface-hover);
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 1.2rem;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}
textarea.form-control {
  min-height: 90px;
  resize: vertical;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}
.btn-secondary {
  background-color: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background-color: var(--surface-hover);
}
.btn-danger {
  background-color: var(--danger);
  color: #fff;
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background-color: var(--success-subtle); color: var(--success); }
.badge-warning { background-color: var(--warning-subtle); color: var(--warning); }
.badge-danger { background-color: var(--danger-subtle); color: var(--danger); }
.badge-info { background-color: var(--primary-subtle); color: var(--primary); }

/* Alerts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.alert-success { background-color: var(--success-subtle); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background-color: var(--danger-subtle); color: var(--danger); border: 1px solid var(--danger); }
.alert-warning { background-color: var(--warning-subtle); color: var(--warning); border: 1px solid var(--warning); }

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}
.toast {
  background-color: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  animation: slideIn 0.3s forwards;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Key box */
.key-box {
  background-color: var(--surface-alt);
  border: 1px dashed var(--border-light);
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
  user-select: all;
  margin: 1rem 0;
}
