/* ==========================================================================
   Leyline Explorer — Dark Theme Stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
  /* Colors */
  --bg-base:        #0a0e17;
  --bg-surface:     #111827;
  --bg-surface-2:   #0f172a;
  --bg-sidebar:     #080c13;
  --border:         #1e293b;
  --border-hover:   #334155;

  --accent-cyan:    #22d3ee;
  --accent-purple:  #a78bfa;
  --accent-gold:    #fbbf24;

  --success:        #34d399;
  --warning:        #fbbf24;
  --error:          #f87171;
  --info:           #60a5fa;

  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --text-accent:    #22d3ee;

  /* Glow effects */
  --glow-cyan:      0 0 12px rgba(34, 211, 238, 0.25), 0 0 24px rgba(34, 211, 238, 0.1);
  --glow-gold:      0 0 12px rgba(251, 191, 36, 0.3),  0 0 24px rgba(251, 191, 36, 0.1);
  --glow-purple:    0 0 12px rgba(167, 139, 250, 0.25), 0 0 24px rgba(167, 139, 250, 0.1);

  /* Typography */
  --font-mono:  'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-ui:    system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Sizing */
  --sidebar-w:      220px;
  --header-h-mobile: 56px;
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      12px;

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;
}

/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

img, svg { display: block; }

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

a:hover { color: #67e8f9; }

button { cursor: pointer; font-family: inherit; }

table { border-collapse: collapse; width: 100%; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* Accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  padding: 8px 16px;
  background: var(--accent-cyan);
  color: #000;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 9999;
}
.skip-link:focus { top: 8px; }

/* --------------------------------------------------------------------------
   3. App Shell Layout
   -------------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   4. Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.logo-subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Live indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition-normal), box-shadow var(--transition-normal);
}

.live-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px var(--success), 0 0 12px rgba(52, 211, 153, 0.4);
  animation: pulse-dot 2s ease-in-out infinite;
}

.live-dot.disconnected {
  background: var(--error);
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 6px var(--success), 0 0 12px rgba(52, 211, 153, 0.4); }
  50%       { box-shadow: 0 0 8px var(--success), 0 0 20px rgba(52, 211, 153, 0.6); }
}

/* Nav List */
.nav-list {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-bottom: 2px;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.nav-item:hover {
  background: rgba(34, 211, 238, 0.06);
  color: var(--text-primary);
}
.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: rgba(34, 211, 238, 0.1);
  color: var(--accent-cyan);
  font-weight: 600;
}
.nav-item.active svg {
  opacity: 1;
  color: var(--accent-cyan);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.node-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.node-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.node-uptime {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   5. Mobile Header
   -------------------------------------------------------------------------- */

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h-mobile);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 110;
}

.mobile-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  letter-spacing: 0.05em;
}

.hamburger {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.mobile-live .live-dot { width: 8px; height: 8px; }

/* --------------------------------------------------------------------------
   6. Main Content
   -------------------------------------------------------------------------- */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   7. Page Sections
   -------------------------------------------------------------------------- */

.page {
  display: none;
  animation: page-in var(--transition-normal) ease forwards;
}

.page.active {
  display: block;
}

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   8. Panels (cards)
   -------------------------------------------------------------------------- */

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.panel:hover {
  border-color: var(--border-hover);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.panel-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  margin-left: 6px;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-link {
  font-size: 12px;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}
.panel-link:hover { color: var(--accent-cyan); }

/* --------------------------------------------------------------------------
   9. Stats Grid
   -------------------------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  cursor: default;
}

.stat-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  transform: translateY(-1px);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.peers   { background: rgba(34, 211, 238, 0.12); color: var(--accent-cyan); }
.stat-icon.msgs    { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); }
.stat-icon.tags    { background: rgba(251, 191, 36, 0.12);  color: var(--accent-gold); }
.stat-icon.ledger  { background: rgba(52, 211, 153, 0.12);  color: var(--success); }
.stat-icon.pending { background: rgba(251, 191, 36, 0.12);  color: var(--warning); }
.stat-icon.success { background: rgba(52, 211, 153, 0.12);  color: var(--success); }
.stat-icon.warning { background: rgba(248, 113, 113, 0.12); color: var(--error); }

.stat-body {
  min-width: 0;
  flex: 1;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
  transition: color var(--transition-fast);
}

.stat-value.flash {
  color: var(--accent-cyan);
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-trend {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   10. Buttons & Inputs
   -------------------------------------------------------------------------- */

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.btn-ghost.btn-sm { padding: 4px 10px; font-size: 11px; }

.btn-ghost.btn-icon {
  padding: 4px 6px;
  border: none;
}

.btn-ghost.btn-icon svg { width: 16px; height: 16px; }

.search-input, .select-input {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input:focus, .select-input:focus {
  border-color: var(--accent-cyan);
}

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

.select-input {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px;
}

.select-input option { background: var(--bg-surface); }

/* --------------------------------------------------------------------------
   11. Stat Badges
   -------------------------------------------------------------------------- */

.stat-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 99px;
}

.seed-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 99px;
}

.seed-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}

/* --------------------------------------------------------------------------
   12. Topology Graph
   -------------------------------------------------------------------------- */

.graph-container {
  position: relative;
  background: var(--bg-surface-2);
  min-height: 320px;
  overflow: hidden;
}

.graph-container.graph-lg {
  min-height: 440px;
}

.graph-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.graph-placeholder svg {
  width: 60px;
  height: 60px;
  opacity: 0.4;
  animation: spin-slow 8s linear infinite;
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.graph-container svg.topology-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* D3 node styles */
.node circle {
  stroke-width: 2px;
  cursor: pointer;
  transition: r 300ms ease, stroke-width 150ms ease;
}

.node circle:hover { stroke-width: 3px; }

.node.seed circle {
  fill: rgba(251, 191, 36, 0.15);
  stroke: var(--accent-gold);
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.5));
}

.node.peer circle {
  fill: rgba(34, 211, 238, 0.08);
  stroke: var(--accent-cyan);
}

.node.peer.dim circle { stroke: var(--text-muted); fill: transparent; }

.link {
  stroke: rgba(30, 41, 59, 0.8);
  stroke-width: 1.5px;
}

.link.active {
  stroke: rgba(34, 211, 238, 0.3);
  stroke-width: 2px;
}

.graph-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.seed { background: var(--accent-gold); box-shadow: 0 0 5px var(--accent-gold); }
.legend-dot.peer { background: var(--accent-cyan); }

.legend-line {
  width: 20px;
  height: 2px;
  background: rgba(30, 41, 59, 1);
  border-radius: 1px;
  flex-shrink: 0;
}

/* Graph tooltip */
.graph-tooltip {
  position: fixed;
  background: #1e293b;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 1000;
  max-width: 260px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.graph-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-fp { color: var(--accent-cyan); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.tooltip-row { color: var(--text-secondary); margin-top: 2px; }
.tooltip-row span { color: var(--text-primary); }

/* --------------------------------------------------------------------------
   13. Charts
   -------------------------------------------------------------------------- */

.chart-container {
  padding: 16px 18px;
  position: relative;
  height: 200px;
}

.chart-container.chart-sm {
  height: 120px;
}

.chart-container canvas {
  max-height: 100%;
}

/* --------------------------------------------------------------------------
   14. Two-column Grid
   -------------------------------------------------------------------------- */

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   15. Overview Lists (Top Tags / Recent Services)
   -------------------------------------------------------------------------- */

.overview-list {
  list-style: none;
  padding: 4px 0;
}

.overview-list-item {
  display: flex;
  align-items: center;
  padding: 9px 18px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  transition: background var(--transition-fast);
}

.overview-list-item:last-child { border-bottom: none; }
.overview-list-item:hover { background: rgba(255,255,255,0.02); }

.overview-tag-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-tag-rate {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.overview-service-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-placeholder {
  padding: 20px 18px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

/* --------------------------------------------------------------------------
   16. Tables
   -------------------------------------------------------------------------- */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  font-size: 12px;
  font-family: var(--font-mono);
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.4);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

.data-table tbody tr:last-child td { border-bottom: none; }

/* Striped rows */
.data-table tbody tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.4);
}

.data-table tbody tr:nth-child(even):hover td {
  background: rgba(255,255,255,0.025);
}

.table-placeholder {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  font-family: var(--font-ui);
}

/* --------------------------------------------------------------------------
   17. Ledger Table Specifics
   -------------------------------------------------------------------------- */

.col-index         { width: 70px; }
.col-time          { width: 90px; }
.col-size          { width: 80px; }
.col-confirmations { width: 160px; }
.col-status        { width: 120px; }

.ledger-index {
  color: var(--text-muted);
  font-weight: 600;
}

.ledger-time {
  color: var(--text-secondary);
  white-space: nowrap;
}

.ledger-size {
  color: var(--text-primary);
  font-weight: 500;
}

/* Confirmation bar */
.conf-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.conf-blocks {
  display: flex;
  gap: 2px;
}

.conf-block {
  width: 9px;
  height: 13px;
  border-radius: 2px;
  transition: background var(--transition-normal);
}

.conf-block.filled { background: var(--accent-cyan); box-shadow: 0 0 4px rgba(34, 211, 238, 0.4); }
.conf-block.empty  { background: var(--border); }

.conf-count {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.status-badge.confirmed  { background: rgba(52, 211, 153, 0.12); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.25); }
.status-badge.pending    { background: rgba(251, 191, 36, 0.12);  color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.25); }
.status-badge.rejected   { background: rgba(248, 113, 113, 0.12); color: var(--error);   border: 1px solid rgba(248, 113, 113, 0.25); }
.status-badge.active     { background: rgba(52, 211, 153, 0.12);  color: var(--success); border: 1px solid rgba(52, 211, 153, 0.25); }
.status-badge.expired    { background: rgba(71, 85, 105, 0.2);    color: var(--text-muted); border: 1px solid var(--border); }
.status-badge.valid      { background: rgba(52, 211, 153, 0.12);  color: var(--success); border: 1px solid rgba(52, 211, 153, 0.25); }
.status-badge.unsigned   { background: rgba(251, 191, 36, 0.12);  color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.25); }
.status-badge.invalid    { background: rgba(248, 113, 113, 0.12); color: var(--error);   border: 1px solid rgba(248, 113, 113, 0.25); }

/* Ledger footer */
.ledger-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.integrity-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.integrity-icon { font-size: 14px; }
.integrity-status.ok    { color: var(--success); }
.integrity-status.fail  { color: var(--error); }
.integrity-status.check { color: var(--text-muted); }

.ledger-stats-row {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.ledger-stats-row strong { color: var(--text-primary); }

.auto-refresh-label { font-size: 11px; color: var(--text-muted); }

/* Row flash animations */
@keyframes row-flash-new {
  0%   { background: rgba(34, 211, 238, 0.12); }
  100% { background: transparent; }
}

@keyframes row-flash-update {
  0%   { background: rgba(167, 139, 250, 0.12); }
  100% { background: transparent; }
}

tr.new-row td    { animation: row-flash-new    1s ease forwards; }
tr.updated-row td { animation: row-flash-update 0.6s ease forwards; }

/* --------------------------------------------------------------------------
   18. Peer Explorer Page
   -------------------------------------------------------------------------- */

.peer-layout {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.peer-graph-panel {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.peer-detail-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.detail-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-list {
  padding: 12px 0;
  font-family: var(--font-mono);
}

.detail-list dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 4px 16px 1px;
}

.detail-list dd {
  font-size: 12px;
  color: var(--text-primary);
  padding: 0 16px 10px;
  word-break: break-all;
}

.detail-list dd.accent { color: var(--accent-cyan); }

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 16px 10px;
}

/* --------------------------------------------------------------------------
   19. Tag Activity Page
   -------------------------------------------------------------------------- */

.tag-group {
  border-bottom: 1px solid var(--border);
}

.tag-group:last-child { border-bottom: none; }

.tag-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  user-select: none;
  transition: background var(--transition-fast);
}

.tag-group-header:hover { background: rgba(255,255,255,0.02); }

.tag-group-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.tag-group-header.collapsed .tag-group-chevron {
  transform: rotate(-90deg);
}

.tag-group-prefix {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-purple);
}

.tag-group-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.tag-group-body.collapsed { display: none; }

.tag-row {
  display: grid;
  grid-template-columns: 1fr 100px 100px 100px 100px;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.4);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  transition: background var(--transition-fast);
}

.tag-row:hover { background: rgba(34, 211, 238, 0.04); }
.tag-row.selected { background: rgba(34, 211, 238, 0.08); }

.tag-row:last-child { border-bottom: none; }

.tag-row-header {
  display: grid;
  grid-template-columns: 1fr 100px 100px 100px 100px;
  padding: 8px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2);
}

.tag-name-cell { color: var(--accent-cyan); }
.tag-cell { color: var(--text-secondary); text-align: right; }
.tag-cell:first-child { text-align: left; }

.tag-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.tag-stat {
  text-align: center;
}

.tag-stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.tag-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 3px;
}

/* Tag pills */
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent-cyan);
  border: 1px solid rgba(34, 211, 238, 0.2);
  white-space: nowrap;
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   20. Service Directory Page
   -------------------------------------------------------------------------- */

.provider-fp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ttl-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ttl-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  max-width: 80px;
}

.ttl-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-cyan);
  transition: width 1s ease;
}

.ttl-bar-fill.low  { background: var(--error); }
.ttl-bar-fill.med  { background: var(--warning); }
.ttl-bar-fill.high { background: var(--success); }

.ttl-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   21. Consensus Monitor Page
   -------------------------------------------------------------------------- */

/* Quorum gauge */
.gauge-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}

.gauge-ring {
  position: relative;
  width: 180px;
  height: 180px;
}

.gauge-svg {
  width: 100%;
  height: 100%;
}

.gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.gauge-fill {
  fill: none;
  stroke: var(--accent-cyan);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s ease;
}

.gauge-fill.low  { stroke: var(--error); }
.gauge-fill.med  { stroke: var(--warning); }
.gauge-fill.high { stroke: var(--success); }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.gauge-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Participation bar */
.participation-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.participation-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-cyan);
  transition: width 0.6s ease;
}

.participation-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   22. Games Dashboard Page
   -------------------------------------------------------------------------- */

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.game-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.game-card:hover {
  border-color: var(--accent-purple);
  box-shadow: var(--glow-purple);
  transform: translateY(-2px);
}

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

.game-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(167, 139, 250, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.game-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.game-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-purple);
}

.game-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.game-stat {
  text-align: center;
  padding: 10px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.game-stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-purple);
  display: block;
}

.game-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 3px;
}

.games-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.games-empty svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.3;
}

/* --------------------------------------------------------------------------
   23. Toasts
   -------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: toast-in 0.25s ease forwards;
  pointer-events: auto;
  max-width: 300px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.info    .toast-dot { background: var(--info); }
.toast.success .toast-dot { background: var(--success); }
.toast.warning .toast-dot { background: var(--warning); }
.toast.error   .toast-dot { background: var(--error); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* --------------------------------------------------------------------------
   24. Accent utility
   -------------------------------------------------------------------------- */

.accent { color: var(--accent-cyan); }
.accent-gold { color: var(--accent-gold); }
.accent-purple { color: var(--accent-purple); }

/* --------------------------------------------------------------------------
   25. Scrollbar Styling
   -------------------------------------------------------------------------- */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --------------------------------------------------------------------------
   26. Responsive — Mobile (≤ 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    top: var(--header-h-mobile);
    height: calc(100vh - var(--header-h-mobile));
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    margin-top: var(--header-h-mobile);
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .two-col-grid {
    grid-template-columns: 1fr;
  }

  .peer-layout {
    flex-direction: column;
  }

  .peer-detail-panel {
    width: 100%;
  }

  .ledger-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .tag-detail-stats {
    grid-template-columns: 1fr 1fr;
  }

  .tag-row,
  .tag-row-header {
    grid-template-columns: 1fr 80px 80px;
  }

  .tag-row > *:nth-child(4),
  .tag-row > *:nth-child(5),
  .tag-row-header > *:nth-child(4),
  .tag-row-header > *:nth-child(5) {
    display: none;
  }

  .games-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 20px; }
  .page-header h1 { font-size: 18px; }
}

/* --------------------------------------------------------------------------
   27. Sidebar overlay (mobile)
   -------------------------------------------------------------------------- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-h-mobile);
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.visible { display: block; }

/* --------------------------------------------------------------------------
   28. Loading skeleton
   -------------------------------------------------------------------------- */

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, rgba(30,41,59,0.5) 50%, var(--bg-surface-2) 75%);
  background-size: 200% auto;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--radius-sm);
  display: inline-block;
}
