:root {
  color-scheme: light;
  --page: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --surface-strong: #e8eef0;
  --text: #17221d;
  --muted: #5f6d69;
  --border: #d5dedc;
  --green: #24715d;
  --green-dark: #12392f;
  --blue: #356f95;
  --amber: #b56d27;
  --red: #a9483d;
  --violet: #6b5aa7;
  --shadow-sm: 0 1px 2px rgba(18, 31, 28, 0.08);
  --shadow-md: 0 12px 26px rgba(18, 31, 28, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: #142923;
  color: #f8fbf9;
}

.app-header h1,
.panel h2,
.metric-group h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header .eyebrow,
.hero-panel .eyebrow {
  color: #9fe0c6;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  min-height: 40px;
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--green);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.button.secondary {
  border-color: #c7d8d2;
  background: #ffffff;
  color: var(--green-dark);
}

.app-header .button.secondary {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.button:disabled {
  border-color: var(--border);
  background: #edf0eb;
  color: #8a948e;
  cursor: not-allowed;
}

.button:not(:disabled):hover {
  border-color: #1d5a4b;
  transform: translateY(-1px);
}

.layout {
  display: grid;
  gap: 18px;
  padding: 18px clamp(12px, 4vw, 48px) 42px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.15fr);
  gap: 20px;
  min-height: 190px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid #1c4a3f;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(18, 57, 47, 0.98), rgba(34, 91, 78, 0.94)),
    #173a32;
  color: #f8fbf9;
  box-shadow: var(--shadow-md);
}

.hero-main {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
}

.hero-temperature {
  overflow-wrap: anywhere;
  font-size: clamp(44px, 9vw, 82px);
  font-weight: 900;
  line-height: 0.95;
}

.hero-meta {
  max-width: 680px;
  color: #cce4da;
  font-weight: 700;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: center;
}

.hero-stats article {
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.hero-stats span {
  color: #cce4da;
  font-size: 13px;
  font-weight: 800;
}

.hero-stats strong {
  overflow-wrap: anywhere;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.05;
}

.status-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 50px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.status-band > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 900;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--muted);
}

.status-dot.online {
  background: var(--green);
}

.status-dot.stale {
  background: var(--amber);
}

.status-dot.waiting {
  background: var(--muted);
}

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

.summary-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-item strong {
  overflow-wrap: anywhere;
  font-size: clamp(18px, 2.5vw, 27px);
  line-height: 1.1;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 20px;
  line-height: 1.2;
}

.panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.instrument-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 14px;
}

.instrument-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  min-width: 0;
  min-height: 292px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
  box-shadow: var(--shadow-sm);
}

.instrument-card.dragging {
  border-color: var(--green);
  box-shadow: var(--shadow-md);
  opacity: 0.72;
}

.instrument-grid-dragging .instrument-card {
  user-select: none;
}

.instrument-drag-handle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #65756f;
  cursor: grab;
  touch-action: none;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.instrument-drag-handle span {
  width: 16px;
  height: 18px;
  background-image: radial-gradient(circle, currentColor 1.4px, transparent 1.5px);
  background-position: 0 0;
  background-size: 6px 6px;
  opacity: 0.85;
}

.instrument-drag-handle:hover,
.instrument-drag-handle:focus-visible {
  border-color: #c9d8d3;
  background: #eef6f2;
  color: var(--green-dark);
}

.instrument-drag-handle:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.instrument-drag-handle:active,
.instrument-card.dragging .instrument-drag-handle {
  cursor: grabbing;
}

.instrument-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-right: 34px;
}

.instrument-head span,
.instrument-foot,
.comfort-stack span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.instrument-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 22px;
  line-height: 1.05;
  text-align: right;
}

.instrument-foot {
  min-height: 20px;
  overflow-wrap: anywhere;
}

.dial,
.compass {
  position: relative;
  align-self: center;
  justify-self: center;
  width: min(190px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
}

.dial {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #ffffff 0 53%, transparent 54%),
    conic-gradient(from 220deg, var(--accent) 0 var(--gauge-percent), #dce6e2 var(--gauge-percent) 72%, transparent 72% 100%),
    #eef4f1;
  border: 1px solid #cad8d4;
  box-shadow: inset 0 0 0 9px #f8fbfa;
}

.dial::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 1px solid rgba(23, 34, 29, 0.08);
  z-index: 1;
}

.dial-face {
  display: grid;
  place-items: center;
  gap: 4px;
  width: 64%;
  min-height: 64%;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(23, 34, 29, 0.06);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  z-index: 3;
}

.dial-value {
  overflow-wrap: anywhere;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.dial-face small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dial-needle {
  position: absolute;
  left: calc(50% - 2px);
  bottom: 50%;
  width: 4px;
  height: 34%;
  border-radius: 999px;
  background: #17221d;
  transform: rotate(var(--needle-angle));
  transform-origin: 50% 100%;
  z-index: 2;
}

.dial-needle::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #17221d;
  transform: translateX(-50%);
}

.thermometer {
  position: relative;
  display: grid;
  grid-template-columns: 54px 52px;
  justify-content: center;
  align-content: center;
  min-height: 172px;
}

.thermometer-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 138px;
  padding-block: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.thermometer-tube {
  position: relative;
  justify-self: center;
  width: 24px;
  height: 142px;
  overflow: hidden;
  border: 2px solid #c9d8d3;
  border-radius: 999px;
  background: #eef4f1;
}

.thermometer-fill {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: var(--thermo-fill);
  border-radius: 999px;
  background: linear-gradient(180deg, #e46e4d, var(--green));
}

.thermometer-bulb {
  position: absolute;
  left: calc(50% + 26px);
  bottom: 4px;
  width: 52px;
  height: 52px;
  border: 2px solid #c9d8d3;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #ffceb9 0 12%, #d9573d 13% 62%, #bd432f 63% 100%);
  transform: translateX(-50%);
}

.compass {
  display: grid;
  place-items: center;
  border: 1px solid #c9d8d3;
  background:
    radial-gradient(circle at center, #ffffff 0 51%, transparent 52%),
    repeating-conic-gradient(from 0deg, #cfdcda 0deg 2deg, transparent 2deg 15deg),
    #eef4f1;
}

.compass-ring {
  position: absolute;
  inset: 18px;
  border: 1px solid #c9d8d3;
  border-radius: 50%;
}

.cardinal {
  position: absolute;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.north {
  top: 10px;
}

.east {
  right: 14px;
}

.south {
  bottom: 10px;
}

.west {
  left: 14px;
}

.compass-needle {
  position: absolute;
  width: 10px;
  height: 72px;
  transform: rotate(var(--wind-angle));
  transform-origin: 50% 50%;
}

.compass-needle::before,
.compass-needle::after {
  content: "";
  position: absolute;
  left: 50%;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  transform: translateX(-50%);
}

.compass-needle::before {
  top: -2px;
  border-bottom: 48px solid var(--red);
}

.compass-needle::after {
  bottom: -2px;
  border-top: 28px solid #71807b;
}

.compass-center {
  display: grid;
  place-items: center;
  z-index: 2;
  width: 70px;
  height: 70px;
  border: 1px solid #c9d8d3;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.compass-center strong {
  font-size: 19px;
  line-height: 1;
}

.compass-center span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.rain-gauge {
  display: grid;
  place-items: center;
  min-height: 172px;
}

.rain-tube {
  position: relative;
  width: 96px;
  height: 156px;
  overflow: hidden;
  border: 2px solid #bfd3dc;
  border-radius: 10px 10px 22px 22px;
  background: linear-gradient(180deg, #ffffff 0%, #eef7fb 100%);
}

.rain-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--rain-fill);
  background: linear-gradient(180deg, rgba(75, 156, 200, 0.46), rgba(53, 111, 149, 0.86));
}

.rain-mark {
  position: absolute;
  right: 8px;
  color: #43606f;
  font-size: 11px;
  font-weight: 900;
}

.rain-mark::before {
  content: "";
  position: absolute;
  right: 22px;
  top: 50%;
  width: 44px;
  border-top: 1px solid rgba(67, 96, 111, 0.42);
}

.mark-high {
  top: 10px;
}

.mark-mid {
  top: 72px;
}

.mark-low {
  bottom: 8px;
}

.comfort-stack {
  display: grid;
  align-content: center;
  gap: 10px;
}

.comfort-stack div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.comfort-stack strong {
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1;
  text-align: right;
}

.metric-groups,
.normalized-metrics {
  display: grid;
  gap: 14px;
}

.metric-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--metric-accent, var(--green));
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.metric-chip strong {
  color: var(--text);
  font-size: 15px;
}

.metric-table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.metric-table {
  min-width: 720px;
  table-layout: fixed;
}

.metric-table th:nth-child(1),
.metric-table td:nth-child(1) {
  width: 42%;
}

.metric-table th:nth-child(2),
.metric-table td:nth-child(2) {
  width: 18%;
  text-align: right;
}

.metric-table th:nth-child(3),
.metric-table td:nth-child(3) {
  width: 14%;
}

.metric-table th:nth-child(4),
.metric-table td:nth-child(4) {
  width: 26%;
}

.metric-section-row th {
  padding: 9px 12px;
  border-left: 4px solid var(--metric-accent, var(--green));
  background: #eef5f1;
  color: var(--text);
  font-size: 13px;
  text-transform: none;
}

.metric-section-row span {
  font-weight: 900;
}

.metric-section-row em {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.metric-data-row td {
  background: #ffffff;
}

.metric-label {
  color: var(--text);
  font-weight: 800;
}

.metric-value strong {
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1;
}

.metric-unit {
  color: var(--muted);
  font-weight: 800;
}

.metric-source code {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef3f1;
  color: #315a50;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.metric-outdoor {
  --metric-accent: var(--green);
}

.metric-indoor {
  --metric-accent: var(--blue);
}

.metric-wind {
  --metric-accent: var(--violet);
}

.metric-rain {
  --metric-accent: var(--blue);
}

.metric-air {
  --metric-accent: var(--amber);
}

.metric-sensor {
  --metric-accent: #60706c;
}

.metric-default {
  --metric-accent: #60706c;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfa;
}

select {
  max-width: 260px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-strong);
  color: #465751;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  overflow-wrap: anywhere;
}

tbody tr:nth-child(even) td {
  background: #f8faf9;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 980px) {
  .hero-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-header,
  .status-band,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .layout {
    padding-inline: 12px;
  }

  .app-header {
    padding-inline: 12px;
  }

  .button {
    width: 100%;
  }

  .hero-panel,
  .hero-stats,
  .summary-grid,
  .awekas-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

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

  .instrument-card {
    min-height: 274px;
    padding: 14px;
  }

  .instrument-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .instrument-head strong {
    font-size: 20px;
    text-align: left;
  }

  .dial,
  .compass {
    width: min(172px, 100%);
  }

  .dial-value {
    font-size: 20px;
  }

  .thermometer {
    min-height: 156px;
  }

  .rain-gauge {
    min-height: 156px;
  }

  .rain-tube {
    height: 140px;
  }

  table {
    min-width: 100%;
    table-layout: fixed;
  }

  .metric-table {
    min-width: 640px;
  }

  th,
  td {
    padding-inline: 8px;
  }
}
