/* ===== Layout ===== */
:root {
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-sidebar: #010409;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #3b82f6;
  --success: #3fb950;
  --danger: #f85149;
  --warning: #d29922;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 0; }

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

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(13,17,23,0.74), rgba(13,17,23,0.84)),
    var(--auth-bg-image, radial-gradient(circle at top, rgba(59,130,246,0.14), transparent 34%)),
    var(--bg);
  background-size: cover;
  background-position: center;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 1.1rem;
}

.auth-brand i {
  color: var(--accent);
  font-size: 1.3rem;
}

.login-bg-preview {
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-size: cover;
  background-position: center;
}

.settings-tabs {
  gap: 8px;
}

.settings-tabs .nav-link {
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}

.settings-tabs .nav-link:hover {
  color: var(--text);
  border-color: rgba(59,130,246,0.45);
}

.settings-tabs .nav-link.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sidebar-brand i { font-size: 1.2rem; color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.sidebar-nav .nav-link.active { background: rgba(59,130,246,0.15); color: var(--accent); }
.sidebar-nav .nav-link i { font-size: 0.95rem; flex-shrink: 0; }

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

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
}

/* ===== Main content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
}

.content-body { padding: 24px; }

/* ===== Cards ===== */
.bg-card { background: var(--bg-card) !important; border-color: var(--border) !important; }
.card { border: 1px solid var(--border); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 12px 16px;
}
.table-dark { --bs-table-bg: transparent; --bs-table-border-color: var(--border); }
.table-hover > tbody > tr:hover { --bs-table-hover-bg: rgba(255,255,255,0.04); }

/* ===== Monitor cards ===== */
.monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
}
.monitor-card.border-success { border-color: rgba(63,185,80,0.4) !important; }
.monitor-card.border-danger  { border-color: rgba(248,81,73,0.4) !important; }

.monitor-card-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.monitor-card-body   { padding: 12px 16px; flex: 1; }
.monitor-card-footer { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stat-row:last-child { border-bottom: none; }

/* ===== Status dots ===== */
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}
.status-dot.up      { background: var(--success); }
.status-dot.down    { background: var(--danger); animation: none; }
.status-dot.nodata  { background: var(--text-muted); animation: none; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(63,185,80,0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(63,185,80,0); }
}

/* ===== Stat cards ===== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.stat-card-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.stat-card-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-card-sub   { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Uptime calendar ===== */
.uptime-calendar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.cal-day {
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}
.cal-day.up       { background: var(--success); }
.cal-day.degraded { background: var(--warning); }
.cal-day.down     { background: var(--danger); }
.cal-day.nodata   { background: var(--border); }

/* ===== Security header badges ===== */
.header-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.header-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.header-badge.ok   { background: rgba(63,185,80,0.15); color: var(--success); border: 1px solid rgba(63,185,80,0.3); }
.header-badge.fail { background: rgba(248,81,73,0.15); color: var(--danger);  border: 1px solid rgba(248,81,73,0.3); }

/* ===== Score grade ===== */
.score-grade {
  font-size: 1.8rem;
  font-weight: 900;
  width: 48px; height: 48px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.grade-A { background: rgba(63,185,80,0.2); color: var(--success); }
.grade-B { background: rgba(63,185,80,0.12); color: #7ee787; }
.grade-C { background: rgba(210,153,34,0.2); color: var(--warning); }
.grade-D { background: rgba(248,81,73,0.15); color: #ffa198; }
.grade-F { background: rgba(248,81,73,0.25); color: var(--danger); }

/* ===== World map ===== */
#world-map {
  height: 380px;
  border-radius: 0 0 8px 8px;
  z-index: 1;
}
.leaflet-container { background: #1a2030; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
}
