:root {
  --bg: #070b14;
  --bg-card: rgba(18, 26, 43, 0.72);
  --bg-input: #0d1525;
  --border: rgba(120, 170, 255, 0.18);
  --border-strong: rgba(120, 170, 255, 0.45);
  --text: #e8eefc;
  --text-dim: #93a4c4;
  --accent: #5ad1ff;
  --accent2: #7b8cff;
  --aurora1: #2bd4a8;
  --aurora2: #4aa3ff;
  --aurora3: #9b6bff;
  --ok: #43e08b;
  --warn: #ffcc55;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #122a4d 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

/* Aurora background */
.aurora {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 60vh;
  background:
    radial-gradient(40% 60% at 20% 30%, var(--aurora1) 0%, transparent 60%),
    radial-gradient(45% 55% at 55% 20%, var(--aurora2) 0%, transparent 60%),
    radial-gradient(40% 60% at 85% 35%, var(--aurora3) 0%, transparent 60%);
  filter: blur(70px);
  opacity: 0.28;
  z-index: 0;
  pointer-events: none;
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateX(-3%) translateY(-2%) scale(1); }
  to   { transform: translateX(3%) translateY(2%) scale(1.08); }
}

.hero, .container, .footer { position: relative; z-index: 1; }

/* Header */
.hero {
  text-align: center;
  padding: 48px 20px 12px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  margin: 0;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #fff, var(--accent) 60%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { color: var(--text); font-size: 1.05rem; margin: 10px 0 4px; }
.hint { color: var(--text-dim); margin: 0; font-size: 0.92rem; }
.hint strong { color: var(--accent); }

/* Topbar */
.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.15); color: var(--text); }

/* Lock Screen */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.lock-box {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  max-width: 360px;
  width: 90%;
  backdrop-filter: blur(14px);
}
.lock-brand { font-size: 1.2rem; font-weight: 700; color: var(--accent); margin: 0 0 16px; letter-spacing: 1px; }
.lock-box h2 { margin: 0 0 8px; color: var(--accent); }
.lock-box p { color: var(--text-dim); margin: 0 0 20px; }
.lock-fields { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.lock-fields input { width: 240px; text-align: center; }
.lock-fields button { width: 240px; }
.lock-error { color: #ef4444; font-size: 0.85rem; margin-top: 14px; }

/* Container */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 24px;
  margin-bottom: 24px;
}
.card h2 { margin: 0 0 18px; font-size: 1.15rem; color: var(--accent); }

/* Traffic Monitor */
.traffic-card { border-color: rgba(255, 200, 50, 0.3); }
.traffic-card h2 { color: #ffc832; }
.traffic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.traffic-stat { display: flex; flex-direction: column; gap: 6px; }
.traffic-label { font-size: 0.8rem; color: var(--text-dim); }
.traffic-value { display: flex; gap: 6px; align-items: center; }
.traffic-value input { width: 90px; padding: 7px 10px; font-size: 0.9rem; }
.traffic-value select { padding: 7px 8px; font-size: 0.82rem; }
.traffic-pct { font-size: 1.6rem; font-weight: 700; color: var(--ok); }
.traffic-bar-wrap {
  width: 100%; height: 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 7px; overflow: hidden;
  margin-bottom: 10px;
}
.traffic-bar {
  height: 100%; width: 0%;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--ok), #ffc832);
  transition: width 0.4s ease, background 0.3s;
}
.traffic-bar.warn { background: linear-gradient(90deg, #ffc832, #ef4444); }
.traffic-bar.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }
.traffic-hint { display: block; color: var(--text-dim); font-size: 0.76rem; }

/* Quick generate */
.quick-card { border-color: rgba(43, 212, 168, 0.35); }
.quick-card h2 { color: var(--aurora1); }
.quick-desc { color: var(--text-dim); font-size: 0.92rem; margin: 0 0 16px; }
.quick-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.quick-field { flex: 1; min-width: 220px; }
.quick-btn {
  height: 44px;
  padding: 0 24px;
  font-size: 1rem;
  white-space: nowrap;
}
.quick-steps {
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(43, 212, 168, 0.06);
  border: 1px dashed rgba(43, 212, 168, 0.25);
  border-radius: 10px;
}
.quick-steps .step-title {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--aurora1);
  font-weight: 600;
}
.quick-steps ol {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 0.84rem;
  line-height: 1.8;
}
.quick-steps li { color: var(--text); }
.quick-proto-field { min-width: 120px; max-width: 150px; }
.quick-hint { display: block; margin-top: 10px; color: var(--text-dim); font-size: 0.78rem; }

/* Grid layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.86rem; color: var(--text-dim); }
.field > span em { color: var(--warn); font-style: normal; }
.field small { color: var(--text-dim); font-size: 0.74rem; opacity: 0.8; }

input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(90, 209, 255, 0.12);
}
textarea { min-height: 60px; font-size: 0.82rem; word-break: break-all; }

.with-btn { display: flex; gap: 8px; }
.with-btn input, .with-btn textarea { flex: 1; }

/* Buttons */
button {
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #142038;
  padding: 11px 16px;
  font-size: 0.92rem;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
button:hover { border-color: var(--border-strong); }
button:active { transform: translateY(1px); }
button.mini { padding: 8px 12px; font-size: 0.85rem; white-space: nowrap; }
button.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #04111f;
  font-weight: 700;
  border: none;
}
button.ghost { background: transparent; }

/* Advanced options */
.advanced {
  margin: 18px 0 6px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 6px 14px;
}
.advanced summary {
  cursor: pointer;
  color: var(--text-dim);
  padding: 8px 0;
  user-select: none;
}
.advanced[open] summary { color: var(--accent); margin-bottom: 10px; }

/* Actions */
.actions, .sub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

/* Subscription section */
.sub-card { border-color: rgba(90, 209, 255, 0.3); }
.sub-box { margin-bottom: 12px; }

/* Nodes grid */
.nodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.empty-msg {
  text-align: center;
  color: var(--text-dim);
  grid-column: 1 / -1;
  padding: 40px 0;
}

/* Node card */
.node-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  transition: border-color 0.2s;
}
.node-card:hover { border-color: var(--border-strong); }

.node-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
}
.badge {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #04111f;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 1px;
}
.badge-vless { background: linear-gradient(90deg, #43e08b, #2bd4a8); }
.badge-vmess { background: linear-gradient(90deg, #5ad1ff, #7b8cff); }
.badge-trojan { background: linear-gradient(90deg, #ff6b6b, #ee5a24); }
.badge-hysteria2 { background: linear-gradient(90deg, #ffc832, #f39c12); }
.badge-tuic { background: linear-gradient(90deg, #9b6bff, #6c5ce7); color: #fff; }
.node-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.del-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.del-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

/* QR code */
.node-qr {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.node-qr img { display: block; border-radius: 4px; }
.node-qr canvas { display: block; border-radius: 4px; }

/* Node link */
.node-link-box {
  display: flex;
  gap: 8px;
  width: 100%;
}
.node-link {
  flex: 1;
  font-size: 0.76rem;
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.copy-btn {
  font-size: 0.8rem;
  padding: 8px 14px;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.ok { border-color: var(--ok); }
.toast.warn { border-color: var(--warn); color: var(--warn); }

/* Cloudflare Usage Dashboard */
.cf-card { border-color: rgba(255, 165, 0, 0.3); margin-top: 32px; }
.cf-card h2 { color: #f6a623; }
.cf-desc { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 20px; }

.cf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.cf-item {
  background: rgba(13, 21, 37, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.2s;
}
.cf-item:hover { border-color: var(--border-strong); }

.cf-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.cf-label { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.cf-limit { font-size: 0.76rem; color: var(--text-dim); }

.cf-bar-wrap {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}
.cf-bar {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--ok), #f6a623);
  transition: width 0.4s ease, background 0.3s;
}
.cf-bar.warn { background: linear-gradient(90deg, #f6a623, #ef4444); }
.cf-bar.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }

.cf-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cf-input-row input {
  width: 120px;
  padding: 7px 10px;
  font-size: 0.85rem;
}
.cf-unit { font-size: 0.8rem; color: var(--text-dim); }

.cf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

/* Guide Section */
.guide-card { border-color: rgba(90, 209, 255, 0.25); }
.guide-card h2 { color: var(--accent); }
.guide-block { margin-bottom: 20px; }
.guide-block:last-child { margin-bottom: 0; }
.guide-block h3 { color: var(--text); font-size: 0.95rem; margin: 0 0 8px; }
.guide-block p { color: var(--text-dim); font-size: 0.88rem; margin: 0; line-height: 1.7; }
.guide-block ol, .guide-block ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.9;
}
.guide-block li { color: var(--text); }

/* Deploy Section */
.deploy-card { border-color: rgba(123, 140, 255, 0.25); }
.deploy-card h2 { color: var(--accent2); }
.deploy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.deploy-item {
  background: rgba(13, 21, 37, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.deploy-item h3 { margin: 0 0 6px; font-size: 1rem; color: var(--accent); }
.deploy-item p { color: var(--text-dim); font-size: 0.84rem; margin: 0 0 12px; }
.deploy-item ol {
  margin: 0;
  padding-left: 18px;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.9;
}
.deploy-item code {
  background: rgba(90, 209, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent);
}
.code-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.78rem;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.footer p { margin: 0; }

/* Responsive */
@media (max-width: 600px) {
  .hero { padding: 32px 16px 8px; }
  .container { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .nodes-grid { grid-template-columns: 1fr; }
  .deploy-grid { grid-template-columns: 1fr; }
  .actions, .sub-actions { flex-direction: column; }
  .actions button, .sub-actions button { width: 100%; }
  .quick-row { flex-direction: column; }
  .quick-btn { width: 100%; }
}
