:root {
  --bg: #05050f;
  --surface: rgba(15, 15, 35, 0.7);
  --surface-hover: rgba(20, 20, 50, 0.8);
  --border: rgba(124, 58, 237, 0.15);
  --border-hover: rgba(124, 58, 237, 0.35);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --primary: #7c3aed;
  --primary-glow: rgba(124, 58, 237, 0.3);
  --accent: #3b82f6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-lg: 16px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background effects */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

.glow {
  position: fixed; border-radius: 50%; filter: blur(120px); z-index: 0; pointer-events: none;
}
.glow-1 { width: 500px; height: 500px; background: rgba(124, 58, 237, 0.08); top: -100px; right: -100px; }
.glow-2 { width: 400px; height: 400px; background: rgba(59, 130, 246, 0.06); bottom: -50px; left: -50px; }

.app { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 1.5rem; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 0; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; box-shadow: 0 4px 20px var(--primary-glow);
}
.logo-text { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.5px; }
.logo-sub { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

.status-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 9999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warning); animation: pulse 2s ease-in-out infinite;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  margin-bottom: 1.5rem; backdrop-filter: blur(20px);
  transition: border-color 0.3s;
}
.card:hover { border-color: var(--border-hover); }
.create-card { border-color: rgba(124, 58, 237, 0.25); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-header h2 { font-size: 1.1rem; font-weight: 600; }
.card-desc { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

/* Forms */
.input-group { display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.input {
  background: rgba(10, 10, 30, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.7rem 1rem;
  color: var(--text); font-family: inherit; font-size: 0.95rem;
  outline: none; transition: all 0.2s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.input::placeholder { color: rgba(100, 116, 139, 0.5); }

.select-wrapper { position: relative; }
.select {
  appearance: none; cursor: pointer; width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 2.5rem;
}
.select option { background: #0f0f23; color: var(--text); }

.domain-input-group {
  flex-direction: row !important; align-items: center;
  background: rgba(10, 10, 30, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem;
  transition: all 0.2s;
}
.domain-input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.domain-prefix, .domain-suffix {
  padding: 0.7rem 0.75rem; font-size: 0.9rem; color: var(--text-muted);
  white-space: nowrap; user-select: none;
}
.domain-prefix { border-right: 1px solid var(--border); background: rgba(124, 58, 237, 0.05); }
.domain-suffix { border-left: 1px solid var(--border); background: rgba(124, 58, 237, 0.05); }
.domain-input {
  border: none !important; border-radius: 0 !important;
  background: transparent !important; box-shadow: none !important;
  font-weight: 600; font-size: 1.05rem; text-align: center; flex: 1; min-width: 80px;
}

.form-row { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: flex-end; }

.checkbox-wrapper {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font-size: 0.85rem; color: var(--text-muted);
  user-select: none; margin-bottom: 1rem;
}
.checkbox-wrapper input { display: none; }
.checkmark {
  width: 18px; height: 18px; border-radius: 4px;
  border: 1px solid var(--border); background: rgba(10, 10, 30, 0.6);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.checkbox-wrapper input:checked + .checkmark {
  background: var(--primary); border-color: var(--primary);
}
.checkbox-wrapper input:checked + .checkmark::after {
  content: '✓'; color: white; font-size: 0.7rem; font-weight: 700;
}

/* Preview */
.preview {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; border-radius: var(--radius);
  background: rgba(124, 58, 237, 0.06); border: 1px solid rgba(124, 58, 237, 0.12);
  margin-bottom: 1.25rem; font-size: 0.85rem;
}
.preview-label { color: var(--text-muted); font-weight: 500; }
.preview-url { color: var(--primary); text-decoration: none; font-weight: 600; }
.preview-url:hover { text-decoration: underline; }
.preview-arrow { color: var(--text-muted); }
.preview-target { color: var(--accent); font-family: 'SF Mono', monospace; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.5rem; border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.25s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  color: white; width: 100%;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px var(--primary-glow);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); padding: 0.4rem 0.8rem; font-size: 0.8rem;
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }
.btn-danger {
  background: rgba(239, 68, 68, 0.1); color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2); padding: 0.35rem 0.7rem; font-size: 0.78rem;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn-icon { font-size: 1.1rem; }

/* Subdomain List */
.subdomain-list { display: flex; flex-direction: column; gap: 0.75rem; }

.subdomain-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-radius: var(--radius);
  background: rgba(10, 10, 30, 0.4); border: 1px solid var(--border);
  transition: all 0.2s; flex-wrap: wrap; gap: 0.75rem;
}
.subdomain-item:hover { border-color: var(--border-hover); background: rgba(15, 15, 40, 0.5); }

.subdomain-info { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; min-width: 200px; }
.subdomain-name {
  font-weight: 600; font-size: 1rem;
  color: var(--text); display: flex; align-items: center; gap: 0.5rem;
}
.subdomain-name a { color: var(--primary); text-decoration: none; }
.subdomain-name a:hover { text-decoration: underline; }
.subdomain-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 1rem; flex-wrap: wrap; }

.type-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 6px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.type-proxy { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.type-static { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.type-redirect { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.subdomain-actions { display: flex; gap: 0.5rem; align-items: center; }

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; }

/* System Info */
.system-info { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.sys-card {
  padding: 1rem; border-radius: var(--radius);
  background: rgba(10, 10, 30, 0.4); border: 1px solid var(--border);
}
.sys-card .sys-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.35rem; }
.sys-card .sys-value { font-size: 1.1rem; font-weight: 600; }
.sys-card .sys-value.online { color: var(--success); }
.sys-card .sys-value.offline { color: var(--danger); }

/* Loading */
.loading { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem; }

/* Toast */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  padding: 0.85rem 1.25rem; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500; max-width: 380px;
  animation: toastIn 0.3s ease-out; backdrop-filter: blur(10px);
  border: 1px solid; display: flex; align-items: center; gap: 0.5rem;
}
.toast-success { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: #34d399; }
.toast-error { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); color: #fca5a5; }
.toast-info { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); color: #93c5fd; }

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

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 1rem; }
  .header { flex-direction: column; gap: 1rem; align-items: flex-start; }
  .form-row { flex-direction: column; }
  .domain-input-group { flex-wrap: wrap; }
  .domain-prefix, .domain-suffix { font-size: 0.8rem; padding: 0.5rem; }
  .subdomain-item { flex-direction: column; align-items: flex-start; }
  .system-info { grid-template-columns: 1fr 1fr; }
}
