:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --surface: #ffffff;
  --surface-strong: #eef4ec;
  --text: #1b2621;
  --muted: #627069;
  --line: #d8e3dc;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --cool: #2563eb;
  --warm: #dc6b21;
  --hot: #c02626;
  --ok: #16803f;
  --warn: #b45309;
  --shadow: 0 18px 55px rgba(31, 43, 35, 0.13);
  --radius: 8px;
  --thermal: #0f766e;
  --temp-level: 45%;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(244, 247, 242, 0.95)),
    repeating-linear-gradient(135deg, rgba(15, 118, 110, 0.05) 0 1px, transparent 1px 18px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.brand span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand strong {
  font-size: 1.05rem;
}

.brand small,
.status-row,
.app-footer,
.metric-card span,
.detail-list span,
.quality-panel span,
.panel-title-row span,
.range-control span {
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(31, 43, 35, 0.08);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.readout-panel,
.metric-card,
.detail-panel {
  border: 1px solid rgba(216, 227, 220, 0.95);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.readout-panel {
  grid-row: span 3;
  min-height: 620px;
  padding: clamp(18px, 4vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.status-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(98, 112, 105, 0.12);
}

.status-dot[data-state="loading"] {
  background: var(--warn);
  box-shadow: 0 0 0 5px rgba(180, 83, 9, 0.13);
}

.status-dot[data-state="ok"] {
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(22, 128, 63, 0.13);
}

.status-dot[data-state="error"] {
  background: var(--hot);
  box-shadow: 0 0 0 5px rgba(192, 38, 38, 0.13);
}

.readout-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 22px;
  align-items: center;
}

.temperature-block {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.temperature-value {
  font-size: clamp(5rem, 12vw, 9.4rem);
  line-height: 0.9;
  font-weight: 800;
  color: var(--thermal);
  font-variant-numeric: tabular-nums;
}

.temperature-unit {
  margin-top: 10px;
  font-size: clamp(1.3rem, 3vw, 2.1rem);
  font-weight: 700;
  color: var(--muted);
}

.thermo-visual {
  display: grid;
  grid-template-columns: 32px 38px;
  justify-content: end;
  align-items: stretch;
  height: 310px;
}

.thermo-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.thermo-tube {
  position: relative;
  align-self: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef4ec;
  overflow: hidden;
}

.thermo-fill {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  min-height: 18px;
  height: var(--temp-level);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--warm), var(--thermal));
  transition: height 260ms ease, background 260ms ease;
}

.weather-summary {
  min-height: 32px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.primary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  font-weight: 750;
}

.primary-button {
  width: min(260px, 100%);
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.quality-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  min-height: 70px;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.quality-panel div:first-child {
  display: grid;
  gap: 3px;
  min-width: 118px;
}

.quality-track {
  height: 10px;
  border-radius: 999px;
  background: #d7ded9;
  overflow: hidden;
}

.quality-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--thermal);
  transition: width 260ms ease;
}

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

.metric-card {
  min-height: 106px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric-card strong {
  font-size: 1.45rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.detail-panel {
  padding: 18px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 1rem;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.detail-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
}

.calibration-panel {
  display: grid;
  gap: 14px;
}

.range-control {
  display: grid;
  gap: 10px;
}

.range-control input {
  width: 100%;
  accent-color: var(--accent);
}

.secondary-button {
  width: 100%;
  background: var(--surface);
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 0.9rem;
}

.app-footer a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.noscript-panel {
  position: fixed;
  inset: auto 12px 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: #fff7ed;
  color: #7c2d12;
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .app-shell {
    padding: 14px;
  }

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

  .readout-panel {
    grid-row: auto;
    min-height: 560px;
  }
}

@media (max-width: 560px) {
  .app-header {
    align-items: flex-start;
  }

  .brand strong {
    font-size: 1rem;
  }

  .readout-panel {
    min-height: 520px;
    padding: 18px;
  }

  .readout-body {
    grid-template-columns: minmax(0, 1fr) 68px;
    gap: 12px;
  }

  .temperature-value {
    font-size: clamp(4.2rem, 24vw, 6.4rem);
  }

  .thermo-visual {
    grid-template-columns: 26px 32px;
    height: 230px;
  }

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

  .quality-panel,
  .app-footer {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
