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

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #7d8590;
  --blue:      #58a6ff;
  --green:     #3fb950;
  --red:       #f85149;
  --yellow:    #e3b341;
  --purple:    #bc8cff;
  --orange:    #ffa657;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Header ─────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: sticky;
  top: 1.25rem;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon { font-size: 1.4rem; }

.clock-time {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.clock-date {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  text-transform: capitalize;
}

/* ── Section ─────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.section-icon { font-size: 1rem; }

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.refresh-badge {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Metrics grid ────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 900px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .metrics-grid { grid-template-columns: 1fr; } }

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  transition: border-color 0.2s, transform 0.15s;
}

.metric-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
}

/* Gauge SVG */
.gauge-wrap {
  position: relative;
  width: 110px;
  height: 110px;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 2.5;
}

.gauge-fill {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.7s ease, stroke 0.4s ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.gauge-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gauge-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

/* Network card */
.metric-card--net { justify-content: center; }

.net-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.net-rows {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.net-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.net-arrow {
  font-weight: 700;
  font-size: 1rem;
}
.net-down { color: var(--green); }
.net-up   { color: var(--blue); }

.net-label { flex: 1; color: var(--muted); font-size: 0.78rem; }

.net-val {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 70px;
  text-align: right;
}

/* ── Services ────────────────────────────────── */
.services-summary {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem;
}

.service-skeleton {
  height: 68px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1;   }
}

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
  cursor: default;
}

.service-card[href] { cursor: pointer; }

.service-card:hover {
  border-color: var(--blue);
  background: var(--surface2);
  transform: translateY(-1px);
}

.service-icon { font-size: 1.6rem; flex-shrink: 0; }

.service-info { flex: 1; min-width: 0; }

.service-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.service-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}

.status-dot.up {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.down {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1;   box-shadow: 0 0 4px var(--green); }
  50%       { opacity: 0.7; box-shadow: 0 0 12px var(--green); }
}

/* ── Bottom grid ─────────────────────────────── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 1rem;
}

@media (max-width: 1100px) { .bottom-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px)  { .bottom-grid { grid-template-columns: 1fr; } }

/* ── Card ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.card-subtitle {
  margin-left: auto;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 400;
}

/* ── Weather ─────────────────────────────────── */
.weather-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.weather-icon { font-size: 3rem; line-height: 1; }

.weather-temp {
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.weather-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.weather-row:last-child { border-bottom: none; }
.weather-row span:last-child { font-weight: 600; }

/* ── Proxmox ─────────────────────────────────── */
.proxmox-node-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.vm-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 240px;
  overflow-y: auto;
}

.vm-list::-webkit-scrollbar { width: 4px; }
.vm-list::-webkit-scrollbar-track { background: transparent; }
.vm-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.vm-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.8rem;
}

.vm-badge {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 700;
  background: var(--blue);
  color: #fff;
  flex-shrink: 0;
}

.vm-badge.ct { background: var(--purple); }

.vm-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vm-status-text { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }

/* ── Quick links ─────────────────────────────── */
.links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.link-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.75rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.75rem;
  text-align: center;
  font-weight: 500;
  transition: all 0.2s;
}

.link-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--surface);
  transform: translateY(-1px);
}

.link-icon { font-size: 1.4rem; line-height: 1; }

/* ── Utilities ───────────────────────────────── */
.muted-text { color: var(--muted); font-size: 0.82rem; }
.error-text { color: var(--red);   font-size: 0.82rem; }
