/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-card-hover: #1f2b3d;
  --border: #2a3548;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --orange: #f97316;
  --purple: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --max-width: 1200px;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ========== Layout ========== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* ========== Header ========== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo span { color: var(--accent); }

.nav { display: flex; gap: 4px; }
.nav-mobile { display: none; }

.nav a {
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: all 0.2s;
  display: block;
}

.nav a:hover, .nav a.active {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* Dropdown Nav */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-dropdown-btn:hover, .nav-dropdown-btn.active {
  color: var(--text-primary);
  background: var(--bg-card);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  min-width: 160px;
  box-shadow: var(--shadow);
  z-index: 200;
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  padding: 8px 12px;
  white-space: nowrap;
}

/* Mobile Nav */
.nav-mobile-group {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.nav-mobile-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Wallet connect button */
.btn-wallet {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-wallet:hover { background: var(--accent-hover); }

.btn-wallet.connected {
  background: var(--green);
}

/* ========== Page Header ========== */
.page-header {
  padding: 32px 0 24px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

/* ========== Search Box ========== */
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.search-box input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-card);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--red);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--green);
}

.btn-success:hover {
  background: #059669;
}

/* ========== Grid ========== */
.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ========== Feature Cards (Home) ========== */
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text-primary);
  display: block;
}

.feature-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  color: var(--text-primary);
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.feature-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ========== Table ========== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead th {
  text-align: left;
  padding: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover { background: var(--bg-card-hover); }

/* ========== Stat Items ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stat-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
}

/* ========== Tags & Badges ========== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.tag-safe { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.tag-warning { background: rgba(245, 158, 11, 0.15); color: var(--yellow); }
.tag-danger { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.tag-info { background: rgba(59, 130, 246, 0.15); color: var(--accent); }

/* ========== Security Check Items ========== */
.check-list { list-style: none; }

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.check-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.check-pass { background: rgba(16, 185, 129, 0.2); color: var(--green); }
.check-fail { background: rgba(239, 68, 68, 0.2); color: var(--red); }
.check-warn { background: rgba(245, 158, 11, 0.2); color: var(--yellow); }

/* ========== Score Ring ========== */
.score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 auto 16px;
}

.score-high { border: 4px solid var(--green); color: var(--green); }
.score-mid { border: 4px solid var(--yellow); color: var(--yellow); }
.score-low { border: 4px solid var(--red); color: var(--red); }

/* ========== Forms ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

/* ========== Progress Bar ========== */
.progress-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* ========== Loading ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

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

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--yellow); }

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

/* ========== Address Display ========== */
.addr {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
}

.addr:hover { text-decoration: underline; }

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ========== Transfer list items ========== */
.transfer-item {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.transfer-item input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}

.transfer-item input:first-child { flex: 2; }
.transfer-item input:nth-child(2) { flex: 1; }

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 60px;
}

/* ========== Mobile ========== */
@media (max-width: 768px) {
  .nav-desktop { display: none !important; }

  .nav-mobile {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
    max-height: 80vh;
    overflow-y: auto;
  }

  .nav-mobile.show { display: flex; }

  .nav-toggle { display: block; }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .search-box {
    flex-direction: column;
  }

  .search-box .btn {
    width: 100%;
  }

  .page-header { padding: 20px 0 16px; }
  .page-header h1 { font-size: 1.25rem; }

  .transfer-item {
    flex-direction: column;
  }

  .transfer-item input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
