:root {
  --bg: #0c0e10;
  --surface: #15181b;
  --surface-alt: #1c2024;
  --border: #272c31;
  --text: #e7e9ea;
  --text-muted: #8a939c;
  --accent: #e879f9;
  --accent-dim: #703a70;
  --danger: #d6564a;
  --danger-dim: #4a2622;
  --safe: #a855f7;
  --safe-dim: #4a2a5a;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}

.frame {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

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

/* --- Sidebar --- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.brand-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}

.brand-link:hover {
  color: var(--accent);
}

.brand-link svg {
  flex-shrink: 0;
}

.local-badge,
.network-badge {
  font-size: 11px;
  color: var(--safe);
  background: var(--safe-dim);
  border: 1px solid #2f4a3a;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}
.local-badge .dot,
.network-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--safe);
  flex-shrink: 0;
}

.wallet-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-addr {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  padding: 8px 0;
}

.hidden { display: none !important; }

.wallet-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.wallet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.wallet-item:hover { background: var(--surface-alt); }
.wallet-item.active {
  background: var(--surface-alt);
  border-color: var(--accent-dim);
}
.wallet-item-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
}
.wallet-item-addr {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.wallet-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.wallet-item-remove:hover { color: var(--danger); }

.empty-hint {
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 0;
}

.add-wallet {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.add-wallet label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.add-wallet input {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.add-wallet input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- Buttons --- */

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.01em;
  border-radius: 7px;
  padding: 9px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-primary:hover:not(:disabled) { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  margin-top: 6px;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); }

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-text:hover { color: var(--text); }

.btn-execute {
  background: var(--safe);
  color: #08130d;
}
.btn-execute:hover:not(:disabled) { opacity: 0.9; }
.btn-execute.live {
  background: var(--danger);
  color: #200a08;
}

/* --- Main panel --- */

.main {
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 900px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.wallet-label {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.mode-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.mode-track {
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: var(--safe-dim);
  border: 1px solid var(--safe);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.mode-switch[data-mode="live"] .mode-track {
  background: var(--danger-dim);
  border-color: var(--danger);
}
.mode-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--safe);
  transition: transform 0.2s, background 0.2s;
}
.mode-switch[data-mode="live"] .mode-thumb {
  transform: translateX(24px);
  background: var(--danger);
}
.mode-caption strong {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.mode-switch[data-mode="dry"] .mode-caption strong { color: var(--safe); }
.mode-switch[data-mode="live"] .mode-caption strong { color: var(--danger); }
.mode-caption small {
  color: var(--text-muted);
  font-size: 11px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}
.panel-head h2 small {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
}

.scan-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.token-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: 6px;
  font-size: 12px;
}
.token-row .tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-right: 8px;
}
.token-row .addr {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 10px;
}

.action-row { margin: 12px 0; }
.fine-print {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
}

#sweepAddress {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.log-panel { flex: 1; }
.log-output {
  background: #08090a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #b9c4cc;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* --- Sweep History --- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  transition: border-color 0.15s;
}

.history-item:hover {
  border-color: var(--accent-dim);
}

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

.history-date {
  font-size: 11px;
  color: var(--text-muted);
}

.history-mode {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-mode.live {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.history-mode.dry {
  background: var(--safe-dim);
  color: var(--safe);
  border: 1px solid var(--safe);
}

.history-address {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.history-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.history-tx {
  font-size: 11px;
  line-height: 1.6;
}

.tx-link {
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 4px;
}

.tx-link:hover {
  text-decoration: underline;
}

/* --- Overlay --- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.overlay.hidden { display: none; }

.confirm-box {
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 24px;
  width: 360px;
}
.confirm-box h3 {
  font-family: var(--font-display);
  color: var(--danger);
  margin: 0 0 8px;
  font-size: 16px;
}
.confirm-box p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.confirm-box input {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
