/* ──────────────────────────────────────────────────────────────────────────────
   MineRace — premium light theme
   ────────────────────────────────────────────────────────────────────────── */

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

:root {
  /* Surfaces */
  --bg:             #f6f7fb;
  --surface:        #ffffff;
  --surface-2:      #f1f5f9;
  --border:         #e5e7eb;
  --border-strong:  #cbd5e1;

  /* Text */
  --text:           #0f172a;
  --text-muted:     #475569;
  --text-subtle:    #94a3b8;

  /* Accents */
  --accent:         #4f46e5;
  --accent-hover:   #4338ca;
  --accent-soft:    #eef2ff;
  --accent-ring:    rgba(79, 70, 229, 0.18);

  /* Status */
  --success:        #16a34a;
  --success-soft:   #dcfce7;
  --warn:           #d97706;
  --warn-soft:      #fef3c7;
  --danger:         #dc2626;
  --danger-soft:    #fee2e2;

  /* Miner palette (canvas-rendered colors are duplicated in app.js MINER_COLOURS) */
  --color-paris:    #f43f5e;
  --color-tokyo:    #0ea5e9;
  --color-nyc:      #10b981;
  --color-mybot:    #f59e0b;
  --color-user:     #8b5cf6;
  --color-genesis:  #94a3b8;

  /* Geometry */
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;
  --radius-pill:    9999px;

  /* Shadows */
  --shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow:         0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg:      0 20px 40px -12px rgba(15, 23, 42, 0.12), 0 8px 16px -8px rgba(15, 23, 42, 0.08);

  /* Easing */
  --ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --duration:       150ms;

  /* Fonts */
  --font-sans:      -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:      ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;

  /* Legacy aliases (admin.css and older code reference these names) */
  --muted:          var(--text-muted);
  --green:          var(--success);
  --red:            var(--danger);
  --yellow:         var(--warn);
}

html, body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { display: flex; flex-direction: column; }

/* Subtle decorative gradient washing the bg */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 0% 0%,   rgba(79, 70, 229, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(14, 165, 233, 0.05) 0%, transparent 35%);
  pointer-events: none;
  z-index: 0;
}
header, main { position: relative; z-index: 1; }

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

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
header h1 span {
  background: linear-gradient(135deg, var(--accent) 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

#chain-status {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#chain-status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px currentColor;
  opacity: .9;
  /* trick: outer halo */
}
#chain-status.valid   { background: var(--success-soft); color: var(--success); }
#chain-status.invalid { background: var(--danger-soft);  color: var(--danger);  }

.admin-link {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--surface);
  transition: all var(--duration) var(--ease);
}
.admin-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
main {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  gap: 0;
  overflow: hidden;
}

/* ── Panels (cards) ───────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease);
}
.panel:hover { box-shadow: var(--shadow); }

.panel h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 14px;
  padding-bottom: 0;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  padding-bottom: 12px;
  border-right: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.4);
}

/* ── Inputs / buttons ─────────────────────────────────────────────────────── */
select, input[type="number"], input[type="text"], textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 8px;
  outline: none;
  transition: all var(--duration) var(--ease);
}
select:focus, input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
input::placeholder { color: var(--text-subtle); }

.btn {
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  transition: all var(--duration) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-green     { background: var(--success); color: #fff; }
.btn-red       { background: var(--danger);  color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); border-color: var(--border-strong); }

/* ── Chain info (sidebar) ─────────────────────────────────────────────────── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 0.88rem;
  border-bottom: 1px dashed var(--border);
}
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-row span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}
.info-row span:last-child  {
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── Pill badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-msg {
  color: var(--text-subtle);
  font-size: 0.85rem;
  text-align: center;
  padding: 14px 4px;
  font-style: italic;
}

/* ── Mempool ──────────────────────────────────────────────────────────────── */
#mempool-list { max-height: 220px; overflow-y: auto; }
.mempool-row {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  transition: all var(--duration) var(--ease);
}
.mempool-row:hover { border-color: var(--border-strong); }
.mempool-row:last-child { margin-bottom: 0; }
.mempool-addr {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.78rem;
}
.mempool-amount {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ── Known addresses table ────────────────────────────────────────────────── */
#address-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
#address-table th {
  text-align: left;
  padding: 8px 4px 10px;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}
#address-table th:last-child { text-align: right; }
#address-table td {
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
#address-table tr:last-child td { border-bottom: none; }
#address-table td:first-child { font-family: var(--font-mono); font-size: 0.78rem; }
#address-table td:last-child  {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
#address-table td span[title] { cursor: pointer; transition: color var(--duration) var(--ease); }
#address-table td span[title]:hover { color: var(--accent); }

/* ── Explorer (right column) ──────────────────────────────────────────────── */
#explorer-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#explorer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* The card itself shouldn't scroll; only the feed inside scrolls. */
}

.explorer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.explorer-head h2 { margin-bottom: 0; }

/* ── Legend (inline, top-right of explorer head) ──────────────────────────── */
#legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-muted);
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
}

/* ── Block feed ───────────────────────────────────────────────────────────── */
.block-feed {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px; /* breathing room for scrollbar */
}

.block-card {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 200ms var(--ease),
    box-shadow 200ms var(--ease),
    border-color 200ms var(--ease);
  animation: cardIn 280ms var(--ease);
  position: relative;
}
.block-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.block-card.is-new {
  border-color: var(--stripe);
  box-shadow: 0 0 0 1px var(--stripe), 0 8px 20px -4px color-mix(in srgb, var(--stripe) 30%, transparent);
  animation: cardIn 280ms var(--ease), newPulse 1.6s var(--ease) 1;
}
@keyframes newPulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--stripe), 0 8px 20px -4px color-mix(in srgb, var(--stripe) 30%, transparent); }
  50%      { box-shadow: 0 0 0 1px var(--stripe), 0 12px 28px -2px color-mix(in srgb, var(--stripe) 55%, transparent); }
}

.bc-stripe {
  background: var(--stripe, var(--text-subtle));
}
.bc-main {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0; /* lets flex children shrink, enables ellipsis */
}
.bc-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.bc-index {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.bc-time {
  font-size: 0.76rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bc-row2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.bc-miner {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bc-miner .legend-dot { vertical-align: -1px; }
.bc-txs {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.bc-hash {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bc-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--text-subtle);
  font-size: 1.4rem;
  transition: transform 150ms var(--ease), color 150ms var(--ease);
}
.block-card:hover .bc-chevron {
  color: var(--accent);
  transform: translateX(2px);
}

.explorer-footer {
  text-align: center;
  padding: 10px 0 2px;
  font-size: 0.78rem;
  color: var(--text-subtle);
}

/* ── Leaderboard ──────────────────────────────────────────────────────────── */
#leaderboard { margin: 0 14px 14px; }
#leaderboard h2 { margin-bottom: 14px; }
#leaderboard table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
#leaderboard th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}
#leaderboard th:not(:first-child),
#leaderboard td:not(:first-child) { text-align: right; }
#leaderboard td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
#leaderboard tr:last-child td { border-bottom: none; }
#leaderboard tr:hover td { background: var(--surface-2); }
#leaderboard td:first-child { font-family: var(--font-mono); font-size: 0.82rem; }
#leaderboard td:not(:first-child) {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── Block detail popup ───────────────────────────────────────────────────── */
#block-detail {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  z-index: 100;
  max-width: 560px;
  width: 92%;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
#block-detail h3 {
  color: var(--text);
  margin-bottom: 18px;
  font-size: 1.05rem;
  font-weight: 700;
}
#block-detail .close-btn {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface-2); border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}
#block-detail .close-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
#block-detail table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
#block-detail td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
  vertical-align: top;
}
#block-detail tr:last-child td { border-bottom: none; }
#block-detail td:first-child {
  color: var(--text-muted);
  width: 120px;
  white-space: nowrap;
  font-weight: 500;
}
#block-detail td:not(:first-child) {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
}
#overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 99;
}

/* ── AI Chat panel ────────────────────────────────────────────────────────── */
#panel-chat #chat-history {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#panel-chat #chat-history.empty { display: block; }
#panel-chat .msg {
  padding: 8px 12px;
  border-radius: var(--radius);
  max-width: 88%;
  word-wrap: break-word;
  line-height: 1.45;
  animation: msgIn 200ms var(--ease);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
#panel-chat .msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
#panel-chat .msg.bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
#panel-chat .msg.bot.thinking {
  color: var(--text-muted);
  font-style: italic;
}
#panel-chat .msg.bot.error {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
  color: var(--danger);
}
#panel-chat #chat-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
#panel-chat #chat-input {
  flex: 1;
  margin-bottom: 0;
}
#panel-chat #chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
#panel-chat #chat-send:hover:not(:disabled) { background: var(--accent-hover); }
#panel-chat #chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* ── Admin-panel-only helpers (used by admin.html) ────────────────────────── */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.info-table td, .info-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.info-table tr:last-child td { border-bottom: none; }
.info-table th {
  color: var(--text-subtle);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}
.info-table td:first-child { color: var(--text-muted); font-weight: 500; }
.info-table td:not(:first-child) {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.config-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.config-row label {
  flex: 0 0 110px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.config-row input, .config-row select {
  flex: 1;
  margin: 0;
}
.config-row .btn { flex: 0 0 80px; width: auto; }
.cfg-msg { font-size: 0.78rem; color: var(--success); margin-top: 4px; min-height: 1em; }
.cfg-msg.err { color: var(--danger); }

/* ── Responsive: stack sidebar above main on narrow viewports ────────────── */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  #sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }
  #explorer-area { overflow: visible; }
  #explorer-panel { overflow: visible; }
  .block-feed {
    max-height: 70vh; /* scroll within itself on phones, not the whole page */
  }
  header { padding: 12px 16px; }
  header h1 { font-size: 1.15rem; }
  .panel { margin: 10px; padding: 14px 16px; }
  #leaderboard { margin: 0 10px 10px; }

  /* Explorer head: stack legend below title on narrow screens */
  .explorer-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  #legend { justify-content: flex-start; }

  /* Tighter block cards on phones */
  .block-card { grid-template-columns: 4px 1fr auto; }
  .bc-main    { padding: 10px 12px; gap: 5px; }
  .bc-index   { font-size: 0.98rem; }
  .bc-chevron { padding: 0 10px; font-size: 1.2rem; }
  .bc-hash    { font-size: 0.68rem; }
}

/* ── Scrollbars (subtle) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ──────────────────────────────────────────────────────────────────────────────
   Recent activity panel
   ────────────────────────────────────────────────────────────────────────── */
.muted-hint {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-subtle);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 8px;
}

.activity-list {
  max-height: 460px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.activity-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.activity-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.activity-block {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.activity-flow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 0.84rem;
}
.activity-flow .addr-mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-arrow {
  color: var(--text-subtle);
  font-weight: 700;
  flex-shrink: 0;
}
.activity-from, .activity-to {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.activity-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--success);
  white-space: nowrap;
}
.activity-amount.cb { color: var(--warn); }

.cb-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.bot-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

/* Generic monospaced truncated address span */
.addr-mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
}

/* Clickable hint applied to addresses anywhere in the dashboard */
.link {
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px dotted transparent;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Whole-row clickability for leaderboard rows */
.clickable-row { cursor: pointer; transition: background var(--duration) var(--ease); }
.clickable-row:hover td { background: var(--surface-2); }

/* ──────────────────────────────────────────────────────────────────────────────
   Address Detail modal
   ────────────────────────────────────────────────────────────────────────── */
#address-detail {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  z-index: 100;
  max-width: 640px;
  width: 94%;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
#address-detail h3 {
  margin-bottom: 14px;
  font-size: 1.05rem;
  font-weight: 700;
}
#address-detail .close-btn {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface-2); border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}
#address-detail .close-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.ad-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.legend-dot.lg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7);
}
.ad-addr {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  flex: 1;
  min-width: 0;
}
.ad-addr code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  word-break: break-all;
  color: var(--text);
  flex: 1;
}
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--duration) var(--ease);
}
.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ad-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.ad-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.ad-stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 6px;
}
.ad-stat-val {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.ad-stat-val span {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.ad-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin: 16px 0 8px;
}
.ad-section-label .ok  { color: var(--success); text-transform: none; letter-spacing: 0; font-weight: 600; }
.ad-section-label .err { color: var(--danger);  text-transform: none; letter-spacing: 0; font-weight: 600; }

.ad-tx-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ad-tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.ad-tx-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--text-subtle);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ad-tx-table th:nth-child(2),
.ad-tx-table td:nth-child(2) { width: 80px; }
.ad-tx-table th:last-child,
.ad-tx-table td:last-child { text-align: right; width: 110px; }
.ad-tx-table td {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.ad-tx-table td.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.ad-tx-table td.amount.in  { color: var(--success); }
.ad-tx-table td.amount.out { color: var(--danger);  }

/* ── Block detail modal polish ────────────────────────────────────────────── */
.bd-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.bd-index {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.bd-time {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.bd-meta {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 18px;
}
.bd-meta td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.bd-meta tr:last-child td { border-bottom: none; }
.bd-meta td:first-child {
  color: var(--text-muted);
  width: 110px;
  font-weight: 500;
}
.bd-meta td.mono       { font-family: var(--font-mono); font-size: 0.78rem; }
.bd-meta td.breakall   { word-break: break-all; }
.bd-section-label {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin: 14px 0 8px;
}
.bd-tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.bd-tx-table th {
  background: var(--surface-2);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  text-align: left;
  padding: 8px 12px;
}
.bd-tx-table th.arrow, .bd-tx-table td.arrow { width: 30px; text-align: center; color: var(--text-subtle); }
.bd-tx-table th:last-child, .bd-tx-table td.amount { text-align: right; width: 90px; }
.bd-tx-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}
.bd-tx-table td.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--success);
}
.bd-tx-table td.amount.cb { color: var(--warn); }

.mono { font-family: var(--font-mono); font-size: 0.8rem; }
.breakall { word-break: break-all; }

@media (max-width: 900px) {
  #address-detail { padding: 20px; width: 96%; }
  .ad-stats { grid-template-columns: repeat(2, 1fr); }
  .activity-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 12px;
  }
  .activity-block { grid-column: 1 / 3; }
  .bd-meta td:first-child { width: 90px; }
}
