:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #16161f;
  --border: #1e1e2e;
  --accent: #7c6af7;
  --accent2: #4ade80;
  --accent3: #f97316;
  --text: #e2e2f0;
  --muted: #6b6b8a;
  --online: #4ade80;
  --offline: #f87171;
  --warn: #f97316;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

.noise {
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: 0.4;
}
.grid-bg {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.25; pointer-events: none; z-index: 0;
}
.glow {
  position: fixed; top: -200px; left: 50%; transform: translateX(-50%);
  width: 700px; height: 500px;
  background: radial-gradient(ellipse, rgba(124,106,247,0.07) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

.container {
  position: relative; z-index: 1;
  max-width: 960px; margin: 0 auto;
  padding: 40px 20px 60px;
}

header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; flex-direction: column; gap: 4px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.logo {
  font-family: 'Space Mono', monospace;
  font-size: 1rem; font-weight: 700;
  color: var(--accent); letter-spacing: 0.05em;
}
.logo span { color: var(--muted); }
.logo-sub {
  font-size: 0.58rem; color: var(--muted); letter-spacing: 0.18em;
}
.live-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.62rem; color: var(--muted); letter-spacing: 0.12em;
  background: rgba(74,222,128,0.06);
  border: 1px solid rgba(74,222,128,0.15);
  padding: 6px 14px; border-radius: 20px;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.live-badge[data-state="loading"] {
  background: rgba(124,106,247,0.06);
  border-color: rgba(124,106,247,0.2);
  color: var(--accent);
}
.live-badge[data-state="loading"] .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.live-badge[data-state="error"] {
  background: rgba(248,113,113,0.06);
  border-color: rgba(248,113,113,0.2);
  color: var(--offline);
}
.live-badge[data-state="error"] .dot { background: var(--offline); box-shadow: 0 0 8px var(--offline); }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--online); box-shadow: 0 0 8px var(--online);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1;transform:scale(1); } 50% { opacity:0.4;transform:scale(0.75); } }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-right {
  font-size: 0.6rem; color: var(--muted); letter-spacing: 0.08em;
}
.ctl {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px;
  transition: border-color 0.2s;
}
.ctl:hover { border-color: rgba(124,106,247,0.35); }
.ctl-label {
  font-size: 0.55rem; color: var(--muted);
  letter-spacing: 0.15em; text-transform: uppercase;
}
.ctl-select {
  background: transparent; color: var(--text);
  border: none; outline: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem; padding: 4px 4px; cursor: pointer;
}
.ctl-select option { background: var(--surface); color: var(--text); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem; letter-spacing: 0.08em;
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-ghost:hover {
  border-color: rgba(124,106,247,0.5);
  color: var(--accent);
}
.btn-ghost:disabled,
.btn-ghost[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:disabled:hover,
.btn-ghost[disabled]:hover {
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost.sm { padding: 4px 10px; font-size: 0.58rem; }

.section-title {
  font-size: 0.58rem; letter-spacing: 0.25em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 12px;
}
.section-title::before {
  content:''; width:3px; height:12px;
  background: var(--accent); border-radius:2px; flex-shrink:0;
}
.section-title::after {
  content:''; flex:1; height:1px; background: var(--border);
}
.section-sub {
  font-size: 0.55rem; letter-spacing: 0.15em;
  color: var(--muted); text-transform: none;
  font-weight: 400;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 22px;
  margin-bottom: 12px;
  position: relative; overflow: hidden;
  transition: border-color 0.25s, transform 0.25s;
}
.card:hover { border-color: rgba(124,106,247,0.35); transform: translateY(-1px); }
.card::before {
  content:''; position:absolute; top:0; left:0; right:0; height:1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.card:hover::before { opacity: 0.5; }

/* HERO status card */
.hero-card {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 32px;
  overflow: hidden;
}
.hero-card::before {
  content:''; position:absolute; inset:0;
  background: linear-gradient(135deg, transparent 40%, rgba(124,106,247,0.06) 100%);
  pointer-events: none;
}
.hero-glow {
  position: absolute; top: -80px; right: -80px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 60%);
  opacity: 0.12; pointer-events: none;
  transition: background 0.4s, opacity 0.4s;
}
.hero-card[data-state="up"] .hero-glow { background: radial-gradient(circle, var(--online) 0%, transparent 60%); opacity: 0.18; }
.hero-card[data-state="down"] .hero-glow { background: radial-gradient(circle, var(--offline) 0%, transparent 60%); opacity: 0.18; }
.hero-card[data-state="up"] { border-color: rgba(74,222,128,0.28); }
.hero-card[data-state="down"] { border-color: rgba(248,113,113,0.35); }

.hero-left { position: relative; z-index: 1; flex: 1; min-width: 240px; }
.hero-label {
  font-size: 0.58rem; letter-spacing: 0.25em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 10px;
}
.hero-status {
  font-family: 'Space Mono', monospace;
  font-size: 2.2rem; font-weight: 700;
  color: var(--accent); letter-spacing: 0.02em;
  margin-bottom: 6px;
  transition: color 0.3s;
}
.hero-card[data-state="up"] .hero-status { color: var(--online); }
.hero-card[data-state="down"] .hero-status { color: var(--offline); }
.hero-sub {
  font-size: 0.7rem; color: var(--muted);
  letter-spacing: 0.05em;
}
.hero-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(124, 106, 247, 0.4);
  transition: color 0.2s, border-color 0.2s;
}
.hero-link:hover {
  color: #a494ff;
  border-bottom-color: rgba(124, 106, 247, 0.8);
}
.hero-api-note {
  margin-top: 10px;
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.hero-right {
  display: flex; gap: 20px; position: relative; z-index: 1;
}
.hero-metric {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  min-width: 110px;
  text-align: center;
}
.hero-metric-label {
  font-size: 0.55rem; letter-spacing: 0.15em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 6px;
}
.hero-metric-value {
  font-family: 'Space Mono', monospace;
  font-size: 1.3rem; font-weight: 700;
  color: var(--text);
}
.hero-metric-value .unit {
  font-size: 0.65rem; color: var(--muted);
  margin-left: 2px; font-weight: 400;
}

/* Leaflet map */
#map, #visitorMap {
  width: 100%; height: 300px;
  border-radius: 8px; overflow: hidden;
  background: #0d0d14;
}
.leaflet-container { background: #0d0d14 !important; }

.map-info-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0; margin-top: 16px;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.map-info-item {
  padding: 14px 16px; background: var(--surface2);
  border-right: 1px solid var(--border);
}
.map-info-item:last-child { border-right: none; }
.map-info-label {
  font-size: 0.55rem; letter-spacing: 0.15em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 5px;
}
.map-info-value { font-size: 0.82rem; font-weight: 600; color: var(--text); word-break: break-all; }
.map-info-value.accent { color: var(--accent); }
.map-info-value.orange { color: var(--accent3); }
.map-info-value.green { color: var(--accent2); }

.card-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem; font-weight: 700;
  color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card-title svg { opacity: 0.6; }
.chart-title-row { justify-content: space-between; }
.chart-title-row > span { display: flex; align-items: center; gap: 8px; }

/* Info grid — label / value rows */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.info-row {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  background: var(--surface);
  font-size: 0.72rem;
  min-height: 42px;
}
.info-row.full { grid-column: 1 / -1; }
.info-key {
  color: var(--muted);
  letter-spacing: 0.05em;
  font-size: 0.62rem;
  text-transform: uppercase;
  flex-shrink: 0;
}
.info-val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
  font-size: 0.72rem;
}
.info-val.accent { color: var(--accent); }
.info-val.orange { color: var(--accent3); }
.info-val.green { color: var(--accent2); font-family: 'Space Mono', monospace; }
.info-val.mono-sm { font-size: 0.62rem; letter-spacing: 0; color: var(--muted); }

@media (max-width: 700px) {
  .info-grid { grid-template-columns: 1fr; }
  .info-row.full { grid-column: 1; }
}

/* Chart */
.chart-wrap { position: relative; height: 260px; padding-top: 4px; }
.chart-hint {
  margin-top: 12px;
  font-size: 0.58rem; color: var(--muted);
  letter-spacing: 0.08em;
}

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  display: inline-block;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.last-update {
  text-align: center;
  font-size: 0.6rem; color: var(--muted);
  margin-top: 28px; letter-spacing: 0.1em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.refresh-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted); animation: pulse 2s infinite;
}

footer {
  text-align: center; margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.6rem; color: var(--muted); letter-spacing: 0.08em;
  display: flex; align-items: center; justify-content: center;
  gap: 14px; flex-wrap: wrap;
}
footer a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--text); }
.footer-sep { color: var(--border); }

.fade-in {
  opacity: 0; transform: translateY(12px);
  animation: fadeIn 0.5s ease forwards;
}
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }
.fade-in:nth-child(1) { animation-delay: 0.05s; }
.fade-in:nth-child(2) { animation-delay: 0.15s; }
.fade-in:nth-child(3) { animation-delay: 0.25s; }

@media (max-width: 700px) {
  .map-info-row { grid-template-columns: 1fr 1fr; }
  .map-info-item:nth-child(2) { border-right: none; }
  .map-info-item:nth-child(1),
  .map-info-item:nth-child(2) { border-bottom: 1px solid var(--border); }
  header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { text-align: left; }
  .hero-card { flex-direction: column; align-items: flex-start; padding: 22px 20px; }
  .hero-right { width: 100%; }
  .hero-metric { flex: 1; min-width: 0; }
  .hero-status { font-size: 1.8rem; }
}
