/* ==========================================================================
   RPT ENERGY IoT - SCADA & MIERUKA DESIGN SYSTEM (LIGHT THEME)
   Theme: Clean Industrial Light Theme (Enterprise SCADA / Mieruka Style)
   High legibility, polished white & slate surfaces, crisp data contrast
   ========================================================================== */

:root {
    /* Base & Surface Colors */
    --bg-base: #f1f5f9;       /* Slate 100 */
    --bg-surface: #ffffff;    /* Pure White */
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc; /* Slate 50 */
    --border-color: #cbd5e1;  /* Slate 300 */
    --border-subtle: #e2e8f0; /* Slate 200 */
    
    /* Vibrant Status Accents */
    --color-primary: #0284c7;       /* Industrial Sky Blue */
    --color-primary-light: #e0f2fe; /* Light Sky */
    --color-primary-hover: #0369a1;
    --color-success: #059669;       /* Emerald */
    --color-success-light: #d1fae5;
    --color-warning: #d97706;       /* Amber */
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;        /* Crimson Red */
    --color-danger-light: #fee2e2;
    --color-purple: #7c3aed;        /* Violet */
    --color-purple-light: #ede9fe;

    /* Text Hierarchy */
    --color-text-main: #0f172a;    /* Slate 900 (High contrast) */
    --color-text-muted: #475569;   /* Slate 600 */
    --color-text-dim: #64748b;     /* Slate 500 */
    --color-text-light: #94a3b8;   /* Slate 400 */

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 2px 8px -1px rgba(15, 23, 42, 0.08), 0 1px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--color-text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Subtle Geometric Background */
.bg-ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 10% 10%, rgba(2, 132, 199, 0.04) 0%, transparent 40%),
                radial-gradient(circle at 90% 90%, rgba(220, 38, 38, 0.03) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* Polished Card Surface */
.glass-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.glass-panel:hover {
    border-color: #94a3b8;
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   LOGIN PAGE (LIGHT THEME - CLEAN & PROFESSIONAL)
   ========================================================================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.login-bg-glow {
    display: none;
}

.login-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.login-card {
    padding: 40px 36px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.12), 0 0 1px 1px rgba(15, 23, 42, 0.05);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-primary-light);
    border: 1px solid rgba(2, 132, 199, 0.3);
    color: var(--color-primary);
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
}

.pulse-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 6px var(--color-primary);
    animation: blinker 1.5s infinite;
}

@keyframes blinker {
    50% { opacity: 0.3; }
}

.login-logo-container {
    margin-bottom: 14px;
}

.glow-icon {
    font-size: 3rem;
    color: var(--color-primary);
}

.login-title {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--color-text-main);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.plant-specs-tag {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 0.78rem;
    font-weight: 600;
}

.plant-specs-tag span {
    background: #f1f5f9;
    border: 1px solid var(--border-subtle);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--color-text-muted);
}

.plant-specs-tag .badge-alert {
    background: var(--color-danger-light);
    border-color: rgba(220, 38, 38, 0.3);
    color: var(--color-danger);
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-main);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--color-text-main);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn-toggle-pwd {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--color-text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
}

.btn-toggle-pwd:hover {
    color: var(--color-text-main);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: #0284c7;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
    background: #0369a1;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    transform: translateY(-1px);
}

.btn-login {
    margin-top: 10px;
    padding: 14px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--color-text-dim);
    border-top: 1px solid var(--border-subtle);
    padding-top: 18px;
}

.login-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 20px;
}

.alert-danger {
    background: var(--color-danger-light);
    border: 1px solid rgba(220, 38, 38, 0.3);
    color: #991b1b;
}

.alert-success {
    background: var(--color-success-light);
    border: 1px solid rgba(5, 150, 105, 0.3);
    color: #065f46;
}

/* ==========================================================================
   MAIN DASHBOARD NAVBAR (LIGHT THEME)
   ========================================================================== */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 1.8rem;
    color: var(--color-primary);
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text-main);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.plant-code {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 16px;
}

.critical-kpi-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-danger-light);
    border: 1px solid rgba(220, 38, 38, 0.3);
    padding: 6px 14px;
    border-radius: 8px;
}

.kpi-title {
    font-size: 0.72rem;
    color: #991b1b;
    font-weight: 700;
    text-transform: uppercase;
}

.kpi-value-wrapper {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.kpi-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-danger);
    font-family: var(--font-mono);
}

.kpi-max {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 8px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #0284c7;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-main);
}

.user-role-label {
    font-size: 0.68rem;
    color: var(--color-primary);
    font-weight: 700;
}

.btn-icon {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: #f1f5f9;
    color: var(--color-text-main);
    border-color: #94a3b8;
}

.btn-icon.active {
    color: var(--color-warning);
    border-color: var(--color-warning);
    background: var(--color-warning-light);
}

/* ==========================================================================
   NAVIGATION TABS (LIGHT THEME)
   ========================================================================== */
.tabs-nav-bar {
    display: flex;
    gap: 6px;
    padding: 8px 28px 0 28px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.nav-tab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-tab-btn:hover {
    color: var(--color-text-main);
}

.nav-tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: #f0f9ff;
    font-weight: 700;
}

.badge-tab {
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--color-danger-light);
    color: var(--color-danger);
    font-weight: 700;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.main-content {
    flex: 1;
    padding: 24px 28px;
    max-width: 1680px;
    margin: 0 auto;
    width: 100%;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Emergency Alert Banner */
.emergency-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    border-left: 5px solid #dc2626;
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.banner-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.banner-icon {
    font-size: 1.8rem;
    color: #dc2626;
}

.banner-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #991b1b;
}

.banner-desc {
    font-size: 0.82rem;
    color: #b91c1c;
}

/* ==========================================================================
   METRIC CARDS GRID (OVERVIEW)
   ========================================================================== */
.metrics-top-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric-label {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.metric-icon-wrap.danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.metric-icon-wrap.success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.metric-icon-wrap.warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.metric-val {
    font-size: 1.9rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--color-text-main);
}

.metric-unit {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

.metric-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--color-text-dim);
}

.progress-track {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
    transition: width 0.5s ease;
}

/* ==========================================================================
   SCADA MAIN GAUGES & CHARTS SECTION
   ========================================================================== */
.scada-split-grid {
    display: grid;
    grid-template-columns: 1.3fr 2fr;
    gap: 20px;
    margin-bottom: 24px;
}

.gauge-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--color-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--color-primary);
}

.main-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    position: relative;
}

.gauge-circle {
    position: relative;
    width: 240px;
    height: 240px;
}

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

.gauge-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 16;
}

.gauge-progress {
    fill: none;
    stroke: var(--color-danger);
    stroke-width: 16;
    stroke-linecap: round;
    stroke-dasharray: 628;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset 0.8s ease;
}

.gauge-center-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-val-big {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--color-text-main);
    line-height: 1;
}

.gauge-sub-unit {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-top: 4px;
}

.gauge-status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    margin-top: 6px;
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.lvmdb-dual-bars {
    margin-top: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.lvmdb-bar-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bar-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-text-main);
}

/* Chart Panel */
.chart-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.chart-wrapper {
    flex: 1;
    min-height: 280px;
    position: relative;
}

/* Electrical Phase Meters Row */
.phase-meters-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.phase-card {
    padding: 18px;
}

.phase-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-main);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.phase-readings-row {
    display: flex;
    justify-content: space-between;
}

.phase-item {
    display: flex;
    flex-direction: column;
}

.phase-lbl {
    font-size: 0.72rem;
    color: var(--color-text-dim);
}

.phase-num {
    font-size: 1.25rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--color-text-main);
}

/* ==========================================================================
   LIVE REALISTIC ANIMATED MACHINE DIGITAL TWIN (TAB 2)
   ========================================================================== */
.view-mode-selector {
    display: inline-flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    gap: 4px;
}

.btn-view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-view-toggle.active {
    background: #ffffff;
    color: var(--color-primary);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.factory-digital-twin-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.zones-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.machine-zone-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.zone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.zone-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--color-text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.zone-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-success-light);
    color: var(--color-success);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

/* Machine Visualizer Viewport */
.machine-stage {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    height: 180px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

/* Plating Animated Crane & Tanks */
.plating-track {
    position: absolute;
    top: 25px;
    left: 20px;
    right: 20px;
    height: 4px;
    background: #94a3b8;
}

.plating-hoist-carriage {
    position: absolute;
    top: 15px;
    width: 36px;
    height: 24px;
    background: #0284c7;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.7rem;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.4);
    animation: platingHoistTravel 8s infinite alternate ease-in-out;
}

@keyframes platingHoistTravel {
    0% { left: 30px; }
    30% { left: 120px; }
    70% { left: 240px; }
    100% { left: 360px; }
}

.plating-hanger {
    position: absolute;
    top: 24px;
    left: 17px;
    width: 2px;
    height: 45px;
    background: #475569;
    animation: platingDip 8s infinite ease-in-out;
}

@keyframes platingDip {
    0%, 100% { height: 25px; }
    30%, 70% { height: 55px; }
}

.plating-basket {
    position: absolute;
    bottom: -12px;
    left: -10px;
    width: 22px;
    height: 14px;
    background: #d97706;
    border-radius: 2px;
}

.plating-tanks-row {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    justify-content: space-around;
}

.tank-box {
    flex: 1;
    height: 65px;
    background: #e2e8f0;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #334155;
}

.tank-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 75%;
    background: rgba(2, 132, 199, 0.35);
    animation: liquidBubble 2s infinite ease-in-out alternate;
}

.tank-liquid.copper { background: rgba(217, 119, 6, 0.35); }
.tank-liquid.nickel { background: rgba(16, 185, 129, 0.35); }
.tank-liquid.chrome { background: rgba(14, 165, 233, 0.45); }

@keyframes liquidBubble {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

/* Injection Molding Machine Animation */
.injection-machine-view {
    position: relative;
    width: 90%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.inj-base {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    height: 16px;
    background: #334155;
    border-radius: 4px;
}

.inj-platen-fixed {
    width: 45px;
    height: 80px;
    background: #0284c7;
    border-radius: 4px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
}

.inj-platen-moving {
    width: 45px;
    height: 80px;
    background: #0369a1;
    border-radius: 4px;
    z-index: 2;
    position: relative;
    animation: clampCycle 5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes clampCycle {
    0%, 20% { transform: translateX(0); }   /* Mold Closed */
    40%, 70% { transform: translateX(-50px); } /* Mold Open & Eject */
    85%, 100% { transform: translateX(0); } /* Clamping */
}

.inj-barrel {
    position: absolute;
    right: 15px;
    width: 140px;
    height: 28px;
    background: #475569;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding-left: 10px;
    color: #f8fafc;
    font-size: 0.68rem;
    font-weight: 700;
}

.inj-barrel-heat {
    position: absolute;
    top: -4px;
    left: 20px;
    right: 20px;
    height: 6px;
    background: #ea580c;
    border-radius: 2px;
    box-shadow: 0 0 8px #ea580c;
    animation: heaterPulse 1.5s infinite alternate;
}

@keyframes heaterPulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.inj-hopper {
    position: absolute;
    top: -26px;
    right: 25px;
    width: 32px;
    height: 26px;
    background: #d97706;
    clip-path: polygon(0% 0%, 100% 0%, 75% 100%, 25% 100%);
}

.part-ejecting {
    position: absolute;
    left: 85px;
    top: 40px;
    width: 16px;
    height: 16px;
    background: #10b981;
    border-radius: 2px;
    animation: partDrop 5s infinite;
}

@keyframes partDrop {
    0%, 45% { opacity: 0; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(0); }
    60% { opacity: 1; transform: translateY(35px); }
    70%, 100% { opacity: 0; transform: translateY(45px); }
}

/* Painting Conveyor & Robot Animation */
.conveyor-belt {
    position: absolute;
    bottom: 25px;
    left: 10px;
    right: 10px;
    height: 12px;
    background: repeating-linear-gradient(90deg, #475569 0px, #475569 10px, #64748b 10px, #64748b 20px);
    border-radius: 4px;
    animation: conveyorRoll 2s infinite linear;
}

@keyframes conveyorRoll {
    from { background-position: 0 0; }
    to { background-position: 40px 0; }
}

.spray-robot-arm {
    position: absolute;
    top: 20px;
    left: 45%;
    width: 8px;
    height: 45px;
    background: #0284c7;
    transform-origin: top center;
    animation: sprayArmSweep 2.5s infinite ease-in-out alternate;
}

@keyframes sprayArmSweep {
    0% { transform: rotate(-25deg); }
    100% { transform: rotate(25deg); }
}

.spray-mist {
    position: absolute;
    bottom: -15px;
    left: -12px;
    width: 32px;
    height: 20px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.6) 0%, transparent 70%);
    animation: mistPulse 0.5s infinite alternate;
}

@keyframes mistPulse {
    0% { opacity: 0.3; transform: scale(0.8); }
    100% { opacity: 0.9; transform: scale(1.2); }
}

/* Cooling Tower Fan Animation */
.ct-fan-icon {
    font-size: 2.2rem;
    color: var(--color-primary);
    animation: fanSpin 0.8s infinite linear;
}

@keyframes fanSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Water drop animation */
.water-spray {
    color: #0284c7;
    animation: waterGush 1s infinite alternate;
}

@keyframes waterGush {
    0% { opacity: 0.3; transform: translateY(-2px); }
    100% { opacity: 0.8; transform: translateY(2px); }
}

/* Machine Metrics Mini-Grid */
.machine-metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.m-metric-item {
    display: flex;
    flex-direction: column;
}

.m-label {
    font-size: 0.7rem;
    color: var(--color-text-dim);
}

.m-val {
    font-size: 0.95rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--color-text-main);
}

/* ==========================================================================
   CAD FLOORPLAN (MODE B)
   ========================================================================== */
.layout-viewer-card {
    padding: 24px;
}

.layout-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.layout-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.78rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-normal { background: var(--color-success); }
.dot-warning { background: var(--color-warning); }
.dot-critical { background: var(--color-danger); animation: pulseDanger 1.5s infinite; }

@keyframes pulseDanger {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
}

.interactive-layout-container {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--border-color);
}

.layout-image-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
}

.layout-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

.layout-hotspot {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.layout-hotspot:hover {
    transform: translate(-50%, -50%) scale(1.15);
    z-index: 20;
}

.hotspot-pin {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.hotspot-pin.critical { background: #dc2626; border-color: #ef4444; }
.hotspot-pin.warning { background: #d97706; border-color: #f59e0b; }
.hotspot-pin.normal { background: #059669; border-color: #10b981; }

.hotspot-detail-box {
    margin-top: 20px;
    padding: 18px 24px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

/* ==========================================================================
   SINGLE LINE DIAGRAM (SLD) TAB (LIGHT THEME)
   ========================================================================== */
.sld-panel {
    padding: 24px;
}

.sld-tree-container {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 30px;
    overflow-x: auto;
}

.sld-root-row {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.sld-node {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 18px;
    min-width: 220px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: var(--transition);
}

.sld-node:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.sld-node.critical-node {
    border: 2px solid #dc2626;
    background: #fff1f2;
}

.node-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--color-text-main);
    margin-bottom: 4px;
}

.node-specs {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.node-metric {
    font-family: var(--font-mono);
    font-weight: 800;
    color: var(--color-primary);
    margin-top: 4px;
    font-size: 0.85rem;
}

.sld-branches-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
    position: relative;
}

.sld-branch-column {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.branch-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sub-feeder-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feeder-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 0.82rem;
    transition: var(--transition);
}

.feeder-card:hover {
    background: #f0f9ff;
    border-color: #bae6fd;
}

/* Role Badges */
.role-badge {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-admin { background: var(--color-danger-light); color: var(--color-danger); }
.badge-engineer { background: var(--color-primary-light); color: var(--color-primary); }
.badge-tech { background: var(--color-success-light); color: var(--color-success); }

/* ==========================================================================
   4M & ACTION PLAN TAB (LIGHT THEME)
   ========================================================================== */
.action-plan-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.action-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.action-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.plan-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.plan-pillar-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.pillar-menghilangkan { background: var(--color-danger-light); color: var(--color-danger); border: 1px solid rgba(220, 38, 38, 0.2); }
.pillar-mengurangi { background: var(--color-warning-light); color: var(--color-warning); border: 1px solid rgba(217, 119, 6, 0.2); }
.pillar-memperpanjang { background: var(--color-purple-light); color: var(--color-purple); border: 1px solid rgba(124, 58, 237, 0.2); }
.pillar-mengganti { background: var(--color-success-light); color: var(--color-success); border: 1px solid rgba(5, 150, 105, 0.2); }

.plan-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--color-text-main);
    margin-bottom: 8px;
}

.plan-desc {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 16px;
    line-height: 1.45;
}

.plan-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.plan-pic {
    font-weight: 700;
    color: var(--color-primary);
}

.plan-status-select {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--color-text-main);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

/* Spec vs Actual Table */
.table-panel {
    padding: 24px;
}

.data-table-wrapper {
    overflow-x: auto;
    margin-top: 14px;
}

.scada-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.scada-table th {
    background: #f8fafc;
    padding: 12px 16px;
    color: var(--color-text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.scada-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--color-text-main);
}

.scada-table tr:hover td {
    background: #f8fafc;
}

/* ==========================================================================
   RESPONSIVE QUERIES
   ========================================================================== */
@media (max-width: 1200px) {
    .metrics-top-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .scada-split-grid {
        grid-template-columns: 1fr;
    }
    .phase-meters-grid {
        grid-template-columns: 1fr;
    }
    .sld-branches-grid {
        grid-template-columns: 1fr;
    }
    .zones-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }
    .main-content {
        padding: 16px;
    }
    .metrics-top-grid {
        grid-template-columns: 1fr;
    }
    .tabs-nav-bar {
        padding: 8px 16px 0 16px;
    }
}
