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

/* ─── CSS Variables ─────────────────────────────────── */
:root {
  --color-bg-primary: #101010;
  --color-bg-secondary: #141414;
  --color-bg-tertiary: #1a181c;
  --color-bg-elevated: #22222e;
  --color-surface: #101010;
  --color-surface-hover: #252532;
  --color-surface-active: #2a2a3a;
  --color-border: #2d2d3a;
  --color-border-light: #3a3a4a;
  --color-text-primary: #f5f5f7;
  --color-text-secondary: #a0a0b0;
  --color-text-muted: #6a6a7a;
  --color-primary: #00bdf6;
  --color-primary-dark: #0099cc;
  --color-primary-900: rgba(0, 189, 246, 0.1);
  --color-success: #10b981;
  --color-success-900: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-900: rgba(245, 158, 11, 0.1);
  --color-danger: #ef4444;
  --color-danger-900: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6;
  --color-info-900: rgba(59, 130, 246, 0.1);
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(0, 189, 246, 0.3);
}

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

html, body {
  height: 100%;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ─── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ─── App Layout ────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.sidebar-logo svg { color: #fff; }

.sidebar-brand {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  color: var(--color-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.nav-item.active {
  background: var(--color-primary-900);
  color: var(--color-primary);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.5rem 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary-900);
  border: 1px solid var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  flex-shrink: 0;
}

.user-details { overflow: hidden; flex: 1; }
.user-name { font-size: 0.8125rem; font-weight: 500; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--color-text-muted); text-transform: capitalize; }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: none;
  border: none;
  padding: 0.25rem 0;
  transition: color var(--transition-fast);
  width: 100%;
}

.btn-logout:hover { color: var(--color-danger); }

/* ─── Main Content ──────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg-primary);
}

.page-wrapper {
  padding: 2rem;
  max-width: 1400px;
}

/* ─── Page Header ───────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a { color: var(--color-text-secondary); transition: color var(--transition-fast); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb-sep { color: var(--color-text-muted); }

/* ─── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-border-light);
}

.btn-danger {
  background: var(--color-danger-900);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }

/* ─── Cards ─────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.card-body { padding: 1.5rem; }

/* ─── Stat Cards ────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-value.cyan { color: var(--color-primary); }
.stat-value.green { color: var(--color-success); }
.stat-value.amber { color: var(--color-warning); }
.stat-value.muted { color: var(--color-text-muted); }

/* ─── Tables ────────────────────────────────────────── */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.75rem 1.25rem;
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--color-surface-hover); }
.data-table tbody tr.clickable { cursor: pointer; }

.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.font-mono { font-family: 'JetBrains Mono', monospace; font-size: 0.8125rem; }

/* ─── Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.75rem;
  font-weight: 500;
  gap: 0.25rem;
}

.badge-cyan { background: var(--color-primary-900); color: var(--color-primary); }
.badge-green { background: var(--color-success-900); color: var(--color-success); }
.badge-amber { background: var(--color-warning-900); color: var(--color-warning); }
.badge-red { background: var(--color-danger-900); color: var(--color-danger); }
.badge-muted { background: rgba(107, 114, 128, 0.1); color: var(--color-text-muted); }
.badge-purple { background: rgba(139, 92, 246, 0.1); color: #a78bfa; }

/* ─── Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  color-scheme: dark;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-900);
}

.form-input::placeholder { color: var(--color-text-muted); }
.form-select option { background: var(--color-bg-elevated); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--color-danger);
  margin-top: 0.25rem;
  display: none;
}
.form-error.visible { display: block; }

.form-success {
  padding: 1rem;
  background: var(--color-success-900);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  display: none;
}
.form-success.visible { display: block; }
.form-success-title { font-weight: 600; color: var(--color-success); margin-bottom: 0.25rem; }
.form-success-code { font-family: 'JetBrains Mono', monospace; font-size: 1.25rem; color: var(--color-text-primary); letter-spacing: 0.05em; }

/* ─── Modal ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 600; color: var(--color-text-primary); }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: 1.25rem; line-height: 1;
}
.modal-close:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ─── Empty State ───────────────────────────────────── */
.empty-state {
  padding: 3rem;
  text-align: center;
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state-title { font-size: 1rem; font-weight: 500; color: var(--color-text-secondary); margin-bottom: 0.375rem; }
.empty-state-desc { font-size: 0.875rem; }

/* ─── Detail Grid ───────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.detail-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.detail-sub {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ─── Activation Card ───────────────────────────────── */
.activation-card {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.activation-card:last-child { margin-bottom: 0; }

.activation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.activation-mac {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
}

.activation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.activation-meta span { display: flex; align-items: center; gap: 0.25rem; }
.activation-meta strong { color: var(--color-text-muted); font-weight: 400; }

/* ─── Loading ───────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 12rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  gap: 0.75rem;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.3s ease;
  font-size: 0.875rem;
  max-width: 360px;
}

.toast.success { border-color: rgba(16, 185, 129, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg { color: var(--color-text-primary); flex: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Login Page ────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--color-bg-primary);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.login-card-header {
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}

.login-logo {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: var(--shadow-glow);
}

.login-logo svg { color: #fff; width: 24px; height: 24px; }
.login-title { font-size: 1.25rem; font-weight: 600; color: var(--color-text-primary); }
.login-sub { font-size: 0.875rem; color: var(--color-text-muted); margin-top: 0.25rem; }

.login-card-body { padding: 1.75rem 2rem 2rem; }

.otp-input {
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 1.5rem !important;
  letter-spacing: 0.5em;
  text-align: center;
}

/* ─── Confirm Dialog ────────────────────────────────── */
.confirm-danger .modal-header { border-bottom-color: rgba(239, 68, 68, 0.2); }
.confirm-danger .modal-title { color: var(--color-danger); }

/* ─── Misc Utilities ────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
