:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #101729;
  --muted: #647086;
  --line: #e4e9f1;
  --green: #0aa34f;
  --green-dark: #07843f;
  --green-soft: #e6f7ed;
  --blue: #1167f2;
  --blue-soft: #e9f1ff;
  --cyan: #0fb6c8;
  --cyan-soft: #e5fbfd;
  --yellow: #f3b33d;
  --yellow-soft: #fff5dc;
  --red: #d94848;
  --red-soft: #ffe9e9;
  --shadow: 0 18px 55px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(10, 163, 79, 0.08), transparent 32rem),
    linear-gradient(180deg, #fbfcfe 0%, var(--bg) 58%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.layout {
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main-content {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px 14px 92px;
  overflow-x: hidden;
}

.page,
.dashboard-page,
.chart-grid,
.dashboard-bottom,
.content-grid,
.sensor-grid {
  min-width: 0;
}

.topbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.page-heading {
  min-width: 0;
}

.mobile-title-icon {
  display: none;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.status-pill {
  min-height: 56px;
  display: grid;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.05);
}

.status-pill b {
  font-size: 12px;
}

.status-pill small {
  color: var(--muted);
  font-weight: 800;
}

.status-pill.ok small {
  color: var(--green);
}

.status-pill.bad small {
  color: var(--red);
}

.status-pill.warn small {
  color: #926312;
}

.status-pill.neutral small {
  color: var(--muted);
}

.dashboard-page {
  display: grid;
  gap: 20px;
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sensor-card,
.panel-card,
.chart-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  min-width: 0;
}

.sensor-card {
  min-height: 164px;
  display: grid;
  gap: 8px;
  padding: 16px;
  overflow: hidden;
}

.sensor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3a4659;
  font-size: 13px;
  font-weight: 850;
}

.sensor-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  flex: 0 0 44px;
}

.sensor-card.soil .sensor-icon,
.sensor-card.water .sensor-icon {
  background: var(--blue-soft);
  color: var(--blue);
}

.sensor-card.air .sensor-icon,
.sensor-card.rain .sensor-icon {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.sensor-card.pump .sensor-icon {
  background: var(--yellow-soft);
  color: #9a6500;
  font-family: "Segoe UI Symbol", "Segoe UI", system-ui, sans-serif;
}

.sensor-card.water .sensor-icon,
.sensor-card.pump .sensor-icon {
  font-size: 0;
}

.sensor-card.water .sensor-icon::before {
  content: "🛢️";
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 23px;
}

.sensor-card.pump .sensor-icon::before {
  content: "⚙️";
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 23px;
}

.sensor-value {
  margin-top: 4px;
  font-size: 34px;
  font-weight: 950;
  line-height: 1;
}

.sensor-value small {
  color: #3c4758;
  font-size: 18px;
}

.sensor-value.text {
  font-size: 28px;
}

.sensor-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.sensor-badge {
  width: fit-content;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0 0;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.1;
  text-align: center;
}

.sensor-badge.warn {
  background: var(--yellow-soft);
  color: #8b5a00;
}

.sensor-badge.bad {
  background: var(--red-soft);
  color: var(--red);
}

.sensor-card canvas {
  width: 100%;
  max-width: 100%;
  height: 48px;
  margin-top: auto;
  display: block;
}

.chart-grid {
  display: grid;
  gap: 14px;
}

.chart-card {
  padding: 16px;
  overflow: hidden;
  position: relative;
}

.chart-title,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chart-title h3,
.panel-heading h3,
.panel-card h3 {
  margin: 0;
  font-size: 17px;
}

.chart-title span {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
}

.chart-card canvas {
  width: 100%;
  max-width: 100%;
  height: 260px;
  display: block;
  touch-action: none;
}

.history-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.history-stat-card {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.05);
}

.history-stat-card div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.history-stat-card span,
.history-stat-card small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-stat-card strong {
  font-size: 28px;
  line-height: 1;
}

.history-stat-card i {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-style: normal;
  font-weight: 950;
}

.history-stat-card.soil i {
  background: var(--blue-soft);
  color: var(--blue);
}

.history-stat-card.temp i {
  background: var(--green-soft);
  color: var(--green-dark);
}

.history-stat-card.water i {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.history-stat-card.alert i {
  background: var(--yellow-soft);
  color: #8b5a00;
}

.history-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
  margin-top: 14px;
}

.history-period-events {
  grid-column: 1 / -1;
}

.soft-counter {
  min-width: 34px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
}

.history-cycle-list,
.history-insight-list {
  display: grid;
  gap: 10px;
}

.history-cycle-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px;
}

.cycle-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.cycle-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cycle-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cycle-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(66px, 1fr));
  gap: 8px;
}

.cycle-metrics span {
  min-height: 48px;
  display: grid;
  align-content: center;
  gap: 2px;
  border-radius: 12px;
  background: #ffffff;
  padding: 7px 9px;
  font-size: 14px;
  font-weight: 950;
  text-align: center;
}

.cycle-metrics b {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.cycle-metrics .positive {
  color: var(--green-dark);
}

.cycle-metrics .negative {
  color: var(--red);
}

.history-insight {
  display: grid;
  gap: 3px;
  border-left: 5px solid var(--green);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 12px;
}

.history-insight.warning {
  border-left-color: var(--yellow);
}

.history-insight.critical {
  border-left-color: var(--red);
}

.history-insight span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

.dashboard-bottom {
  display: grid;
  gap: 14px;
}

.panel-card {
  padding: 18px;
}

.overall-panel {
  display: grid;
  gap: 4px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--green-soft), #f8fffb);
  padding: 16px;
}

.overall-panel.regando {
  background: linear-gradient(135deg, var(--blue-soft), #f8fbff);
}

.overall-panel.bloqueado,
.overall-panel.desconectado {
  background: linear-gradient(135deg, var(--red-soft), #fffafa);
}

.overall-panel.aplazado {
  background: linear-gradient(135deg, var(--yellow-soft), #fffdf7);
}

.overall-panel strong {
  font-size: 24px;
}

.overall-panel span {
  color: var(--muted);
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.status-list div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: baseline;
}

.status-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.status-list dd {
  margin: 0;
  font-weight: 850;
}

.compact-events,
.events-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  gap: 3px;
  border-left: 5px solid var(--green);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 12px;
}

.event-item.warning {
  border-left-color: var(--yellow);
}

.event-item.critical {
  border-left-color: var(--red);
}

.event-item strong {
  font-size: 14px;
}

.event-item span,
.event-item time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.weather-summary {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 750;
}

.forecast-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  padding-bottom: 4px;
}

.forecast-day {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  padding: 12px;
  text-align: center;
}

.forecast-day strong {
  display: block;
  margin-bottom: 8px;
}

.weather-symbol {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border-radius: 16px;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 26px;
  line-height: 1;
}

.weather-symbol.sunny {
  background: #fff7d9;
}

.weather-symbol.partly {
  background: #ecf8ff;
}

.weather-symbol.cloudy {
  background: #eef3fa;
}

.weather-symbol.rainy {
  background: #e9f1ff;
}

.forecast-day .condition {
  color: var(--muted);
  min-height: 34px;
  font-size: 13px;
  font-weight: 800;
}

.forecast-day .temp {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 950;
}

.forecast-day .rain-line {
  margin-top: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  align-items: center;
  padding: 6px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.chart-legend button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
}

.chart-legend button.active {
  border-color: color-mix(in srgb, var(--legend-color) 42%, var(--line));
  background: color-mix(in srgb, var(--legend-color) 12%, #ffffff);
  color: var(--text);
}

.chart-legend button:disabled {
  cursor: default;
  opacity: 1;
}

.chart-legend i {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: var(--legend-color);
}

.irrigation-equipment-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.irrigation-equipment-card .danger {
  width: min(260px, 100%);
}

.chart-tooltip {
  position: fixed;
  z-index: 50;
  max-width: min(260px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.16);
  color: var(--text);
  padding: 9px 11px;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.chart-tooltip span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 120px;
  font-size: 12px;
  font-weight: 900;
}

.chart-tooltip b {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-weight: 900;
}

.chart-tooltip i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 999px;
  background: var(--tooltip-color);
  margin-right: 6px;
}

.content-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.sensor-calibration-card {
  margin-bottom: 14px;
}

.sensor-status-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.sensor-status-readout div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 11px 12px;
}

.sensor-status-readout dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.sensor-status-readout dd {
  margin: 0;
  font-weight: 900;
}

.button-stack,
.settings-form {
  display: grid;
  gap: 10px;
}

.calibration-actions {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.notification-actions {
  margin-top: 12px;
}

.calibration-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.calibration-readout div {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 12px;
}

.calibration-readout span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.calibration-readout strong {
  display: block;
  margin-top: 5px;
  color: var(--blue);
  font-size: 24px;
  line-height: 1;
}

.calibration-readout p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.calibration-readout p.warn {
  color: var(--red);
  font-weight: 900;
}

.settings-form label,
.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  color: var(--text);
  padding: 8px 11px;
}

.primary {
  background: linear-gradient(135deg, var(--green), #12bd60);
  color: #fff;
}

.secondary {
  background: var(--green-soft);
  color: var(--green-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger {
  background: var(--red);
  color: #fff;
}

.mini-button,
.small-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}

.muted,
.card-text,
.result-text {
  color: var(--muted);
}

.range-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.range-tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.range-tabs button.active {
  background: var(--green);
  color: #fff;
}

.full-chart canvas {
  height: 360px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.bottom-nav a {
  min-height: 62px;
  display: grid;
  place-content: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.bottom-nav a.active {
  color: var(--green);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 14px 0 6px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-weight: 950;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.full {
  width: 100%;
}

.form-error,
.form-warning {
  border-radius: 12px;
  padding: 10px 12px;
}

.form-error {
  background: var(--red-soft);
  color: var(--red);
}

.form-warning {
  background: var(--yellow-soft);
  color: #76500f;
}

@media (max-width: 599px) {
  .main-content {
    padding: 14px 10px 88px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-heading {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  .mobile-title-icon {
    width: 46px;
    height: 46px;
    display: block;
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(10, 163, 79, 0.16);
  }

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

  .topbar p {
    margin-top: 3px;
    font-size: 14px;
    line-height: 1.25;
  }

  .top-status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .status-pill {
    min-height: 50px;
    border-radius: 14px;
    padding: 8px 7px;
    box-shadow: 0 8px 22px rgba(23, 32, 51, 0.04);
  }

  .status-pill b {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-pill small {
    overflow: hidden;
    font-size: 12px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .sensor-card {
    min-height: 142px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "head value"
      "note note"
      "chart chart";
    gap: 8px 10px;
    padding: 14px;
  }

  .sensor-card.temperature,
  .sensor-card.soil,
  .sensor-card.air {
    min-height: 216px;
  }

  .sensor-head {
    grid-area: head;
    justify-self: start;
    max-width: 100%;
    gap: 7px;
    text-align: left;
    font-size: 14px;
    line-height: 1.15;
  }

  .sensor-head span:last-child {
    min-width: 0;
  }

  .sensor-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    font-size: 19px;
  }

  .sensor-value {
    grid-area: value;
    align-self: start;
    justify-self: end;
    margin: 0;
    font-size: 34px;
    text-align: right;
    white-space: nowrap;
  }

  .sensor-value small {
    font-size: 17px;
  }

  .sensor-value.text {
    max-width: 150px;
    font-size: clamp(23px, 7.5vw, 31px);
    white-space: normal;
  }

  .sensor-note {
    display: none;
  }

  .sensor-badge {
    grid-area: note;
  }

  .sensor-card canvas {
    grid-area: chart;
    height: 132px;
    margin-top: 2px;
  }

  .sensor-badge {
    min-height: 42px;
    padding: 9px 15px;
    font-size: 14px;
  }

  .dashboard-charts {
    display: none;
  }

  .dashboard-bottom {
    gap: 12px;
  }

  .control-summary {
    order: 1;
    padding: 14px;
  }

  .weather-panel {
    order: 2;
  }

  .dashboard-events-card {
    order: 3;
  }

  .control-summary .panel-heading {
    margin-bottom: 8px;
  }

  .control-summary .overall-panel {
    gap: 2px;
    border-radius: 14px;
    padding: 12px;
  }

  .control-summary .overall-panel strong {
    font-size: 22px;
  }

  .control-summary .overall-panel span {
    font-size: 13px;
    line-height: 1.25;
  }

  .control-summary .status-list {
    gap: 6px;
    margin-top: 10px;
  }

  .control-summary .status-list div {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 8px;
  }

  .control-summary .status-list dt {
    font-size: 11px;
  }

  .control-summary .status-list dd {
    font-size: 12px;
  }

  .chart-card canvas {
    height: 210px;
  }

  .full-chart canvas {
    height: 430px;
  }

  .full-chart .chart-legend {
    gap: 10px 16px;
    padding-top: 10px;
    font-size: 13px;
  }

  .full-chart .chart-legend button {
    min-height: 38px;
    flex: 1 1 142px;
    padding: 0 10px;
    font-size: 12px;
  }

  .full-chart .chart-legend i {
    width: 26px;
    height: 5px;
  }

  .history-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 12px 0;
  }

  .history-stat-card {
    min-height: 118px;
    align-items: flex-start;
    border-radius: 15px;
    padding: 12px;
  }

  .history-stat-card strong {
    font-size: 25px;
  }

  .history-stat-card span,
  .history-stat-card small {
    white-space: normal;
  }

  .history-stat-card i {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 13px;
    font-size: 13px;
  }

  .history-detail-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
  }

  .history-cycle-item {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .cycle-main strong {
    white-space: normal;
  }

  .cycle-main span {
    font-size: 13px;
    line-height: 1.25;
  }

  .cycle-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cycle-metrics span {
    min-width: 0;
    padding: 8px 6px;
    font-size: 13px;
  }

  .history-insight span {
    font-size: 13px;
  }

  .compact-history-events .event-item {
    padding: 11px;
  }

  .chart-card {
    padding: 14px 12px;
  }

  .chart-title {
    align-items: flex-start;
  }

  .chart-title h3 {
    font-size: 15px;
  }

  .forecast-days {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .forecast-day {
    border-radius: 13px;
    padding: 10px 7px;
  }

  .weather-symbol {
    width: 40px;
    height: 40px;
    margin-bottom: 7px;
    border-radius: 14px;
    font-size: 23px;
  }

  .forecast-day strong {
    margin-bottom: 7px;
    font-size: 13px;
  }

  .forecast-day .condition {
    min-height: 32px;
    font-size: 12px;
    line-height: 1.2;
  }

  .forecast-day .temp {
    font-size: 16px;
  }

  .forecast-day .rain-line {
    font-size: 11px;
  }

  .sensor-status-readout {
    grid-template-columns: 1fr;
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
  }

  .sensor-status-readout div {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 10px;
    align-items: baseline;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 10px 11px;
  }

  .sensor-status-readout dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
  }

  .sensor-status-readout dd {
    margin: 0;
    font-weight: 900;
  }

  .calibration-actions {
    grid-template-columns: 1fr;
  }

  .status-list div {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

@media (min-width: 720px) {
  .sensor-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .layout {
    display: grid;
    grid-template-columns: 270px 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(20px);
    padding: 28px 16px;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
  }

  .sidebar-brand strong {
    display: block;
    font-size: 18px;
  }

  .sidebar-brand span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
  }

  .brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  .nav-links {
    display: grid;
    align-content: start;
    gap: 8px;
  }

  .nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 14px;
    padding: 13px 14px;
    color: #40506a;
    font-weight: 900;
  }

  .nav-links a.active {
    background: linear-gradient(90deg, var(--green-soft), rgba(230, 247, 237, 0.32));
    color: var(--green-dark);
  }

  .nav-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid currentColor;
  }

  .sidebar-user {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    padding: 12px;
  }

  .avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #1d2433;
    color: #fff;
    font-weight: 950;
  }

  .sidebar-user strong,
  .sidebar-user span {
    display: block;
  }

  .sidebar-user span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
  }

  .main-content {
    padding: 28px 28px 42px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .top-status {
    min-width: 520px;
  }

  .sensor-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-bottom {
    grid-template-columns: 1.02fr 1fr 1.08fr;
  }

  .bottom-nav {
    display: none;
  }
}
