/* =========================================================================
   Divi Network Mapper — Main Stylesheet
   Dark industrial theme: navy base, teal accent, JetBrains Mono for data
   ========================================================================= */

/* -------------------------------------------------------------------------
   CSS Custom Properties
   ------------------------------------------------------------------------- */
:root {
  /* Base palette */
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-elevated:   #1f2937;
  --bg-hover:      #243044;

  /* Borders */
  --border-subtle: #21262d;
  --border-muted:  #30363d;
  --border-active: #4ecca3;

  /* Text */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;
  --text-code:      #cdd9e5;

  /* Accent / status */
  --accent:         #4ecca3;
  --accent-dim:     rgba(78, 204, 163, 0.15);
  --accent-glow:    rgba(78, 204, 163, 0.35);
  --warn:           #f59e0b;
  --warn-dim:       rgba(245, 158, 11, 0.15);
  --error:          #ef4444;
  --error-dim:      rgba(239, 68, 68, 0.15);
  --info:           #3b82f6;
  --info-dim:       rgba(59, 130, 246, 0.15);

  /* Masternode tier colors */
  --tier-copper:   #b87333;
  --tier-silver:   #adb5bd;
  --tier-gold:     #ffd700;
  --tier-platinum: #e5e4e2;
  --tier-diamond:  #b9f2ff;

  /* Typography */
  --font-ui:   'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Sizing */
  --header-height: 52px;
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  10px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --shadow-elevated: 0 4px 16px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--text-code);
}

/* -------------------------------------------------------------------------
   Layout Shell
   ------------------------------------------------------------------------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0;
  z-index: 1000;
  padding: 0 16px 0 0;
}

.app-main {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* -------------------------------------------------------------------------
   Header Brand
   ------------------------------------------------------------------------- */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: 100%;
  border-right: 1px solid var(--border-subtle);
  min-width: 220px;
}

.brand-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Navigation Tabs
   ------------------------------------------------------------------------- */
.app-nav {
  display: flex;
  align-items: stretch;
  height: 100%;
  flex: 1;
  padding: 0 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  position: relative;
}

.nav-tab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-tab:hover {
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-elevated);
}

.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-tab.active svg {
  opacity: 1;
}

/* -------------------------------------------------------------------------
   SSE Live Indicator
   ------------------------------------------------------------------------- */
.header-status {
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.sse-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  cursor: default;
}

.sse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s ease;
}

.sse-indicator.connected .sse-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  animation: sse-pulse 2s ease-in-out infinite;
}

.sse-indicator.error .sse-dot {
  background: var(--error);
}

@keyframes sse-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sse-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sse-indicator.connected .sse-label {
  color: var(--accent);
}

/* -------------------------------------------------------------------------
   View Containers
   ------------------------------------------------------------------------- */
.view-container {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.view-container.active {
  display: block;
}

.view-inner {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* -------------------------------------------------------------------------
   Loading States
   ------------------------------------------------------------------------- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 300px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.hidden {
  display: none !important;
}

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

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

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-action {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

/* -------------------------------------------------------------------------
   Stat Cards (big numbers)
   ------------------------------------------------------------------------- */
.stat-value {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  margin-top: 4px;
}

/* -------------------------------------------------------------------------
   Dashboard Layout
   ------------------------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* -------------------------------------------------------------------------
   Tier mini-cards
   ------------------------------------------------------------------------- */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.tier-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.tier-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.tier-card.copper::before  { background: var(--tier-copper); }
.tier-card.silver::before  { background: var(--tier-silver); }
.tier-card.gold::before    { background: var(--tier-gold); }
.tier-card.platinum::before{ background: var(--tier-platinum); }
.tier-card.diamond::before { background: var(--tier-diamond); }

.tier-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.tier-card.copper  .tier-name { color: var(--tier-copper); }
.tier-card.silver  .tier-name { color: var(--tier-silver); }
.tier-card.gold    .tier-name { color: var(--tier-gold); }
.tier-card.platinum .tier-name { color: var(--tier-platinum); }
.tier-card.diamond .tier-name { color: var(--tier-diamond); }

.tier-count {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

/* -------------------------------------------------------------------------
   Country Bar Chart
   ------------------------------------------------------------------------- */
.country-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.country-row {
  display: grid;
  grid-template-columns: 72px 1fr 48px;
  align-items: center;
  gap: 10px;
}

.country-name {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-bar-track {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.country-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--accent-glow);
}

.country-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

/* -------------------------------------------------------------------------
   Network Health Grid
   ------------------------------------------------------------------------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.health-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

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

.health-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.health-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 3px;
}

/* -------------------------------------------------------------------------
   Last Crawl Info
   ------------------------------------------------------------------------- */
.crawl-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.crawl-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.crawl-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.crawl-stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

/* -------------------------------------------------------------------------
   Crawl Progress
   ------------------------------------------------------------------------- */
.crawl-progress-wrap {
  margin-top: 12px;
}

.progress-bar-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2dd4bf);
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #0d1117;
}

.btn-primary:hover {
  background: #5ee8b5;
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-primary:disabled {
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-muted);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error-dim);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-muted);
}

.btn-sm:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm svg {
  width: 13px;
  height: 13px;
}

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

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

.data-table tbody tr.row-good { background: rgba(78, 204, 163, 0.05); }
.data-table tbody tr.row-warn { background: rgba(245, 158, 11, 0.05); }
.data-table tbody tr.row-bad  { background: rgba(239, 68, 68, 0.05); }

/* Monospace cells */
.cell-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* -------------------------------------------------------------------------
   Status badges
   ------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

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

.badge-active {
  background: rgba(78, 204, 163, 0.15);
  color: var(--accent);
  border: 1px solid rgba(78, 204, 163, 0.3);
}
.badge-active .badge-dot { background: var(--accent); }

.badge-warn {
  background: var(--warn-dim);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-warn .badge-dot { background: var(--warn); }

.badge-error {
  background: var(--error-dim);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-error .badge-dot { background: var(--error); }

.badge-info {
  background: var(--info-dim);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-info .badge-dot { background: var(--info); }

.badge-muted {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-muted);
}
.badge-muted .badge-dot { background: var(--text-muted); }

/* Tier badges */
.badge-copper   { background: rgba(184,115,51,0.15);  color: var(--tier-copper);   border: 1px solid rgba(184,115,51,0.3); }
.badge-silver   { background: rgba(173,181,189,0.15); color: var(--tier-silver);   border: 1px solid rgba(173,181,189,0.3); }
.badge-gold     { background: rgba(255,215,0,0.15);   color: var(--tier-gold);     border: 1px solid rgba(255,215,0,0.3); }
.badge-platinum { background: rgba(229,228,226,0.12); color: var(--tier-platinum); border: 1px solid rgba(229,228,226,0.3); }
.badge-diamond  { background: rgba(185,242,255,0.12); color: var(--tier-diamond);  border: 1px solid rgba(185,242,255,0.3); }

/* -------------------------------------------------------------------------
   Map Container
   ------------------------------------------------------------------------- */
#map-container {
  position: absolute;
  inset: 0;
}

#leaflet-map {
  width: 100%;
  height: 100%;
  background: #0a0e14;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(13, 17, 23, 0.7);
  z-index: 600;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Leaflet overrides for dark theme */
.leaflet-container {
  font-family: var(--font-ui);
}

.leaflet-popup-content-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  color: var(--text-primary);
  padding: 0;
}

.leaflet-popup-content {
  margin: 0;
  width: auto !important;
}

.leaflet-popup-tip {
  background: var(--bg-surface);
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  padding: 4px 8px !important;
}

.node-popup {
  padding: 14px 16px;
  min-width: 240px;
}

.node-popup-header {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.node-popup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 12px;
}

.node-popup-key {
  color: var(--text-muted);
  white-space: nowrap;
}

.node-popup-val {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-align: right;
}

/* Map legend */
.map-legend {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-card);
}

.legend-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

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

/* Marker cluster overrides */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(78, 204, 163, 0.2) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(78, 204, 163, 0.5) !important;
  color: var(--bg-base) !important;
  font-family: var(--font-mono) !important;
  font-weight: 600 !important;
}

/* -------------------------------------------------------------------------
   Graph Container
   ------------------------------------------------------------------------- */
#graph-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.graph-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-elevated);
  min-width: 200px;
}

.graph-controls-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.range-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

#graph-svg {
  flex: 1;
  width: 100%;
  height: 100%;
  background: var(--bg-base);
}

.graph-tooltip {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  pointer-events: none;
  z-index: 100;
  max-width: 220px;
  box-shadow: var(--shadow-elevated);
}

.graph-tooltip-ip {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.graph-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.graph-tooltip-key {
  color: var(--text-muted);
}

.graph-tooltip-val {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(13, 17, 23, 0.75);
  z-index: 20;
  color: var(--text-secondary);
  font-size: 14px;
}

.graph-stats {
  position: absolute;
  bottom: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  gap: 14px;
}

/* D3 node and link styles (via classes applied in JS) */
.graph-link {
  stroke: #21262d;
  stroke-opacity: 0.7;
  stroke-width: 1;
}

.graph-node {
  cursor: grab;
  stroke-width: 1.5;
  transition: stroke 0.15s, stroke-width 0.15s;
}

.graph-node:active {
  cursor: grabbing;
}

.graph-node.highlighted {
  stroke-width: 3;
  stroke: var(--accent);
}

.graph-node-new {
  animation: node-appear 1.5s ease-out;
}

@keyframes node-appear {
  0%   { opacity: 0; r: 2; }
  30%  { opacity: 1; r: 10; }
  100% { opacity: 1; }
}

/* -------------------------------------------------------------------------
   Peers View
   ------------------------------------------------------------------------- */
.peers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(600px, 1fr));
  gap: 20px;
}

.managed-node-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.managed-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.managed-node-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.managed-node-body {
  padding: 16px 18px;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: var(--bg-base);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.mode-btn {
  padding: 4px 12px;
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: var(--text-muted);
  background: transparent;
}

.mode-btn.active {
  background: var(--accent);
  color: #0d1117;
}

/* Section headers within a managed node card */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  margin-top: 18px;
}

.section-header:first-child {
  margin-top: 0;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Recommendations */
.recommendations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rec-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.rec-action-add {
  border-left: 3px solid var(--accent);
}

.rec-action-remove {
  border-left: 3px solid var(--error);
}

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

.rec-ip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.rec-reasons {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-score {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.rec-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Applied changes log */
.changes-log {
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
}

.log-entry {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.log-entry:last-child { border-bottom: none; }

.log-entry .log-time {
  color: var(--text-muted);
  margin-right: 8px;
}

.log-entry .log-action-add    { color: var(--accent); }
.log-entry .log-action-remove { color: var(--error); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
}

.empty-state-icon {
  font-size: 40px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.6;
}

.empty-state-code {
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-code);
  text-align: left;
  width: 100%;
  max-width: 480px;
  line-height: 1.7;
}

/* -------------------------------------------------------------------------
   Toast Notifications
   ------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-elevated);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  border-left: 3px solid var(--border-muted);
}

.toast.toast-success { border-left-color: var(--accent); }
.toast.toast-error   { border-left-color: var(--error); }
.toast.toast-warn    { border-left-color: var(--warn); }
.toast.toast-info    { border-left-color: var(--info); }

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

/* -------------------------------------------------------------------------
   Error Banner
   ------------------------------------------------------------------------- */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--error-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--error);
  margin-bottom: 16px;
}

/* -------------------------------------------------------------------------
   Stats Grid (Forks, Orphans pages)
   ------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
}

.stat-card .stat-sub {
  font-size: 12px;
  margin-top: 4px;
}

/* -------------------------------------------------------------------------
   API Documentation Layout
   ------------------------------------------------------------------------- */
.api-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  position: absolute;
  inset: 0;
}

.api-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 16px 0;
}

.api-sidebar-section {
  margin-bottom: 8px;
}

.api-sidebar-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 16px 4px;
}

.api-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
}

.api-sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.api-sidebar-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
}

.api-sidebar-method {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.api-sidebar-method.get {
  background: rgba(78, 204, 163, 0.15);
  color: var(--accent);
}

.api-sidebar-method.post {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
}

.api-sidebar-method.rpc {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
}

.api-content {
  overflow-y: auto;
  padding: 24px;
}

.api-endpoint-detail {
  margin-bottom: 24px;
}

.api-endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.api-endpoint-path {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-primary);
}

.api-endpoint-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.api-params-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13px;
}

.api-params-table th {
  text-align: left;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.api-params-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.api-params-table td:first-child {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.api-try-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.api-try-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.api-try-url {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-try-body {
  padding: 16px;
}

.api-try-response {
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  max-height: 400px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.api-rpc-params {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
  margin-bottom: 12px;
  box-sizing: border-box;
}

/* Button group */
.btn-group {
  display: flex;
  gap: 0;
}

.btn-group .btn-sm {
  border-radius: 0;
  border-right: none;
}

.btn-group .btn-sm:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn-sm:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-right: 1px solid var(--border-muted);
}

.btn-active {
  background: var(--accent) !important;
  color: #0d1117 !important;
  border-color: var(--accent) !important;
}

/* -------------------------------------------------------------------------
   Misc Utilities
   ------------------------------------------------------------------------- */
.text-muted    { color: var(--text-muted); }
.text-accent   { color: var(--accent); }
.text-warn     { color: var(--warn); }
.text-error    { color: var(--error); }
.text-right    { text-align: right; }
.font-mono     { font-family: var(--font-mono); }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.mt-8          { margin-top: 8px; }
.mt-12         { margin-top: 12px; }
.mt-16         { margin-top: 16px; }
.mb-8          { margin-bottom: 8px; }
.mb-12         { margin-bottom: 12px; }
.mb-16         { margin-bottom: 16px; }
.w-full        { width: 100%; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
