:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-soft: #0b1220;
  --panel: rgba(16, 24, 41, 0.82);
  --panel-line: rgba(148, 163, 184, 0.13);
  --text: #e8eefc;
  --muted: #8492ad;
  --muted-strong: #a9b6cc;
  --accent: #38bdf8;
  --green: #34d399;
  --amber: #fbbf24;
  --danger: #fb7185;
  --radius: 18px;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(56, 189, 248, 0.13), transparent 62%),
    radial-gradient(760px 460px at 92% 4%, rgba(167, 139, 250, 0.1), transparent 60%),
    linear-gradient(180deg, #080d18 0%, #070b14 55%, #060a12 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 78%);
}

::selection {
  background: rgba(56, 189, 248, 0.28);
}

.app {
  position: relative;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 30px 26px 44px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 2px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
}

.brand-mark {
  position: relative;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.28), transparent 46%),
    linear-gradient(145deg, #1f7fa8, #0d3f61 62%, #0a2740);
  border: 1px solid rgba(125, 211, 252, 0.35);
  box-shadow:
    0 10px 26px rgba(8, 47, 73, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(186, 230, 253, 0.55);
  inset: 9px;
}

.brand-mark::after {
  inset: 16px;
  background: #7dd3fc;
  border: none;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.9);
}

.brand-mark span {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 55%);
}

.eyebrow {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.22em;
  color: #6d87a8;
  margin-bottom: 3px;
}

.brand-text h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.12;
  font-weight: 640;
  letter-spacing: 0.015em;
}

.brand-text p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.masthead-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.recording,
.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(13, 20, 34, 0.7);
  font-size: 12px;
  color: var(--muted-strong);
  white-space: nowrap;
}

.rec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.5);
  animation: recPulse 2s infinite;
}

.recording.is-idle .rec-dot {
  background: var(--muted);
  animation: none;
  box-shadow: none;
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 9px rgba(251, 191, 36, 0.55);
}

.connection.is-live .conn-dot {
  background: var(--green);
  box-shadow: 0 0 9px rgba(52, 211, 153, 0.6);
}

.connection.is-offline .conn-dot {
  background: var(--danger);
  box-shadow: 0 0 9px rgba(251, 113, 133, 0.5);
}

@keyframes recPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.45);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(251, 113, 133, 0);
  }
}

/* ---------- metric cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 14px;
  margin: 22px 0 16px;
}

.cards.is-quad {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(168px, auto));
  grid-auto-flow: column;
}

.card {
  position: relative;
  min-height: 168px;
  padding: 17px 19px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-line);
  background:
    radial-gradient(220px 120px at 100% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
  box-shadow:
    0 18px 44px rgba(2, 6, 16, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  overflow: hidden;
  transition:
    transform 180ms ease,
    border-color 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--panel-line));
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.75;
  box-shadow: 0 0 14px var(--accent);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 560;
  color: var(--muted-strong);
}

.card-label .mini-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.unit-chip {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(148, 163, 184, 0.06);
}

.card-value {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 12px 0 4px;
}

.card-value .num {
  font-size: 33px;
  font-weight: 620;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.card-value .unit {
  font-size: 12px;
  color: var(--muted);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
}

.delta.up {
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.1);
}

.delta.down {
  color: #fda4af;
  background: rgba(251, 113, 133, 0.1);
}

.card-stats {
  display: flex;
  gap: 17px;
  margin-top: 9px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat span {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: #67758f;
}

.stat b {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-strong);
  font-variant-numeric: tabular-nums;
}

.spark {
  display: block;
  width: calc(100% + 2px);
  height: 34px;
  margin: 8px -1px -2px;
  opacity: 0.95;
}

.card.skeleton {
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

/* ---------- panels ---------- */

.panel {
  position: relative;
  margin-top: 16px;
  padding: 20px 22px 16px;
  border-radius: 20px;
  border: 1px solid var(--panel-line);
  background: linear-gradient(180deg, rgba(18, 27, 46, 0.86), rgba(12, 19, 33, 0.88));
  box-shadow:
    0 24px 60px rgba(2, 6, 16, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: baseline;
  gap: 11px;
}

.panel-title h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(7, 12, 22, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition:
    color 140ms ease,
    background 140ms ease;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  color: var(--text);
  background: linear-gradient(180deg, #22324f, #1a2942);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.06);
  color: var(--muted-strong);
  font: inherit;
  font-size: 11.5px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.btn:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.11);
  border-color: rgba(148, 163, 184, 0.28);
}

.btn.is-paused {
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.08);
}

.pause-icon {
  position: relative;
  display: inline-block;
  width: 9px;
  height: 10px;
}

.pause-icon::before,
.pause-icon::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.5px;
  border-radius: 1px;
  background: currentColor;
}

.pause-icon::before {
  left: 0;
}

.pause-icon::after {
  right: 0;
}

.btn.is-paused .pause-icon::before {
  left: 1px;
  top: 1px;
  width: 0;
  height: 0;
  bottom: auto;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
  background: none;
  border-radius: 0;
}

.btn.is-paused .pause-icon::after {
  display: none;
}

/* ---------- chart ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 15px 0 2px;
  min-height: 26px;
}

.spread-values {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin: 0;
  order: 2;
}

.spread-top {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 12px;
  margin: 14px 0 4px;
  align-items: stretch;
}

.spread-value {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 8px 12px 7px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)),
    rgba(8, 13, 24, 0.4);
  overflow: hidden;
}

.spread-value::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--spread-color);
  box-shadow: 0 0 12px var(--spread-color);
}

.spread-value-top {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.spread-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted-strong);
}

.spread-name i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--spread-color);
  box-shadow: 0 0 8px var(--spread-color);
}

.spread-formula {
  font-size: 9.5px;
  color: #5f6d86;
  white-space: nowrap;
}

.spread-value strong {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: block;
  margin-top: 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.spread-sub {
  grid-column: 1;
  grid-row: 2;
  display: block;
  margin-top: 0;
  font-family: var(--mono);
  font-size: 9.5px;
  color: #67758f;
}

.spread-value.is-alarming {
  animation: spreadAlarmFlash 0.9s ease-in-out infinite;
}

@keyframes spreadAlarmFlash {
  0%,
  100% {
    border-color: color-mix(in srgb, var(--spread-color) 55%, transparent);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--spread-color) 18%, transparent),
      0 0 12px color-mix(in srgb, var(--spread-color) 24%, transparent);
  }
  50% {
    border-color: var(--spread-color);
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--spread-color) 24%, transparent),
      0 0 26px var(--spread-color);
  }
}

.alarm-box {
  position: relative;
  order: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 9px 12px 8px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008)),
    rgba(8, 13, 24, 0.4);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.alarm-box.is-armed {
  border: 2px solid rgba(52, 211, 153, 0.55);
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.14),
    0 0 18px rgba(52, 211, 153, 0.14);
}

.alarm-box.is-timing {
  border: 2px solid rgba(251, 191, 36, 0.75);
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.12),
    0 0 22px rgba(251, 191, 36, 0.22);
}

.alarm-box::before,
.alarm-box::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.alarm-box::before {
  left: 0;
  background: #fb7185;
  box-shadow: 0 0 14px rgba(251, 113, 133, 0.9);
}

.alarm-box::after {
  right: 0;
  background: #22d3ee;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.9);
}

.alarm-box.is-a-alarm {
  border: 3px solid rgba(251, 113, 133, 0.92);
  box-shadow:
    0 0 0 3px rgba(251, 113, 133, 0.22),
    0 0 34px rgba(251, 113, 133, 0.45);
}

.alarm-box.is-b-alarm {
  border: 3px solid rgba(34, 211, 238, 0.92);
  box-shadow:
    0 0 0 3px rgba(34, 211, 238, 0.2),
    0 0 34px rgba(34, 211, 238, 0.4);
}

.alarm-box.is-a-alarm.is-b-alarm {
  border-color: rgba(167, 139, 250, 0.92);
  box-shadow:
    0 0 0 3px rgba(167, 139, 250, 0.2),
    0 0 30px rgba(251, 113, 133, 0.35),
    0 0 42px rgba(34, 211, 238, 0.35);
}

.alarm-box.is-a-alarm.is-ringing {
  animation: alarmPulseA 0.9s ease-in-out infinite;
}

.alarm-box.is-b-alarm.is-ringing {
  animation: alarmPulseB 0.9s ease-in-out infinite;
}

.alarm-box.is-a-alarm.is-b-alarm.is-ringing {
  animation: alarmPulseBoth 0.9s ease-in-out infinite;
}

.alarm-box.is-a-alarm::before,
.alarm-box.is-b-alarm::after {
  opacity: 1;
}

.alarm-box.is-a-alarm.is-ringing::before,
.alarm-box.is-b-alarm.is-ringing::after {
  animation: sidePulse 0.9s ease-in-out infinite;
}

@keyframes alarmPulseA {
  0%,
  100% {
    border-color: rgba(251, 113, 133, 0.8);
    box-shadow:
      0 0 0 2px rgba(251, 113, 133, 0.3),
      0 0 24px rgba(251, 113, 133, 0.35);
  }
  50% {
    border-color: rgba(251, 113, 133, 1);
    box-shadow:
      0 0 0 8px rgba(251, 113, 133, 0),
      0 0 42px rgba(251, 113, 133, 0.6);
  }
}

@keyframes alarmPulseB {
  0%,
  100% {
    border-color: rgba(34, 211, 238, 0.8);
    box-shadow:
      0 0 0 2px rgba(34, 211, 238, 0.3),
      0 0 24px rgba(34, 211, 238, 0.35);
  }
  50% {
    border-color: rgba(34, 211, 238, 1);
    box-shadow:
      0 0 0 8px rgba(34, 211, 238, 0),
      0 0 42px rgba(34, 211, 238, 0.6);
  }
}

@keyframes alarmPulseBoth {
  0%,
  100% {
    border-color: rgba(167, 139, 250, 0.8);
    box-shadow:
      0 0 0 2px rgba(251, 113, 133, 0.18),
      0 0 26px rgba(34, 211, 238, 0.35);
  }
  50% {
    border-color: rgba(196, 181, 253, 1);
    box-shadow:
      0 0 0 8px rgba(167, 139, 250, 0),
      0 0 42px rgba(251, 113, 133, 0.4),
      0 0 52px rgba(34, 211, 238, 0.4);
  }
}

@keyframes sidePulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.alarm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alarm-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted-strong);
}

.alarm-title i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
  transition:
    background 150ms ease,
    box-shadow 150ms ease;
}

.alarm-dot.a {
  background: #fb7185;
  opacity: 0.55;
}

.alarm-dot.b {
  background: #22d3ee;
  opacity: 0.55;
}

.alarm-box.is-armed .alarm-dot,
.alarm-box.is-timing .alarm-dot {
  opacity: 0.82;
}

.alarm-box.is-a-alarm .alarm-dot.a {
  opacity: 1;
}

.alarm-box.is-b-alarm .alarm-dot.b {
  opacity: 1;
}

.alarm-box.is-a-alarm.is-ringing .alarm-dot.a {
  animation: dotPulseA 0.9s ease-in-out infinite;
}

.alarm-box.is-b-alarm.is-ringing .alarm-dot.b {
  animation: dotPulseB 0.9s ease-in-out infinite;
}

@keyframes dotPulseA {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(251, 113, 133, 0.55);
  }
  50% {
    box-shadow:
      0 0 12px #fb7185,
      0 0 22px rgba(251, 113, 133, 0.65);
  }
}

@keyframes dotPulseB {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(34, 211, 238, 0.55);
  }
  50% {
    box-shadow:
      0 0 12px #22d3ee,
      0 0 22px rgba(34, 211, 238, 0.65);
  }
}

.alarm-switch {
  position: relative;
  width: 28px;
  height: 16px;
  flex: none;
  cursor: pointer;
}

.alarm-switch input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.alarm-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #182234;
  transition:
    background 150ms ease,
    border-color 150ms ease;
}

.alarm-switch span::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #8190a8;
  transition:
    transform 150ms ease,
    background 150ms ease;
}

.alarm-switch input:checked + span {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.45);
}

.alarm-switch input:checked + span::after {
  transform: translateX(12px);
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

.alarm-rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  align-items: center;
}

.alarm-rule {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 10.5px;
  color: var(--muted);
}

.alarm-side {
  font-family: var(--mono);
  color: var(--muted-strong);
}

.alarm-op {
  color: #64748b;
}

.alarm-rule input,
.alarm-timing input {
  width: 58px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 5px;
  background: rgba(7, 12, 22, 0.65);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10.5px;
  outline: none;
}

.alarm-rule input:focus,
.alarm-timing input:focus {
  border-color: rgba(56, 189, 248, 0.5);
}

.alarm-box input[type="number"]::-webkit-inner-spin-button,
.alarm-box input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.alarm-box input[type="number"] {
  -moz-appearance: textfield;
}

.alarm-unit {
  font-family: var(--mono);
  font-size: 9px;
  color: #5f6d86;
  white-space: nowrap;
}

.alarm-timing {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 5px;
}

.alarm-timing label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 10px;
  color: var(--muted);
}

.alarm-timing input {
  width: 38px;
}

.alarm-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

.alarm-foot select {
  height: 24px;
  max-width: 100px;
  padding: 0 4px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 5px;
  background: rgba(7, 12, 22, 0.65);
  color: var(--muted-strong);
  font: inherit;
  font-size: 10px;
}

.alarm-test {
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 10px;
}

.alarm-status {
  margin-left: auto;
  max-width: 120px;
  overflow: hidden;
  font-size: 10px;
  color: #64748b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alarm-box.is-timing .alarm-status {
  color: var(--amber);
}

.alarm-box.is-triggered .alarm-status {
  color: var(--danger);
}

.alarm-box.is-a-alarm .alarm-status {
  color: #fb7185;
}

.alarm-box.is-b-alarm .alarm-status {
  color: #22d3ee;
}

.alarm-box.is-a-alarm.is-b-alarm .alarm-status {
  color: #c4b5fd;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(8, 13, 24, 0.4);
  color: var(--muted-strong);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition:
    opacity 150ms ease,
    border-color 150ms ease;
}

.legend-chip .bullet {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chip-color);
  box-shadow: 0 0 8px var(--chip-color);
}

.legend-chip .legend-unit {
  color: #5f6d86;
  font-family: var(--mono);
  font-size: 9.5px;
}

.legend-chip:hover {
  border-color: rgba(148, 163, 184, 0.3);
}

.legend-chip.static {
  cursor: default;
}

.legend-chip.static:hover {
  border-color: rgba(148, 163, 184, 0.12);
}

.legend-chip.is-off {
  opacity: 0.38;
}

.legend-chip.is-off .bullet {
  box-shadow: none;
}

.chart-wrap {
  position: relative;
  height: 352px;
  margin-top: 4px;
}

.spread-wrap {
  height: 276px;
}

#chart {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12.5px;
  pointer-events: none;
}

.chart-empty[hidden] {
  display: none;
}

.chart-empty p {
  margin: 0;
}

.empty-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(56, 189, 248, 0.35);
  position: relative;
}

.empty-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.55);
  animation: emptyPulse 1.8s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%,
  100% {
    transform: scale(0.75);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 158px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(7, 12, 22, 0.95);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
  font-size: 11.5px;
  backdrop-filter: blur(10px);
}

.tooltip .tip-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.tip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
}

.tip-row .tip-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-strong);
}

.tip-row .tip-name i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tip-color);
}

.tip-row b {
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.paused-flag {
  position: absolute;
  top: 10px;
  right: 8px;
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.09);
  color: #fcd34d;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 10.5px;
  color: #64728b;
}

#pointInfo {
  font-family: var(--mono);
  color: var(--muted);
}

.foot-note {
  color: #55637d;
}

/* ---------- feed ---------- */

.feed-panel {
  padding-bottom: 8px;
}

.muted {
  font-size: 11px;
  color: #5f6d86;
}

.table-scroll {
  position: relative;
  margin: 12px -8px 0;
  overflow: auto;
  max-height: 342px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}

.table-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 8px;
}

.feed-table {
  width: 100%;
  border-collapse: collapse;
}

.feed-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 7px 8px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 550;
  letter-spacing: 0.1em;
  color: #66748d;
  background: rgba(12, 19, 33, 0.96);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.feed-table th.num,
.feed-table td.num {
  text-align: right;
}

.feed-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  font-size: 12px;
  color: var(--muted-strong);
  white-space: nowrap;
}

.feed-table tr:last-child td {
  border-bottom: none;
}

.feed-table tbody tr {
  transition: background 120ms ease;
}

.feed-table tbody tr:hover {
  background: rgba(148, 163, 184, 0.045);
}

.feed-table tr.is-new {
  animation: rowFlash 900ms ease-out;
}

@keyframes rowFlash {
  0% {
    background: rgba(56, 189, 248, 0.13);
  }
  100% {
    background: transparent;
  }
}

.feed-time {
  font-family: var(--mono);
  font-size: 11px;
  color: #7c8aa3;
  font-variant-numeric: tabular-nums;
}

.metric-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.metric-cell i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--metric-color);
  box-shadow: 0 0 7px var(--metric-color);
}

.feed-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.feed-value small {
  margin-left: 4px;
  font-family: var(--sans);
  font-size: 10px;
  color: #64728b;
}

.source-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(148, 163, 184, 0.05);
  font-family: var(--mono);
  font-size: 9.5px;
  color: #74829b;
}

.feed-empty {
  padding: 34px 8px 40px;
  text-align: center;
  font-size: 12px;
  color: #5c6a83;
}

.feed-empty[hidden] {
  display: none;
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  font-size: 10.5px;
  color: #4f5d76;
  letter-spacing: 0.02em;
}

.dot-sep {
  color: #31405a;
}

:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.65);
  outline-offset: 2px;
}

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

  .masthead {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .masthead-right {
    width: 100%;
    justify-content: flex-start;
  }

  .brand-text h1 {
    font-size: 22px;
  }

  .recording {
    display: none;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 11px;
    margin-top: 18px;
  }

  .cards.is-quad {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .spread-top {
    grid-template-columns: 1fr;
  }

  .spread-values {
    grid-template-columns: 1fr;
    gap: 7px;
    order: 1;
  }

  .alarm-box {
    order: 2;
  }

  .spread-value {
    column-gap: 10px;
  }

  .spread-value strong {
    font-size: 22px;
  }

  .spread-formula {
    white-space: normal;
    text-align: right;
  }

  .alarm-status {
    max-width: 100px;
  }

  .alarm-timing label {
    font-size: 9.5px;
  }

  .card {
    min-height: 158px;
    padding: 15px 16px 12px;
  }

  .card-value .num {
    font-size: 28px;
  }

  .card-stats {
    gap: 13px;
  }

  .panel {
    padding: 16px 14px 12px;
    border-radius: 16px;
  }

  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .segmented {
    flex: 1;
  }

  .segmented button {
    flex: 1;
    padding: 6px 4px;
    font-size: 10.5px;
  }

  .btn {
    padding: 0 10px;
  }

  .chart-wrap {
    height: 288px;
    margin-top: 8px;
  }

  .spread-wrap {
    height: 236px;
  }

  .foot-note {
    display: none;
  }

  .source-col {
    display: none;
  }

  .feed-table th,
  .feed-table td {
    padding-left: 6px;
    padding-right: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
