:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #1c242b;
  --muted: #66727f;
  --line: #dde4eb;
  --green: #16855f;
  --amber: #b86b00;
  --red: #c83232;
  --blue: #2868b7;
  --teal: #1f8a9b;
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

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

.topbar {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}

button:hover {
  background: #2c3a47;
}

button:active {
  transform: scale(0.97);
}

button.flash {
  background: var(--teal);
}

.btn-hint {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.btn-hint small {
  color: var(--muted);
  font-size: 11px;
}

.status-pill,
.risk {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill {
  background: #e7f4ef;
  color: var(--green);
}

.summary-grid,
.bottom-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.bottom-grid {
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 16px;
}

.metric,
.panel,
.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgb(20 30 40 / 5%);
}

.metric {
  min-height: 118px;
  padding: 16px;
}

.metric span,
.metric small,
.chart-heading small {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 30px;
}

.metric.danger strong {
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 16px;
}

.equipment-list,
.alarm-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.equipment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
}

.equipment-row.active {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.equipment-row strong,
.alarm strong {
  display: block;
}

.equipment-row small,
.alarm small {
  color: var(--muted);
}

.risk.normal {
  background: #e7f4ef;
  color: var(--green);
}

.risk.warning {
  background: #fff2db;
  color: var(--amber);
}

.risk.danger {
  background: #fde6e6;
  color: var(--red);
}

.chart-card {
  margin-top: 14px;
  padding: 14px;
}

canvas {
  width: 100%;
  height: auto;
  margin-top: 10px;
}

.fft-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 10px;
  height: 180px;
  margin-top: 12px;
  padding-top: 16px;
}

.fft-bar {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 24px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--blue), var(--teal));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 4px;
}

.flow {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}

.flow li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.flow li + li {
  margin-top: 3px;
  position: relative;
}

.flow li + li::before {
  content: "↓";
  position: absolute;
  top: -13px;
  left: 19px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}

.flow-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.flow li strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.3;
}

.flow li small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.alarm {
  border-left: 4px solid var(--amber);
  padding: 10px 12px;
  border-radius: 6px;
  background: #fbfcfd;
}

.alarm.danger {
  border-left-color: var(--red);
}

.alarm-time {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

@keyframes highlight {
  from { background: #e8f4ff; }
  to   { background: #fbfcfd; }
}

.alarm.updated {
  animation: highlight 0.8s ease-out forwards;
}

.constraint-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.constraint-list p {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .summary-grid,
  .workspace,
  .bottom-grid,
  .flow {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
