:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #101726;
  --bg-card: #172138;
  --bg-card-hover: #1e2c49;
  --border-color: #243352;
  --border-highlight: #3b82f6;
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --accent-hover: #1d4ed8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout & Views */
.view {
  display: none;
  width: 100%;
  flex: 1;
}
.view.active {
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px clamp(16px, 5vw, 48px);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  font-weight: 700;
  font-size: 20px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}
.logo svg {
  color: var(--accent-light);
}
.logo span {
  color: var(--accent-light);
}

.nav-links {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.18s ease;
  padding: 8px;
}
.nav-link:hover {
  color: var(--text-main);
}
.user-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: none;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  text-decoration: none;
  min-height: 44px;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 34px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
  min-height: 48px;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
}
.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}

/* Hero Section */
.hero {
  padding: clamp(36px, 7vw, 80px) clamp(16px, 5vw, 48px);
  text-align: center;
  max-width: 960px;
  margin: 0 auto;
}
.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 30px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.28);
  color: #93c5fd;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 24px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
}
.hero h1 {
  font-size: clamp(30px, 6.5vw, 54px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  line-height: 1.22;
}
.hero h1 span {
  background: linear-gradient(135deg, #93c5fd, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: clamp(16px, 2.5vw, 19px);
  color: var(--text-muted);
  margin-bottom: 32px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.stat-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-top: 24px;
  text-align: center;
}
.stat-item strong {
  display: block;
  font-size: clamp(22px, 4vw, 28px);
  color: var(--text-main);
  font-weight: 800;
}
.stat-item span {
  font-size: 13px;
  color: var(--text-muted);
}

.section-title {
  text-align: center;
  padding: 32px 16px 8px;
}
.section-title h2 {
  font-size: clamp(24px, 4.5vw, 36px);
  margin-bottom: 8px;
}
.section-title p {
  color: var(--text-muted);
  font-size: 16px;
}

/* Grids & Cards */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  padding: clamp(16px, 5vw, 40px);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.4);
}
.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.card h3 {
  font-size: 19px;
  margin-bottom: 10px;
  color: var(--text-main);
}
.card p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
}

/* Playground on Home */
.playground-section {
  max-width: 900px;
  width: calc(100% - 32px);
  margin: 20px auto 60px;
}
.playground-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}
.playground-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}
.playground-header h3 {
  font-size: 16px;
  margin-bottom: 4px;
}
.code-preview {
  background: #060911;
  font-family: var(--font-mono);
  font-size: 14px;
  color: #cbd5e1;
  padding: 18px;
  overflow-x: auto;
  white-space: pre;
  border-radius: 0 0 var(--radius) var(--radius);
  line-height: 1.5;
}

/* Forms & Authentication */
.form-container {
  max-width: 440px;
  margin: 40px auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: clamp(24px, 5vw, 36px);
  border-radius: var(--radius);
  width: calc(100% - 32px);
}
.form-header {
  text-align: center;
  margin-bottom: 24px;
}
.form-header h2 {
  font-size: 24px;
  margin-bottom: 6px;
}
.form-header p {
  font-size: 14px;
  color: var(--text-muted);
}
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  min-height: 44px;
}
.form-control:focus {
  border-color: var(--accent-light);
}
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394a3b8%22%20stroke-width%3D%222%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.form-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}
.form-footer a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
}
.demo-box {
  background: rgba(59, 130, 246, 0.08);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 20px;
  text-align: center;
}
.demo-box p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.demo-btn-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Dashboard Layout */
.dashboard-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 75px);
}
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.sidebar-heading {
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #64748b;
  padding: 8px 12px 4px;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  min-height: 44px;
}
.sidebar-link svg {
  flex-shrink: 0;
}
.sidebar-link:hover, .sidebar-link.active {
  background: var(--bg-card);
  color: var(--text-main);
}
.sidebar-link.active {
  border-left: 3px solid var(--accent-light);
  font-weight: 600;
}
.sidebar-link.text-danger {
  color: #f87171;
}
.sidebar-link.text-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.dashboard-content {
  flex: 1;
  padding: clamp(16px, 4vw, 36px);
  overflow-y: auto;
  background: var(--bg-primary);
}

/* Dash Header */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}
.dash-header h2 {
  font-size: clamp(20px, 3.5vw, 28px);
}
.dash-tab {
  display: none;
}
.dash-tab.active {
  display: block;
}
.admin-tab {
  display: none;
}
.admin-tab.active {
  display: block;
}

/* Stat Card */
.stat-num {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  margin: 10px 0 14px;
  color: var(--text-main);
}

/* Wallet Banner */
.wallet-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: center;
}
.wallet-amount {
  font-size: clamp(34px, 6vw, 48px);
  color: #38bdf8;
  font-weight: 800;
  margin: 8px 0;
}
.wallet-refill-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: var(--radius-sm);
}
.wallet-refill-box h4 {
  font-size: 16px;
  margin-bottom: 6px;
}
.deposit-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Key Gen Form & Result */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}
.check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.new-key-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.copy-field {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.copy-field input {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #38bdf8;
}

/* Docs Grid */
.docs-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  margin-top: 16px;
}
.docs-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.doc-nav-btn {
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}
.doc-nav-btn.active, .doc-nav-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--accent-light);
}
.doc-sec {
  display: none;
}
.doc-sec.active {
  display: block;
}
.doc-sec h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--accent-light);
  font-family: var(--font-mono);
}
.doc-sec h4 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: var(--text-muted);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
th {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td {
  color: var(--text-main);
}
.code-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #93c5fd;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  max-width: 90vw;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  padding: 24px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 36px clamp(16px, 5vw, 48px) 24px;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 24px;
}
.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
}
.footer-links a:hover {
  color: var(--text-main);
}
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

/* Mobile Responsive */
@media(max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
    gap: 6px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-heading {
    display: none;
  }
  .sidebar-link {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 14px;
  }
  .docs-grid {
    grid-template-columns: 1fr;
  }
  .hero-actions {
    flex-direction: column;
  }
  .hero-actions .btn {
    width: 100%;
  }
}
