:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: #d8dee9;
  --blue: #0f4c81;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #facc15;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}
.topbar {
  background: linear-gradient(90deg, #082f49, #0f4c81);
  color: white;
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
h1 { margin: 0; font-size: 26px; letter-spacing: .2px; }
.subtitle { margin: 6px 0 0; color: #dbeafe; font-size: 14px; }
.connection-panel {
  min-width: 250px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,.08);
}
.conn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 12px #ef4444;
}
.conn-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 12px #22c55e;
}
.conn-text { font-weight: 700; }
.last-update { font-size: 12px; color: #dbeafe; margin-top: 3px; }
main { padding: 22px 28px 30px; }
.toolbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.topic-box {
  padding: 8px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  font-size: 14px;
}
.topic-box span { color: var(--muted); margin-right: 6px; }
button {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  color: white;
  background: #0f4c81;
  font-weight: 700;
}
button:hover { opacity: .9; }
.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.class-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.class-header {
  padding: 14px 18px;
  background: #eaf2fb;
  border-bottom: 1px solid var(--line);
  font-size: 20px;
  font-weight: 800;
  color: #0f4c81;
}
.sub-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
}
.sub-card {
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #fbfdff;
  overflow: hidden;
}
.sub-title {
  padding: 12px 14px;
  font-weight: 800;
  background: #f1f5f9;
  border-bottom: 1px solid #dbe3ef;
}
.field-row {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) minmax(115px, auto);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f7;
}
.field-row:last-child { border-bottom: none; }
.field-name {
  font-size: 14px;
  color: #334155;
  line-height: 1.25;
}
.field-id {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
}
.value-badge {
  min-width: 100px;
  text-align: center;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 14px;
  background: white;
}
.value-badge.number {
  font-size: 18px;
}
.blink {
  animation: blinkAnim 1s linear infinite;
}
@keyframes blinkAnim {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: .18; }
}
.raw-panel {
  margin-top: 18px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.raw-panel h2 { font-size: 16px; margin: 0 0 10px; color: white; }
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}
footer {
  padding: 14px 28px 24px;
  color: #667085;
  font-size: 13px;
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .connection-panel { width: 100%; }
  main { padding: 16px; }
  .sub-grid { grid-template-columns: 1fr; }
}

.penstock-image-wrap {
  padding: 10px 12px 8px;
  border-bottom: 1px solid #edf2f7;
  background: #fbfdff;
}
.penstock-image {
  width: 100%;
  height: 118px;
  object-fit: contain;
  display: block;
  border-radius: 10px;
  background: #ffffff;
}
.penstock-image-caption {
  margin-top: 5px;
  font-size: 11px;
  color: #64748b;
  text-align: center;
}


.penstock-image-wrap img,
.penstock-position-image,
.penstock-img {
  width: 100%;
  height: 260px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  background: #ffffff;
}

.penstock-image-caption {
  text-align: center;
  font-size: 13px;
  color: #475569;
  margin-top: 6px;
}