/* --- Global & Background --- */
body { margin: 0; padding: 0; padding-bottom: 50px; font-family: 'Segoe UI', sans-serif; background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%); min-height: 100vh; display: flex; flex-direction: column; align-items: center; overflow-x: hidden; user-select: none; }

/* --- Header --- */
.app-header { width: 100%; background: #1a252f; color: white; text-align: center; padding: 15px 0; margin-bottom: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); border-bottom: 4px solid #3498db; position: relative; }
.main-title { margin: 0; color: #ecf0f1; font-size: 1.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
.subtitle { margin: 5px 0 0 0; font-size: 0.9rem; color: #bdc3c7; font-weight: 500; letter-spacing: 1px; }
.header-credits { position: absolute; bottom: 8px; right: 20px; font-size: 12px; color: #95a5a6; font-weight: bold; letter-spacing: 0.5px; }

/* --- Stage & Layering --- */
.stage { display: flex; align-items: center; justify-content: center; gap: 140px; background: rgba(255, 255, 255, 0.45); border: 1px solid rgba(255, 255, 255, 0.6); backdrop-filter: blur(10px); border-radius: 20px; box-shadow: 0 20px 40px rgba(0,0,0,0.1); padding: 90px 60px 50px 60px; position: relative; max-width: 1100px; width: 95%; box-sizing: border-box; margin-top: 0; }

/* SVGs drawn at Z-index 2 (behind the pipe) */
svg#hoses { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
/* RPZ Block drawn at Z-index 10 (in front of hoses) */
.rpz-block { width: 460px; height: 60px; background: #c19a6b; border: 4px solid #8e6c46; border-radius: 12px; display: flex; justify-content: space-around; position: relative; z-index: 10; box-shadow: inset 0 6px 10px rgba(0,0,0,0.4), 0 8px 12px rgba(0,0,0,0.3); }

/* --- Hoses & Flow Styling --- */
.hose { fill: none; stroke-width: 7; stroke-linecap: round; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.4)); transition: stroke-dashoffset 0.5s; }
.hose-flow { fill: none; stroke-width: 4; stroke-dasharray: 12 12; animation: flowHose 0.4s linear infinite; filter: drop-shadow(0 0 3px rgba(255,255,255,0.9)); transition: stroke-dashoffset 0.5s; }
@keyframes flowHose { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
.hose-flow-reverse { animation: flowHoseReverse 0.4s linear infinite; }
@keyframes flowHoseReverse { from { stroke-dashoffset: -24; } to { stroke-dashoffset: 0; } }

.tc-red { background: #d32f2f !important; color: white !important; border-color: #b71c1c !important; }
.tc-blue { background: #2980b9 !important; color: white !important; border-color: #1a5276 !important; }
.tc-yellow { background: #f1c40f !important; color: #333 !important; border-color: #f39c12 !important; }
.hose-pressurized { stroke: #f39c12 !important; filter: drop-shadow(0 0 8px #f1c40f) drop-shadow(0 0 12px #f1c40f) !important; animation: pulsePressure 0.8s infinite alternate; }
@keyframes pulsePressure { from { filter: drop-shadow(0 0 5px #f1c40f); } to { filter: drop-shadow(0 0 15px #e67e22); stroke: #e67e22; } }

.stamp { position: absolute; top: 30%; left: 30%; transform: translate(-50%, -50%) rotate(-15deg) scale(2); font-size: 5rem; font-weight: 900; letter-spacing: 4px; text-transform: uppercase; border: 8px solid; border-radius: 12px; padding: 10px 30px; opacity: 0; z-index: 100; pointer-events: none; transition: transform 0.4s, opacity 0.4s; }
.stamp-pass { color: rgba(39, 174, 96, 0.85); border-color: rgba(39, 174, 96, 0.85); opacity: 1; transform: translate(-50%, -50%) rotate(-15deg) scale(1); }
.stamp-fail { color: rgba(192, 57, 43, 0.85); border-color: rgba(192, 57, 43, 0.85); opacity: 1; transform: translate(-50%, -50%) rotate(-15deg) scale(1); }

/* Modals */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(4px); align-items: center; justify-content: center; }
.modal-content { background: #ecf0f1; padding: 25px 30px; border-radius: 12px; width: 450px; max-width: 90%; border: 4px solid #34495e; color: #2c3e50; box-shadow: 0 15px 30px rgba(0,0,0,0.4); position: relative; }
.modal-content h2 { margin-top: 0; color: #c0392b; font-size: 1.4rem; border-bottom: 2px solid #bdc3c7; padding-bottom: 10px; text-transform: uppercase; }
.math-box { background: #34495e; color: #ecf0f1; padding: 15px; border-radius: 8px; font-family: monospace; margin: 15px 0; font-size: 13px; font-weight: bold; }
.close-btn { position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold; color: #7f8c8d; cursor: pointer; transition: 0.2s; } .close-btn:hover { color: #e74c3c; }

/* RPZ Device Internals */
.rpz-cover-plate { position: absolute; top: 0; bottom: 0; left: 110px; right: 30px; background: #c19a6b repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 2px, transparent 2px, transparent 4px); border-radius: 8px; border: 2px solid #8e6c46; z-index: 2; padding: 5px; box-sizing: border-box; }
.main-watts-label { font-size: 11px; font-weight: 800; color: #333; text-transform: uppercase; border-bottom: 2px solid #8e6c46; padding-bottom: 3px; }
.status-bar { position: absolute; top: -190px; left: 0; width: 100%; background: #34495e; padding: 12px 15px; border-radius: 8px; font-size: 14px; line-height: 1.4; font-weight: bold; color: #f1c40f; box-sizing: border-box; z-index: 50; text-align: center; box-shadow: 0 6px 15px rgba(0,0,0,0.25); }

.pipe { position: absolute; top: 10px; width: 60px; height: 40px; background: #bdc3c7; border: 3px solid #7f8c8d; border-radius: 4px; z-index: 0; overflow: hidden; }
.pipe-in { left: -60px; border-right: none; } .pipe-out { right: -60px; border-left: none; }
.water-texture { background: repeating-linear-gradient(-45deg, rgba(52, 152, 219, 0.4), rgba(41, 128, 185, 0.6) 30px); background-size: 42px 42px; animation: flowTexture 1s linear infinite; width: 100%; height: 100%; }
@keyframes flowTexture { 0% { background-position: 0 0; } 100% { background-position: 42px 0; } }
.water-chamber { position: absolute; top: 0; bottom: 0; left: 120px; right: 40px; border-radius: 4px; overflow: hidden; z-index: 1; }

.check-valve { position: absolute; top: -5px; height: calc(100% + 10px); width: 8px; background: #2c3e50; z-index: 4; display: flex; flex-direction: column; align-items: center; border-radius: 2px; }
#cv1 { left: 50%; } #cv2 { left: 75%; }
.cv-label { position: absolute; top: -22px; font-size: 11px; font-weight: 900; color: #c0392b; z-index: 20; background: rgba(255, 255, 255, 0.85); padding: 1px 4px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.cv-flap { width: 6px; height: 45px; background: #3498db; border: 2px solid #2980b9; border-radius: 3px; position: absolute; top: 6px; left: 8px; transform-origin: top left; transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); }
.check-valve.flowing .cv-flap { transform: rotate(45deg); }

.relief-valve { position: absolute; bottom: -60px; left: 50%; transform: translateX(-50%); width: 90px; height: 60px; background: inherit; border: 4px solid #8e6c46; border-top: none; border-radius: 0 0 45px 45px; z-index: 20; display: flex; flex-direction: column; align-items: center; box-shadow: inset 0 -4px 6px rgba(0,0,0,0.1), 0 6px 8px rgba(0,0,0,0.2); cursor: pointer; transition: transform 0.2s; }
.relief-valve:hover { transform: translateX(-50%) scale(1.05); }
.rv-hint { position: absolute; top: 6px; right: 6px; background: #e74c3c; color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 12px; font-weight: bold; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 4px rgba(0,0,0,0.3); animation: pulseHint 1.5s infinite; pointer-events: none; }
@keyframes pulseHint { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); } 70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); } }
.rv-label { font-size: 9px; font-weight: bold; color: #34495e; margin-top: 15px; letter-spacing: 1px; }
.rv-dump-port { width: 36px; height: 12px; background: #34495e; border-radius: 0 0 6px 6px; position: absolute; bottom: -12px; border: 2px solid #1a252f; border-top: none; display: flex; justify-content: center; }
.water-dump { width: 20px; height: 0; background: rgba(52, 152, 219, 0.7); position: absolute; top: 10px; transition: height 0.3s cubic-bezier(0.4, 0.0, 1, 1); z-index: -1; border-radius: 0 0 10px 10px; }
.relief-valve.dumping .water-dump { height: 120px; animation: splash 0.2s infinite alternate; }
@keyframes splash { 0% { width: 18px; background: rgba(52, 152, 219, 0.7); } 100% { width: 22px; background: rgba(41, 128, 185, 0.8); } }

.shutoff-valve { position: absolute; width: 36px; height: 36px; background: #34495e; border: 3px solid #1a252f; border-radius: 50%; top: 10px; cursor: pointer; z-index: 20; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 5px rgba(0,0,0,0.5), 0 4px 6px rgba(0,0,0,0.3); }
.sov-label { position: absolute; top: -32px; font-size: 10px; font-weight: 800; color: #2c3e50; background: #ecf0f1; border: 1px solid #bdc3c7; padding: 2px 6px; border-radius: 4px; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.valve-lever { position: relative; width: 50px; height: 16px; background: #27ae60; border: 2px solid #1e8449; border-radius: 3px; transition: transform 0.3s; display: flex; align-items: center; justify-content: center; }
.shutoff-valve .valve-lever::after { content: 'WATTS'; font-size: 8px; font-weight: bold; color: #fff; letter-spacing: 1px; }
.shutoff-valve.closed .valve-lever { transform: rotate(90deg); background: #c0392b; border-color: #922b21; }
#sov1 { left: 95px; } #sov2 { right: 5px; }  

.port-container { position: relative; width: 45px; height: 50px; margin-top: -50px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; z-index: 20; } 
.tc-toggle { position: absolute; top: -22px; width: 32px; height: 16px; background: #c0392b; border: 2px solid #922b21; border-radius: 4px; color: white; font-size: 8px; font-weight: bold; display: flex; justify-content: center; align-items: center; cursor: pointer; z-index: 4; transition: 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.tc-toggle.open { background: #27ae60; border-color: #1e8449; }
.tc-head { width: 36px; height: 36px; background: #fdfefe; border: 3px solid #8e6c46; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; color: #2c3e50; z-index: 3; transition: 0.2s; box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.2); }
.tc-head:hover { transform: scale(1.1); background: #eceff1; }
.tc-head.ready-to-connect { animation: pulseTC 1s infinite alternate; background: #fffde7; border-color: #fbc02d; }
@keyframes pulseTC { from { box-shadow: 0 0 5px #fbc02d; } to { box-shadow: 0 0 15px #fbc02d; } }
.connector-stem { width: 14px; height: 14px; background: #c19a6b repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 2px, transparent 2px, transparent 4px); border: 2px solid #8e6c46; border-top: none; border-bottom: none; z-index: 1; }

/* --- Test Kit Box (COMPACTED) --- */
.test-kit { width: 300px; background: #2c3e50; padding: 10px 15px 90px 15px; border-radius: 12px; border: 6px solid #1a252f; color: white; text-align: center; position: relative; z-index: 20; }

.bleed-valves-top { display: flex; justify-content: space-around; position: absolute; top: -45px; width: 100%; left: 0; z-index: 20; }
.valve-container { display: flex; flex-direction: column; align-items: center; }
.valve-label { font-size: 11px; color: #34495e; font-weight: bold; text-align: center; margin-bottom: 2px; }

/* Small Rotary Top Knobs */
.round-knob-small { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #1a252f; cursor: ns-resize; box-shadow: 0 3px 5px rgba(0,0,0,0.5), inset 0 2px 3px rgba(255,255,255,0.2); transition: box-shadow 0.1s, filter 0.1s; position: relative; margin: 4px 0; z-index: 25; }
.round-knob-small:hover { filter: brightness(1.2); box-shadow: 0 0 6px rgba(255,255,255,0.4); }
.round-knob-small:active { filter: brightness(0.9); }
.round-knob-small::after { content: ''; position: absolute; top: 3px; left: calc(50% - 1.5px); width: 3px; height: 10px; background: rgba(0,0,0,0.6); border-radius: 1.5px; }
.knob-grey { background: #7f8c8d; }

.valve-status { font-size: 11px; font-weight: bold; color: #fff; background: #c0392b; padding: 2px 6px; border-radius: 4px; transition: 0.3s; border: 1px solid #922b21; }

.gauge-area-inner { display: flex; align-items: center; justify-content: space-around; background: #34495e; padding: 5px 10px; border-radius: 8px; margin-bottom: 8px; border: 2px solid #1a252f; }
.large-gauge-dial { width: 65px; height: 65px; background: #fdfefe; border: 5px solid #2c3e50; border-radius: 50%; position: relative; box-shadow: inset 0 4px 8px rgba(0,0,0,0.2); display: flex; justify-content: center; align-items: center; }
.large-gauge-dial::before { content: ''; position: absolute; top: 4px; left: 4px; right: 4px; bottom: 4px; border-radius: 50%; border: 2px dashed #bdc3c7; }
.large-gauge-needle { width: 3px; height: 30px; background: #e74c3c; position: absolute; bottom: 50%; transform-origin: bottom center; transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); z-index: 2; border-radius: 2px 2px 0 0; }
.large-gauge-pivot { width: 12px; height: 12px; background: #e67e22; border-radius: 50%; position: absolute; z-index: 3; border: 2px solid #2c3e50; }
.large-gauge-value { position: absolute; bottom: 4px; font-family: monospace; font-size: 11px; font-weight: bold; color: #2c3e50; background: #ecf0f1; padding: 1px 4px; border-radius: 4px; border: 1px solid #bdc3c7; z-index: 1; }

.gauge-controls { display: flex; flex-direction: column; align-items: center; }
.large-gauge-label { font-size: 13px; font-weight: bold; color: #bdc3c7; letter-spacing: 1px; margin-bottom: 5px; }
.psi-input-wrapper input { width: 45px; background: #ecf0f1; border: 1px solid #7f8c8d; border-radius: 3px; text-align: center; font-family: monospace; font-weight: bold; font-size: 13px; color: #2c3e50; padding: 2px; }

.lcd { background: #002200; color: #39ff14; font-family: monospace; font-size: 1.6rem; padding: 2px; border-radius: 6px; border: 2px solid #444; margin-bottom: 8px; box-shadow: inset 0 0 10px #000; }

.fault-panel { background: #1a252f; border-radius: 6px; padding: 5px 8px; margin-bottom: 8px; }
.fault-toggle-row { display: flex; justify-content: space-around; align-items: center; }
.fault-toggle-row span { font-size: 12px; font-weight: bold; color: #bdc3c7; }
.f-switch { width: 30px; height: 14px; background: #c0392b; border-radius: 7px; cursor: pointer; position: relative; transition: 0.3s; border: 1px solid #922b21; }
.f-switch::after { content: ''; position: absolute; top: 1px; left: 1px; width: 10px; height: 10px; background: white; border-radius: 50%; transition: 0.3s; }
.f-switch.active { background: #27ae60; border-color: #1e8449; }
.f-switch.active::after { transform: translateX(16px); }

.results-board { background: #1a252f; border-radius: 6px; padding: 6px 10px; margin-bottom: 10px; text-align: left; border: 2px solid #34495e; }
.result-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 12px; font-weight: bold; color: #bdc3c7; }
.result-row:last-child { margin-bottom: 0; }
.res-badge { padding: 2px 6px; border-radius: 3px; font-size: 10px; background: #7f8c8d; color: white; letter-spacing: 1px; transition: 0.3s; }
.res-pass { background: #27ae60; }
.res-fail { background: #c0392b; }

.btn-reset { width: 100%; padding: 8px; background: #e67e22; border: none; border-radius: 5px; color: white; font-weight: bold; cursor: pointer; font-size: 13px; text-transform: uppercase; }

/* --- BOTTOM CONTROL AREA --- */
.bottom-control-area { position: absolute; bottom: -30px; left: 0; width: 100%; display: flex; justify-content: space-around; align-items: flex-end; }
.bottom-column { display: flex; flex-direction: column; align-items: center; }

.bottom-label { font-size: 11px; font-weight: 900; color: #bdc3c7; margin-bottom: 2px; letter-spacing: 1px; }
.bottom-status { font-size: 11px; font-weight: bold; background: #1a252f; color: #bdc3c7; padding: 2px 6px; border-radius: 3px; margin-bottom: 5px; border: 1px solid #34495e; min-width: 45px; text-align: center; }

.round-knob { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #1a252f; cursor: ns-resize; box-shadow: 0 4px 6px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.3); transition: box-shadow 0.1s, filter 0.1s; position: relative; margin-bottom: -5px; z-index: 25; }
.round-knob:hover { filter: brightness(1.2); box-shadow: 0 0 8px rgba(255,255,255,0.5); }
.round-knob:active { filter: brightness(0.9); }
.round-knob::after { content: ''; position: absolute; top: 4px; left: calc(50% - 2px); width: 4px; height: 12px; background: rgba(0,0,0,0.5); border-radius: 2px; }

.knob-red { background: #c0392b; }
.knob-blue { background: #2980b9; }
.knob-yellow { background: #f1c40f; }

/* The Small Hose Fittings directly under the knobs */
.hose-fitting { width: 18px; height: 30px; border: 3px solid #1a252f; border-top: none; border-radius: 0 0 5px 5px; position: relative; z-index: 20; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: flex-end; padding-bottom: 6px; box-sizing: border-box; }
.hose-fitting::after { content: ''; position: absolute; bottom: 3px; left: -4px; width: 20px; height: 8px; background: inherit; border: 3px solid #1a252f; border-radius: 2px; }
.hose-fitting:hover { transform: translateY(3px); filter: brightness(1.2); }
.hose-selected { filter: brightness(1.5); box-shadow: 0 5px 15px rgba(255,255,255,0.4); }
.fitting-red { background: #d32f2f; } .fitting-blue { background: #2980b9; } .fitting-yellow { background: #f1c40f; }

.hose-hint { font-size: 16px; font-weight: 900; color: white; pointer-events: none; z-index: 30; text-shadow: 1px 1px 2px #000; line-height: 1; }

/* === JUST-IN-TIME DRAG TIP === */
.drag-tip { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #e74c3c; color: white; padding: 12px 24px; border-radius: 8px; font-weight: 900; font-size: 14px; letter-spacing: 0.5px; box-shadow: 0 6px 20px rgba(0,0,0,0.5); z-index: 10000; display: none; pointer-events: none; animation: popInTip 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popInTip { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
