:root {
  --bg-base: #0f1115;
  --bg-surface: #16181d;
  --bg-surface-hover: #1e2128;
  --border-color: #2a2d35;
  
  --text-primary: #f0f2f5;
  --text-secondary: #9ba1a6;
  --text-muted: #6b7280;
  
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.5);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3 { font-weight: 600; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Overlay & Login */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  animation: slideUp 0.4s ease forwards;
}

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

.login-card h3 {
  font-size: 24px;
  margin-bottom: 8px;
  text-align: center;
}

.login-card .subtitle {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 30px;
  font-size: 14px;
}

/* Forms & Inputs */
.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

input[type="text"], input[type="password"], select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.btn-primary {
  width: 100%;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 0 15px var(--accent-glow);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-icon svg { width: 18px; height: 18px; }

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  margin-bottom: 30px;
  justify-content: center;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
}

.logo h2 { font-size: 20px; letter-spacing: -0.5px; }

.user-profile {
  padding: 16px 24px;
  margin: 0 12px 24px;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-color);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-primary);
}

.user-info { display: flex; flex-direction: column; }
.user-info .name { font-size: 14px; font-weight: 600; }
.user-info .role { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.nav-item svg { width: 20px; height: 20px; }
.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); }

.sidebar-footer { padding: 24px; display:flex; flex-direction:column; gap:12px; }

.btn-logout {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--danger);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover {
  background: rgba(239,68,68,0.1);
  border-color: var(--danger);
}
.credits-badge {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.credits-badge .label { font-size: 12px; color: var(--success); }
.credits-badge .value { font-size: 16px; font-weight: 700; color: var(--success); }

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  min-width: 0;
}

.topbar {
  height: 70px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  background: var(--bg-surface);
}

.topbar h1 { font-size: 20px; font-weight: 600; }

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-base);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
}

.view {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Cards & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.connections { background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); }
.stat-icon.online { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.active-lines { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

.stat-info { display: flex; flex-direction: column; flex: 1; }
.stat-info .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-info .value { font-size: 24px; font-weight: 700; color: var(--text-primary); }

.stat-card.highlight {
  background: linear-gradient(145deg, var(--bg-surface), #1a1d24);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.progress-bar {
  height: 6px;
  background: var(--bg-base);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), #8b5cf6);
  border-radius: 3px;
  transition: width 1s ease;
}

.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
}

.mt-6 { margin-top: 30px; }
.mt-4 { margin-top: 20px; }
.w-full { width: 100%; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.card-header h3 { font-size: 18px; }

/* Table */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: var(--bg-base);
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* Create Demo Layout */
.two-col-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 30px;
}

.form-section { height: fit-content; }

.result-section {
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-base));
  border: 1px solid var(--border-color);
}

.success-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.success-icon {
  width: 48px;
  height: 48px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.success-icon svg { width: 24px; height: 24px; }
.success-header h3 { color: var(--success); font-size: 20px; }

.result-details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.2);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.05);
}

.detail-row.column {
  flex-direction: column;
  align-items: flex-start;
}

.detail-row .label { color: var(--text-secondary); font-size: 13px; }
.detail-row .value { font-size: 15px; font-weight: 500; }
.highlight-text { color: var(--accent-primary); letter-spacing: 1px; font-family: monospace; font-size: 16px !important; }

.value-copy { display: flex; align-items: center; gap: 12px; }

.copy-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.copy-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.copy-btn svg { width: 14px; height: 14px; }

.copy-btn.large {
  padding: 10px 16px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  background: rgba(255,255,255,0.05);
}
.copy-btn.large:hover { background: rgba(255,255,255,0.1); }

.password-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}
.password-wrapper input { flex: 1; }

.m3u-box {
  width: 100%;
  display: flex;
  gap: 12px;
}
.m3u-box input { flex: 1; font-family: monospace; color: var(--success); background: rgba(0,0,0,0.3); border-color: rgba(16,185,129,0.2); }

.error-msg {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  margin-top: 16px;
}

.mb-2 { margin-bottom: 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--text-primary);
  color: var(--bg-base);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 2000;
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.text-muted { color: var(--text-muted) !important; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}
.badge-expired {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}
.badge-source {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
}

pre {
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.6;
}

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

/* ────────────────────────────────────────────
   Utility classes (replacing inline styles)
   ──────────────────────────────────────────── */
.btn-sm {
  width: auto !important;
  padding: 6px 14px !important;
  font-size: 13px;
  gap: 6px;
}
.btn-xs {
  width: auto !important;
  padding: 4px 8px !important;
  font-size: 12px;
  line-height: 1;
  gap: 4px;
}
.btn-icon-sm {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.icon-sm {
  width: 14px;
  height: 14px;
}
.icon-xs {
  width: 16px;
  height: 16px;
}
.modal-card {
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card-wide {
  max-width: 700px;
}
.modal-card-sm {
  max-width: 450px;
}
.modal-card-xs {
  max-width: 400px;
}
.edit-hint {
  color: var(--text-muted);
  font-size: 12px;
}
.password-rules {
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.menu-options-grid {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.log-detail-json {
  background: var(--bg-base);
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
}
.delete-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}
.btn-icon-xs {
  width: 28px;
  height: 28px;
}
.btn-icon-md {
  width: 32px;
  height: 32px;
}
.btn-icon-danger {
  color: var(--danger);
  width: 32px;
  height: 32px;
}
.icon-pwd-xs {
  width: 12px;
  height: 12px;
}
.icon-pwd {
  width: 14px;
  height: 14px;
}
.td-bold {
  font-weight: 500;
}
.value-copy-sm {
  gap: 6px;
}
.pwd-text {
  font-family: monospace;
  color: var(--accent-primary);
  font-size: 14px;
}
.btn-pwd-toggle {
  width: 28px;
  height: 28px;
}
.copy-btn-xs {
  width: 28px;
  height: 28px;
  padding: 4px;
}
.text-nowrap {
  white-space: nowrap;
}
.text-small {
  font-size: 12px;
}
.td-ellipsis {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.td-ellipsis-sm {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.code-endpoint {
  font-size: 12px;
  color: var(--accent-primary);
}
.nav-icon {
  margin-right: 8px;
}
.pkg-badge {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.menu-option-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  cursor: pointer;
}
.btn-full {
  margin-top: 12px;
  width: 100%;
}
.max-w-480 {
  max-width: 480px;
}
.mb-16 {
  margin-bottom: 16px;
}
.mb-20 {
  margin-bottom: 20px;
}
.text-secondary {
  color: var(--text-secondary);
}
.log-detail-content {
  max-height: 60vh;
  overflow-y: auto;
}
