:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    box-sizing: border-box;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0; /* CRITICAL FOR iOS SAFARI TO PREVENT AUTO EXPANSION */
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

img, video, canvas, svg, table, input, select, textarea {
    max-width: 100%;
}

.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: float 20s infinite alternate;
}

.shape-1 {
    width: 450px;
    height: 450px;
    background: #4338ca;
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 380px;
    height: 380px;
    background: #047857;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 280px;
    height: 280px;
    background: #0f766e;
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(25px, 40px) scale(1.08); }
}

.container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 24px;
    width: 95%;
    box-sizing: border-box;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.glass-panel-inner {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.glass-panel-inner:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.header-title h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.8px;
    line-height: 1.2;
}

.header-title span { color: var(--primary); }
.header-title p { color: var(--text-secondary); font-size: 1.05rem; }

.badge-prod {
    font-size: 0.75rem;
    vertical-align: middle;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #10b981;
    color: #34d399;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    display: inline-block;
}

.header-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.header-meta-item {
    font-size: 0.86rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-sep {
    color: rgba(255, 255, 255, 0.2);
}

.header-meta-calib {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.header-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    font-size: 0.78rem;
    font-weight: 600;
    color: #34d399;
    cursor: pointer;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.header-btn-pdf {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.header-btn-pdf:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: #10b981;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.header-btn-reports {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
    border: 1px solid rgba(45, 212, 191, 0.3);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.header-btn-reports:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 118, 110, 0.55);
}

.header-btn-settings {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.header-btn-settings:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.82rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-sizing: border-box;
}

.status-pill:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.18);
}

.pill-label {
    color: #94a3b8;
    font-weight: 500;
}

.pill-val {
    color: #f8fafc;
    font-weight: 600;
}

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.connected {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}
.dot.disconnected { 
    background-color: var(--danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.shadow-btn {
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}
.shadow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 1.8s infinite;
    flex-shrink: 0;
}

/* NPK Soil Health */
.soil-health {
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.soil-health h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.npk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.npk-item {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.npk-item h4 {
    margin-top: 12px;
    font-weight: 600;
}
.npk-item small { color: var(--text-secondary); }

.npk-circle {
    width: 110px;
    height: 110px;
    margin: 0 auto;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.3);
    border: 4px solid var(--glass-border);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    transition: all 0.5s ease;
    box-sizing: border-box;
}

.npk-circle .val {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
}
.npk-circle .unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Sensor Grid (Soil Nutrition Average) */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.sensor-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 12px 14px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.sensor-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-2px);
}

.sensor-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: #38bdf8;
    line-height: 1.2;
    word-break: break-all;
}

.sensor-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.2px;
    word-break: break-word;
}

/* Agri Status Tags */
.agri-status-tag {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.agri-status-tag.status-optimal {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.agri-status-tag.status-low {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.4);
}

.agri-status-tag.status-high {
    background: rgba(59, 130, 246, 0.15);
    color: #38bdf8;
    border-color: rgba(59, 130, 246, 0.4);
}

.agri-status-tag.status-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.icon {
    font-size: 2.2rem;
    background: rgba(255, 255, 255, 0.05);
    width: 54px;
    height: 54px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 14px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.metric-data {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.metric-data h3 {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    line-height: 1.3;
}

.metric-data p {
    font-size: 1.65rem;
    font-weight: 700;
    margin: 2px 0;
    line-height: 1.2;
    word-break: normal;
}

/* Content Split Layout */
.content-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.left-column-split {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Control Panel */
.control-panel, .chart-panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.control-panel h2, .chart-panel h2 {
    font-size: 1.35rem;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
    word-break: break-word;
}

.tank-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tank {
    background: rgba(0,0,0,0.2);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.tank h3 { font-size: 1.0rem; margin-bottom: 8px; word-break: break-word; }

.valves-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.valve-item {
    background: rgba(0,0,0,0.2);
    padding: 12px 14px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.valve-item span {
    word-break: break-word;
    flex: 1;
    padding-right: 6px;
    font-size: 0.9rem;
}

.valve-item.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Switch */
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; box-sizing: border-box; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.12);
    transition: .3s;
}
.slider:before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 4px; bottom: 4px;
    background-color: #94a3b8; transition: .3s;
}
input:checked + .slider { background-color: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
input:checked + .slider:before { transform: translateX(22px); background-color: white; }
.slider.round { border-radius: 30px; }
.slider.round:before { border-radius: 50%; }

/* Smart Actions */
.smart-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.macro-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-blue { background: #3b82f6; box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-green { background: #10b981; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.btn-red, .btn-danger {
    background: linear-gradient(135deg, #dc2626, #991b1b) !important;
    color: #ffffff !important;
    border: 1px solid rgba(239, 68, 68, 0.6) !important;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4) !important;
}
.btn-red:hover, .btn-danger:hover {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.6) !important;
    transform: translateY(-2px);
}
.btn-cancel-job {
    background: linear-gradient(135deg, #dc2626, #991b1b) !important;
    color: #ffffff !important;
    border: 1px solid rgba(239, 68, 68, 0.6) !important;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-cancel-job:hover {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.6) !important;
    transform: translateY(-1px);
}

/* Mobile adjustments for Active Job Popup Banner */
#active-job-banner {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
    border: 1px solid rgba(56, 189, 248, 0.45);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75);
    border-radius: 12px;
    padding: 10px 16px;
    color: #f8fafc;
    font-size: 0.86rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    backdrop-filter: blur(14px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - 24px);
    max-width: 480px;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    #active-job-banner {
        top: 8px;
        padding: 8px 12px;
        font-size: 0.78rem;
        border-radius: 10px;
        gap: 8px;
    }
    .btn-cancel-job {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
    /* Hide header button text labels on all standard smartphones — show emoji icons only */
    .header-btn-label {
        display: none !important;
    }
}

/* ========================================================================= */
/* Job History: Desktop Table vs Mobile Cards Responsive System             */
/* ========================================================================= */
@media (min-width: 769px) {
    .desktop-only-table {
        display: table !important;
    }
    .mobile-only-cards {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .desktop-only-table {
        display: none !important;
    }
    .mobile-only-cards {
        display: flex !important;
    }
}

.job-history-table th {
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.job-history-table td {
    padding: 10px 8px;
    font-size: 0.84rem;
    vertical-align: middle;
}

.job-history-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.job-sub-note {
    font-size: 0.73rem;
    color: #94a3b8;
    font-weight: normal;
    line-height: 1.25;
    margin-top: 3px;
}

.job-log-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.job-log-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(15, 23, 42, 0.95);
}

.job-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.job-log-time {
    font-size: 0.82rem;
    font-weight: 700;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 5px;
}

.job-log-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.job-log-title {
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.job-log-volume {
    font-size: 0.86rem;
    font-weight: 700;
    color: #f8fafc;
    text-align: right;
}

.job-log-volume-sub {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: normal;
}

.job-log-notes {
    font-size: 0.78rem;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid #38bdf8;
    padding: 6px 10px;
    border-radius: 4px;
    line-height: 1.4;
}

.badge-status {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.badge-status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-status-bypass {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-status-aborted {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Chart Panel Layout */
.chart-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chart-badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-sizing: border-box;
}

.chart-kpi-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chart-kpi-item {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
    min-width: 0;
}

.chart-kpi-item:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
}

.kpi-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kpi-title {
    color: #94a3b8;
    font-weight: 500;
}

.kpi-value {
    color: #ffffff;
    font-weight: 700;
    margin-left: auto;
}

/* Toolbar & Filters */
.chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chart-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    box-sizing: border-box;
}

.filter-btn {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.filter-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #ffffff;
    border-color: rgba(59, 130, 246, 0.4);
}

.filter-btn.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.chart-time-selector {
    display: flex;
    align-items: center;
    gap: 5px;
    box-sizing: border-box;
}

.time-label {
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 500;
}

.time-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.time-btn:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

.time-btn.active {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border-color: #10b981;
    font-weight: 700;
}

.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.alert-banner {
    background: rgba(239, 68, 68, 0.2);
    border-left: 4px solid var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-weight: 500;
    font-size: 0.9rem;
    box-sizing: border-box;
    width: 100%;
}
.hidden { display: none !important; }

/* Progress UI */
.progress-banner {
    background: rgba(15, 23, 42, 0.8);
    border-left: 4px solid var(--primary);
    padding: 14px 18px;
    margin-bottom: 18px;
    box-sizing: border-box;
    width: 100%;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.bg-blue { background: var(--primary); }
.bg-green { background: var(--success); }

/* Table Responsive Scrolling Wrapper */
.table-responsive-container, [style*="overflow-x: auto"] {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* Universal Weather 12-Hour Forecast (Desktop PC & Mobile Horizontal Scroll) */
#forecast-12h-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 12px !important;
    padding: 6px 2px 14px 2px !important;
    box-sizing: border-box !important;
    scrollbar-width: thin !important;
}

#forecast-12h-container::-webkit-scrollbar {
    height: 6px;
}
#forecast-12h-container::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
}
#forecast-12h-container::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.3);
    border-radius: 4px;
}
#forecast-12h-container::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.6);
}

.forecast-card, #forecast-12h-container > div {
    flex: 0 0 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
    flex-shrink: 0 !important;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    box-sizing: border-box !important;
    transition: transform 0.2s ease, background 0.2s ease;
}

.forecast-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(56, 189, 248, 0.4);
}

.table-scroll-hint {
    display: none;
    font-size: 0.74rem;
    color: #38bdf8;
    text-align: right;
    margin-bottom: 6px;
    font-weight: 500;
}

/* Terminal Log */
.terminal-log {
    background: #020617;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    max-height: 240px;
    overflow-y: auto;
    color: #94a3b8;
    line-height: 1.5;
    word-break: break-all;
    box-sizing: border-box;
    width: 100%;
}

.log-line { margin-bottom: 3px; font-family: 'JetBrains Mono', monospace; }
.log-line.text-blue { color: #38bdf8 !important; }
.log-line.text-green { color: #10b981 !important; }
.log-line.text-purple { color: #c084fc !important; }
.log-line.text-red { color: #f87171 !important; font-weight: bold; }
.log-line.text-yellow { color: #fbbf24 !important; }

/* Input Glass */
.input-glass {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 8px 12px;
    color: #f8fafc;
    font-family: inherit;
    font-size: 0.88rem;
    width: 100%;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.input-glass:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* Settings Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(3, 7, 18, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
}

.modal-content {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.18);
    width: 95%;
    max-width: 780px;
    max-height: 92vh;
    border-radius: 18px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.85), 0 0 35px rgba(56, 189, 248, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    animation: modalPop 0.22s ease-out;
    box-sizing: border-box;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    background: rgba(30, 41, 59, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: #f8fafc;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.settings-tab-bar {
    display: flex;
    flex-wrap: wrap;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 16px;
    gap: 8px;
    box-sizing: border-box;
}

.settings-tab-btn {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-sizing: border-box;
}

.settings-tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
    box-sizing: border-box;
}

.modal-tab-panel { display: none; width: 100%; box-sizing: border-box; }
.modal-tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

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

.modal-footer {
    padding: 12px 20px;
    background: rgba(30, 41, 59, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    box-sizing: border-box;
}

/* Mobile Bottom Floating Navigation Bar (Dock) */
.mobile-bottom-dock {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    height: 60px;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 9999;
    padding: 4px 6px;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.6);
    box-sizing: border-box;
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    text-decoration: none;
    background: transparent;
    border: none;
    padding: 4px 6px;
    border-radius: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    flex: 1;
    max-width: 58px;
    box-sizing: border-box;
}

.dock-icon {
    font-size: 1.2rem;
    line-height: 1;
    margin-bottom: 2px;
}

.dock-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.dock-item:hover, .dock-item:active {
    color: #f8fafc;
}

.dock-item.active {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

/* ========================================================================= */
/* COMPREHENSIVE RESPONSIVE DESIGN & MOBILE FIXES (iOS & Android)            */
/* ========================================================================= */

@media (max-width: 1100px) {
    .content-split {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 16px !important;
    }
}

@media (max-width: 768px) {
    /* Spacious full-width container on mobile (Restoring card width) */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 75px auto !important;
        padding: 10px 8px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
    }

    .mobile-bottom-dock {
        display: flex !important;
        height: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        padding-bottom: max(4px, env(safe-area-inset-bottom, 4px)) !important;
    }

    .table-scroll-hint {
        display: block !important;
    }

    /* Header styling */
    header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        margin-bottom: 14px !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .header-title h1 {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .header-title p {
        font-size: 0.82rem !important;
        line-height: 1.45 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Header Controls Hidden on Mobile (Replaced by Bottom Dock) */
    .header-controls {
        display: none !important;
    }

    /* Diagnostics Ribbon Hidden on Mobile */
    .system-status-bar, #sec-diagnostics {
        display: none !important;
    }

    /* Soil Health & NPK 2x2 */
    .soil-health {
        padding: 12px 10px !important;
        margin-bottom: 16px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .npk-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .npk-circle {
        width: 76px !important;
        height: 76px !important;
        border-width: 3px !important;
    }

    .npk-circle .val {
        font-size: 1.25rem !important;
    }

    .npk-item h4 {
        font-size: 0.78rem !important;
        margin-top: 6px !important;
    }

    .npk-item small {
        font-size: 0.66rem !important;
    }

    .agri-status-tag {
        font-size: 0.66rem !important;
        padding: 2px 6px !important;
    }

    /* 12-Hour Weather Forecast (Guaranteed Horizontal Touch Scroll on iOS) */
    #forecast-12h-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 4px 2px 10px 2px !important;
        gap: 8px !important;
        box-sizing: border-box !important;
        scrollbar-width: thin !important;
    }

    #forecast-12h-container > div, .forecast-card {
        flex: 0 0 92px !important;
        min-width: 92px !important;
        max-width: 92px !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
    }

    /* Metrics Grid 2-column on mobile */
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-bottom: 16px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .metric-card {
        padding: 10px !important;
        gap: 8px !important;
        border-radius: 12px !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .metric-card .icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.2rem !important;
        border-radius: 8px !important;
    }

    .metric-data h3 {
        font-size: 0.68rem !important;
        letter-spacing: 0.2px !important;
    }

    .metric-data p {
        font-size: 1.15rem !important;
    }

    /* All sections contained */
    section {
        padding: 12px 10px !important;
        margin-bottom: 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    #sec-weather div[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    #sec-guide div[style*="grid-template-columns"],
    #threat-items-grid,
    #sec-sprayer div[style*="grid-template-columns: repeat(auto-fit, minmax(250px, 1fr))"],
    #sec-sprayer div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"],
    #sec-future-advisory div[style*="grid-template-columns: repeat(auto-fit, minmax(300px, 1fr))"],
    #sec-recipe div[style*="grid-template-columns: repeat(auto-fit, minmax(230px, 1fr))"],
    #sec-recipe div[style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    #sec-future-advisory div[style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"],
    #sec-ai-multiplier div[style*="grid-template-columns: repeat(auto-fit, minmax(130px, 1fr))"],
    #sec-ai-multiplier div[style*="grid-template-columns: repeat(auto-fit, minmax(140px, 1fr))"],
    #sec-sprayer div[style*="grid-template-columns: repeat(auto-fit, minmax(130px, 1fr))"],
    #sec-sprayer div[style*="grid-template-columns: repeat(auto-fit, minmax(140px, 1fr))"] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
    }

    #sec-recipe div[style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Content Split & Left Column Fix */
    .content-split {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 16px !important;
        box-sizing: border-box !important;
    }

    .left-column-split {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 16px !important;
        box-sizing: border-box !important;
    }

    /* Panduan Kualitas Tanah Ideal */
    .chart-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .chart-panel ul {
        padding-left: 16px !important;
        margin: 0 !important;
        word-break: break-word !important;
    }

    .chart-panel li {
        font-size: 0.8rem !important;
        line-height: 1.45 !important;
        margin-bottom: 5px !important;
        word-break: break-word !important;
    }

    /* Rata-Rata Sensor Kesehatan Tanah */
    .sensor-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .sensor-item {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 8px 10px !important;
        overflow: hidden !important;
    }

    .sensor-value {
        font-size: 1.25rem !important;
        word-break: break-all !important;
    }

    /* History Chart & Toolbar Horizontal Scroll */
    #sec-charts {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .chart-container {
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: 230px !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .chart-toolbar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .chart-filters {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding-bottom: 4px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 5px !important;
        box-sizing: border-box !important;
    }
    .chart-filters::-webkit-scrollbar { display: none; }

    .chart-kpi-bar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding-bottom: 4px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 5px !important;
        box-sizing: border-box !important;
    }
    .chart-kpi-bar::-webkit-scrollbar { display: none; }

    .filter-btn, .time-btn {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        min-height: 32px !important;
        padding: 4px 8px !important;
        font-size: 0.72rem !important;
    }

    .chart-kpi-item {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 4px 6px !important;
        font-size: 0.72rem !important;
    }

    /* Kontrol Cerdas & Jalur Irigasi Blok */
    #sec-controls {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .tank-status {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }

    .tank {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        padding: 12px 10px !important;
    }

    .valves-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }

    .valve-item {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 12px !important;
    }

    .valve-item span {
        font-size: 0.82rem !important;
        word-break: break-word !important;
        flex: 1 !important;
        padding-right: 6px !important;
    }

    /* Tombol Otomasi */
    .smart-actions {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .macro-buttons {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }

    .macro-buttons .btn {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        min-height: 42px !important;
        font-size: 0.82rem !important;
        padding: 10px !important;
        justify-content: center !important;
        text-align: center !important;
        word-break: break-word !important;
    }

    /* Settings Modal Mobile Bottom Sheet */
    .modal {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 92vh !important;
        max-height: 92vh !important;
        border-radius: 20px 20px 0 0 !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 12px 14px !important;
    }

    .modal-body {
        padding: 12px 14px !important;
    }

    .modal-footer {
        padding: 8px 14px !important;
        flex-direction: column-reverse !important;
    }

    .modal-footer .btn {
        width: 100% !important;
        min-height: 42px !important;
    }

    .settings-tab-bar {
        padding: 6px 8px !important;
    }

    .settings-tab-btn {
        font-size: 0.74rem !important;
        padding: 5px 8px !important;
    }
}

/* Extra Small Phones (iPhone SE, Small Android < 380px) */
@media (max-width: 380px) {
    .container {
        padding: 6px 4px !important;
    }

    .header-title h1 {
        font-size: 1.3rem !important;
    }

    .header-controls {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px !important;
    }

    /* On tiny screens, hide button labels – show emoji icons only */
    .header-btn-label {
        display: none !important;
    }

    .npk-circle {
        width: 68px !important;
        height: 68px !important;
    }

    .npk-circle .val {
        font-size: 1.1rem !important;
    }

    .status-pill {
        font-size: 0.66rem !important;
        padding: 4px 4px !important;
    }

    .metric-data p {
        font-size: 1.05rem !important;
    }
}

/* ==========================================================================
   DESKTOP & TABLET WORKSPACE TAB NAVIGATION BAR (ZERO INFINITE SCROLL)
   ========================================================================== */
.desktop-workspace-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 22px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(16px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.desktop-workspace-nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.ws-tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0; /* CRITICAL FOR iOS SAFARI TO PREVENT FONT/BUTTON STACKING */
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
}

.ws-tab-btn:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.ws-tab-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(37, 99, 235, 0.25));
    border: 1px solid rgba(96, 165, 250, 0.55);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.ws-tab-icon {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
}

.ws-tab-text {
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
}

.workspace-tab-pane {
    display: none;
    animation: fadeInWorkspaceTab 0.25s ease forwards;
}

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

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

@media (max-width: 768px) {
    .desktop-workspace-nav {
        padding: 6px 8px;
        gap: 6px;
        margin-bottom: 16px;
        border-radius: 12px;
    }
    .ws-tab-btn {
        padding: 7px 11px;
        font-size: 0.78rem;
        gap: 5px;
        flex-shrink: 0;
    }
    .ws-tab-icon {
        font-size: 0.90rem;
    }
    .sub-tab-btn {
        padding: 5px 11px;
        font-size: 0.75rem;
        gap: 4px;
        flex-shrink: 0;
    }
}

/* ==========================================================================
   PIN / PASSWORD SECURITY MODAL FOR MANUAL VALVE & PUMP CONTROLS
   ========================================================================== */
.pin-modal-card {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.96));
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(239, 68, 68, 0.2);
    border-radius: 16px;
    max-width: 420px;
    width: 90%;
    padding: 24px;
    margin: auto;
    position: relative;
    backdrop-filter: blur(20px);
}

.pin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.pin-modal-header h3 {
    margin: 0;
    color: #f87171;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pin-input-display {
    width: 100%;
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(239, 68, 68, 0.4);
    border-radius: 10px;
    color: #ffffff;
    font-family: monospace;
    margin-bottom: 16px;
    outline: none;
}

.pin-input-display:focus {
    border-color: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.pin-keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.pin-key-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #f8fafc;
    font-size: 1.3rem;
    font-weight: 600;
    padding: 12px 0;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.pin-key-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.03);
}

.pin-key-btn:active {
    transform: scale(0.96);
    background: rgba(239, 68, 68, 0.3);
}

.pin-key-btn.action-btn {
    font-size: 1.0rem;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

.pin-unlocked-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* =========================================================================
   SUB-TAB NAVIGATION PILLS (Progressive Disclosure & Zero-Scroll Architecture)
   ========================================================================= */
.sub-tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    overflow-x: auto;
    padding: 4px 2px 8px 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}
.sub-tab-nav::-webkit-scrollbar {
    display: none;
}
.sub-tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}
.sub-tab-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}
.sub-tab-btn.active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(14, 165, 233, 0.45));
    border-color: #38bdf8;
    color: #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}
.sub-tab-pane {
    display: none;
    animation: fadeInSubTab 0.25s ease forwards;
}
.sub-tab-pane.active {
    display: block !important;
}
@keyframes fadeInSubTab {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Collapsible Accordion Header */
.accordion-toggle-card {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}
.accordion-toggle-card:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}
.accordion-icon {
    transition: transform 0.25s ease;
    display: inline-block;
}
.accordion-icon.open {
    transform: rotate(180deg);
}

/* Agronomy Ideal Guide Columns Layout (High-Density Multi-Column Desktop & Mobile Optimized) */
.agronomy-columns-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.roadmap-strip-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

@media (max-width: 1024px) {
    .agronomy-columns-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .roadmap-strip-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .agronomy-columns-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .roadmap-strip-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    #sec-agronomy-ideal-guide {
        padding: 14px 12px !important;
    }
}

/* ==========================================
   📚 INTEGRATED ENCYCLOPEDIA PANE STYLES
   ========================================== */
.enc-subpane {
    animation: fadeInPane 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* =========================================================================
   WORKSPACE TAB PANES & UNIVERSAL CONTAINER CONSTRAINTS
   ========================================================================= */
.workspace-tab-pane {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
}

.workspace-tab-pane > section,
.workspace-tab-pane > div,
.sub-tab-pane > section,
.sub-tab-pane > div {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
}

/* Refined Macro Buttons Container */
.macro-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.macro-buttons .btn {
    padding: 8px 14px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
    box-sizing: border-box;
}

/* Mobile Viewport Constraints */
@media (max-width: 768px) {
    .valves-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .macro-buttons {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .macro-buttons .btn {
        width: 100% !important;
        min-height: 42px !important;
        font-size: 0.84rem !important;
        padding: 10px 14px !important;
        justify-content: center !important;
    }

    .tanks-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .glass-panel-inner {
        padding: 14px 12px !important;
        border-radius: 12px !important;
    }
}

/* =========================================================================
   DURIANOS v3.5: MONTHLY ADAPTIVE CLIMATE & AGE-SYNCHRONIZED INTELLIGENCE UI
   ========================================================================= */
.mai-panel {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(6, 78, 59, 0.22)) !important;
    border: 1px solid rgba(16, 185, 129, 0.35) !important;
    border-left: 4px solid #10b981 !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 36px rgba(0,0,0,0.4) !important;
    margin-top: 24px;
    margin-bottom: 24px;
    padding: 22px;
}

.mai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.35);
}

.mai-badge-blue {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.35);
}

.mai-badge-amber {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

.mai-badge-red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.35);
}

.mai-nav-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.mai-tab-btn {
    background: rgba(30, 41, 59, 0.7);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mai-tab-btn:hover {
    background: rgba(51, 65, 85, 0.8);
    color: #f8fafc;
    border-color: rgba(56, 189, 248, 0.4);
}

.mai-tab-btn.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(6, 78, 59, 0.4));
    color: #34d399;
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.mai-subtab-pane {
    display: none;
    animation: maiFadeIn 0.3s ease;
}

.mai-subtab-pane.active {
    display: block;
}

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

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

.mai-table th {
    background: rgba(15, 23, 42, 0.95);
    color: #94a3b8;
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.mai-table td {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
}

.mai-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.mai-quick-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 14px;
    transition: all 0.3s ease;
}

.mai-quick-card:hover {
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* ========================================================================== */
/* 🌟 DURIANOS V3.5 ROLE SELECTOR (MANDOR / AGRONOM / INVESTOR)               */
/* ========================================================================== */
.role-selector-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 24px;
    padding: 3px 6px;
    gap: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.role-selector-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    padding: 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.role-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.06);
}

.role-btn.active {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border-color: #38bdf8;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}

/* Role Visibility Adaptations */
body[data-user-role="mandor"] .role-agronomist-only,
body[data-user-role="mandor"] .role-investor-only {
    display: none !important;
}

body[data-user-role="mandor"] .mandor-primary-card {
    border: 2px solid #38bdf8 !important;
    background: rgba(15, 23, 42, 0.95) !important;
}

body[data-user-role="investor"] .role-agronomist-only,
body[data-user-role="investor"] .role-mandor-only {
    display: none !important;
}

/* ========================================================================== */
/* 💧 INTERACTIVE HYDRAULIC DIGITAL TWIN SCHEMATIC                            */
/* ========================================================================== */
.hydraulic-twin-card {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.92));
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    position: relative;
    overflow: hidden;
}

.twin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 10px;
}

.twin-title {
    color: #38bdf8;
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.twin-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.72rem;
    color: #cbd5e1;
    flex-wrap: wrap;
}

.twin-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.twin-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.twin-svg-container {
    width: 100%;
    overflow-x: auto;
    background: rgba(10, 15, 29, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px;
}

/* Dynamic Animated Flow Lines */
@keyframes pipeFlowWater {
    0% { stroke-dashoffset: 40; }
    100% { stroke-dashoffset: 0; }
}

@keyframes pipeFlowFert {
    0% { stroke-dashoffset: 40; }
    100% { stroke-dashoffset: 0; }
}

.pipe-dormant {
    stroke: #334155;
    stroke-width: 4;
    stroke-linecap: round;
    transition: all 0.4s ease;
}

.pipe-active-water {
    stroke: #38bdf8;
    stroke-width: 5;
    stroke-dasharray: 8, 4;
    stroke-linecap: round;
    animation: pipeFlowWater 0.8s linear infinite;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.7));
}

.pipe-active-fert {
    stroke: #34d399;
    stroke-width: 5;
    stroke-dasharray: 8, 4;
    stroke-linecap: round;
    animation: pipeFlowFert 0.8s linear infinite;
    filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.7));
}

.twin-node-active {
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.8));
}

.twin-zone-badge {
    cursor: pointer;
    transition: transform 0.2s ease;
}
.twin-zone-badge:hover {
    transform: scale(1.05);
}

/* ========================================================================== */
/* 💡 EXPLAINABLE AI (XAI) DECISION MODAL & EQUATION DRAWER                   */
/* ========================================================================== */
.xai-equation-box {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.82rem;
    color: #cbd5e1;
    line-height: 1.5;
}

.xai-step-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
}

.xai-step-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.xai-step-calc {
    font-size: 0.78rem;
    color: #94a3b8;
    margin: 0;
}

/* ========================================================================== */
/* ⚡ STREAMLINED HEADER & QUICK ACTIONS MODAL STYLES                         */
/* ========================================================================== */
.btn-header-xai {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    border: 1px solid #38bdf8;
    color: white;
    border-radius: 10px;
    font-weight: 600;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-header-xai:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    border-color: #7dd3fc;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.btn-header-menu {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #f8fafc;
    border-radius: 10px;
    font-weight: 600;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-header-menu:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: #38bdf8;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.quick-action-tile {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-action-tile:hover {
    transform: translateY(-2px);
    filter: brightness(1.15);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* ========================================================================== */
/* 📱 MOBILE RESPONSIVE OPTIMIZATION (CLEAN 1-ROW HEADER & THUMB-FRIENDLY)    */
/* ========================================================================== */
.desktop-only-flex {
    display: inline-flex !important;
}

@media (min-width: 769px) {
    .diag-chevron {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .desktop-only-flex {
        display: none !important;
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 75px auto !important;
        padding: 10px 8px !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
    }

    header {
        padding: 4px 4px 12px 4px !important;
        margin-bottom: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .header-title {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .header-title h1 {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
        margin: 0 0 6px 0 !important;
        color: #f8fafc !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .header-title p {
        display: block !important;
        font-size: 0.82rem !important;
        color: #94a3b8 !important;
        margin: 0 0 8px 0 !important;
        line-height: 1.45 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .header-meta-bar {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        margin-top: 6px !important;
        padding-top: 8px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .header-meta-item {
        font-size: 0.76rem !important;
        color: #cbd5e1 !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        line-height: 1.4 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        width: 100% !important;
    }

    .header-meta-calib {
        display: flex !important;
        margin-top: 2px !important;
        width: auto !important;
    }

    /* Header Controls Hidden on Mobile (Clean Experience) */
    .header-controls {
        display: none !important;
    }

    /* Diagnostics Ribbon Hidden on Mobile */
    #sec-diagnostics, .system-status-bar {
        display: none !important;
    }

    /* Top Workspace Nav Hidden on Mobile (Handled by .mobile-bottom-dock) */
    .desktop-workspace-nav {
        display: none !important;
    }

    .ws-tab-btn {
        padding: 8px 12px !important;
        font-size: 0.78rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        min-height: 40px !important;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .metric-card {
        padding: 12px 10px !important;
    }

    .metric-card h3 {
        font-size: 0.78rem !important;
    }

    .metric-card p {
        font-size: 1.25rem !important;
    }
}

/* ========================================================================== */
/* 🎭 ROLE-BASED WORKSPACE DECLUTTERING RULES                                 */
/* ========================================================================== */
[data-user-role="mandor"] .advanced-scientific-only,
[data-user-role="mandor"] #subtab-nav-telemetry,
[data-user-role="mandor"] #sec-monthly-adaptive-intelligence,
[data-user-role="mandor"] .mai-panel,
[data-user-role="mandor"] #soil-ai-card {
    display: none !important;
}

[data-user-role="mandor"] .mandor-highlight {
    border: 2px solid #10b981 !important;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3) !important;
}

[data-user-role="investor"] #subtab-nav-telemetry,
[data-user-role="investor"] #sec-monthly-adaptive-intelligence {
    display: none !important;
}

/* ========================================================================== */
/* ☀️ SUNLIGHT MODE (OUTDOOR HIGH-CONTRAST FIELD ERGONOMICS)                   */
/* ========================================================================== */
:root[data-mode="field"] {
    --bg-color: #030712 !important;
    --text-primary: #ffffff !important;
    --text-secondary: #cbd5e1 !important;
    --glass-bg: #0f172a !important;
    --glass-border: #475569 !important;
    --primary: #38bdf8 !important;
    --success: #10b981 !important;
    --warning: #f59e0b !important;
    --danger: #ef4444 !important;
}

:root[data-mode="field"] body {
    background: #030712 !important;
    color: #ffffff !important;
}

:root[data-mode="field"] .glass-panel,
:root[data-mode="field"] .card,
:root[data-mode="field"] .metric-card,
:root[data-mode="field"] .control-card,
:root[data-mode="field"] .status-card,
:root[data-mode="field"] .dashboard-section {
    background: #0f172a !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 2px solid #475569 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6) !important;
}

:root[data-mode="field"] .telemetry-val,
:root[data-mode="field"] .metric-value,
:root[data-mode="field"] .metric-reading,
:root[data-mode="field"] .val {
    font-weight: 800 !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8) !important;
    font-variant-numeric: tabular-nums !important;
}

:root[data-mode="field"] .badge,
:root[data-mode="field"] .status-pill {
    font-weight: 800 !important;
    border-width: 2px !important;
}

/* ========================================================================== */
/* 🚨 FLOATING SMART STOP BAR (ZERO-PIN INSTANT EMERGENCY HALT)                */
/* ========================================================================== */
.ssbar {
    position: fixed;
    right: 18px;
    bottom: 84px;
    z-index: 9999;
    pointer-events: auto;
}

.ssbar__btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 16px;
    border: 2px solid #fecaca;
    border-radius: 9999px;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.88rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(220, 38, 38, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    min-height: 48px;
}

.ssbar__btn:hover {
    transform: scale(1.03);
    box-shadow: 0 12px 30px rgba(220, 38, 38, 0.65);
}

.ssbar__btn:active {
    transform: scale(0.95);
}

.ssbar__icon {
    font-size: 1.25rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.ssbar__txt {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.ssbar__txt b {
    font-size: 0.88rem;
    letter-spacing: 0.05em;
}

.ssbar__txt small {
    font-size: 0.68rem;
    color: #fecaca;
    font-weight: 600;
}

.ssbar__ring {
    position: absolute;
    inset: -4px;
    border-radius: 9999px;
    border: 2px solid rgba(239, 68, 68, 0.7);
    animation: ss-pulse-ring 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
}

@keyframes ss-pulse-ring {
    0% { transform: scale(0.95); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 0.3; }
    100% { transform: scale(1.3); opacity: 0; }
}

body.is-emergency-lockdown {
    filter: saturate(1.1);
}

body.is-emergency-lockdown .ssbar__btn {
    background: #000000 !important;
    border-color: #ef4444 !important;
    animation: ss-btn-flash 0.5s infinite alternate !important;
}

@keyframes ss-btn-flash {
    from { box-shadow: 0 0 0 0 #ffffff; }
    to { box-shadow: 0 0 0 8px #ef4444; }
}

/* ========================================================================== */
/* 📱 TOUCH-TARGET ERGONOMICS (MINIMUM 48PX / 64PX GLOVE-FRIENDLY FIELD CREW) */
/* ========================================================================== */
@media (max-width: 768px) {
    .ws-tab-btn,
    .sub-tab-btn,
    .valve-toggle-btn,
    .btn-action-primary,
    .btn-action-secondary,
    .role-btn,
    .tab-btn,
    .control-btn,
    .btn {
        min-height: 48px !important;
        padding: 12px 16px !important;
        touch-action: manipulation;
    }

    .valve-item {
        min-height: 56px !important;
        padding: 12px 16px !important;
    }

    .valve-item .switch {
        min-width: 58px;
        min-height: 34px;
        transform: scale(1.15);
        transform-origin: right center;
    }

    /* 🚨 Sembunyikan floating bar di smartphone agar tidak menghalangi kartu & navigasi */
    /* Akses darurat tetap tersedia via Menu Aksi Cepat, Tab Kontrol, dan Tab Siram */
    .ssbar {
        display: none !important;
    }
}

/* ========================================================================== */
/* 🔢 NUMERIC STABILITY & ZERO-LAYOUT SHIFT (TABULAR NUMERALS GLOBAL)         */
/* ========================================================================== */
.telemetry-val, .metric-value, .metric-reading, .val, .card-val,
.agronomy-stat, .stat-value, .numeric-data, table td, .pill-num,
.weather-val, .flow-val, .ec-val, .ph-val, .temp-val {
    font-variant-numeric: tabular-nums !important;
    font-feature-settings: "tnum" 1 !important;
    letter-spacing: -0.01em;
}

/* Double-Encoding for Status Badges (WCAG AA) */
.badge, .status-pill, .dot-label, .hardware-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* ========================================================================== */
/* ⚡ VALVE STATE-MACHINE TRANSITIONING VISUAL FEEDBACK                      */
/* ========================================================================== */
.valve-item.is-transitioning {
    opacity: 0.9;
    border-color: #f59e0b !important;
    animation: valve-trans-pulse 1.2s infinite alternate ease-in-out;
}

@keyframes valve-trans-pulse {
    from {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45);
    }
    to {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.0);
    }
}




/* ========================================================================== */
/* 🌿 PROGRESSIVE DISCLOSURE ACCORDIONS & EXECUTIVE SUMMARY (v3.6-HARMONIZED)  */
/* ========================================================================== */

/* Executive Summary Strip Card */
.executive-summary-strip {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.75) 0%, rgba(30, 41, 59, 0.65) 100%);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.executive-summary-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.executive-summary-title h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
}

.executive-summary-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.executive-metric-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.executive-metric-badge strong {
    color: #38bdf8;
    font-weight: 700;
}

/* Progressive Disclosure Collapsible Accordion (<details>) */
details.accordion-card {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

details.accordion-card:hover {
    border-color: rgba(56, 189, 248, 0.2);
}

details.accordion-card[open] {
    background: rgba(15, 23, 42, 0.75);
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

details.accordion-card > summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.98rem;
    color: #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
    user-select: none;
    background: transparent;
    transition: background 0.2s ease, color 0.2s ease;
}

details.accordion-card > summary::-webkit-details-marker {
    display: none;
}

details.accordion-card > summary:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #38bdf8;
}

.accordion-summary-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.accordion-summary-content .accordion-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.accordion-chevron-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, color 0.2s ease;
    font-size: 0.8rem;
    flex-shrink: 0;
}

details.accordion-card[open] > summary .accordion-chevron-icon {
    transform: rotate(180deg);
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

details.accordion-card > .accordion-body {
    padding: 16px 20px 22px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    animation: accordionFadeIn 0.3s ease-out;
}

@keyframes accordionFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
