/* ══════════════════════════════════════════════
   ESR TANK MONITORING SYSTEM — style.css
   Professional SCADA-grade UI
══════════════════════════════════════════════ */

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

:root {
    --navy: #0f1e38;
    --navy2: #1a2e50;
    --navy3: #243a62;
    --blue: #2563eb;
    --blue-lt: #3b82f6;
    --purple: #3b1fa0;
    --purple-lt: #5b3fd4;
    --green: #16a34a;
    --green-lt: #22c55e;
    --yellow: #ca8a04;
    --orange: #ea580c;
    --red: #dc2626;
    --gray-bg: #f1f5f9;
    --gray-bdr: #cbd5e1;
    --white: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.10);
    --radius: 8px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
}


/* ── SCROLLBAR ── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #e2e8f0;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
}


/* ══════════════ TOPBAR ══════════════ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--navy);
    padding: 0 20px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.hamburger:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-wave {
    width: 36px;
    height: 36px;
    background: var(--blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.logo-main {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 3px;
    display: block;
}

.logo-sub {
    font-size: 0.5rem;
    letter-spacing: 3px;
    color: #94a3b8;
    display: block;
}

.topbar-title {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.datetime-box {
    text-align: right;
}

.dt-time {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.dt-date {
    font-size: 0.65rem;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

.notif-btn {
    position: relative;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1.2rem;
    padding: 6px;
    transition: color 0.2s;
}

.notif-btn:hover {
    color: #fff;
}

.alarm-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--red);
    color: #fff;
    border-radius: 50%;
    font-size: 0.55rem;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.admin-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.82rem;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: all 0.2s;
}

.admin-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}


/* ══════════════ SIDEBAR ══════════════ */

.sidebar {
    position: fixed;
    top: 56px;
    left: -220px;
    width: 220px;
    height: calc(100vh - 56px);
    background: var(--navy2);
    z-index: 150;
    transition: left 0.3s ease;
    box-shadow: 3px 0 16px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 18px 16px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-nav {
    padding: 8px 0;
}

.snav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    color: #94a3b8;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.18s;
    text-decoration: none;
    font-weight: 500;
}

.snav:hover,
.snav.active {
    background: rgba(37, 99, 235, 0.2);
    color: #fff;
    border-left: 3px solid var(--blue);
}


/* ══════════════ NAV TABS ══════════════ */

.nav-tabs {
    display: flex;
    align-items: center;
    background: var(--navy2);
    padding: 0 16px;
    gap: 1px;
    width: 100%;
    position: sticky;
    top: 56px;
    z-index: 99;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tab {
    padding: 11px 18px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s;
    white-space: nowrap;
}

.tab:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    background: rgba(37, 99, 235, 0.2);
    color: #fff;
    border-bottom: 3px solid var(--blue-lt);
}

.sys-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--green-lt);
    border: 1.5px solid var(--green-lt);
    border-radius: 20px;
    padding: 4px 13px;
    transition: all 0.3s;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-dot.green {
    background: var(--green-lt);
    box-shadow: 0 0 6px var(--green-lt);
    animation: blink 2s infinite;
}

.status-dot.red {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
    animation: blink 0.8s infinite;
}

.status-dot.orange {
    background: #fb923c;
    box-shadow: 0 0 6px #fb923c;
    animation: blink 1.2s infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1
    }
    50% {
        opacity: 0.4
    }
}


/* ══════════════ MAIN ══════════════ */

.main-content {
    padding: 14px;
    transition: margin-left 0.3s;
}

.main-content.shifted {
    margin-left: 220px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}


/* ══════════════════════════════════════════════
   SCHEMATIC PANEL
══════════════════════════════════════════════ */

.schematic-panel {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-bdr);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 12px;
}

.img-container {
    position: relative;
    width: 100%;
    line-height: 0;
}

.schematic-img {
    width: 80%;
    height: auto;
    display: block;
    margin-left: 5%;
}


/* All overlays */

.ov {
    position: absolute;
    pointer-events: none;
}


/* ── LEVEL SENSOR label (purple pill) ── */

.ov-label-purple {
    background: var(--purple);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    border-radius: 4px;
    padding: 10px 9px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(59, 31, 160, 0.5);
    transform: translateX(-50%);
}


/* ── TANK LEVEL CARD ── */

.ov-tank-level-card {
    background: #fff;
    border: 2px solid var(--purple);
    border-radius: 6px;
    overflow: hidden;
    min-width: 60px;
    box-shadow: 0 2px 12px rgba(59, 31, 160, 0.2);
}

.tlc-header {
    background: var(--purple);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 8px 8px;
    text-align: center;
}

.tlc-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--navy);
    padding: 10px 8px 14px;
    text-align: center;
}

.tlc-pct {
    font-size: 0.78rem;
    color: #555;
    padding: 1px 8px 5px;
    text-align: center;
}


/* ── ALERT ICON ── */

.ov-alert {
    font-size: 2.2rem;
    color: var(--red);
    text-shadow: 0 0 16px rgba(220, 38, 38, 0.7);
    animation: pulse 1s infinite;
    line-height: 1;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1)
    }
    50% {
        opacity: 0.5;
        transform: scale(0.92)
    }
}


/* ── GAUGE BAR ── */

.gauge-container {
    width: 1.5%;
    display: flex;
    align-items: flex-end;
}

.gauge-track {
    width: 100%;
    height: 100%;
    background: rgba(203, 213, 225, 0.5);
    border: 1px solid rgba(100, 116, 139, 0.3);
    border-radius: 3px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.gauge-fill-safe {
    width: 100%;
    background: linear-gradient(to top, #16a34a, #4ade80);
    transition: height 0.8s cubic-bezier(.4, 0, .2, 1);
}

.gauge-fill-warn {
    width: 100%;
    background: linear-gradient(to top, #ca8a04, #fbbf24);
    transition: height 0.8s cubic-bezier(.4, 0, .2, 1);
}

.gauge-fill-danger {
    width: 100%;
    background: linear-gradient(to top, #dc2626, #f87171);
    transition: height 0.8s cubic-bezier(.4, 0, .2, 1);
}


/* ── INSTRUMENT LABELS (above instruments) ── */

.inst-label-purple {
    background: var(--purple);
    color: #fff;
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 4px;
    padding: 2px 7px;
    white-space: nowrap;
    text-align: center;
    line-height: 1.35;
    box-shadow: 0 2px 6px rgba(59, 31, 160, 0.4);
    transform: translateX(-50%);
}


/* ── INSTRUMENT DEVICES ── */

.inst-device {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 36px;
    transform: translateX(-50%);
}

.inst-device i {
    font-size: 1.1rem;
}

.inst-id {
    font-size: 0.45rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
}

.pt-device i {
    color: #1565c0;
}

.pt-device .inst-id {
    background: #1565c0;
    color: #fff;
}

.fm-device i {
    color: #0f766e;
}

.fm-device .inst-id {
    background: #0f766e;
    color: #fff;
}

.fcv-device i {
    color: #374151;
}

.fcv-device .inst-id {
    background: #374151;
    color: #fff;
}


/* ── VALUE CARDS ── */

.val-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(91, 63, 212, 0.4);
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    padding: 5px 6px 4px;
    backdrop-filter: blur(4px);
}

.vc-label {
    font-size: 0.5rem;
    font-weight: 700;
    color: #c4b5fd;
    letter-spacing: 0.6px;
    margin-bottom: 3px;
}

.vc-val {
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 0.5;
}

.vc-val.white {
    color: rgba(30, 20, 100);
}

.vc-val.green {
    color: #4ade80;
}

.vc-val.red {
    color: #f87171;
}

.vc-sep {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 4px 0;
}


/* Drain valve card — white bg */

.drain-card {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1.5px solid #cbd5e1 !important;
}

.drain-card .vc-label {
    color: #64748b;
}


/* ── DIRECTION LABELS ── */

.ov-dir {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.45;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 4px;
    padding: 3px 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}


/* ══════════════════════════════════════════════
   SUMMARY BAR
══════════════════════════════════════════════ */

.summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-bdr);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
}

.sum-card {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 140px;
}

.sum-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    border: 1.5px solid;
}

.sum-icon-wrap.blue {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.sum-icon-wrap.teal {
    background: #f0fdf4;
    color: #065f46;
    border-color: #a7f3d0;
}

.sum-icon-wrap.indigo {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.sum-icon-wrap.orange {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}

.sum-icon-wrap.purple2 {
    background: #faf5ff;
    color: #7e22ce;
    border-color: #e9d5ff;
}

.sum-icon-wrap.yellow {
    background: #fefce8;
    color: #a16207;
    border-color: #fef08a;
}

.sum-label {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.8px;
}

.sum-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 1px;
}


/* ══════════════ LEGEND ══════════════ */

.legend-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    padding: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

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

.leg-line {
    display: inline-block;
    width: 26px;
    height: 4px;
    border-radius: 2px;
}

.leg-line.green {
    background: #16a34a;
}

.leg-line.dashed {
    background: none;
    border-top: 2.5px dashed #5b3fd4;
}

.leg-sq {
    display: inline-block;
    width: 14px;
    height: 10px;
    border-radius: 2px;
}

.pt-color {
    background: #1565c0;
}

.fm-color {
    background: #0f766e;
}

.fcv-color {
    background: #374151;
}


/* ══════════════════════════════════════════════
   INNER PAGES (Trends, Alarms, etc.)
══════════════════════════════════════════════ */

.inner-page {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-bdr);
    padding: 24px;
    box-shadow: var(--shadow);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--gray-bdr);
}

.page-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-header h2 i {
    color: var(--blue);
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-header-actions select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--gray-bdr);
    font-size: 0.78rem;
    color: var(--text);
    background: #fff;
    cursor: pointer;
}


/* ── CHARTS ── */

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.chart-card {
    background: var(--gray-bg);
    border-radius: 8px;
    border: 1px solid var(--gray-bdr);
    padding: 14px;
}

.chart-card-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}


/* ── TABLES ── */

.pro-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.pro-table th {
    background: var(--navy);
    color: #e2e8f0;
    padding: 9px 12px;
    text-align: left;
    font-size: 0.68rem;
    letter-spacing: 0.8px;
    white-space: nowrap;
}

.pro-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
}

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

.alarm-high td {
    border-left: 3px solid var(--red);
}

.alarm-med td {
    border-left: 3px solid var(--orange);
}

.alarm-low td {
    border-left: 3px solid var(--yellow);
}


/* ── PILLS / BADGES ── */

.pill {
    display: inline-block;
    border-radius: 12px;
    padding: 2px 9px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.pill.red {
    background: #fee2e2;
    color: #991b1b;
}

.pill.orange {
    background: #ffedd5;
    color: #9a3412;
}

.pill.yellow {
    background: #fef9c3;
    color: #854d0e;
}

.pill.green {
    background: #dcfce7;
    color: #14532d;
}

.pill.blue {
    background: #dbeafe;
    color: #1e40af;
}

.pill-outline {
    display: inline-block;
    border-radius: 12px;
    padding: 2px 9px;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1.5px solid;
}

.pill-outline.orange {
    color: var(--orange);
    border-color: var(--orange);
}

.pill-outline.green {
    color: var(--green);
    border-color: var(--green);
}


/* Alarm stats */

.alarms-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.astat {
    flex: 1;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    border: 1.5px solid;
}

.astat.red {
    background: #fee2e2;
    border-color: #fca5a5;
}

.astat.orange {
    background: #ffedd5;
    border-color: #fdba74;
}

.astat.yellow {
    background: #fef9c3;
    border-color: #fde047;
}

.astat.gray {
    background: #f1f5f9;
    border-color: var(--gray-bdr);
}

.astat-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
}

.astat-lbl {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
}


/* ACK Button */

.btn-ack {
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-ack:hover {
    background: var(--blue);
}

.btn-ack.acked {
    background: var(--green);
    cursor: default;
}


/* ── REPORTS ── */

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.report-card {
    background: #f8fafc;
    border: 1px solid var(--gray-bdr);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rc-icon {
    font-size: 2.2rem;
}

.rc-icon .fa-file-pdf {
    color: var(--red);
}

.rc-icon .fa-file-excel {
    color: var(--green);
}

.rc-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--navy);
}

.rc-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.rc-stats {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rc-stats b {
    color: var(--text);
}

.live-report h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 10px;
}


/* ── SETTINGS ── */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.settings-section {
    background: #f8fafc;
    border: 1px solid var(--gray-bdr);
    border-radius: 8px;
    padding: 16px;
}

.settings-section h3 {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.settings-section label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

.settings-section input {
    padding: 7px 10px;
    border: 1.5px solid var(--gray-bdr);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.settings-section input:focus {
    border-color: var(--blue);
}

.settings-actions {
    display: flex;
    gap: 10px;
}


/* ── BUTTONS ── */

.btn-primary {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1.5px solid var(--gray-bdr);
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-dl {
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    transition: 0.2s;
}

.btn-dl:hover {
    background: var(--blue);
}


/* ── TOAST ── */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: var(--navy);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}


/* ── RESPONSIVE ── */

@media (max-width: 1024px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
    .report-grid {
        grid-template-columns: 1fr 1fr;
    }
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .topbar-title {
        display: none;
    }
    .tab {
        padding: 10px 10px;
        font-size: 0.65rem;
    }
    .tab span {
        display: none;
    }
    .report-grid {
        grid-template-columns: 1fr;
    }
    .alarms-stats {
        flex-wrap: wrap;
    }
    .summary-bar {
        gap: 6px;
    }
    .sum-card {
        min-width: 120px;
    }
}


/* ── MINI INSTRUMENT TABLE (left empty space on schematic) ── */

.mini-inst-table {
    background: rgba(255, 255, 255, 0.95);
    border: 1.5px solid var(--purple);
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(59, 31, 160, 0.25);
    padding: 10px 8px;
    width: 17%;
    backdrop-filter: blur(4px);
}

.mit-title {
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--purple);
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-align: center;
}

.mini-inst-table table {
    width: 100%;
    border-collapse: collapse;
}

.mini-inst-table th {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: var(--purple);
    padding: 6px 4px;
    text-align: left;
}

.mini-inst-table td {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--navy);
    padding: 9px 4px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.mit-sub {
    font-size: 0.42rem;
    font-weight: 600;
    color: var(--text-muted);
}


/* ===========================
   FLOWING WATER PIPE
=========================== */

.pipe {
    position: absolute;
    border: 1px solid #666;
    overflow: hidden;
    background: #d9d9d9;
    border-radius: 0;
}

.equipment {
    position: absolute;
    width: 40px;
    height: auto;
    top: 75%;
    left: 8%;
    z-index: 111;
}


/*************************
HORIZONTAL
**************************/

.horizontal {
    left: 14.4%;
    top: 49%;
    width: 33%;
    height: 18px;
    border-radius: 10px;
    transform: rotate(-90deg);
}

.horizontal-water2 {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.horizontal2 {
    left: 39.7%;
    top: 68.7%;
    width: 15%;
    height: 16px;
    border-top: none;
    border-right: none;
    transform: rotate(90deg);
}

.horizontal-water {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/*************************
VERTICAL
**************************/

.vertical {
    left: 30%;
    top: 16%;
    width: 9.7%;
    height: 18px;
    border-bottom: none;
    border-radius: 10px 0 0 10px;
    transform: rotate(0deg);
}

.vertical-water {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vertical2 {
    left: 4.5%;
    top: 83%;
    width: 27%;
    height: 18px;
    border-bottom: none;
    border-radius: 10px;
    border: 1px solid #666;
    border-top: none;
    transform: rotate(0deg);
}

.vertical-water2 {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vertical3 {
    left: 47%;
    top: 80%;
    width: 45%;
    height: 18px;
    border-bottom: none;
    border: 1px solid #666;
    transform: rotate(0deg);
}

.vertical-water3 {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* Vertical Part */


/*************************
WATER
**************************/

.water {
    display: block;
}


/*************************
STOP FLOW
**************************/

.stop .water {
    display: none !important;
}

.pipe.stop .water {
    opacity: 0;
}


/* ════════ AUTO / MANUAL TOGGLE SWITCH ════════ */

.mode-switch-wrapper {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.85);
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mode-label {
    font-weight: bold;
    font-size: 0.85rem;
    color: #38bdf8;
    letter-spacing: 0.5px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #f59e0b;
    /* Amber warning color for Manual */
}

input:checked+.slider:before {
    transform: translateX(22px);
}


/* ════════ MANUAL CONTROL POPUP DRAWER ════════ */

.manual-drawer {
    position: absolute;
    top: 60px;
    left: 15px;
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid #38bdf8;
    border-radius: 8px;
    padding: 15px;
    z-index: 101;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: none;
    /* Controlled via JS */
    backdrop-filter: blur(8px);
}

.manual-drawer.open {
    display: block;
    animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.drawer-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: #38bdf8;
}

.drawer-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
}

.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: block;
    font-size: 0.75rem;
    color: #cbd5e1;
    margin-bottom: 5px;
}

.control-group input[type="number"] {
    width: 100%;
    padding: 6px;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 4px;
    color: #fff;
    font-size: 0.85rem;
}

.btn-group {
    display: flex;
    gap: 5px;
}

.btn-ctrl {
    flex: 1;
    padding: 5px;
    background: #334155;
    border: none;
    color: #94a3b8;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn-ctrl.active {
    background: #0284c7;
    color: #fff;
}

.btn-apply {
    width: 100%;
    padding: 8px;
    background: #10b981;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
}

.water-level-container {
    position: absolute;
    /* CHANGE THESE to match your actual tank */
    left: 39.8%;
    top: 17.4%;
    width: 15%;
    height: 23%;
    overflow: hidden;
    /* IMPORTANT */
    border-radius: 0 0 10px 10px;
}

.tank-water-gif {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    /* JS will control this */
    height: 0%;
    object-fit: cover;
    object-position: bottom;
    transition: height 0.8s ease;
}