:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #111726;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(28, 38, 59, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-card-hover: rgba(99, 102, 241, 0.4);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --status-online: #10b981;
  --status-degraded: #f59e0b;
  --status-offline: #ef4444;
  --status-unknown: #6b7280;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(139, 92, 246, 0.08) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* Header & Navbar */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-card);
  margin-bottom: 2.5rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.logo-badge {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.logo-badge svg {
  width: 28px;
  height: 28px;
  stroke: #ffffff;
}

.brand-info h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  font-size: 0.8rem;
  font-weight: 500;
  backdrop-filter: blur(8px);
}

.tailscale-badge.active {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.tailscale-badge.inactive {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-pill {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

.user-pill svg {
  stroke: #818cf8;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 9999px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-logout svg {
  stroke: currentColor;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: pulseAura 2s infinite ease-in-out;
}

@keyframes pulseAura {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* Control Bar (Search, Filters, Refresh) */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.search-box {
  position: relative;
  min-width: 280px;
  flex: 1;
  max-width: 400px;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.6rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-indigo);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-box svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--text-dim);
}

.filter-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover, .filter-btn.active {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-refresh svg {
  width: 16px;
  height: 16px;
}

.btn-refresh.spinning svg {
  animation: spin 1s linear infinite;
}

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

/* Category Sections */
.category-section {
  margin-bottom: 2.75rem;
}

.category-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.category-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.category-desc {
  font-size: 0.825rem;
  color: var(--text-dim);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
}

.service-card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.6), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.service-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: var(--border-card-hover);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.service-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.card-identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.icon-wrapper svg {
  width: 22px;
  height: 22px;
}

.service-name {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
}

.badge-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.badge-tag.tailscale {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--status-unknown);
}

.status-online .status-dot {
  background-color: var(--status-online);
  box-shadow: 0 0 8px var(--status-online);
}

.status-degraded .status-dot {
  background-color: var(--status-degraded);
  box-shadow: 0 0 8px var(--status-degraded);
}

.status-offline .status-dot {
  background-color: var(--status-offline);
  box-shadow: 0 0 8px var(--status-offline);
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1.25rem;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.775rem;
  color: var(--text-dim);
}

.latency-metric {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.latency-metric svg {
  width: 14px;
  height: 14px;
}

.action-link {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent-indigo);
  font-weight: 500;
}

.action-link svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.service-card:hover .action-link svg {
  transform: translateX(3px);
}

/* Uptime Global Badge (Header) */
.uptime-badge {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.uptime-badge .pulse-dot {
  color: #10b981;
}

/* Uptime Section inside Service Cards */
.uptime-section {
  margin-top: auto;
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.service-card:hover .uptime-section {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.07);
}

.uptime-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.725rem;
  margin-bottom: 0.45rem;
}

.uptime-label {
  color: var(--text-muted);
  font-weight: 500;
}

.uptime-percent {
  font-weight: 600;
  color: #34d399;
  letter-spacing: -0.01em;
}

.uptime-percent.degraded {
  color: #fbbf24;
}

.uptime-percent.down {
  color: #f87171;
}

.uptime-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 14px;
  width: 100%;
}

.uptime-bar {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, filter 0.15s ease;
  position: relative;
  cursor: pointer;
}

.uptime-bar:hover {
  transform: scaleY(1.35) scaleX(1.1);
  z-index: 2;
  filter: brightness(1.25);
}

.uptime-bar.online {
  background: #10b981;
}

.uptime-bar.degraded {
  background: #f59e0b;
}

.uptime-bar.down {
  background: #ef4444;
}

.uptime-bar.nodata {
  background: rgba(255, 255, 255, 0.07);
}

.uptime-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-card);
  text-align: center;
  font-size: 0.825rem;
  color: var(--text-dim);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent-cyan);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    padding: 1.5rem 1rem;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: none;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
}
