/* BENDUNGAN CIAWI - VISUAL POLISH */

/* SCROLL ROOT: dokumen tetap dapat digulir */
html {
    height: auto !important;
    min-height: 100%;
    overflow-x: clip;
    overflow-y: auto !important;
    overscroll-behavior-y: auto !important;
}
body {
    height: auto !important;
    min-height: 100vh !important;
    overflow-x: clip;
    overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-y pinch-zoom;
}
#dashboard-top,
#dashboard-main-content {
    height: auto !important;
    min-height: 0;
    overflow: visible !important;
    min-width: 0;
}
header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
}

/* KARTU TELEMETRI DESKTOP */
#live-inlet-card,
#live-outlet-card {
    display: grid !important;
    flex: 1 1 420px !important;
    min-width: 0 !important;
    grid-template-columns:
        max-content max-content minmax(38px,1fr)
        max-content minmax(42px,1fr)
        max-content minmax(70px,1.2fr);
    align-items: center;
    column-gap: clamp(6px, .7vw, 11px);
    row-gap: 5px;
    padding: 13px 16px !important;
    min-height: 76px;
}
#live-inlet-card > span:first-child,
#live-outlet-card > span:first-child {
    font-size: 13px !important;
    font-weight: 800 !important;
    white-space: nowrap;
}
#live-inlet-card > span:nth-child(2),
#live-inlet-card > span:nth-child(4),
#live-inlet-card > span:nth-child(6),
#live-outlet-card > span:nth-child(2),
#live-outlet-card > span:nth-child(4),
#live-outlet-card > span:nth-child(6) {
    font-size: 11px !important;
    font-weight: 700 !important;
}
#live-inlet-jam, #live-outlet-jam {
    font-size: 17px !important;
    font-weight: 800 !important;
    white-space: nowrap;
}
#live-inlet-tma, #live-outlet-tma,
#live-inlet-debit, #live-outlet-debit {
    font-size: 21px !important;
    line-height: 1.15 !important;
    font-weight: 800 !important;
    white-space: nowrap;
}

/* Navigasi HP dan tablet */
#mobile-nav { display: none; }
#mobile-nav > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(76,215,246,.35);
    border-radius: 9px;
    background: #111c33;
    color: #7dd3fc;
    cursor: pointer;
}
#mobile-nav > summary::-webkit-details-marker { display: none; }
#mobile-nav .mobile-nav-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: absolute;
    right: 0;
    top: calc(100% + 9px);
    width: min(84vw, 290px);
    padding: 9px;
    border: 1px solid rgba(76,215,246,.25);
    border-radius: 12px;
    background: #091426;
    box-shadow: 0 12px 32px rgba(0,0,0,.38);
}
#mobile-nav .mobile-nav-panel button,
#mobile-nav .mobile-nav-panel a {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #dbeafe;
    text-align: left;
    text-decoration: none;
    font: 600 13px/1.35 system-ui,sans-serif;
    cursor: pointer;
}
#mobile-nav .mobile-nav-panel button:hover,
#mobile-nav .mobile-nav-panel a:hover {
    background: rgba(76,215,246,.12);
}

/* Motion: halus, konsisten, tidak menyilaukan */
.bg-surface-card {
    animation: none !important;
    transition: border-color .22s ease, box-shadow .22s ease !important;
}
.int-btn.active,
.tbl-filter.active,
.chart-filter-btn.active {
    animation: none !important;
    box-shadow: none !important;
}
#kpi-elv, #kpi-vol, #kpi-qout, #kpi-qin,
#dam-live-status {
    animation: none !important;
    text-shadow: none !important;
}
@media (hover: hover) and (pointer: fine) {
    .bg-surface-card:hover {
        transform: translateY(-1px);
        box-shadow: 0 5px 16px rgba(6,182,212,.08);
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    #mobile-nav {
        display: block;
        position: relative;
        flex: 0 0 auto;
    }
    #live-inlet-card,
    #live-outlet-card {
        flex-basis: 100% !important;
        grid-template-columns:
            max-content minmax(0,1fr)
            max-content minmax(0,1fr)
            max-content minmax(0,1.2fr);
    }
    #live-inlet-card > span:first-child,
    #live-outlet-card > span:first-child {
        grid-column: 1 / -1;
    }
}

/* HP */
@media (max-width: 767px) {
    header > div.h-16 {
        height: auto !important;
        min-height: 64px;
        padding: 8px 10px !important;
        gap: 7px !important;
        flex-wrap: wrap !important;
    }
    header > div.h-16 > div:first-child {
        flex: 1 1 155px;
        min-width: 0;
        gap: 7px !important;
    }
    header > div.h-16 > div:first-child > div:last-child {
        min-width: 0;
    }
    header > div.h-16 h1 {
        font-size: 12px !important;
        line-height: 1.25;
    }
    header > div.h-16 > div:last-child {
        min-width: 0;
        gap: 5px !important;
        margin-left: auto;
    }
    header .cms-toolbar {
        display: flex !important;
        gap: 3px !important;
    }
    header .cms-toolbar button {
        width: 32px;
        min-width: 32px;
        height: 34px;
        padding: 5px !important;
        overflow: hidden;
        font-size: 0 !important;
        justify-content: center;
    }
    header .cms-toolbar button .material-symbols-outlined {
        font-size: 16px !important;
    }
    header .rounded-full { display: none !important; }
    header nav { display: none !important; }

    #mobile-nav {
        display: block;
        position: relative;
        flex: 0 0 auto;
    }

    #dashboard-top {
        padding: 100px 11px 22px !important;
        gap: 12px !important;
    }
    #dashboard-top > div:has(#kpi-elv) {
        display: grid !important;
        grid-template-columns: repeat(2,minmax(0,1fr)) !important;
        gap: 9px !important;
    }
    #dashboard-top > div:has(#kpi-elv) > div {
        min-width: 0;
        padding: 10px !important;
    }
    #kpi-elv, #kpi-vol, #kpi-qout, #kpi-qin {
        font-size: clamp(18px, 5vw, 22px) !important;
    }
    #kpi-elv-sub, #kpi-vol-sub,
    #kpi-qout-sub, #kpi-qin-sub {
        font-size: 9px !important;
    }

    #dashboard-top > div:has(#live-inlet-card) > div:nth-child(2) {
        width: 100%;
        align-items: stretch;
        gap: 9px !important;
    }
    #live-inlet-card,
    #live-outlet-card {
        flex: 1 1 100% !important;
        width: 100%;
        min-height: 76px;
        grid-template-columns:
            max-content minmax(0,1fr)
            max-content minmax(0,1fr)
            max-content minmax(0,1.2fr) !important;
        column-gap: 6px !important;
        row-gap: 7px !important;
        padding: 10px 11px !important;
    }
    #live-inlet-card > span:first-child,
    #live-outlet-card > span:first-child {
        grid-column: 1 / -1;
        font-size: 12px !important;
    }
    #live-inlet-card > span:nth-child(2),
    #live-inlet-card > span:nth-child(4),
    #live-inlet-card > span:nth-child(6),
    #live-outlet-card > span:nth-child(2),
    #live-outlet-card > span:nth-child(4),
    #live-outlet-card > span:nth-child(6) {
        font-size: 10px !important;
    }
    #live-inlet-jam, #live-outlet-jam { font-size: 14px !important; }
    #live-inlet-tma, #live-outlet-tma,
    #live-inlet-debit, #live-outlet-debit {
        font-size: clamp(15px, 4.5vw, 19px) !important;
    }

    #dashboard-main-content { gap: 12px !important; }
    #dashboard-main-content > .bg-surface-card,
    #section-hidrograf,
    #section-tabel-telemetri {
        padding: 11px !important;
    }
    #dashboard-main-content h3,
    #section-hidrograf h3,
    #section-tabel-telemetri h3 {
        font-size: 13px !important;
        line-height: 1.4;
    }
    #dashboard-main-content .phase-btn {
        flex: 1 1 44%;
        min-width: 0;
        white-space: normal;
        font-size: 10px !important;
        padding: 7px 5px !important;
    }
    #dashboard-main-content > .bg-surface-card:first-child
    .bg-surface-container-lowest {
        height: 185px !important;
    }
    #section-hidrograf svg {
        width: 100%;
        height: auto;
    }
    #section-neraca {
        grid-template-columns: minmax(0,1fr) !important;
        gap: 10px !important;
    }
    #section-neraca > div {
        min-width: 0;
        width: 100%;
        padding: 10px !important;
    }

    #section-tabel-telemetri {
        padding: 11px !important;
        gap: 11px !important;
    }
    #section-tabel-telemetri .overflow-x-auto {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }
    #section-tabel-telemetri table { min-width: 1150px; }
    #section-tabel-telemetri button {
        min-height: 34px;
        font-size: 10px !important;
        white-space: normal;
    }

    #alarm-banner {
        top: 72px !important;
        left: 7px !important;
        right: 7px !important;
        width: auto !important;
        transform: none !important;
        padding: 8px 9px !important;
        gap: 7px !important;
        font-size: 10px !important;
        line-height: 1.4;
    }

    #pzOverlay {
        padding: 10px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    #pzOverlay > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    #pzOverlay form#pzForm,
    #pzOverlay form#pzFormTimb {
        grid-template-columns: minmax(0,1fr) !important;
        gap: 9px !important;
    }
    #pzOverlay input,
    #pzOverlay select,
    #pzOverlay button { max-width: 100%; min-width: 0; }
    #pzOverlay #pzGrid,
    #pzOverlay #pzRuGrid {
        grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    }
    #pzOverlay table { min-width: 700px; }
}

/* Hormati preferensi pengurangan gerakan */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}