/* --- Stat Display Container --- */
.rs-stat-display {
    position: relative;
    padding: 20px 0;
}

/* --- Shared Grid Layout --- */
.rs-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* Updated to allow 4 items per row */
    gap: 30px;
    justify-content: center;
}

/* Override for Node Sequence: Allow 4 in a row (min-width 220px) */
.rs-stat-nodes .rs-stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.rs-stat-item {
    background: #fff;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.rs-stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

/* ===========================
   TACHOMETER LAYOUT
   =========================== */
.rs-tachometer-graph {
    position: relative;
    width: 200px;
    height: 100px;
    margin: 0 auto 20px auto;
    overflow: hidden;
}

.rs-tachometer-svg {
    width: 100%;
    height: 200px; 
}

.rs-tachometer-bg {
    fill: none;
    stroke: #e9ecef;
    stroke-width: 15;
}

.rs-tachometer-fill {
    fill: none;
    stroke-width: 15;
    stroke-linecap: round;
    stroke-dasharray: 0, 1000;
    transition: stroke-dasharray 1.5s ease-out;
}

/* ===========================
   CIRCULAR (DONUT) LAYOUT
   =========================== */
.rs-circle-graph {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 20px auto;
}

.rs-circle-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.rs-circle-bg {
    fill: none;
    stroke: #e9ecef;
    stroke-width: 12;
}

.rs-circle-fill {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 0, 1000;
    transition: stroke-dasharray 1.5s ease-out;
}

.rs-circle-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    text-align: center;
}

/* ===========================
   LINEAR PROGRESS LAYOUT
   =========================== */
.rs-linear-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
    gap: 15px;
}

.rs-linear-header > div:first-child {
    flex: 1;
    display: flex;
    align-items: center;
    text-align: left;
    min-width: 0;
}

.rs-linear-icon {
    font-size: 24px;
    margin-right: 10px;
    flex-shrink: 0;
    line-height: 1;
}

.rs-linear-bar-bg {
    width: 100%;
    height: 12px;
    background-color: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.rs-linear-bar-fill {
    height: 100%;
    width: 0; 
    border-radius: 6px;
    transition: width 1.5s ease-out;
}

/* ===========================
   WATER (LIQUID) LAYOUT
   =========================== */

.rs-stat-water .rs-stat-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    padding: 20px;
}

.rs-water-container {
    position: relative;
    width: 80px;
    height: 160px;
    border-radius: 40px;
    background: #e9ecef;
    border: 3px solid #fff;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.05), 
        0 10px 20px rgba(0,0,0,0.1);
    margin-right: 25px;
    overflow: hidden;
    z-index: 1;
    flex-shrink: 0;
}

/* Top-Left Glass Reflection (Highlight) */
.rs-water-container::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 12px;
    width: 8px;
    height: 120px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,0.0));
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
    opacity: 0.3;
}

/* Bottom-Right Glass Reflection (Rim Light / Caustic) */
.rs-water-container::before {
    content: '';
    position: absolute;
    bottom: 15px;
    right: 8px;
    width: 40px;
    height: 12px;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    z-index: 5;
    pointer-events: none;
    transform: rotate(-15deg);
    filter: blur(2px);
    opacity: 0.5;
}

/* Meniscus Layer */
.rs-meniscus-layer {
    position: absolute;
    top: var(--target-top, 100%);
    left: 0;
    width: 100%;
    height: 20px; 
    margin-top: -10px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 60%);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
    z-index: 4; 
    pointer-events: none;
    transition: top 1.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* STILL FLUID (No Wave) */
.rs-water-wave {
    position: absolute;
    top: var(--target-top, 100%);
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #007cba;
    
    /* VIVID OIL EFFECT */
    filter: saturate(3) contrast(1.3) brightness(0.85);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.3);
    background-image: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, rgba(0,0,0,0.3) 100%);
    
    border-radius: 0;
    animation: none;
    
    transition: top 1.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
}

.rs-water-glint {
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    filter: blur(1px);
    box-shadow: 0 0 5px rgba(255,255,255,0.9);
    opacity: 0;
    z-index: 3;
    animation: rs-glint-sparkle 3s infinite ease-in-out;
}

@keyframes rs-glint-sparkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 0.9; transform: scale(1.4); }
}

.rs-water-info { flex: 1; min-width: 0; }
.rs-water-info .rs-stat-icon { font-size: 28px; margin-bottom: 5px; display: block; }
.rs-water-info .rs-stat-value { font-size: 2.2rem; margin-bottom: 0; }
.rs-water-info .rs-stat-label { margin-top: 5px; display: block; }

.rs-water-bubble {
    position: absolute;
    bottom: -10px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    z-index: 2;
    animation: rs-bubble-rise 3s infinite linear;
    pointer-events: none;
}

@keyframes rs-bubble-rise {
    0% { bottom: -10px; transform: translateX(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { bottom: 110%; transform: translateX(-5px); opacity: 0; }
}


/* ===========================
   RETRO / STEAMPUNK LAYOUT (OVERHAUL)
   =========================== */

/* Base container: Dark metal plate */
.rs-stat-retro .rs-stat-item {
    background: linear-gradient(135deg, #4b4b4b, #2c2c2c);
    border-radius: 6px;
    padding: 0; /* Removing padding to let the frame handle spacing */
    box-shadow: 0 15px 25px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace;
    color: #d4c598; /* Parchment text color */
}

/* The Frame: Brass/Copper edge with gradients */
.rs-retro-frame {
    padding: 25px 20px;
    border: 8px solid #b87333; /* Fallback Copper */
    /* Brushed metal gradient border */
    border-image: linear-gradient(to bottom right, #e6c17b, #8b5a2b, #e6c17b) 1;
    position: relative;
    background: 
        radial-gradient(circle at center, rgba(0,0,0,0) 0%, rgba(0,0,0,0.6) 100%),
        repeating-linear-gradient(45deg, rgba(0,0,0,0.05) 0px, rgba(0,0,0,0.05) 2px, transparent 2px, transparent 4px);
    z-index: 1;
}

/* Corner Screw Heads */
.rs-retro-screw {
    position: absolute;
    width: 14px;
    height: 14px;
    background: radial-gradient(circle, #e6c17b 0%, #8b5a2b 100%);
    border-radius: 50%;
    box-shadow: 0 2px 3px rgba(0,0,0,0.8);
    z-index: 2;
}
/* Screw Slot (The line in the screw) */
.rs-retro-screw::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 2px;
    right: 2px;
    height: 2px;
    background: #333;
    transform: rotate(45deg);
}

/* Positioning Screws */
.rs-retro-screw.tl { top: 6px; left: 6px; }
.rs-retro-screw.tr { top: 6px; right: 6px; transform: rotate(90deg); }
.rs-retro-screw.bl { bottom: 6px; left: 6px; transform: rotate(45deg); }
.rs-retro-screw.br { bottom: 6px; right: 6px; transform: rotate(135deg); }

/* The Header (Icon + Label) */
.rs-retro-header {
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 2px rgba(0,0,0,0.8);
    border-bottom: 1px dashed #666;
    padding-bottom: 10px;
}

/* NIXIE TUBE VALUE DISPLAY (The Glowing Box) */
.rs-retro-nixie-box {
    background: #000;
    border: 3px inset #555;
    border-radius: 4px;
    padding: 15px 10px;
    margin: 20px 0;
    position: relative;
    box-shadow: inset 0 0 15px rgba(0,0,0,1);
}

/* Glass Reflection on Nixie Tube */
.rs-retro-nixie-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1), rgba(255,255,255,0));
    pointer-events: none;
}

.rs-retro-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffaa00; /* Glowing Amber */
    text-shadow: 
        0 0 5px #ffaa00, 
        0 0 10px #ff5500, 
        0 0 20px #ff5500;
    letter-spacing: 4px;
}

/* STEAM PIPE PROGRESS BAR */
.rs-retro-pipe-container {
    height: 20px;
    background: #222;
    border-radius: 10px;
    border: 2px solid #555;
    position: relative;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.8);
    overflow: hidden;
}

.rs-retro-pipe-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(to bottom, #d97d46 0%, #a0400b 50%, #6e2c00 100%); /* Copper Pipe Look */
    box-shadow: 0 0 10px rgba(160, 64, 11, 0.5);
    position: relative;
    transition: width 1.5s ease-out;
}

/* Shine on the pipe */
.rs-retro-pipe-fill::after {
    content: '';
    position: absolute;
    top: 2px; left: 0; right: 0; height: 4px;
    background: rgba(255,255,255,0.3);
}

/* Vertical grid lines (Grating) over the pipe */
.rs-retro-pipe-container::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(90deg, rgba(0,0,0,0.5) 0px, rgba(0,0,0,0.5) 2px, transparent 2px, transparent 20px);
    pointer-events: none;
    z-index: 2;
}


/* ===========================
   SHARED TEXT STYLES
   =========================== */
.rs-stat-content {
    position: relative;
    z-index: 2;
}
.rs-stat-tachometer .rs-stat-content {
    margin-top: -60px;
}

.rs-stat-icon {
    font-size: 24px;
    margin-bottom: 5px;
    display: inline-block;
}

.rs-stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
    color: #333;
    white-space: nowrap; 
    flex-shrink: 0; 
}

.rs-stat-circle .rs-stat-value,
.rs-stat-linear .rs-stat-value,
.rs-stat-water .rs-stat-value {
    font-size: 2rem; 
}

.rs-linear-header .rs-stat-value {
    font-size: 1.5rem;
    margin-bottom: 0;
    line-height: 1.2;
}

.rs-stat-label {
    font-size: 1rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.2;
}

/* ===========================
   NODE SEQUENCE LAYOUT
   =========================== */

/* Container for the sequence */
.rs-stat-nodes .rs-stat-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 20px;
    background: #f8f9fa; /* Very light tech background */
    border: 1px solid #e9ecef;
    border-radius: 12px;
}

/* The vertical track (Left side) */
.rs-node-track-container {
    position: relative;
    width: 40px;
    height: 180px; /* Tall vertical sequence */
    margin-right: 25px;
    display: flex;
    flex-direction: column-reverse; /* Build from bottom up */
    justify-content: space-between;
    align-items: center;
}

/* The connecting spine line */
.rs-node-spine {
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 50%;
    width: 2px;
    background: #e9ecef; /* Inactive grey line */
    transform: translateX(-50%);
    z-index: 0;
}

/* Active spine (fills up) */
.rs-node-spine-fill {
    position: absolute;
    bottom: 5px; /* Start at bottom */
    left: 50%;
    width: 2px;
    height: 0%; /* Animates to height */
    background: currentColor; /* Inherits stat color */
    transform: translateX(-50%);
    z-index: 0;
    transition: height 1.5s ease-out;
}

/* Individual Nodes (Dots) */
.rs-node-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e9ecef; /* Inactive color */
    border: 2px solid #fff;
    z-index: 1;
    position: relative;
    transition: background-color 0.4s ease, transform 0.4s ease;
    box-shadow: 0 0 0 1px #e9ecef;
}

/* Active Node State */
.rs-node-dot.active {
    background: currentColor; /* Inherits stat color */
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor;
    transform: scale(1.1);
}

/* Pulsing effect for the topmost active node */
.rs-node-dot.active.pulse {
    animation: rs-node-pulse 2s infinite;
}

/* Info Section (Right side) */
.rs-node-info {
    flex: 1;
    text-align: left;
}
.rs-node-info .rs-stat-value {
    font-size: 2.5rem;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; /* Clean modern font */
    font-weight: 300; /* Thin weight looks more "sci-fi" */
}

/* UPDATED: Easier to read label, no subtle styling */
.rs-node-info .rs-stat-label {
    font-size: 1rem;
    letter-spacing: normal;
    text-transform: none;
    opacity: 1;
    color: #333;
    font-weight: 600;
    margin-top: 5px;
    display: block;
}

@keyframes rs-node-pulse {
    0% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor; }
    50% { box-shadow: 0 0 0 2px #fff, 0 0 0 8px rgba(0,0,0,0.1); }
    100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor; }
}