/* Pump Head — industrial hydraulic instrument aesthetic */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=IBM+Plex+Mono:wght@400;500;600&family=Syne:wght@600;700;800&display=swap");

:root {
  --ink: #0a1628;
  --ink-2: #122033;
  --panel: #132a40;
  --panel-2: #1a334d;
  --line: rgba(125, 211, 252, 0.12);
  --line-strong: rgba(125, 211, 252, 0.28);
  --water: #38bdf8;
  --water-deep: #0284c7;
  --teal: #2dd4bf;
  --amber: #fbbf24;
  --coral: #fb7185;
  --mint: #6ee7b7;
  --text: #e8f1f8;
  --muted: #8ba3b8;
  --dim: #5c738a;
  --input-bg: rgba(8, 18, 32, 0.65);
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(45, 212, 191, 0.08), transparent 50%),
    radial-gradient(800px 400px at 50% 100%, rgba(2, 132, 199, 0.1), transparent 45%),
    linear-gradient(165deg, #07101c 0%, var(--ink) 40%, #0c1a2e 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--water), var(--water-deep));
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
  display: grid;
  place-items: center;
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 36rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.duty-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(45, 212, 191, 0.1));
  border: 1px solid var(--line-strong);
  min-width: 220px;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(245, 158, 11, 0.9));
  color: #1c1917;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-export:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(251, 191, 36, 0.28);
}

.btn-export:active {
  transform: translateY(0);
}

.btn-export:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.duty-pill .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
}

.duty-pill .value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--teal);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: linear-gradient(165deg, rgba(26, 51, 77, 0.75), rgba(19, 42, 64, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.panel-hd h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.panel-hd .tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--dim);
  letter-spacing: 0.06em;
}

.panel-bd {
  padding: 1rem 1.1rem 1.15rem;
}

/* Form controls */
.inputs {
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
}

.inputs::-webkit-scrollbar {
  width: 8px;
}
.inputs::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.2);
  border-radius: 8px;
}

.section {
  margin-bottom: 1.15rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--water);
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.65rem;
}

.field-grid .full {
  grid-column: 1 / -1;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

label.field span {
  font-size: 0.72rem;
  color: var(--muted);
}

label.field input,
label.field select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

label.field input:focus,
label.field select:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

label.field select {
  font-family: var(--font);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.check-row input {
  accent-color: var(--water);
}

/* Fittings mini table */
.fit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.fit-table th {
  text-align: left;
  color: var(--dim);
  font-weight: 500;
  padding: 0.25rem 0.2rem 0.45rem;
  border-bottom: 1px solid var(--line);
}

.fit-table td {
  padding: 0.28rem 0.2rem;
  border-bottom: 1px solid rgba(125, 211, 252, 0.06);
  color: var(--muted);
}

.fit-table input {
  width: 3.2rem;
  padding: 0.25rem 0.3rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-align: center;
}

.leq-readout {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.leq-readout .chip {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(8, 18, 32, 0.5);
  border: 1px solid var(--line);
}

.leq-readout .chip b {
  display: block;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--amber);
}

.leq-readout .chip span {
  font-size: 0.68rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Results column */
.results {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

/* KPI strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .kpi-strip {
    grid-template-columns: 1fr 1fr;
  }
}

.kpi {
  position: relative;
  overflow: hidden;
  padding: 1rem 1rem 0.9rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(26, 51, 77, 0.9), rgba(15, 35, 55, 0.95));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--water), var(--teal));
  opacity: 0.85;
}

.kpi.accent-amber::after {
  background: linear-gradient(90deg, var(--amber), #f59e0b);
}
.kpi.accent-coral::after {
  background: linear-gradient(90deg, var(--coral), #e11d48);
}
.kpi.accent-mint::after {
  background: linear-gradient(90deg, var(--mint), var(--teal));
}

.kpi .k {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  margin-bottom: 0.35rem;
}

.kpi .v {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.kpi .u {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 0.25rem;
}

.kpi .sub {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Schematic */
.schematic-wrap {
  padding: 0.5rem 0.75rem 0.75rem;
}

.schematic-svg {
  width: 100%;
  height: auto;
  display: block;
  min-height: 220px;
}

.schematic-svg .pipe {
  fill: none;
  stroke: url(#pipeGrad);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.schematic-svg .pipe-glow {
  fill: none;
  stroke: rgba(56, 189, 248, 0.25);
  stroke-width: 18;
  stroke-linecap: round;
  filter: blur(2px);
}

.schematic-svg .flow-dash {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 2;
  stroke-dasharray: 6 10;
  stroke-linecap: round;
  animation: flow 1.2s linear infinite;
}

@keyframes flow {
  to {
    stroke-dashoffset: -32;
  }
}

.schematic-svg .tank {
  fill: rgba(8, 18, 32, 0.6);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.schematic-svg .water-fill {
  fill: url(#waterGrad);
  opacity: 0.85;
}

.schematic-svg .pump-body {
  fill: #1e3a52;
  stroke: var(--teal);
  stroke-width: 2;
}

.schematic-svg .label {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 11px;
}

.schematic-svg .value {
  fill: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
}

.schematic-svg .elev-line {
  stroke: rgba(251, 191, 36, 0.45);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* Charts row */
.charts {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.15rem;
}

@media (max-width: 900px) {
  .charts {
    grid-template-columns: 1fr;
  }
}

.chart-box {
  position: relative;
  min-height: 280px;
}

.chart-box canvas {
  width: 100% !important;
  height: 260px !important;
}

/* TDH stack */
.tdh-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tdh-row {
  display: grid;
  grid-template-columns: 110px 1fr 64px;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.8rem;
}

.tdh-row .name {
  color: var(--muted);
}

.tdh-row .bar-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(8, 18, 32, 0.55);
  overflow: hidden;
  border: 1px solid var(--line);
}

.tdh-row .bar {
  height: 100%;
  border-radius: 999px;
  width: 0;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.tdh-row .bar.static {
  background: linear-gradient(90deg, #0369a1, var(--water));
}
.tdh-row .bar.pressure {
  background: linear-gradient(90deg, #0f766e, var(--teal));
}
.tdh-row .bar.friction {
  background: linear-gradient(90deg, #b45309, var(--amber));
}
.tdh-row .bar.exit {
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
}
.tdh-row .bar.total {
  background: linear-gradient(90deg, var(--water-deep), var(--mint));
}

.tdh-row .num {
  font-family: var(--mono);
  text-align: right;
  color: var(--text);
}

/* Gauges */
.gauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.gauge {
  text-align: center;
}

.gauge-ring {
  --p: 0;
  --c: var(--water);
  width: 120px;
  height: 120px;
  margin: 0 auto 0.5rem;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(8, 18, 32, 0.7) 0);
  display: grid;
  place-items: center;
  position: relative;
}

.gauge-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
}

.gauge-ring .inner {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.05rem;
}

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

.gauge .hint {
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.gauge .hint.ok {
  color: var(--mint);
}
.gauge .hint.high,
.gauge .hint.fail {
  color: var(--coral);
}
.gauge .hint.low,
.gauge .hint.caution {
  color: var(--amber);
}
.gauge .hint.marginal {
  color: var(--coral);
}

/* NPSH meter */
.npsh-meter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}

.npsh-bars {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.npsh-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.npsh-bar-label b {
  font-family: var(--mono);
  color: var(--text);
  font-weight: 500;
}

.npsh-track {
  height: 16px;
  border-radius: 8px;
  background: rgba(8, 18, 32, 0.55);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.npsh-fill {
  height: 100%;
  width: 0;
  transition: width 0.4s ease;
  border-radius: 8px;
}

.npsh-fill.a {
  background: linear-gradient(90deg, var(--water-deep), var(--water));
}
.npsh-fill.r {
  background: linear-gradient(90deg, #9f1239, var(--coral));
}

.npsh-badge {
  min-width: 140px;
  text-align: center;
  padding: 0.85rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 18, 32, 0.45);
}

.npsh-badge[data-status="ok"] {
  border-color: rgba(110, 231, 183, 0.45);
  color: var(--mint);
}
.npsh-badge[data-status="caution"] {
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--amber);
}
.npsh-badge[data-status="marginal"],
.npsh-badge[data-status="fail"] {
  border-color: rgba(251, 113, 133, 0.5);
  color: var(--coral);
}

.npsh-badge .big {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 600;
  display: block;
}

.npsh-badge .lbl {
  font-size: 0.72rem;
  margin-top: 0.25rem;
  line-height: 1.3;
}

/* Details grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

@media (max-width: 720px) {
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.detail {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(8, 18, 32, 0.4);
  border: 1px solid var(--line);
}

.detail .dk {
  font-size: 0.68rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail .dv {
  font-family: var(--mono);
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

/* Footer note */
.footnote {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--dim);
  line-height: 1.45;
}

.footnote code {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}
