:root {
  --bg: #09111a;
  --bg-deep: #0d1722;
  --bg-panel: rgba(11, 20, 30, 0.92);
  --bg-soft: rgba(18, 31, 43, 0.88);
  --border: rgba(172, 201, 221, 0.14);
  --text: #f2f6f9;
  --muted: #93a7b8;
  --solar: #ffbe45;
  --surplus: #8df59f;
  --battery: #4be4c2;
  --old: #f48e43;
  --new: #5aa8ff;
  --gas: #ff7b6b;
  --shared: #c892ff;
  --electric-total: #72e2ff;
  --valve: #f3e88f;
  --danger: #ff6e67;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 190, 69, 0.14), transparent 26%),
    radial-gradient(circle at top right, rgba(75, 228, 194, 0.12), transparent 24%),
    linear-gradient(145deg, #061018 0%, #0b1520 52%, #101927 100%);
  font-family: "Avenir Next", "IBM Plex Sans", "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
}

.app-shell {
  width: min(1600px, calc(100vw - 28px));
  margin: 14px auto 24px;
}

.panel {
  background: linear-gradient(180deg, rgba(17, 28, 40, 0.96), rgba(10, 18, 28, 0.94));
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: 22px 24px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--solar);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "DIN Condensed", "Arial Narrow", "Franklin Gothic Medium", sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.94;
  text-wrap: balance;
}

h2 {
  font-size: 1.55rem;
  line-height: 1;
}

.lede {
  margin: 12px 0 0;
  max-width: 62ch;
  color: #d1dce6;
  font-size: 0.92rem;
  line-height: 1.45;
}

.profile-chip {
  display: inline-grid;
  gap: 4px;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-chip span,
.profile-chip em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.8rem;
}

.profile-chip strong {
  font-size: 1rem;
  color: #ffffff;
}

.hero-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
}

.hero-toolbar-copy {
  display: grid;
  gap: 3px;
}

.hero-toolbar-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-toolbar-copy strong {
  font-size: 0.95rem;
  color: #dce6ef;
}

.settings-toggle-button,
.settings-close-button {
  white-space: nowrap;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(3, 8, 13, 0.62);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.live-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.metric-card,
.summary-card {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(24, 37, 51, 0.85), rgba(15, 24, 35, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-label,
.summary-label,
.control-top span,
.assumption-title {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-value,
.summary-value {
  display: block;
  margin-top: 4px;
  font-size: 1.42rem;
  font-weight: 700;
  line-height: 1;
}

.metric-foot {
  display: block;
  margin-top: 8px;
  color: #adbece;
  font-size: 0.82rem;
}

.metric-value.solar {
  color: var(--solar);
}

.legend-swatch.solar {
  background: var(--solar);
}

.metric-value.surplus {
  color: var(--surplus);
}

.legend-swatch.surplus {
  background: var(--surplus);
}

.metric-value.shared {
  color: var(--shared);
}

.legend-swatch.shared {
  background: var(--shared);
}

.metric-value.gas {
  color: var(--gas);
}

.legend-swatch.gas {
  background: var(--gas);
}

.metric-value.total-electric {
  color: var(--electric-total);
}

.legend-swatch.total-electric {
  background: var(--electric-total);
}

.metric-value.battery {
  color: var(--battery);
}

.legend-swatch.battery {
  background: var(--battery);
}

.metric-value.solar,
.metric-value.shared,
.metric-value.total-electric,
.metric-value.surplus,
.metric-value.gas,
.metric-value.battery {
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.04);
}

.legend-swatch.solar,
.legend-swatch.shared,
.legend-swatch.total-electric,
.legend-swatch.surplus,
.legend-swatch.gas,
.legend-swatch.battery {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.08);
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.control-panel,
.schematic-panel,
.logic-panel,
.chart-panel {
  padding: 20px;
}

.control-panel,
.logic-panel,
.sensor-panel,
.cabinet-panel {
  font-size: 0.94rem;
}

.control-panel {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 30;
  width: min(460px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  transform: translateX(calc(-100% - 28px));
  opacity: 0;
  pointer-events: none;
  transition: transform 220ms ease, opacity 180ms ease;
}

body.settings-open {
  overflow: hidden;
}

body.settings-open .settings-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.settings-open .control-panel {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.control-panel h2,
.logic-panel h2,
.sensor-panel h2,
.cabinet-panel h2,
.chart-panel h2 {
  font-size: 1.42rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.settings-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 14px;
  background: linear-gradient(180deg, rgba(17, 28, 40, 0.98), rgba(17, 28, 40, 0.92));
}

.primary-button,
.ghost-button,
.preset-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.primary-button {
  padding: 11px 18px;
  background: linear-gradient(135deg, var(--solar), #ff9c42);
  color: #142130;
  font-weight: 700;
}

.ghost-button {
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.playback-buttons {
  display: flex;
  gap: 10px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.profile-manager {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.profile-manager-head p {
  margin: 6px 0 0;
  color: #cfdae4;
  font-size: 0.88rem;
  line-height: 1.4;
}

.profile-grid,
.profile-data-grid {
  display: grid;
  gap: 12px;
}

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-status {
  margin: 0;
  color: #c6d5e2;
  font-size: 0.84rem;
}

.profile-data-input {
  width: 100%;
  min-height: 122px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 12, 18, 0.72);
  color: #f7fbff;
  font: 0.88rem/1.5 "IBM Plex Mono", "SFMono-Regular", monospace;
  resize: vertical;
}

.preset-button {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #d5e2ed;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preset-button.active {
  color: #0c1520;
  background: linear-gradient(135deg, var(--battery), #85f0dc);
  border-color: rgba(75, 228, 194, 0.4);
}

.control-grid {
  display: grid;
  gap: 14px;
}

.control-field {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.control-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.control-top strong {
  color: #f7fbff;
  font-size: 0.92rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--solar);
}

.control-input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 12, 18, 0.65);
  color: #f7fbff;
  font: inherit;
}

.control-input::-webkit-outer-spin-button,
.control-input::-webkit-inner-spin-button {
  margin: 0;
}

.control-toggle {
  position: relative;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.control-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f7fbff;
  transition: transform 160ms ease, background 160ms ease;
}

.control-toggle input[type="checkbox"]:checked + .toggle-track {
  background: rgba(255, 190, 69, 0.24);
  border-color: rgba(255, 190, 69, 0.48);
}

.control-toggle input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
  transform: translateX(24px);
  background: #ffbe45;
}

.control-help {
  grid-column: 1 / -1;
  color: #b8c7d3;
  font-size: 0.82rem;
  line-height: 1.35;
}

.assumption-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.assumption-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.assumption-item p {
  margin: 8px 0 0;
  color: #cfdae4;
  font-size: 0.88rem;
  line-height: 1.4;
}

.schematic-panel {
  grid-column: 1 / -1;
  min-height: 860px;
  padding: 16px 10px 14px;
}

.schematic-view-switch {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.view-toggle {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  background: transparent;
  color: #d8e5ef;
  font: inherit;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.view-toggle.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.schematic-view {
  display: none;
}

.schematic-view.is-active {
  display: block;
}

.logic-panel {
  grid-column: 1 / -1;
}

.animation-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(210px, 260px) minmax(320px, 1fr);
  gap: 12px;
  align-items: center;
  margin: 6px 6px 12px;
}

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

.cumulative-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 6px 12px;
}

.cumulative-card {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(22, 35, 49, 0.9), rgba(12, 21, 31, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.finance-strip {
  margin-top: 0;
}

.finance-card {
  background: linear-gradient(180deg, rgba(28, 37, 52, 0.94), rgba(14, 22, 32, 0.98));
  border-color: rgba(200, 146, 255, 0.18);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #d8e6ef;
}

.schematic-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.speed-dock {
  min-width: 280px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.speed-dock-inline {
  min-width: 0;
  width: 100%;
  padding: 12px 14px;
}

.time-dock {
  min-width: 0;
}

.window-dock {
  grid-column: 1 / -1;
  min-width: 0;
}

.speed-dock-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.speed-dock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.time-picker-row,
.window-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.time-picker-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.time-picker-input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 12, 18, 0.65);
  color: #f7fbff;
  font: inherit;
}

.window-meta {
  color: #d8e6ef;
}

.window-meta span {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.dual-range {
  position: relative;
  height: 32px;
  margin-top: 10px;
  --range-start: 0%;
  --range-end: 100%;
}

.dual-range-rail {
  position: absolute;
  inset: 50% 8px auto;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.12) 0 var(--range-start),
    rgba(255, 190, 69, 0.36) var(--range-start) var(--range-end),
    rgba(255, 255, 255, 0.12) var(--range-end) 100%
  );
}

.dual-range input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.dual-range input[type="range"]::-webkit-slider-runnable-track {
  height: 32px;
  background: transparent;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 7px;
  border-radius: 50%;
  border: 2px solid #0b141d;
  background: #f7fbff;
  box-shadow: 0 0 0 3px rgba(255, 190, 69, 0.14);
  pointer-events: auto;
  cursor: pointer;
}

.dual-range input[type="range"]::-moz-range-track {
  height: 32px;
  background: transparent;
  border: 0;
}

.dual-range input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #0b141d;
  background: #f7fbff;
  box-shadow: 0 0 0 3px rgba(255, 190, 69, 0.14);
  pointer-events: auto;
  cursor: pointer;
}

.window-start-range::-webkit-slider-thumb,
.window-start-range::-moz-range-thumb {
  background: #d9f1ff;
}

.window-end-range::-webkit-slider-thumb,
.window-end-range::-moz-range-thumb {
  background: #ffbe45;
}

.speed-dock input[type="range"] {
  margin: 0;
}

.speed-dock strong {
  min-width: 38px;
  text-align: right;
  font-size: 1rem;
}

.badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surplus);
  box-shadow: 0 0 14px rgba(141, 245, 159, 0.8);
}

.plant-svg {
  display: block;
  width: calc(100% + 48px);
  max-width: none;
  height: auto;
  margin: -8px 0 0 -24px;
  overflow: visible;
}

.project-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 8px;
  border-radius: 24px;
  background: #f6f1e7;
  border: 1px solid rgba(37, 50, 66, 0.18);
}

.project-view-note {
  margin: 12px 6px 0;
  color: #cfdae4;
  font-size: 0.88rem;
  line-height: 1.45;
}

.electro-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 8px;
  border-radius: 24px;
  background: #eef4fa;
  border: 1px solid rgba(37, 50, 66, 0.18);
}

.electro-sheet {
  fill: #f5f8fb;
  stroke: #d4dde6;
  stroke-width: 2;
}

.electro-title,
.electro-subtitle,
.electro-zone-title,
.electro-legend-title,
.electro-legend-text,
.electro-block-title,
.electro-block-value,
.electro-block-detail {
  fill: #1d2a35;
  font-family: "IBM Plex Sans Condensed", "DIN Condensed", "Arial Narrow", sans-serif;
}

.electro-title {
  font-size: 28px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.electro-subtitle {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.electro-zone-title,
.electro-legend-title {
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.electro-legend-text,
.electro-block-title,
.electro-block-detail {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.electro-block-value {
  font-size: 20px;
  font-weight: 700;
}

.electro-zone-box {
  fill: rgba(255, 255, 255, 0.8);
  stroke: #31404f;
  stroke-width: 2.2;
}

.electro-zone-box.cabinet {
  fill: rgba(233, 244, 255, 0.9);
}

.electro-zone-box.field {
  fill: rgba(250, 251, 252, 0.92);
}

.electro-block {
  fill: rgba(255, 255, 255, 0.96);
  stroke: #2b3948;
  stroke-width: 2;
  transition: fill 180ms ease, stroke 180ms ease, filter 180ms ease;
}

.electro-block.active {
  fill: #fff4d7;
  stroke: #a86c12;
  filter: drop-shadow(0 6px 18px rgba(168, 108, 18, 0.18));
}

.electro-block.source.solar {
  fill: rgba(255, 235, 196, 0.96);
}

.electro-block.source.battery {
  fill: rgba(212, 249, 241, 0.96);
}

.electro-block.source.shared {
  fill: rgba(237, 226, 255, 0.96);
}

.electro-block.source.gas {
  fill: rgba(255, 225, 216, 0.96);
}

.electro-block.source.neutral {
  fill: rgba(231, 239, 246, 0.96);
}

.electro-block.cabinet-block.cpu {
  fill: rgba(217, 235, 251, 0.96);
}

.electro-block.cabinet-block.io {
  fill: rgba(247, 250, 253, 0.98);
}

.electro-block.cabinet-block.finance {
  fill: rgba(244, 239, 252, 0.98);
}

.electro-block.field-block.notes {
  fill: rgba(249, 252, 255, 0.98);
}

.electro-link {
  fill: none;
  stroke-width: 4.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.74;
  transition: opacity 180ms ease, stroke-width 180ms ease, stroke 180ms ease;
}

.electro-link.modbus {
  stroke: #5d7389;
  color: #5d7389;
  stroke-dasharray: 10 8;
}

.electro-link.signal {
  stroke: #2f8f5b;
  color: #2f8f5b;
  stroke-dasharray: 12 8;
}

.electro-link.power {
  stroke: #a66d15;
  color: #a66d15;
}

.electro-link.flow-active {
  opacity: 1;
  stroke: currentColor;
  stroke-width: 6;
  animation: pipe-flow 1100ms linear infinite;
}

.electro-link.demo {
  opacity: 1;
  stroke: currentColor;
}

.electro-stage-led {
  fill: #d9e0e7;
  stroke: #334150;
  stroke-width: 1.2;
}

.electro-stage-led.active {
  fill: #ffbe45;
  stroke: #8d5f0f;
}

.pipe {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.16;
  transition: opacity 180ms ease, filter 180ms ease, stroke 180ms ease;
}

.pipe.flow-active {
  opacity: 0.95;
  stroke-dasharray: 16 12;
  animation: pipe-flow 900ms linear infinite;
  filter: drop-shadow(0 0 8px currentColor);
}

.pipe-solar {
  stroke: var(--solar);
  color: var(--solar);
}

.pipe-battery {
  stroke: var(--battery);
  color: var(--battery);
}

.pipe-gas {
  stroke: var(--gas);
  color: var(--gas);
}

.pipe-transfer {
  stroke: #66dbff;
  color: #66dbff;
}

.pipe-demand {
  stroke: #ffd983;
  color: #ffd983;
}

.pipe-return {
  stroke: #6f9dc7;
  color: #6f9dc7;
}

.project-sheet {
  fill: #f8f4ec;
  stroke: #d4cab9;
  stroke-width: 2;
}

.project-title,
.project-subtitle,
.project-label,
.project-branch-title,
.project-branch-subtitle,
.project-branch-note,
.project-legend-title,
.project-legend-text,
.project-tag,
.project-box-title,
.project-box-value,
.project-value,
.project-value-label,
.project-sensor-id {
  fill: #1d2a35;
  font-family: "IBM Plex Sans Condensed", "DIN Condensed", "Arial Narrow", sans-serif;
}

.project-title {
  font-size: 28px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-subtitle {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.project-pipe {
  fill: none;
  stroke: #36414c;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.72;
  transition: opacity 180ms ease, stroke 180ms ease, stroke-width 180ms ease;
}

.project-pipe.flow-active {
  opacity: 1;
  stroke: currentColor;
  stroke-width: 6.5;
  stroke-dasharray: 18 12;
  animation: pipe-flow 1100ms linear infinite;
}

.project-pipe.medium-solar {
  color: #be7c12;
}

.project-pipe.medium-battery {
  color: #0e8a73;
}

.project-pipe.medium-gas {
  color: #b54e33;
}

.project-pipe.medium-transfer {
  color: #0c89b8;
}

.project-pipe.medium-demand {
  color: #39434d;
}

.project-pipe.medium-return {
  color: #687a8d;
}

.project-pipe.return-base {
  stroke-dasharray: 15 10;
}

.project-pipe.demo {
  stroke: currentColor;
  opacity: 1;
}

.project-source-box,
.project-branch-box,
.project-tank-shell {
  fill: rgba(255, 255, 255, 0.92);
  stroke: #243241;
  stroke-width: 2.2;
}

.project-source-box.medium-solar-box {
  fill: rgba(255, 235, 196, 0.9);
}

.project-source-box.medium-battery-box {
  fill: rgba(207, 249, 236, 0.9);
}

.project-source-box.medium-gas-box {
  fill: rgba(255, 221, 213, 0.92);
}

.project-box-title {
  font-size: 16px;
  letter-spacing: 0.08em;
}

.project-box-value,
.project-value {
  font-size: 24px;
  font-weight: 700;
}

.project-value.small,
.project-branch-note {
  font-size: 18px;
}

.project-label,
.project-branch-title,
.project-legend-title {
  font-size: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.project-label.small,
.project-branch-subtitle,
.project-tag,
.project-value-label,
.project-legend-text {
  font-size: 15px;
  letter-spacing: 0.08em;
}

.project-tag {
  fill: #435160;
}

.project-tag.emphasis {
  fill: #17364d;
  font-weight: 700;
}

.project-value-label {
  text-transform: uppercase;
}

.project-coil {
  fill: none;
  stroke: rgba(137, 110, 61, 0.9);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-stage-indicator {
  fill: #d8dee5;
  stroke: #334150;
  stroke-width: 1.2;
}

.project-stage-indicator.active {
  fill: #ffbe45;
  stroke: #8d5f0f;
}

.project-pump {
  fill: #ffffff;
  stroke: #243241;
  stroke-width: 2.4;
}

.project-pump.active {
  fill: #e6f8ff;
  stroke: #1387b7;
}

.project-pump-blade {
  fill: #243241;
}

.project-sensor {
  fill: #ffffff;
  stroke: #243241;
  stroke-width: 2;
}

.project-sensor.mix {
  fill: #fff2c7;
  stroke: #8e7f2c;
}

.project-sensor.safety {
  fill: #eef3f8;
  stroke: #51606d;
}

.project-sensor.safety.active {
  fill: #ebf8f0;
  stroke: #2f8f5b;
}

.project-sensor.safety.tripped {
  fill: #ffe2db;
  stroke: #b54e33;
}

.project-sensor-id {
  font-size: 11px;
  font-weight: 700;
}

.project-safety-note.tripped {
  fill: #8f2d16;
  font-weight: 700;
}

.source-shell,
.building-shell,
.tank-shell {
  fill: rgba(17, 28, 40, 0.74);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1.5;
}

.tank-shell {
  fill: url(#tankShell);
}

.panel-line {
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 2.5;
}

.battery-icon {
  fill: rgba(75, 228, 194, 0.12);
  stroke: rgba(75, 228, 194, 0.7);
  stroke-width: 2;
}

.battery-charge-bar,
.battery-pin {
  fill: var(--battery);
}

.burner-shell {
  fill: rgba(255, 123, 107, 0.08);
  stroke: rgba(255, 123, 107, 0.42);
  stroke-width: 2;
}

.flame-main {
  fill: #ff9447;
}

.flame-inner {
  fill: #ffe38a;
}

.node-title,
.tank-title,
.building-title,
.bridge-title {
  fill: #eff7fd;
  font-family: "DIN Condensed", "Arial Narrow", sans-serif;
  font-size: 24px;
  letter-spacing: 0.04em;
}

.node-value,
.tank-temp,
.bridge-value {
  fill: #ffffff;
  font-size: 28px;
  font-weight: 700;
}

.node-foot,
.tank-subtitle,
.tank-small-label,
.tank-status,
.bridge-foot,
.building-foot {
  fill: #afc2d2;
  font-size: 16px;
}

.tank-subtitle {
  font-size: 18px;
}

.tank-small-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 14px;
}

.tank-status,
.bridge-value,
.building-foot {
  font-size: 20px;
}

.tank-outline {
  fill: none;
  stroke: rgba(255, 255, 255, 0.11);
  stroke-width: 2;
}

.coil-shape {
  fill: none;
  stroke: rgba(255, 241, 171, 0.75);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.heater-dots circle {
  fill: rgba(255, 255, 255, 0.08);
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1.5;
}

.heater-dots circle.active {
  fill: var(--solar);
  stroke: rgba(255, 255, 255, 0.45);
  filter: drop-shadow(0 0 8px rgba(255, 190, 69, 0.8));
}

.pump-shell {
  fill: rgba(20, 33, 45, 0.88);
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 2;
}

.pump-shell.active {
  fill: rgba(102, 219, 255, 0.16);
  stroke: rgba(102, 219, 255, 0.8);
  filter: drop-shadow(0 0 12px rgba(102, 219, 255, 0.6));
}

.pump-core {
  fill: rgba(255, 255, 255, 0.08);
}

.pump-blade {
  fill: rgba(102, 219, 255, 0.85);
}

.pump-blade.second {
  opacity: 0.6;
}

.mix-valve {
  fill: rgba(243, 232, 143, 0.18);
  stroke: rgba(243, 232, 143, 0.7);
  stroke-width: 2;
}

.mix-valve.active {
  fill: rgba(243, 232, 143, 0.32);
  filter: drop-shadow(0 0 10px rgba(243, 232, 143, 0.5));
}

.building-block {
  fill: rgba(255, 255, 255, 0.1);
}

.building-block.tall {
  fill: rgba(255, 255, 255, 0.14);
}

.building-pipe {
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 5;
}

.sensor-callout {
  fill: none;
  stroke: rgba(194, 221, 238, 0.42);
  stroke-width: 1.8;
  stroke-dasharray: 5 5;
}

.sensor-dot {
  fill: rgba(103, 171, 244, 0.18);
  stroke: rgba(113, 176, 243, 0.9);
  stroke-width: 2;
}

.sensor-dot.active {
  fill: rgba(141, 245, 159, 0.18);
  stroke: rgba(141, 245, 159, 0.92);
  filter: drop-shadow(0 0 8px rgba(141, 245, 159, 0.5));
}

.sensor-dot.return {
  stroke: rgba(123, 194, 255, 0.92);
}

.sensor-dot.pressure {
  stroke: rgba(255, 190, 69, 0.92);
}

.sensor-dot.transfer {
  stroke: rgba(102, 219, 255, 0.92);
}

.sensor-dot.supply {
  stroke: rgba(243, 232, 143, 0.92);
}

.sensor-id,
.sensor-value {
  fill: #deebf4;
  font-size: 13px;
}

.sensor-id {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sensor-value {
  fill: #ffffff;
  font-size: 15px;
  font-weight: 700;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e8f1f8;
  font-size: 0.92rem;
}

.status-pill.active {
  background: rgba(141, 245, 159, 0.16);
  border-color: rgba(141, 245, 159, 0.32);
}

.logic-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.logic-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.logic-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.94rem;
}

.logic-item p {
  margin: 0;
  color: #d5e1ea;
  font-size: 0.88rem;
  line-height: 1.4;
}

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

.summary-value {
  margin-top: 8px;
}

.sensor-panel,
.cabinet-panel,
.chart-panel {
  grid-column: 1 / -1;
}

.sensor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(290px, 0.8fr);
  gap: 18px;
}

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

.sensor-group-card,
.io-panel,
.cabinet-module,
.note-card {
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(21, 33, 46, 0.9), rgba(12, 21, 31, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.sensor-group-card,
.io-panel {
  padding: 18px;
}

.sensor-group-card h3,
.cabinet-module h3 {
  margin: 0 0 6px;
  font-size: 0.96rem;
}

.sensor-group-card p,
.note-card p,
.cabinet-module p {
  margin: 0;
  color: #d3dfea;
  font-size: 0.86rem;
  line-height: 1.38;
}

.sensor-group-head,
.side-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.sensor-group-head strong,
.side-heading strong {
  font-size: 0.92rem;
}

.sensor-list {
  display: grid;
  gap: 10px;
}

.sensor-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sensor-row.signal-modbus {
  border-color: rgba(75, 228, 194, 0.22);
}

.sensor-row.signal-digital {
  border-color: rgba(255, 190, 69, 0.18);
}

.sensor-row.signal-calc {
  border-color: rgba(243, 232, 143, 0.18);
}

.sensor-row.signal-safety {
  border-color: rgba(255, 123, 107, 0.18);
}

.sensor-chip {
  min-width: 70px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #eff7fd;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sensor-main strong,
.sensor-main span,
.io-row strong,
.io-row span {
  display: block;
}

.sensor-main strong,
.io-row strong {
  font-size: 0.9rem;
}

.sensor-main span,
.io-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.sensor-reading {
  text-align: right;
}

.sensor-reading strong {
  display: block;
  font-size: 0.92rem;
}

.sensor-reading span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sensor-notes,
.note-stack {
  display: grid;
  gap: 12px;
}

.note-card {
  padding: 16px 18px;
}

.cabinet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cabinet-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.cabinet-rack {
  display: grid;
  gap: 14px;
}

.cabinet-row {
  padding: 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(11, 20, 29, 0.88), rgba(7, 14, 23, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cabinet-row-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 14px;
}

.cabinet-row-head h3,
.cabinet-row-head p {
  margin: 0;
}

.cabinet-row-head p {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.cabinet-module {
  padding: 14px;
}

.cabinet-module.active {
  border-color: rgba(141, 245, 159, 0.34);
  box-shadow: inset 0 0 0 1px rgba(141, 245, 159, 0.18);
}

.module-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #dce7ef;
  font-size: 0.77rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-leds {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.module-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.module-led.active {
  background: var(--surplus);
  border-color: rgba(141, 245, 159, 0.7);
  box-shadow: 0 0 10px rgba(141, 245, 159, 0.55);
}

.cabinet-side {
  display: grid;
  gap: 14px;
}

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

.io-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.io-kind {
  display: inline-flex;
  justify-content: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #f4f7fa;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.io-kind.ai {
  background: rgba(90, 168, 255, 0.16);
}

.io-kind.di {
  background: rgba(255, 190, 69, 0.16);
}

.io-kind.do {
  background: rgba(244, 142, 67, 0.16);
}

.io-kind.bus {
  background: rgba(75, 228, 194, 0.16);
}

.io-row em {
  font-style: normal;
  color: #ffffff;
  font-size: 0.86rem;
}

#power-chart,
#cumulative-chart,
#temperature-chart {
  width: 100%;
  min-height: 300px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    rgba(9, 16, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  color: #c9d7e2;
  font-size: 0.92rem;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.legend-swatch.old {
  background: var(--old);
}

.legend-swatch.new {
  background: var(--new);
}

.legend-swatch.valve {
  background: var(--valve);
}

.legend-swatch.return {
  background: #6f9dc7;
}

.primary-button:hover,
.ghost-button:hover,
.preset-button:hover {
  transform: translateY(-1px);
}

@keyframes pipe-flow {
  to {
    stroke-dashoffset: -56;
  }
}

@media (max-width: 1280px) {
  .live-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .schematic-panel,
  .logic-panel,
  .sensor-panel,
  .cabinet-panel,
  .chart-panel {
    grid-column: 1 / -1;
  }

  .schematic-panel {
    min-height: auto;
    padding: 18px;
  }

  .schematic-view-switch {
    width: 100%;
  }

  .animation-toolbar {
    grid-template-columns: 1fr;
    margin: 12px 0;
  }

  .cumulative-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 0 12px;
  }

  .animation-actions {
    order: 2;
  }

  .live-badge {
    order: 1;
    justify-self: start;
  }

  .time-dock {
    order: 3;
  }

  .speed-dock-inline {
    order: 4;
  }

  .window-dock {
    order: 5;
  }

  .window-meta {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .window-meta span {
    text-align: left;
  }

  .plant-svg {
    width: 100%;
    margin: 0;
  }

  .project-svg {
    margin-top: 0;
  }

  .sensor-layout,
  .cabinet-layout {
    grid-template-columns: 1fr;
  }

  .sensor-groups,
  .cabinet-modules {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    margin: 10px auto 22px;
  }

  .hero,
  .control-panel,
  .schematic-panel,
  .logic-panel,
  .sensor-panel,
  .cabinet-panel,
  .chart-panel {
    padding: 18px;
  }

  .live-strip,
  .dashboard,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .cumulative-strip {
    grid-template-columns: 1fr;
  }

  .chart-panel,
  .logic-panel,
  .sensor-panel,
  .cabinet-panel {
    grid-column: auto;
  }

  .panel-heading {
    flex-direction: column;
  }

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

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

  .sensor-row,
  .io-row {
    grid-template-columns: 1fr;
  }

  .sensor-group-head,
  .side-heading,
  .cabinet-row-head {
    flex-direction: column;
  }

  .speed-dock {
    min-width: 0;
    width: 100%;
  }

  .sensor-reading {
    text-align: left;
  }

  .schematic-panel {
    min-height: auto;
  }

  .control-panel {
    top: 10px;
    left: 9px;
    width: calc(100vw - 18px);
    max-height: calc(100vh - 20px);
  }
}
