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

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: #0f1115;
  color: #e2e8f0;
  min-height: 100vh;
  padding: 16px;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 0;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
  text-align: center;
  margin: 0;
}

.dropdown-wrapper {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.custom-select {
  position: relative;
  width: 100%;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #181b21;
  border: 2px solid #3b82f6;
  border-radius: 10px;
  padding: 12px 16px;
  color: #f8fafc;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}

.select-trigger:hover {
  border-color: #60a5fa;
  background-color: #1e293b;
  box-shadow: 0 6px 16px rgba(59,130,246,0.25);
}

.select-trigger.active {
  border-color: #60a5fa;
  background-color: #1e293b;
  border-radius: 12px 12px 0 0;
}

.select-placeholder {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.select-placeholder img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}

.select-arrow {
  width: 24px;
  height: 24px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.select-trigger.active .select-arrow {
  transform: rotate(180deg);
}

.select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  background: #181b21;
  border: 2px solid #3b82f6;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
  z-index: 100;
}

.select-options.active {
  display: block;
}

.select-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #252830;
}

.select-option:last-child {
  border-bottom: none;
}

.select-option:hover {
  background: #1e293b;
}

.select-option img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #2a2e36;
}

.select-option span {
  font-size: 1rem;
  font-weight: 500;
  color: #e2e8f0;
}

/* Scrollbar */
.select-options::-webkit-scrollbar {
  width: 8px;
}

.select-options::-webkit-scrollbar-track {
  background: #14161c;
}

.select-options::-webkit-scrollbar-thumb {
  background: #3b82f6;
  border-radius: 4px;
}

.select-options::-webkit-scrollbar-thumb:hover {
  background: #60a5fa;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1e293b;
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 8px 14px;
  color: #e2e8f0;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-refresh:hover {
  background: #243447;
  border-color: #3b82f6;
}

.btn-refresh.spin svg {
  animation: spin 1s linear infinite;
}

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

/* Chain Detail Card - Compact Single Card */
.chain-detail {
  max-width: 750px;
  margin: 0 auto;
}

.chain-card-compact {
  background: #181b21;
  border: 1px solid #2a2e36;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.card-header-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #1e293b 0%, #1a1f2e 100%);
  border-bottom: 1px solid #2a2e36;
}

.card-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #0f1115;
  border: 2px solid #3b82f6;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.card-title-info {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 3px 0;
}

.card-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.block-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 10px 16px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 10px;
  min-width: 140px;
}

.block-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.block-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.block-number.loaded {
  color: #22c55e;
}

.block-number.error {
  color: #ef4444;
  font-size: 0.9rem;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  background: #181b21;
}

.compact-table tbody tr {
  transition: background 0.15s;
}

.compact-table tbody tr:hover {
  background: #1a1d24;
}

.compact-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid #252830;
}

.compact-table td {
  padding: 8px 16px;
  font-size: 0.8rem;
  vertical-align: middle;
}

.label-cell {
  width: 100px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.value-cell {
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.value-cell a {
  color: #60a5fa;
  text-decoration: none;
}

.value-cell a:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.value-cell .na {
  color: #64748b;
  font-style: italic;
}

.action-cell {
  width: 50px;
  text-align: right;
}

.action-cell .copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  background: transparent;
  border: 1px solid #2a2e36;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
}

.action-cell .copy-btn:hover {
  color: #e2e8f0;
  border-color: #3b82f6;
  background: rgba(59,130,246,0.1);
}

.action-cell .copy-btn svg {
  width: 13px;
  height: 13px;
}

.separator-row td {
  padding: 6px !important;
  border: none !important;
  background: #14161c !important;
}

.copy-btn {
  background: transparent;
  border: 1px solid #2a2e36;
  border-radius: 6px;
  padding: 4px;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-btn:hover {
  color: #e2e8f0;
  border-color: #475569;
}

.copy-btn svg {
  width: 14px;
  height: 14px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: #64748b;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #181b21;
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: #e2e8f0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 1000;
}

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

/* Scanner page */
.scanner-input {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.input-row input {
  flex: 1;
  min-width: 200px;
  background: #181b21;
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 8px 14px;
  color: #e2e8f0;
  font-size: 0.875rem;
  outline: none;
}

#rpcList {
  width: 100%;
  min-height: 100px;
  background: #181b21;
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 10px 14px;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  outline: none;
  resize: vertical;
}

.scanner-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.btn-primary {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
}

.btn-primary:hover {
  background: #2563eb !important;
  border-color: #2563eb !important;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #94a3b8;
  cursor: pointer;
}

.toggle input {
  accent-color: #3b82f6;
}

.scanner-summary {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: #94a3b8;
}

.sum-item strong {
  color: #f8fafc;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #2a2e36;
  border-radius: 10px;
}

.scanner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.scanner-table thead {
  background: #14161c;
}

.scanner-table th {
  text-align: left;
  padding: 10px 12px;
  color: #cbd5e1;
  font-weight: 600;
  border-bottom: 1px solid #2a2e36;
  white-space: nowrap;
}

.scanner-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #252830;
  color: #e2e8f0;
  vertical-align: middle;
}

.scanner-table tbody tr:hover {
  background: #1a1d24;
}

.scanner-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.endpoint-col {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bg-green {
  background: rgba(34,197,94,0.12);
  color: #22c55e;
}

.bg-red {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

.bg-yellow {
  background: rgba(245,158,11,0.12);
  color: #f59e0b;
}

.bg-gray {
  background: rgba(100,116,139,0.12);
  color: #94a3b8;
}

/* Responsive */
@media (max-width: 640px) {
  body { padding: 16px; }
  header h1 { font-size: 1.5rem; }
  .chain-detail { padding: 20px; }
  .detail-header { flex-direction: column; text-align: center; }
  .detail-logo { width: 64px; height: 64px; }
  .detail-name { font-size: 1.4rem; }
  .detail-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .detail-label { width: 100%; }
  .binary-grid { grid-template-columns: 1fr; }
}
