.field-sensors,
.sensor-section,
.sensor-card-grid,
.sensor-metric-card,
.sensor-history,
.sensor-history-panel,
.sensor-chart {
  min-width: 0;
  max-width: 100%;
}

.field-sensors {
  width: min(1180px, calc(100% - 24px));
  margin: 20px auto;
  color: #17231c;
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sensor-section {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid #dfe9e3;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(19, 83, 53, .08);
}

.sensor-section h2 { margin: 0 0 14px; font-size: 24px; }
.sensor-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sensor-metric-card { padding: 16px; border: 1px solid #dfe9e3; border-radius: 14px; background: #f8fbf9; overflow: hidden; }
.sensor-metric-card h3 { min-height: 2.8em; margin: 0 0 10px; font-size: 17px; overflow-wrap: anywhere; }
.sensor-value { color: #155f3d; font-size: clamp(30px, 5vw, 42px); font-weight: 850; line-height: 1.1; overflow-wrap: anywhere; }
.sensor-value span { font-size: .48em; font-weight: 750; }
.sensor-state, .sensor-timestamp { margin: 8px 0 0; color: #637268; font-size: 13px; }
.sensor-planned-offline { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #fff6d7; color: #705200; font-weight: 750; }
.sensor-metric-card.is-planned-offline { background: #fffdf5; }
.sensor-history { margin-top: 14px; }
.sensor-history button { min-height: 44px; border: 1px solid #218557; border-radius: 10px; background: #fff; color: #155f3d; font: inherit; font-weight: 750; padding: 9px 12px; cursor: pointer; }
.sensor-history-toggle { width: 100%; }
.sensor-history-panel { margin-top: 10px; }
.sensor-periods { display: flex; flex-wrap: wrap; gap: 7px; }
.sensor-periods button { flex: 1 1 80px; }
.sensor-periods button.is-active { background: #218557; color: #fff; }
.sensor-chart { width: 100%; min-height: 170px; margin-top: 10px; overflow: hidden; }
.sensor-chart svg { display: block; width: 100%; max-width: 100%; height: auto; }
.sensor-chart-status { min-height: 1.45em; margin: 8px 0 0; color: #637268; font-size: 13px; }

/* Embedded Asterousia dashboard: continue the native classic weather-panel UI. */
.asterousia-sensor-panel,
.asterousia-sensor-groups,
.asterousia-sensor-subgroup,
.asterousia-sensor-grid,
.asterousia-sensor-metric {
  min-width: 0;
  max-width: 100%;
}

.asterousia-sensor-groups { display: grid; }
.asterousia-sensor-subgroup + .asterousia-sensor-subgroup { border-top: 1px solid #777; }
.asterousia-sensor-subgroup-title {
  margin: 0;
  padding: 5px 10px;
  border-bottom: 1px solid #bdbdbd;
  background: #fff;
  color: #222;
  font: bold 12px/1.35 Arial, Verdana, sans-serif;
  text-align: left;
}
.asterousia-sensor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.asterousia-sensor-metric {
  display: flex;
  flex-direction: column;
  min-height: 136px;
  padding: 8px 10px;
  border-bottom: 1px solid #c4c4c4;
  background: #fff;
  color: #222;
  font: 12px/1.35 Arial, Verdana, sans-serif;
  overflow: hidden;
}
.asterousia-sensor-metric:nth-child(odd) { background: #eee; }
.asterousia-sensor-metric:not(:nth-child(3n)) { border-right: 1px solid #c4c4c4; }
.asterousia-sensor-metric h4 {
  min-height: 2.7em;
  margin: 0 0 6px;
  color: #222;
  font: bold 12px/1.35 Arial, Verdana, sans-serif;
  overflow-wrap: anywhere;
}
.sensor-weather-value {
  min-height: 1.4em;
  color: #222;
  font: bold 12px/1.25 Arial, Verdana, sans-serif;
  overflow-wrap: anywhere;
}
.sensor-weather-timestamp,
.sensor-weather-state {
  margin: 5px 0 0;
  color: #666;
  font: 11px/1.35 Arial, Verdana, sans-serif;
  overflow-wrap: anywhere;
}
.asterousia-sensor-offline {
  margin: 0;
  padding: 7px 10px;
  border-bottom: 1px solid #bdbdbd;
  background: #fff6d7;
  color: #705200;
  font: bold 12px/1.35 Arial, Verdana, sans-serif;
  text-align: center;
}
.asterousia-sensor-metric.is-planned-offline { background: #fffdf5; }
.asterousia-sensor-panel .sensor-history { margin-top: auto; padding-top: 7px; }
.asterousia-sensor-panel .sensor-history-modal-open {
  min-height: 30px;
  border: 1px solid #777;
  border-radius: 2px;
  background: linear-gradient(to bottom, #fff, #ddd);
  color: #222;
  font: 11px Arial, Verdana, sans-serif;
  font-weight: normal;
  padding: 4px 7px;
}

body.sensor-history-modal-open { overflow: hidden; }
.sensor-history-modal,
.sensor-history-modal-backdrop,
.sensor-history-modal-dialog,
.sensor-history-modal-body,
.sensor-history-modal-chart { min-width: 0; max-width: 100%; }
.sensor-history-modal[hidden] { display: none; }
.sensor-history-modal {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100dvh;
  padding: 5vh 5vw;
  box-sizing: border-box;
  font-family: Arial, Verdana, sans-serif;
}
.sensor-history-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 27, 22, .68);
}
.sensor-history-modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1000px, 90vw);
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid #555;
  border-radius: 4px;
  background: #fff;
  color: #222;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.sensor-history-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid #777;
  background: linear-gradient(to bottom, #fafafa, #e8e8e8);
}
.sensor-history-modal-heading { min-width: 0; }
.sensor-history-modal-heading h2 { margin: 0; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.sensor-history-modal-heading p { margin: 4px 0 0; color: #666; font-size: 13px; overflow-wrap: anywhere; }
.sensor-history-modal-x {
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  border: 1px solid #777;
  border-radius: 2px;
  background: #fff;
  color: #222;
  font: 28px/1 Arial, sans-serif;
  cursor: pointer;
}
.sensor-history-modal-body { overflow: auto; padding: 16px; overscroll-behavior: contain; }
.sensor-history-modal-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; margin-bottom: 12px; color: #555; font-size: 13px; }
.sensor-history-modal-periods { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sensor-history-modal-periods button,
.sensor-history-modal-retry,
.sensor-history-modal-footer button {
  min-height: 44px;
  border: 1px solid #777;
  border-radius: 2px;
  background: linear-gradient(to bottom, #fff, #ddd);
  color: #222;
  padding: 8px 16px;
  font: 14px Arial, Verdana, sans-serif;
  cursor: pointer;
}
.sensor-history-modal-periods button.is-active { border-color: #155f3d; background: #218557; color: #fff; font-weight: bold; }
.sensor-history-modal-chart {
  width: 100%;
  min-height: 360px;
  margin: 0;
  overflow: hidden;
  border: 1px solid #c4c4c4;
  background: #fafafa;
}
.sensor-history-modal-chart svg { display: block; width: 100%; max-width: 100%; height: min(50vh, 420px); }
.sensor-history-modal-status { min-height: 1.5em; margin: 10px 0 0; color: #555; font-size: 14px; }
.sensor-history-modal-retry { margin-top: 8px; }
.sensor-history-modal-footer { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid #aaa; background: #eee; }
.sensor-history-modal-dialog :focus-visible { outline: 3px solid #e0a800; outline-offset: 2px; }

@media (max-width: 900px) {
  .sensor-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sensor-history-modal { padding: 3vh 3vw; }
  .sensor-history-modal-dialog { width: 94vw; max-height: 94vh; }
}

@media (max-width: 480px) {
  .field-sensors { width: calc(100% - 16px); }
  .sensor-section { padding: 12px; }
  .sensor-card-grid { grid-template-columns: minmax(0, 1fr); }
  .sensor-metric-card h3 { min-height: 0; }
  .asterousia-sensor-grid { grid-template-columns: minmax(0, 1fr); }
  .asterousia-sensor-metric,
  .asterousia-sensor-metric:not(:nth-child(3n)) { border-right: 0; }
  .asterousia-sensor-metric h4 { min-height: 0; }
  .sensor-history-modal { place-items: end stretch; padding: 0; }
  .sensor-history-modal-dialog { width: 100%; max-width: 100%; max-height: 100dvh; border-radius: 0; }
  .sensor-history-modal-header { padding: 12px; }
  .sensor-history-modal-body { padding: 12px; }
  .sensor-history-modal-periods button { flex: 1 1 0; min-width: 0; padding-inline: 5px; }
  .sensor-history-modal-chart { min-height: 280px; }
  .sensor-history-modal-chart svg { height: min(42vh, 320px); }
}
