.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.module {
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.module:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.module::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--module-accent, var(--accent)), transparent);
  opacity: 0.6;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.module-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.module-icon {
  font-size: 1.1rem;
}

.module-body {
  font-family: var(--font-mono);
}

/* System Module */
.sys-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.82rem;
}

.sys-stat .label { color: var(--text-muted); }
.sys-stat .value { font-weight: 500; }

.progress-bar {
  height: 6px;
  background: var(--hover-bg);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.warn { background: linear-gradient(90deg, var(--warning), #f97316); }
.progress-fill.danger { background: linear-gradient(90deg, var(--danger), #ef4444); }

/* Services Module */
.service-list {
  list-style: none;
}

.service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.82rem;
}

.service-item:last-child { border-bottom: none; }

.service-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.service-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.service-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding-left: 1.6rem; /* roughly aligns under the name text, past the icon */
}

.service-sub.warn { color: var(--warning); }
.service-sub.danger { color: var(--danger); }

.service-status {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-weight: 500;
}

.service-status.running {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.service-status.stopped {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

/* Quick Links */
.quick-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.82rem;
  transition: var(--transition);
}

.quick-link:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateX(2px);
}

/* Activity Feed */
.activity-item {
  display: flex;
  gap: 0.65rem;
  padding: 0.5rem 0;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--glass-border);
}

.activity-item:last-child { border-bottom: none; }

.activity-time {
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-width: 3.5rem;
  flex-shrink: 0;
}

.activity-msg { color: var(--text-secondary); }

/* Weather / Time Module */
.big-stat {
  font-size: 2.5rem;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.big-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.uptime-display {
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--accent);
}

.offline-note {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--danger);
  font-family: var(--font-mono);
}

.schedule-note {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

@media (max-width: 640px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Visitors module */
#visitor-stats-body {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.visitor-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.visitor-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.visitor-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  text-align: center;
}

/* ---- Phone refinements ---- */
@media (max-width: 768px) {
  /* Single column — two columns of stats on a phone is unreadable. */
  .dashboard-grid { grid-template-columns: 1fr; gap: 0.85rem; }

  .module { padding: 0.9rem; }

  /* Quick links become full-width rows with proper touch targets rather
     than small inline chips that are fiddly to hit accurately. */
  .quick-links { flex-direction: column; }
  .quick-link {
    width: 100%;
    justify-content: flex-start;
    min-height: 44px;
    padding: 0.7rem 0.9rem;
  }

  .service-item { padding: 0.7rem 0; }

  /* Long service names and cert subtitles shouldn't push the status pill
     off the edge of a narrow screen. */
  .service-name-wrap { min-width: 0; flex: 1; }
  .service-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .service-status { flex-shrink: 0; }
}
