/* ===== Base page ===== */

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  margin: 0;
  background: radial-gradient(circle at 15% 10%, #edf4ff 0%, #f5f8ff 30%, #eef2f8 100%);
  color: #1b2a41;
}


/* ===== Main container ===== */

.container {
  max-width: 980px;
  margin: 48px auto;
  padding: 28px;
}


/* ===== Titles ===== */

.title {
  font-size: clamp(2rem, 3.4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.subtitle {
  color: #4d5f7d;
  margin-bottom: 30px;
  max-width: 560px;
}


/* ===== Device grid ===== */

.devices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
  align-items: stretch;
}


/* ===== Device card ===== */

.device-card {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  min-height: 270px;
  background: linear-gradient(170deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid #d7e4ff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(20, 43, 92, 0.08);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.device-card.is-stale {
  opacity: 0.72;
  filter: grayscale(0.25);
}

.device-card.is-stale .value-block {
  background: linear-gradient(180deg, #f1f3f6 0%, #eceff3 100%);
  border-color: #d4d9e2;
}

.device-card.is-stale .value {
  color: #64748b;
}

.device-card.is-stale .quality-label {
  opacity: 0.72;
}


/* ===== Device header ===== */

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  /* Reserve space for up to a 2-line device name (clamped). */
  min-height: 76px;
  gap: 12px;
  min-width: 0;
}

.meta-pair {
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
}

.meta-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6780a8;
  margin-bottom: 6px;
}

.device-name {
  display: block;
  max-width: 100%;
  font-weight: 700;
  font-size: 1.08rem;
  color: #152643;
  line-height: 1.25;
  /* Show more of long device names without growing the card. */
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: calc(1.25em * 2);
}


/* ===== Status badges ===== */

.badge {
  min-width: 72px;
  text-align: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-sizing: border-box;
  flex-shrink: 0;
  margin-left: auto;
}

.badge.live {
  background: #dcfce7;
  color: #0f5132;
}

.badge.stale {
  background: #e5e7eb;
  color: #4b5563;
}

.badge.disconnected {
  background: #e5e7eb;
  color: #374151;
}

/* ===== Air quality class ===== */

.quality-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  text-align: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.quality-row {
  margin-top: 8px;
  display: flex;
  justify-content: center;
}

.quality-label.force {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  color: #b91c1c;
  border-color: #fca5a5;
}

.quality-label.high {
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: #c2410c;
  border-color: #fdba74;
}

.quality-label.low {
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  color: #6d28d9;
  border-color: #c4b5fd;
}

.quality-label.fresh {
  background: linear-gradient(180deg, #ecfeff 0%, #cffafe 100%);
  color: #0f766e;
  border-color: #67e8f9;
}

.quality-label.unknown {
  background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
  color: #4b5563;
  border-color: #d1d5db;
}

/* ===== Sensor value ===== */

.value-block {
  background: linear-gradient(180deg, #f6f9ff 0%, #f0f5ff 100%);
  border: 1px solid #e2ebff;
  border-radius: 14px;
  padding: 14px;
}

.value-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0;
  min-height: 72px;
}

.value {
  font-size: 3.15rem;
  font-weight: 800;
  line-height: 1;
  margin: 0;
  color: #132543;
}

/* ===== Timestamp ===== */

.measurement-block {
  border-top: 1px solid #e5edff;
  padding-top: 14px;
}

.measurement-date {
  font-size: 1rem;
  font-weight: 700;
  color: #1f3356;
  margin-bottom: 8px;
}

.measurement-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  color: #5d7297;
  min-height: 22px;
  gap: 8px;
}

.measurement-time {
  white-space: nowrap;
}

.measurement-age {
  white-space: nowrap;
  font-weight: 700;
}


/* ===== Empty state ===== */

.empty {
  text-align: center;
  padding: 64px 20px;
  color: #51627f;
  font-size: 1rem;
  border: 1px dashed #c5d6f7;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

@media (max-width: 640px) {
  .container {
    margin: 30px auto;
    padding: 18px;
  }

  .device-card {
    min-height: 250px;
  }

  .value {
    font-size: 2.75rem;
  }
}
