:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-muted: #f7f9fb;
  --border: #d8e0e7;
  --ink: #17212f;
  --muted: #5d6d7e;
  --soil: #16815c;
  --vibration: #d57a1f;
  --danger: #c23a2b;
  --warning: #b7791f;
  --safe: #17804f;
  --unknown: #697386;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  padding: 24px;
}

.dashboard-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

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

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.topbar h1 {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.connection-status,
.clock-box,
.details-strip > div {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 12px;
  color: var(--ink);
  font-size: 0.9rem;
}

.clock-box,
.details-strip > div {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.clock-box span,
.details-strip span,
.panel-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.clock-box strong,
.details-strip strong {
  font-family: "Courier New", monospace;
  font-size: 0.92rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--unknown);
}

.status-dot.online {
  background: var(--safe);
  box-shadow: 0 0 0 4px rgba(23, 128, 79, 0.14);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(194, 58, 43, 0.14);
}

.risk-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border);
  border-left: 8px solid var(--unknown);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(23, 33, 47, 0.08);
}

.risk-panel.aman {
  border-left-color: var(--safe);
}

.risk-panel.waspada {
  border-left-color: var(--warning);
}

.risk-panel.bahaya {
  border-left-color: var(--danger);
}

.risk-panel.unknown {
  border-left-color: var(--unknown);
}

.risk-value {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.risk-panel p {
  margin-top: 8px;
  color: var(--muted);
  max-width: 720px;
}

.buzzer-state {
  white-space: nowrap;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-weight: 800;
}

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

.sensor-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: 0 8px 18px rgba(23, 33, 47, 0.06);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.card-header span {
  color: var(--muted);
  font-weight: 700;
}

.card-header strong {
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 0.84rem;
}

.gauge-wrap {
  position: relative;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  aspect-ratio: 1.8 / 1;
}

.gauge-svg {
  width: 100%;
  height: 100%;
}

.gauge-track,
.gauge-progress {
  fill: none;
  stroke-width: 16;
  stroke-linecap: round;
}

.gauge-track {
  stroke: #dce4eb;
}

.gauge-progress {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.2s linear;
}

.soil-card .gauge-progress {
  stroke: var(--soil);
}

.vibration-card .gauge-progress {
  stroke: var(--vibration);
}

.needle {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 5px;
  height: 92px;
  margin-left: -2.5px;
  background: linear-gradient(180deg, #f4f7fb 0%, #17212f 100%);
  border-radius: 999px;
  transform-origin: center 84px;
  transform: rotate(-120deg);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
}

.gauge-center-dot {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
}

.gauge-label {
  position: absolute;
  bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.gauge-min {
  left: 0.25rem;
}

.gauge-mid {
  left: 50%;
  transform: translateX(-50%);
}

.gauge-max {
  right: 0.25rem;
}

.sensor-value {
  text-align: center;
  margin-top: -2px;
}

.sensor-value span,
.large-metric span {
  font-size: 2.7rem;
  font-weight: 850;
  line-height: 1;
}

.soil-card .sensor-value span {
  color: var(--soil);
}

.vibration-card .sensor-value span {
  color: var(--vibration);
}

.sensor-value small,
.large-metric small,
.metric-row small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.sensor-note {
  min-height: 42px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

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

.calibration-readout > div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 8px;
}

.calibration-readout span,
.calibration-readout p {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.calibration-readout strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.05rem;
}

.calibration-readout small {
  color: var(--muted);
  font-size: 0.78rem;
}

.calibration-readout p {
  grid-column: 1 / -1;
  line-height: 1.3;
}

.metric-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.large-metric {
  min-height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--muted);
}

.metric-row strong {
  color: var(--ink);
}

.details-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.refresh-btn {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.refresh-btn:hover {
  background: #0d1520;
}

.refresh-btn:active {
  transform: scale(0.98);
}

@media (max-width: 900px) {
  body {
    padding: 16px;
  }

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

  .topbar-status {
    justify-content: flex-start;
  }

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

  .buzzer-state {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  body {
    padding: 10px;
  }

  .topbar-status,
  .details-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .connection-status,
  .clock-box,
  .details-strip > div,
  .refresh-btn {
    width: 100%;
  }

  .sensor-value span,
  .large-metric span {
    font-size: 2.3rem;
  }
}
