* {
  box-sizing: border-box;
}


html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
}


body {
  font-family:
    Arial,
    sans-serif;

  background: #f3f4f6;
  color: #1f2937;
}


button,
select {
  font: inherit;
}


.topbar {
  position: sticky;
  top: 0;
  z-index: 10;

  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 15px;

  padding:
    18px
    max(16px, calc((100vw - 1000px) / 2));

  background: white;
  border-bottom: 1px solid #e5e7eb;
}


.topbar h1 {
  margin: 0;
  font-size: 25px;
}


.topbar p {
  margin: 5px 0 0;

  color: #6b7280;
  font-size: 14px;
}


.status-badge {
  padding: 8px 12px;

  border-radius: 20px;

  font-size: 12px;
  font-weight: 700;
}


.status-badge.checking {
  background: #e5e7eb;
  color: #4b5563;
}


.status-badge.online {
  background: #dcfce7;
  color: #166534;
}


.status-badge.offline {
  background: #fee2e2;
  color: #991b1b;
}


.page {
  width: 100%;
  max-width: 1000px;

  margin: 0 auto;

  padding: 20px 16px 30px;
}


.sensors {
  display: grid;

  grid-template-columns:
    repeat(
      auto-fit,
      minmax(280px, 1fr)
    );

  gap: 14px;
}


.sensor-card {
  width: 100%;

  text-align: left;

  padding: 18px;

  background: white;

  border:
    2px solid
    transparent;

  border-radius: 16px;

  cursor: pointer;

  box-shadow:
    0 2px 8px
    rgba(0, 0, 0, 0.06);

  transition:
    transform 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
}


.sensor-card:hover {
  transform: translateY(-1px);

  box-shadow:
    0 5px 14px
    rgba(0, 0, 0, 0.09);
}


.sensor-card.selected {
  border-color: #2563eb;
}


.sensor-top {
  display: flex;

  justify-content:
    space-between;

  align-items:
    flex-start;

  gap: 10px;
}


.sensor-name {
  font-size: 16px;
  font-weight: 700;
}


.sensor-ip {
  margin-top: 5px;

  color: #9ca3af;

  font-size: 12px;
}


.sensor-status {
  display: flex;

  align-items: center;

  gap: 5px;

  white-space: nowrap;

  font-size: 11px;
  font-weight: 700;
}


.sensor-status.online {
  color: #15803d;
}


.sensor-status.offline {
  color: #b91c1c;
}


.dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  background: currentColor;
}


.sensor-temperature {
  margin-top: 24px;

  font-size: 42px;
  line-height: 1;

  font-weight: 700;
}


.sensor-time {
  margin-top: 12px;

  color: #6b7280;

  font-size: 12px;
}


.history-panel {
  margin-top: 18px;

  padding: 18px;

  background: white;

  border-radius: 16px;

  box-shadow:
    0 2px 8px
    rgba(0, 0, 0, 0.06);
}


.history-header {
  display: flex;

  align-items: center;

  justify-content:
    space-between;

  gap: 15px;
}


.history-header h2 {
  margin: 0;

  font-size: 18px;
}


.history-header p {
  margin: 5px 0 0;

  color: #6b7280;

  font-size: 13px;
}


#historyHours {
  min-height: 40px;

  padding: 8px 10px;

  border:
    1px solid
    #d1d5db;

  border-radius: 9px;

  background: white;
}


.chart-wrap {
  width: 100%;

  margin-top: 18px;

  overflow: hidden;
}


#chart {
  display: block;

  width: 100%;
  height: 300px;

  overflow: visible;
}


.grid-line {
  stroke: #e5e7eb;
  stroke-width: 1;
}


.axis-label {
  fill: #6b7280;

  font-size: 12px;
}


.chart-line {
  fill: none;

  stroke: #2563eb;

  stroke-width: 3;

  stroke-linecap:
    round;

  stroke-linejoin:
    round;
}


.chart-point {
  fill: #2563eb;
}


.chart-info {
  margin-top: 8px;

  color: #6b7280;

  font-size: 12px;
}


.loading,
.empty {
  padding: 35px 20px;

  text-align: center;

  color: #6b7280;

  background: white;

  border-radius: 16px;
}


.footer {
  width: 100%;

  padding:
    0 16px
    25px;

  text-align: center;

  color: #9ca3af;

  font-size: 12px;
}


@media (max-width: 600px) {

  .topbar {
    padding: 14px;
  }


  .topbar h1 {
    font-size: 21px;
  }


  .topbar p {
    font-size: 12px;
  }


  .page {
    padding:
      12px
      12px
      25px;
  }


  .sensors {
    grid-template-columns:
      1fr;
  }


  .sensor-card {
    padding: 15px;
  }


  .sensor-temperature {
    font-size: 38px;
  }


  .history-panel {
    padding: 14px;
  }


  .history-header {
    align-items:
      flex-start;

    flex-direction:
      column;
  }


  #historyHours {
    width: 100%;
  }


  #chart {
    height: 230px;
  }

}

.sensor-card.selected {
  border: 2px solid #2563eb;
}

.sensor-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.sensor-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.sensor-status.online {
  color: #15803d;
}

.sensor-status.offline {
  color: #b91c1c;
}

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

.sensor-ip {
  margin-top: 5px;
  color: #9ca3af;
  font-size: 12px;
}

.chart-wrap {
  width: 100%;
  margin-top: 18px;
  overflow: hidden;
}

#chart {
  display: block;
  width: 100%;
  height: 320px;
}

.grid-line {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.axis-label {
  fill: #6b7280;
  font-size: 12px;
}

.chart-line {
  fill: none;
  stroke: #2563eb;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: #2563eb;
}

.chart-info {
  margin-top: 10px;
  color: #6b7280;
  font-size: 12px;
}

.empty {
  padding: 30px;
  text-align: center;
  background: white;
  border-radius: 16px;
  color: #6b7280;
}

@media (max-width: 600px) {

  #chart {
    height: 250px;
  }

  .sensor-temperature {
    margin-top: 18px;
  }

}
