:root {
  --bg-main: #020617;
  --bg-card: rgba(15, 23, 42, 0.82);
  --border-card: rgba(56, 189, 248, 0.14);
  --border-card-bright: rgba(56, 189, 248, 0.3);
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --color-green: #10B981;
  --color-green-glow: rgba(16, 185, 129, 0.25);
  --color-yellow: #F59E0B;
  --color-yellow-glow: rgba(245, 158, 11, 0.25);
  --color-red: #EF4444;
  --color-red-glow: rgba(239, 68, 68, 0.25);
  --color-sky: #38BDF8;
  --color-nodata: #334155;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
}

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

body {
  background: #020617;
  background-image: linear-gradient(135deg, #020617 0%, #0F172A 50%, #0C4A6E 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* Background glow */
body::before {
  content: '';
  position: fixed; top: -30%; right: -15%;
  width: 55vw; height: 55vw;
  background: radial-gradient(circle, rgba(56,189,248,0.10) 0%, rgba(14,165,233,0.05) 40%, transparent 65%);
  pointer-events: none; z-index: 0;
}
body::after {
  content: '';
  position: fixed; bottom: -25%; left: -10%;
  width: 45vw; height: 45vw;
  background: radial-gradient(circle, rgba(245,158,11,0.06) 0%, rgba(251,113,133,0.04) 50%, transparent 65%);
  pointer-events: none; z-index: 0;
}

.app-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 12px 48px;
  position: relative;
  z-index: 1;
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), inset 0 1px 0 rgba(56,189,248,0.06);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===== HEADER ===== */
.site-header {
  position: relative; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-box {
  width: 36px; height: 36px; border-radius: 8px; overflow: hidden;
  box-shadow: 0 3px 10px rgba(14,165,233,0.3); flex-shrink: 0; background: #0284C7;
}
.brand-logo-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.brand-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.brand-sub { font-size: 0.75rem; color: var(--text-secondary); font-family: var(--font-mono); white-space: nowrap; }
.title-gradient-anim {
  background: linear-gradient(90deg, #38BDF8, #7DD3FC, #FBBF24, #FB7185, #38BDF8);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: gradient-scroll 4s linear infinite;
}
@keyframes gradient-scroll { 0%{background-position:0% 50%} 100%{background-position:200% 50%} }
.live-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.6rem; font-weight: 700; color: var(--color-green); letter-spacing: 0.06em; margin-top: 1px;
}
.live-pulse {
  width: 6px; height: 6px; background: var(--color-green); border-radius: 50%;
  box-shadow: 0 0 6px var(--color-green); animation: pulse-ring 1.8s infinite ease-in-out;
}
@keyframes pulse-ring {
  0%{transform:scale(0.95);box-shadow:0 0 0 0 rgba(16,185,129,0.7)}
  70%{transform:scale(1.1);box-shadow:0 0 0 6px rgba(16,185,129,0)}
  100%{transform:scale(0.95);box-shadow:0 0 0 0 rgba(16,185,129,0)}
}
.header-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Buttons */
.glass-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  border: 1px solid var(--border-card-bright);
  background: rgba(14,165,233,0.08); color: var(--text-primary);
  box-shadow: 0 3px 10px rgba(14,165,233,0.12);
  transition: all 0.2s ease; white-space: nowrap;
}
.glass-btn:hover { background: rgba(14,165,233,0.18); transform: translateY(-1px); }
.glass-btn:active { transform: translateY(1px); }
.lang-icon { display: flex; align-items: center; color: var(--color-sky); }

/* Language Dropdown */
.language-dropdown { position: relative; z-index: 100; }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; width: 155px; padding: 5px;
  display: none; flex-direction: column; gap: 2px; z-index: 1000;
}
.lang-menu.show { display: flex; }
.lang-option {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  font-size: 0.82rem; border-radius: 6px; cursor: pointer;
  color: var(--text-secondary); transition: background 0.15s;
}
.lang-option:hover { background: rgba(56,189,248,0.15); color: var(--text-primary); }
.lang-option.active { background: rgba(14,165,233,0.25); color: var(--color-sky); font-weight: 700; }
.flag-badge {
  font-size: 0.6rem; font-weight: 700; font-family: var(--font-mono);
  padding: 1px 4px; border-radius: 3px; background: rgba(56,189,248,0.15);
  border: 1px solid rgba(56,189,248,0.3); color: var(--color-sky);
}

/* ===== HERO ===== */
.hero-card {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 16px;
  padding: 20px; margin-bottom: 16px; overflow: hidden;
}
.hero-status-icon-wrapper {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; flex-shrink: 0;
}
.hero-status-ring {
  position: absolute; inset: 0; border-radius: 50%;
  transition: all 0.3s; z-index: 1;
}
.hero-status-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 2; transition: all 0.3s;
}
.hero-card.is-online .hero-status-ring { box-shadow: 0 0 24px var(--color-green-glow); border: 2px solid var(--color-green); }
.hero-card.is-online .hero-status-icon { background: rgba(16,185,129,0.15); color: var(--color-green); }
.hero-card.is-degraded .hero-status-ring { box-shadow: 0 0 24px var(--color-yellow-glow); border: 2px solid var(--color-yellow); }
.hero-card.is-degraded .hero-status-icon { background: rgba(245,158,11,0.15); color: var(--color-yellow); }
.hero-card.is-offline .hero-status-ring { box-shadow: 0 0 24px var(--color-red-glow); border: 2px solid var(--color-red); }
.hero-card.is-offline .hero-status-icon { background: rgba(239,68,68,0.15); color: var(--color-red); }
.hero-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hero-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; word-break: break-word; }
.hero-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 10px; font-size: 0.78rem; color: var(--text-secondary);
}
.target-url { color: var(--color-sky); font-family: var(--font-mono); text-decoration: none; font-size: 0.78rem; }
.target-url:hover { text-decoration: underline; }
.meta-divider { color: var(--text-muted); }

/* ===== METRICS ===== */
.metrics-grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.metric-card { padding: 14px 16px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.metric-title {
  font-size: 0.72rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.metric-icon { display: flex; align-items: center; }
.metric-badge {
  font-size: 0.6rem; font-weight: 700; padding: 2px 6px; border-radius: 5px;
  background: rgba(16,185,129,0.15); color: var(--color-green); font-family: var(--font-mono);
}
.metric-badge.degraded { background: rgba(245,158,11,0.15); color: var(--color-yellow); }
.metric-badge.offline { background: rgba(239,68,68,0.15); color: var(--color-red); }
.metric-value-row { display: flex; align-items: baseline; gap: 3px; margin-bottom: 6px; }
.metric-val { font-size: 1.5rem; font-weight: 700; font-family: var(--font-mono); line-height: 1.1; }
.metric-val.highlight-green { color: var(--color-green); }
.metric-unit { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.metric-footer { font-size: 0.72rem; color: var(--text-muted); }
.metric-bar-bg { width: 100%; height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.metric-bar-fill { height: 100%; background: linear-gradient(90deg, #10B981, #34D399); border-radius: 2px; transition: width 0.4s; }

/* ===== SECTIONS ===== */
.section-card { position: relative; z-index: 1; padding: 16px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.card-header-wrap { flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; font-weight: 600; }
.title-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--color-sky); box-shadow: 0 0 8px rgba(56,189,248,0.7);
}
.chart-stats { display: flex; gap: 8px; }
.stat-pill {
  font-size: 0.72rem; color: var(--text-secondary);
  background: rgba(255,255,255,0.04); padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border-card);
}
.chart-container { width: 100%; height: 160px; position: relative; }
#latencyCanvas { width: 100%; height: 100%; display: block; }

/* ===== UPTIME GRID ===== */
.grid-legend { display: flex; align-items: center; gap: 10px; font-size: 0.7rem; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.dot-op { background: var(--color-green); }
.dot-deg { background: var(--color-yellow); }
.dot-out { background: var(--color-red); }
.dot-nodata { background: var(--color-nodata); }
.uptime-grid-wrapper { display: flex; flex-direction: column; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.uptime-grid {
  display: grid; grid-template-columns: repeat(90, 1fr);
  gap: 2px; height: 32px; align-items: center; min-width: 320px;
}
.grid-bar {
  height: 100%; border-radius: 2px; cursor: pointer;
  transition: transform 0.15s, opacity 0.15s; min-width: 2px;
}
.grid-bar:hover { transform: scaleY(1.2); opacity: 0.85; }
.grid-bar.operational { background: var(--color-green); }
.grid-bar.degraded { background: var(--color-yellow); }
.grid-bar.outage { background: var(--color-red); }
.grid-bar.no_data { background: var(--color-nodata); }
.grid-time-labels {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.7rem; color: var(--text-muted);
}
.grid-line { flex: 1; height: 1px; background: var(--border-card); margin: 0 12px; }

/* ===== INCIDENTS ===== */
.incident-list { display: flex; flex-direction: column; gap: 10px; }
.no-incidents {
  display: flex; align-items: center; gap: 8px; padding: 14px;
  background: rgba(16,185,129,0.05); border: 1px dashed rgba(16,185,129,0.3);
  border-radius: 10px; color: var(--color-green); font-size: 0.82rem;
}
.incident-item {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px; background: rgba(255,255,255,0.02); border: 1px solid var(--border-card);
  border-radius: 10px; gap: 10px;
}
.incident-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.incident-header-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.incident-title { font-size: 0.88rem; font-weight: 600; }
.incident-badge { font-size: 0.65rem; font-weight: 600; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.incident-badge.resolved { background: rgba(16,185,129,0.15); color: var(--color-green); }
.incident-badge.active { background: rgba(239,68,68,0.15); color: var(--color-red); }
.incident-details { font-size: 0.75rem; color: var(--text-secondary); word-break: break-word; }
.incident-time { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }

/* ===== FOOTER ===== */
.site-footer { position: relative; z-index: 1; text-align: center; padding: 16px 0 8px; font-size: 0.75rem; color: var(--text-muted); }
.footer-content { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* ===== TOOLTIP ===== */
.tooltip {
  position: fixed; pointer-events: none; background: #0F172A;
  border: 1px solid var(--border-card-bright); padding: 6px 10px; border-radius: 6px;
  font-size: 0.72rem; color: var(--text-primary);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5); z-index: 9999;
  display: none; white-space: nowrap; transform: translate(-50%, -100%);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app-container { padding: 10px 8px 36px; }
  .site-header { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 12px; }
  .header-controls { justify-content: flex-end; }
  .hero-card { flex-direction: column; align-items: flex-start; padding: 16px; gap: 12px; }
  .hero-status-icon-wrapper { width: 48px; height: 48px; }
  .hero-status-icon { width: 38px; height: 38px; }
  .hero-title { font-size: 1.05rem; }
  .hero-meta { font-size: 0.72rem; }
  .hide-mobile { display: none; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { padding: 10px 12px; }
  .metric-val { font-size: 1.25rem; }
  .metric-title { font-size: 0.65rem; }
  .section-card { padding: 12px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .card-title { font-size: 0.85rem; }
  .chart-container { height: 120px; }
  .uptime-grid { height: 26px; }
  .grid-legend { gap: 6px; font-size: 0.62rem; }
  .incident-item { flex-direction: column; gap: 6px; }
  .incident-time { align-self: flex-end; }
  .footer-content { font-size: 0.68rem; }
}

@media (max-width: 380px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
