:root {
  --bg: #0a0a1a;
  --bg-elevated: #0f0f23;
  --bg-panel: #12122a;
  --border-subtle: #1e1e3a;
  --border-strong: #2a2a4a;
  --fg: #e8e8f0;
  --fg-muted: #a0a0b8;
  --accent-cyan: #22d3ee;
  --accent-purple: #a855f7;
  --accent: #22d3ee;
  --accent-gradient: linear-gradient(135deg, #22d3ee 0%, #8b5cf6 50%, #a855f7 100%);
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-purple-soft: rgba(168, 85, 247, 0.12);
  --danger: #f97373;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-soft: 0 18px 40px rgba(10, 10, 26, 0.9);
  --shadow-accent: 0 12px 30px rgba(34, 211, 238, 0.2), 0 8px 20px rgba(168, 85, 247, 0.15);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(circle at top left, rgba(34, 211, 238, 0.05) 0, #0a0a1a 30%, #050510 70%, #000 100%),
              radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.05) 0, #0a0a1a 100%);
  background-color: #0a0a1a;
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* HEADER */

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.brand:hover {
  opacity: 0.85;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  box-shadow: 0 16px 30px rgba(34, 211, 238, 0.15), 0 8px 15px rgba(168, 85, 247, 0.1);
  overflow: hidden;
}

.brand-mark img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

/* SEARCH */

.search {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1 1 260px;
}

.search input {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  background: rgba(18, 18, 42, 0.95);
  color: var(--fg);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

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

.search input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.4), 0 0 20px rgba(34, 211, 238, 0.1);
  background: rgba(18, 18, 42, 1);
}

/* BUTTONS */

.btn-primary,
.btn-ghost {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  color: var(--fg);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #0a0a1a;
  border-color: transparent;
  box-shadow: var(--shadow-accent);
  font-weight: 600;
  -webkit-background-clip: padding-box;
  -webkit-text-fill-color: #0a0a1a;
  background-clip: padding-box;
}

.btn-primary:hover {
  box-shadow: 0 16px 40px rgba(34, 211, 238, 0.3), 0 12px 25px rgba(168, 85, 247, 0.2);
  opacity: 0.95;
}

.btn-ghost {
  border-color: var(--border-subtle);
  color: var(--fg-muted);
  background: rgba(18, 18, 42, 0.6);
}

.btn-ghost:hover {
  border-color: var(--accent-cyan);
  color: var(--fg);
  background: rgba(18, 18, 42, 0.9);
  box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
}

/* MAIN LAYOUT */

.app-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* PANELS */

.panel {
  background: linear-gradient(145deg, rgba(18, 18, 42, 0.96), rgba(15, 15, 35, 0.9));
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  border: 1px solid rgba(42, 42, 74, 0.6);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--fg);
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* STATS GRID */

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

.stat-card {
  border-radius: var(--radius-md);
  border: 1px solid rgba(42, 42, 74, 0.6);
  background: radial-gradient(circle at 10% 0, rgba(34, 211, 238, 0.08) 0, rgba(18, 18, 42, 0.95) 40%),
              radial-gradient(circle at 90% 100%, rgba(168, 85, 247, 0.06) 0, rgba(18, 18, 42, 0.95) 40%);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100px;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-status {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.stat-status.ok {
  background: #22c55e;
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.4;
}

.stat-meta {
  font-size: 0.75rem;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-top: 2px;
}

/* CHART CONTAINER */

.chart-container {
  position: relative;
  height: 300px;
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: rgba(18, 18, 42, 0.5);
}

/* TABLE */

.table-wrapper {
  border-radius: var(--radius-md);
  border: 1px solid rgba(51, 65, 85, 0.9);
  overflow: hidden;
  background: rgba(18, 18, 42, 0.9);
}

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

.table thead {
  background: rgba(18, 18, 42, 0.9);
}

.table th,
.table td {
  padding: 7px 9px;
  text-align: left;
  white-space: nowrap;
}

.table tbody tr {
  border-left: 2px solid transparent; /* Reserve space for hover border */
}

.table th {
  font-weight: 500;
  color: var(--fg-muted);
  border-bottom: 1px solid rgba(42, 42, 74, 0.6);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tbody tr:nth-child(even) {
  background: rgba(18, 18, 42, 0.7);
}

.table tbody tr:hover {
  background: rgba(30, 30, 55, 0.95);
  border-left: 2px solid var(--accent-cyan);
}

/* Gradient text for data links (hashes, IDs, etc.) */
.table a,
.stat-card a,
.stat-meta a {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

.table a:hover,
.stat-card a:hover,
.stat-meta a:hover {
  text-decoration: underline;
  filter: brightness(1.2);
}

/* Exclude navigation/UI links from gradient TEXT (but allow gradient backgrounds) */
.brand a,
.btn-ghost {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: unset;
  background-clip: unset;
}


.table-empty {
  text-align: center;
  color: var(--fg-muted);
}

/* STATUS / BADGES */

.pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  border: 1px solid var(--border-subtle);
}

.pill-muted {
  background: rgba(18, 18, 42, 0.9);
  color: var(--fg-muted);
  border: 1px solid rgba(42, 42, 74, 0.4);
}

/* FOOTER */

.app-footer {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(42, 42, 74, 0.4);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.app-footer .dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
}

/* RESPONSIVE */

@media (max-width: 768px) {
  .app {
    padding: 12px;
    gap: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .app-header .brand {
    width: auto;
    justify-content: flex-start;
    align-self: flex-start;
    flex-shrink: 0;
    margin-left: 0;
    margin-right: auto;
    text-align: left;
  }

  .app-header > div {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .app-header .btn-ghost {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .brand {
    flex-shrink: 0;
  }

  .brand-title {
    font-size: 1rem;
  }

  .brand-subtitle {
    font-size: 0.7rem;
  }

  .search {
    width: 100%;
    flex: 1 1 100%;
    min-width: 0;
  }

  .search input {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .app-header .btn-ghost {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn-primary,
  .btn-ghost {
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px; /* Better touch target */
  }

  .stats-grid {
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 12px;
  }

  .stat-card {
    padding: 14px 16px;
    min-height: auto;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .panel {
    padding: 12px;
  }

  .panel-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-header h2 {
    font-size: 0.9rem;
  }

  .chart-container {
    height: 250px;
    padding: 8px;
  }

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

  .table {
    font-size: 0.75rem;
    min-width: 600px; /* Force horizontal scroll on very small screens */
  }

  .table th,
  .table td {
    padding: 6px 8px;
  }

  .table th {
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 10px;
    gap: 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    height: 36px;
    font-size: 0.7rem;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .stat-meta {
    font-size: 0.7rem;
  }

  .chart-container {
    height: 200px;
  }

  .panel-header h2 {
    font-size: 0.85rem;
  }

  .app-footer {
    font-size: 0.7rem;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .app-footer .dot {
    display: block; /* Show dots on mobile like desktop */
  }

  .app-header > div {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .app-header > div {
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: 8px;
  }

  .app-header .btn-ghost {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Block detail page inline grid */
  [style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}
