:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #5f6b65;
  --line: #d8dfd8;
  --heat: #1d5fb8;
  --pump: #b51f2a;
  --accent: #6d7f2a;
  --focus: #253f87;
  --shadow: 0 18px 45px rgba(23, 33, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px 22px 0;
}

.brand-header {
  display: grid;
  grid-template-columns: minmax(160px, 320px) minmax(0, 1fr);
  gap: 26px;
  align-items: center;
  margin-bottom: 14px;
}

.brand-header img {
  display: block;
  width: min(320px, 62vw);
  height: auto;
  object-fit: contain;
}

.legal-note {
  max-width: 940px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.legal-note h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 1rem;
}

.legal-note p {
  margin-bottom: 6px;
}

.legal-note p:last-child {
  margin-bottom: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(460px, 720px);
  gap: 10px 18px;
  align-items: start;
  margin-bottom: 18px;
}

.page-title {
  grid-column: 2;
  position: relative;
  z-index: 2;
  max-width: min(100%, 720px);
  margin-top: -22px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.55rem);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.result-strip {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-strip div {
  min-width: 0;
  padding: 14px 16px;
  border-left: 1px solid var(--line);
}

.result-strip div:first-child {
  border-left: 0;
}

.result-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.result-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.35rem;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.controls {
  display: grid;
  gap: 14px;
}

.panel,
.chart-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid #c8d1ca;
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 10px 11px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(37, 63, 135, 0.22);
  outline-offset: 1px;
  border-color: var(--focus);
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid #c8d1ca;
  border-radius: 6px;
  background: #fbfcfb;
}

.field input {
  border: 0;
  background: transparent;
}

.field span {
  padding-right: 11px;
  color: var(--muted);
  white-space: nowrap;
}

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

.section-heading h2 {
  margin-bottom: 0;
}

button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #c8d1ca;
  border-radius: 6px;
  background: #f8faf8;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
}

button:hover {
  background: #edf3ef;
}

.pump-table {
  display: grid;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.source-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.pump-row {
  display: grid;
  grid-template-columns: minmax(54px, 0.8fr) repeat(3, minmax(58px, 82px));
  gap: 8px;
  align-items: center;
  margin-top: 0 !important;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

.pump-row:first-child {
  border-top: 0;
}

.pump-row.head {
  background: #edf1ed;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pump-row input {
  padding: 7px 8px;
}

.chart-area {
  min-width: 0;
  padding: 18px;
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  margin-bottom: 12px;
}

.chart-toolbar h2 {
  margin-bottom: 4px;
}

.chart-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend i {
  width: 28px;
  height: 4px;
  border-radius: 99px;
}

.legend .heat {
  background: var(--heat);
}

.legend .pump {
  background: var(--pump);
}

.legend .cop {
  border-top: 4px dashed #8d9490;
  background: transparent;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfb;
}

.analysis-panel {
  margin-top: 16px;
  border: 0;
  border-radius: 8px;
  padding: 16px;
  background: #fffdfd;
}

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

.analysis-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
}

.analysis-card span,
.analysis-card small {
  display: block;
  color: var(--muted);
}

.analysis-card span {
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}

.analysis-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.analysis-card small {
  font-size: 0.78rem;
  line-height: 1.35;
}

.recommendations {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.recommendations h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

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

.recommendation {
  min-width: 0;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
}

.recommendation strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.recommendation p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.recommendation.ok {
  border-left-color: #3e9f3b;
}

.recommendation.warning {
  border-left-color: #d0a321;
}

.recommendation.danger {
  border-left-color: #d94c4c;
}

@media (max-width: 1050px) {
  .brand-header,
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .page-title {
    grid-column: 1;
    margin-top: -12px;
  }

  .result-strip {
    grid-column: 1;
  }

  .legal-note {
    max-width: none;
  }

  .result-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 14px 0;
  }

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

  .result-strip div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .result-strip div:first-child {
    border-top: 0;
  }

  .chart-toolbar {
    display: grid;
  }

  .legend {
    justify-content: flex-start;
  }

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

  .recommendation-list {
    grid-template-columns: 1fr;
  }
}
