:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65717a;
  --line: #d9e0e4;
  --blue: #2357c6;
  --green: #16845b;
  --red: #bb3030;
  --amber: #a35f00;
  --shadow: 0 14px 36px rgba(28, 43, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.login {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.is-locked .login {
  display: grid;
}

.login__panel {
  width: min(420px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login h1,
.topbar h1,
.control h2,
.chart-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.login h1 {
  font-size: 30px;
}

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

.field,
.range-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  min-height: 42px;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

.field--inline {
  grid-template-columns: 92px 1fr;
  align-items: center;
}

.button,
.quick button,
.segmented button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.button:hover,
.quick button:hover,
.segmented button:hover {
  border-color: #aeb9c0;
}

.button--primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button--danger {
  border-color: #e0b4b4;
  color: var(--red);
}

.login__error,
.error-banner {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.dashboard {
  display: none;
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.app:not(.is-locked) .dashboard {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 38px);
}

.topbar__actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status {
  min-width: 82px;
  padding: 8px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status--online {
  color: #0d5e41;
  background: #dff4eb;
}

.status--offline,
.status--idle {
  color: #6c4850;
  background: #f5e6e8;
}

.status--running {
  color: #145e76;
  background: #dff1f6;
}

.summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric,
.chart-panel,
.control {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
}

.metric span,
.fan-readout span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  font-size: 24px;
  letter-spacing: 0;
}

.toolbar {
  min-height: 40px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 62px);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eaf0f2;
}

.segmented button {
  min-height: 30px;
  border: 0;
  background: transparent;
}

.segmented .is-active {
  background: #fff;
  box-shadow: 0 1px 5px rgba(32, 45, 52, 0.14);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

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

.chart-panel {
  min-height: 256px;
  padding: 14px;
}

.chart-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-panel h2 {
  font-size: 17px;
}

.chart-panel__head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart {
  position: relative;
  height: 210px;
}

.chart.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.74);
  z-index: 1;
}

.chart.is-loading::after {
  content: "";
  position: absolute;
  top: calc(50% - 18px);
  left: calc(50% - 18px);
  width: 36px;
  height: 36px;
  border: 3px solid #d7e0e5;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  z-index: 2;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart .grid {
  stroke: #e7ecef;
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.chart .line {
  fill: none;
  stroke-width: 2.5;
}

.control {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 18px;
  padding: 16px;
}

.control__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.control h2 {
  font-size: 24px;
}

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

.fan-readout div {
  min-height: 68px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.fan-readout strong {
  font-size: 21px;
}

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

.quick {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.control__buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .summary {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .control {
    position: static;
  }
}

@media (max-width: 760px) {
  .dashboard {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary,
  .charts,
  .fan-readout {
    grid-template-columns: 1fr;
  }
}
