﻿* {
    box-sizing: border-box;
}

/* MAXWELL wordmark — yuqori panelning bo'sh markaz/o'ng qismi. */
.maxwell-wordmark {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    padding: 0 16px;
    color: #eafaff;
    white-space: nowrap;
}
.maxwell-hydro-mark {
    width: 43px;
    height: 34px;
    fill: none;
    stroke: #dff9ff;
    stroke-width: 1.8;
    stroke-linecap: square;
    stroke-linejoin: miter;
    filter: drop-shadow(0 0 5px rgba(0, 211, 255, .18));
}
.maxwell-hydro-mark .mark-gates {
    fill: rgba(30, 197, 231, .2);
    stroke: #27d7f5;
}
.maxwell-hydro-mark .mark-water {
    stroke: #21d9ff;
    stroke-width: 2.2;
    stroke-linecap: round;
}
.maxwell-type {
    display: grid;
    gap: 2px;
    text-align: left;
}
.maxwell-main {
    display: block;
    color: #f2fbff;
    font-family: "Bahnschrift", "Arial Narrow", "Segoe UI", sans-serif;
    font-size: 18px;
    font-weight: 800;
    line-height: .9;
    letter-spacing: 1.9px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .48);
}
.maxwell-product {
    display: block;
    color: #2ad8f4;
    font-family: "Bahnschrift", "Arial Narrow", "Segoe UI", sans-serif;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 2.05px;
}

/* Katta monitor: avtomatika/darvozalar ustuni ixcham, gidrometriya keng.
   Gate grid 2 ustunligicha qoladi va yangi darvozalar bo'sh joyni to'ldiradi. */
@media (min-width: 1600px) {
    .main-grid {
        grid-template-columns: minmax(760px, 42%) minmax(0, 1fr) !important;
    }
}

@media (max-width: 1350px) {
    .maxwell-wordmark {
        display: none;
    }
}


.hardware-stand-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 16px;
    background: linear-gradient(
        135deg,
        rgba(8, 47, 73, 0.94),
        rgba(15, 23, 42, 0.96)
    );
}

.hardware-stand-info {
    display: grid;
    gap: 4px;
}

.hardware-stand-info small {
    color: #94a3b8;
}

.hardware-stand-status {
    display: grid;
    gap: 5px;
    min-width: 92px;
    text-align: center;
}

.hardware-stand-status span {
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.hardware-online {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.2);
}

.hardware-offline {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.2);
}

.hardware-stand-controls {
    display: flex;
    gap: 8px;
}

.hardware-command {
    min-width: 88px;
    padding: 11px 14px;
    border: 0;
    border-radius: 10px;
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.hardware-command:active {
    transform: translateY(1px);
}

.hardware-open {
    background: #16a34a;
}

.hardware-stop {
    background: #dc2626;
}

.hardware-close {
    background: #2563eb;
}

@media (max-width: 900px) {
    .hardware-stand-panel {
        grid-template-columns: 1fr;
    }

    .hardware-stand-status {
        text-align: left;
    }

    .hardware-stand-controls {
        flex-wrap: wrap;
    }
}

:root {
    --bg: #031019;
    --panel: #071b27;
    --line: #123b4d;
    --text: #dcecf3;
    --muted: #7193a2;
    --cyan: #00d8ff;
    --green: #24cf85;
    --red: #ff5366;
    --orange: #f5a623;
    --yellow: #ffd34b;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;

    background:
        radial-gradient(
            circle at 70% 20%,
            #0a2634 0,
            #031019 38%,
            #020a10 100%
        );

    color: var(--text);

    font-family:
        "Segoe UI",
        Arial,
        sans-serif;

    font-size: 12px;

    overflow: hidden;
}

button,
input,
select {
    font-family: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: 100vw;
    height: 100vh;

    display: grid;

    grid-template-rows:
        64px
        1fr
        30px;

    overflow: hidden;
}


/* =========================================================
   TOP
========================================================= */

.topbar {
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 7px 10px;

    border-bottom:
        1px solid #154154;

    background:
        rgba(
            3,
            16,
            25,
            .97
        );
}

.brand-block {
    min-width: 240px;

    display: flex;

    align-items: center;

    gap: 9px;
}

.brand-icon {
    width: 40px;
    height: 40px;

    display: flex;

    align-items: center;

    justify-content: center;

    border:
        1px solid var(--cyan);

    border-radius: 6px;

    color: var(--cyan);

    font-size: 19px;

    font-weight: 900;
}

.brand-title {
    font-size: 15px;

    font-weight: 900;

    letter-spacing: .7px;
}

.brand-subtitle {
    margin-top: 2px;

    color: #658897;

    font-size: 8px;

    font-weight: 700;
}

.top-status-area {
    min-width: 0;

    display: flex;

    align-items: center;

    justify-content: flex-end;

    gap: 6px;
}

.top-status-chip {
    min-width: 85px;

    padding: 6px 8px;

    border:
        1px solid #19465a;

    border-radius: 5px;

    background: #071923;

    text-align: center;
}

.chip-label {
    display: block;

    color: #648493;

    font-size: 8px;

    font-weight: 800;
}

.top-status-chip strong {
    display: block;

    margin-top: 2px;

    font-size: 9px;
}

.auto-main-button,
.top-action-button,
.admin-top-button {
    height: 42px;

    border-radius: 5px;

    font-size: 9px;

    font-weight: 900;
}

.auto-main-button {
    min-width: 92px;

    border:
        1px solid #52606a;

    background: #212a31;

    color: white;
}

.auto-main-button span,
.auto-main-button strong {
    display: block;
}

.auto-main-button strong {
    margin-top: 2px;

    font-size: 12px;
}

.auto-main-button.on {
    border-color: #20996a;

    background: #0b573c;
}

.auto-main-button.active {
    border-color: var(--red);

    background: #751d2b;
}

.top-action-button {
    padding: 0 11px;

    border:
        1px solid #20516a;

    background: #092433;

    color: #c2dae3;
}

.admin-top-button {
    padding: 0 11px;

    border:
        1px solid #8c6d21;

    background: #352b0e;

    color: #ffdc68;
}

.admin-top-button.unlocked {
    border-color: #1f9b69;

    background: #0b4c36;

    color: #59e6a4;
}

.clock-block {
    min-width: 75px;

    text-align: right;
}

.clock-block strong {
    display: block;

    font-family:
        Consolas,
        monospace;

    font-size: 13px;
}

.clock-block span {
    display: block;

    margin-top: 2px;

    color: #7594a2;

    font-size: 8px;
}


/* =========================================================
   MAIN
========================================================= */

.main-grid {
    min-height: 0;

    display: grid;

    grid-template-columns:
        minmax(530px, 1.08fr)
        minmax(510px, .92fr);

    gap: 7px;

    padding: 7px;

    overflow: hidden;
}

.left-column,
.right-column {
    min-width: 0;
    min-height: 0;
}

.left-column {
    display: grid;

    grid-template-rows:
        auto
        auto
        1fr;

    gap: 6px;
}

.right-column {
    display: grid;

    grid-template-rows:
        54%
        46%;

    gap: 6px;
}

.panel {
    min-width: 0;
    min-height: 0;

    border:
        1px solid var(--line);

    border-radius: 6px;

    background:
        linear-gradient(
            180deg,
            #081d29,
            #04121b
        );

    overflow: hidden;
}

.panel-header {
    min-height: 45px;

    padding: 7px 9px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;

    border-bottom:
        1px solid #123747;
}

.panel-header h2 {
    margin:
        2px 0 0;

    font-size: 13px;
}

.section-eyebrow {
    color: #5b8294;

    font-size: 8px;

    font-weight: 900;

    letter-spacing: .6px;
}

.panel-header-stat {
    text-align: right;
}

.panel-header-stat span {
    display: block;

    color: #688b9b;

    font-size: 8px;
}

.panel-header-stat strong {
    display: block;

    color: var(--green);

    font-size: 16px;
}


/* =========================================================
   AUTO
========================================================= */

.auto-strip {
    min-height: 48px;

    padding: 7px 9px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;

    border:
        1px solid #17465c;

    border-radius: 5px;

    background:
        linear-gradient(
            90deg,
            #082635,
            #071923
        );
}

.auto-strip-title {
    display: block;

    margin-top: 2px;

    font-size: 12px;
}

.auto-strip-summary {
    display: block;

    margin-top: 2px;

    color: #789dab;

    font-size: 8px;
}

.auto-strip-state {
    max-width: 300px;

    padding: 8px 10px;

    border-radius: 4px;

    text-align: center;

    font-size: 9px;

    font-weight: 900;
}

.auto-strip-state.off {
    border:
        1px solid #52616a;

    background: #202932;

    color: #b4c3c9;
}

.auto-strip-state.waiting {
    border:
        1px solid #187a59;

    background: #0a4934;

    color: #5de2a5;
}

.auto-strip-state.active {
    border:
        1px solid #b33849;

    background: #681c28;

    color: #ffbac1;
}


/* =========================================================
   MOTOR
========================================================= */

.motor-interlock-panel {
    min-height: 48px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;

    padding: 6px 9px;

    border:
        1px solid #6a5520;

    border-radius: 5px;

    background:
        linear-gradient(
            90deg,
            #2d260d,
            #13190f
        );
}

.motor-interlock-left {
    display: flex;

    align-items: center;

    gap: 8px;
}

.interlock-icon {
    font-size: 20px;

    color: #ffd34b;
}

.motor-interlock-left strong {
    display: block;

    color: #ffe183;

    font-size: 10px;
}

.motor-interlock-left small {
    display: block;

    margin-top: 2px;

    color: #b1a375;

    font-size: 8px;
}

.motor-interlock-stats {
    display: flex;

    gap: 4px;
}

.motor-interlock-stats > div {
    min-width: 70px;

    padding: 4px 6px;

    border:
        1px solid #5a4a1d;

    border-radius: 4px;

    background:
        rgba(
            0,
            0,
            0,
            .22
        );

    text-align: center;
}

.motor-interlock-stats span {
    display: block;

    color: #a4966a;

    font-size: 7px;
}

.motor-interlock-stats strong {
    display: block;

    margin-top: 1px;

    color: #ffe283;

    font-size: 9px;
}


/* =========================================================
   DARVOZALAR
========================================================= */

.gate-panel {
    display: grid;

    grid-template-rows:
        auto
        1fr;
}

.gate-grid {
    min-height: 0;

    padding: 6px;

    overflow-y: auto;

    overflow-x: hidden;

    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(
                0,
                1fr
            )
        );

    /*
        Darvoza soni o'zgarsa
        kartaning bo'yi o'zgarmaydi.
    */
    grid-auto-rows:
        154px;

    align-content: start;

    gap: 6px;
}

.gate-card {
    height: 154px;

    min-height: 154px;

    max-height: 154px;

    min-width: 0;

    padding: 7px;

    overflow: hidden;

    border:
        1px solid #174355;

    border-radius: 5px;

    background:
        linear-gradient(
            180deg,
            #092635,
            #061923
        );
}

.gate-card.motor-active {
    border-color: #ffd34b;
}

.gate-card.alarm {
    border-color: #bc394b;
}

.gate-card-header {
    height: 25px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 5px;
}

.gate-name {
    min-width: 0;

    display: flex;

    align-items: center;

    gap: 6px;
}

.gate-name > div {
    min-width: 0;
}

.gate-power {
    color: var(--green);

    font-size: 13px;
}

.gate-name strong {
    display: block;

    max-width: 240px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    font-size: 12px;
}

.gate-name small {
    display: block;

    margin-top: 1px;

    color: #688b9b;

    font-size: 8px;
}

.gate-icons {
    display: flex;

    align-items: center;

    gap: 4px;
}

.icon-online {
    color: var(--green);
}

.icon-muted {
    color: #4c6470;
}

.icon-alarm {
    color: var(--red);
}

.alarm-test-btn {
    width: 23px;
    height: 22px;

    padding: 0;

    border:
        1px solid #683a45;

    border-radius: 3px;

    background: #2c151d;

    color: #f18a97;

    font-size: 11px;

    font-weight: 900;
}

.gate-card-body {
    height: 40px;

    margin-top: 4px;

    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 4px;
}

.gate-metric {
    min-width: 0;

    padding: 4px 6px;

    border:
        1px solid #133b4d;

    border-radius: 3px;

    background: #061620;
}

.gate-metric span {
    display: block;

    color: #668b9b;

    font-size: 8px;
}

.gate-metric strong {
    color: #e9f6fa;

    font-size: 15px;
}

.gate-metric small {
    margin-left: 2px;

    color: #6d8c9a;

    font-size: 7px;
}

.gate-progress-labels {
    height: 12px;

    display: flex;

    align-items: end;

    justify-content: space-between;

    color: #62808e;

    font-size: 7px;
}

.gate-progress {
    height: 6px;

    margin-top: 1px;

    position: relative;

    border-radius: 4px;

    background: #142b35;
}

.gate-progress-bar {
    height: 100%;

    border-radius: 4px;

    background:
        linear-gradient(
            90deg,
            #007b9b,
            var(--cyan)
        );
}

.gate-status-line {
    height: 22px;

    margin-top: 3px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 4px;
}

.gate-status,
.limit-pill,
.process-pill,
.queue-pill {
    max-width: 70%;

    padding: 3px 5px;

    border-radius: 3px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    font-size: 7px;

    font-weight: 900;
}

.gate-status {
    background: #102b37;

    color: #8fb0be;
}

.limit-pill {
    background: #0b222d;

    color: #769cac;
}

.process-pill {
    border:
        1px solid #ab3547;

    background: #6d1c29;

    color: #ffd8dc;
}

.queue-pill {
    border:
        1px solid #80661b;

    background: #51400e;

    color: #ffe394;
}

.gate-controls {
    height: 31px;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        58px
        minmax(0, 1fr)
        68px;

    gap: 3px;
}

.gate-control-locked {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid rgba(255, 180, 70, .55);
    border-radius: 8px;
    background: rgba(130, 74, 12, .18);
    color: #ffd28a;
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.gate-controls:has(.gate-control-locked) {
    display: block;
    height: auto;
}

.command-pair {
    min-width: 0;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        21px;

    gap: 2px;
}

.gate-command,
.stop-command,
.exact-command,
.open-setting,
.close-setting {
    min-width: 0;

    height: 29px;

    border-radius: 3px;

    font-size: 8px;

    font-weight: 900;
}

.gate-command {
    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;
}

.gate-command small {
    display: block;

    margin-top: 1px;

    font-size: 7px;

    white-space: nowrap;
}

.open-command {
    border:
        1px solid #238f64;

    background: #0d543c;

    color: #d9ffed;
}

.close-command {
    border:
        1px solid #ad3d4c;

    background: #621d29;

    color: #ffe2e5;
}

.open-setting {
    border:
        1px solid #237b5a;

    background: #0c362a;

    color: #73d7a8;
}

.close-setting {
    border:
        1px solid #83404a;

    background: #35171d;

    color: #e997a1;
}

.stop-command {
    border:
        1px solid #b77915;

    background: #69430b;

    color: #ffe1a5;
}

.exact-command {
    border:
        1px solid #167e99;

    background: #06485a;

    color: #bbf6ff;
}


/* =========================================================
   SUV PANELI
========================================================= */

.water-panel {
    display: grid;

    grid-template-rows:
        auto
        auto
        1fr
        auto;
}

.water-state {
    padding: 5px 8px;

    border:
        1px solid #258f62;

    border-radius: 4px;

    background: #0b4935;

    color: #5ce0a1;

    font-size: 9px;

    font-weight: 900;
}

.sensor-summary-grid {
    display: grid;

    grid-template-columns:
        1.2fr
        1fr
        .85fr;

    gap: 5px;

    padding: 6px;
}

.sensor-summary {
    min-width: 0;

    padding: 7px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 5px;

    border:
        1px solid #164256;

    border-radius: 4px;

    background: #061923;
}

.main-sensor {
    border-color: #137d98;
}

.sensor-name {
    display: block;

    max-width: 150px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: #c9e2ea;

    font-size: 9px;

    font-weight: 900;
}

.sensor-summary small {
    display: block;

    margin-top: 2px;

    color: #62808e;

    font-size: 7px;
}

.water-number {
    color: var(--cyan);

    font-family:
        Consolas,
        monospace;

    font-size: 18px;

    white-space: nowrap;
}

.water-number.small {
    font-size: 15px;
}

.water-chart-wrap {
    min-height: 0;

    position: relative;

    margin:
        0 6px 5px;

    overflow: hidden;

    border:
        1px solid #12394a;

    border-radius: 4px;

    background: #04151f;
}

.water-chart {
    width: 100%;
    height: 100%;
}

.grid-line {
    stroke: #143442;

    stroke-width: 1;
}

.chart-label {
    fill: #668694;

    font-size: 9px;
}

.front-path {
    fill: none;

    stroke: var(--cyan);

    stroke-width: 2.2;
}

.rear-path {
    fill: none;

    stroke: #d99733;

    stroke-width: 1.7;
}

.chart-legend {
    position: absolute;

    right: 9px;
    top: 8px;

    display: flex;

    gap: 9px;

    color: #7c9aa8;

    font-size: 8px;
}

.chart-legend i {
    display: inline-block;

    width: 12px;
    height: 2px;

    margin-right: 3px;

    vertical-align: middle;
}

.legend-front {
    background: var(--cyan);
}

.legend-rear {
    background: #d99733;
}

.auto-threshold-bar {
    display: grid;

    grid-template-columns:
        1fr
        1fr
        1fr
        1.25fr;

    gap: 4px;

    padding: 5px 6px;

    border-top:
        1px solid #123747;
}

.auto-threshold-bar > div {
    min-width: 0;

    padding: 5px 6px;

    border:
        1px solid #133c4d;

    border-radius: 3px;

    background: #061923;
}

.auto-threshold-bar span {
    display: block;

    color: #5d8191;

    font-size: 7px;

    font-weight: 800;
}

.auto-threshold-bar strong {
    display: block;

    margin-top: 2px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: #d7eaf1;

    font-size: 9px;
}

.quick-test > div {
    display: grid;

    grid-template-columns:
        repeat(
            4,
            1fr
        );

    gap: 2px;

    margin-top: 3px;
}

.quick-test button {
    height: 23px;

    padding: 0;

    border:
        1px solid #1f5367;

    border-radius: 3px;

    background: #092b39;

    color: #d0eaf2;

    font-size: 8px;

    font-weight: 900;
}


/* =========================================================
   TARIX / HISOBOT
========================================================= */

.history-panel {
    min-height: 0;

    display: grid;

    grid-template-rows:
        auto
        auto
        auto
        1fr;
}

.history-top {
    min-height: 45px;

    padding: 6px 8px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom:
        1px solid #123747;
}

.history-top h2 {
    margin:
        2px 0 0;

    font-size: 13px;
}

.excel-button {
    height: 32px;

    padding: 0 11px;

    border:
        1px solid #25855f;

    border-radius: 4px;

    background: #0b533a;

    color: #bcf7d9;

    font-size: 9px;

    font-weight: 900;
}

.history-toolbar {
    padding: 5px 7px;

    display: grid;

    grid-template-columns:
        116px
        116px
        62px
        82px
        minmax(105px, 1fr)
        minmax(105px, 1fr)
        minmax(110px, 1.1fr);

    gap: 4px;

    border-bottom:
        1px solid #123747;

    background: #061620;
}

.history-date-field {
    min-width: 0;
}

.history-date-field span {
    display: block;

    margin-bottom: 2px;

    color: #628391;

    font-size: 7px;

    font-weight: 800;
}

.history-toolbar input,
.history-toolbar select,
.history-quick-button,
.history-clear-button {
    width: 100%;

    height: 29px;

    padding:
        0 6px;

    border:
        1px solid #19495e;

    border-radius: 3px;

    background: #061720;

    color: #b9d1da;

    font-size: 8px;

    outline: none;
}

.history-quick-button {
    align-self: end;

    border-color: #246e55;

    background: #0a4935;

    color: #8be6b6;

    font-weight: 900;
}

.history-clear-button {
    align-self: end;

    border-color: #665323;

    background: #30270d;

    color: #e7ce7a;

    font-weight: 900;
}

.history-period-info {
    min-height: 24px;

    padding:
        5px 8px;

    display: flex;

    align-items: center;

    border-bottom:
        1px solid #113646;

    color: #6d8e9c;

    font-size: 8px;
}

.history-list {
    min-height: 0;

    padding: 5px 7px;

    overflow-y: auto;
}

.history-item {
    min-height: 44px;

    margin-bottom: 4px;

    padding: 5px;

    display: grid;

    grid-template-columns:
        58px
        90px
        minmax(0, 1fr)
        72px;

    gap: 6px;

    align-items: center;

    border:
        1px solid #123747;

    border-radius: 4px;

    background: #061822;
}

.history-time {
    color: #6b8c9a;

    font-family:
        Consolas,
        monospace;

    font-size: 8px;
}

.history-gate {
    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: #d9edf4;

    font-size: 9px;

    font-weight: 900;
}

.history-main {
    min-width: 0;
}

.history-main strong {
    display: block;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: #cce1e8;

    font-size: 9px;
}

.history-main span {
    display: block;

    margin-top: 2px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    color: #688895;

    font-size: 7px;
}

.history-result {
    padding: 4px;

    border-radius: 3px;

    text-align: center;

    font-size: 7px;

    font-weight: 900;
}

.result-ok {
    background: #0c4934;

    color: #62e3a6;
}

.result-running {
    background: #5e4610;

    color: #ffe08a;
}

.result-stop {
    background: #49330e;

    color: #eec270;
}

.result-danger {
    background: #631d2a;

    color: #ffbbc2;
}

.history-empty {
    padding: 25px;

    text-align: center;

    color: #60808f;

    font-size: 10px;
}


/* =========================================================
   SCROLL
========================================================= */

.gate-grid::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.admin-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 7px;
}

.gate-grid::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
.admin-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: #04131b;
}

.gate-grid::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
.admin-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: #1d5369;

    border-radius: 10px;
}


/* =========================================================
   FOOTER
========================================================= */

.footer-status {
    display: flex;

    align-items: center;

    justify-content: space-between;

    padding:
        0 10px;

    border-top:
        1px solid #11394a;

    background: #020b11;

    color: #6d8b99;

    font-size: 8px;

    font-weight: 800;
}

.footer-dot {
    display: inline-block;

    width: 6px;
    height: 6px;

    margin-right: 4px;

    border-radius: 50%;
}

.footer-dot.green {
    background: var(--green);
}

.footer-dot.red {
    background: var(--red);
}

.footer-dot.cyan {
    background: var(--cyan);
}


/* =========================================================
   MODAL
========================================================= */

.modal-overlay,
.admin-overlay {
    position: fixed;

    inset: 0;

    display: none;

    align-items: center;

    justify-content: center;

    padding: 18px;

    background:
        rgba(
            0,
            4,
            8,
            .88
        );

    backdrop-filter: blur(6px);
}

.modal-overlay {
    z-index: 1000;
}

.admin-overlay {
    z-index: 2000;
}

.modal-overlay.show,
.admin-overlay.show {
    display: flex;
}

.modal-card {
    width:
        min(
            700px,
            95vw
        );

    max-height: 90vh;

    display: grid;

    grid-template-rows:
        auto
        1fr;

    overflow: hidden;

    border:
        1px solid #23617a;

    border-radius: 7px;

    background: #071b27;
}

.modal-header,
.admin-header {
    min-height: 58px;

    padding: 10px 12px;

    display: flex;

    align-items: center;

    justify-content: space-between;
}

.modal-header {
    border-bottom:
        1px solid #174557;

    background: #092433;
}

.modal-header h2,
.admin-header h2 {
    margin:
        2px 0 0;

    font-size: 15px;
}

.modal-subtitle {
    color: #5f8ca0;

    font-size: 8px;

    font-weight: 900;

    letter-spacing: .7px;
}

.modal-close {
    width: 31px;
    height: 31px;

    padding: 0;

    border:
        1px solid #32586a;

    border-radius: 4px;

    background: #112c38;

    color: #bad3dc;

    font-size: 19px;
}

.modal-body {
    min-height: 0;

    overflow-y: auto;

    padding: 10px;
}

.modal-section label {
    color: #819eab;

    font-size: 9px;

    font-weight: 800;
}

.position-input-grid {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 8px;

    margin-top: 8px;
}

.position-box,
.auto-field {
    padding: 8px;

    border:
        1px solid #16485d;

    border-radius: 4px;

    background: #061822;
}

.position-input {
    margin-top: 5px;

    display: grid;

    grid-template-columns:
        1fr
        35px;

    gap: 5px;

    align-items: center;
}

.position-input input,
.auto-field input {
    width: 100%;
    height: 36px;

    padding:
        0 8px;

    border:
        1px solid #22576d;

    border-radius: 4px;

    background: #04131c;

    color: white;

    font-size: 11px;

    outline: none;
}

.slider-section {
    margin-top: 10px;

    padding: 8px;

    border:
        1px solid #16485d;

    border-radius: 4px;

    background: #061822;
}

.slider-section > label {
    display: flex;

    justify-content: space-between;
}

.position-slider {
    width: 100%;

    margin-top: 8px;
}

.position-preview {
    margin-top: 8px;

    padding: 10px;

    border:
        1px solid #136c83;

    border-radius: 4px;

    background: #07303e;

    text-align: center;
}

.position-preview strong {
    color: var(--cyan);

    font-size: 15px;
}

.modal-actions {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 7px;

    margin-top: 10px;
}

.modal-cancel,
.modal-save {
    min-height: 38px;

    border-radius: 4px;

    font-size: 10px;

    font-weight: 900;
}

.modal-cancel {
    border:
        1px solid #425a65;

    background: #19262d;

    color: #b3c5cc;
}

.modal-save {
    border:
        1px solid #1682a0;

    background: #07546a;

    color: #d7f9ff;
}

.auto-settings-info,
.admin-info-box,
.admin-important-box {
    padding: 9px;

    border-radius: 4px;

    font-size: 9px;

    line-height: 1.6;
}

.auto-settings-info {
    border:
        1px solid #17536a;

    background: #072431;

    color: #88acba;
}

.gate-select-title {
    margin-top: 12px;

    color: #c2e0e9;

    font-size: 10px;

    font-weight: 900;
}


/* =========================================================
   ADMIN
========================================================= */

.admin-window {
    width:
        min(
            1180px,
            97vw
        );

    height:
        min(
            780px,
            92vh
        );

    display: grid;

    grid-template-rows:
        62px
        1fr;

    overflow: hidden;

    border:
        1px solid #7f6824;

    border-radius: 8px;

    background:
        linear-gradient(
            180deg,
            #081c27,
            #04131b
        );
}

.admin-header {
    border-bottom:
        1px solid #68551d;

    background:
        linear-gradient(
            90deg,
            #30280d,
            #09212d
        );
}

.admin-header h2 {
    color: #ffe385;
}

.admin-header-actions {
    display: flex;

    align-items: center;

    gap: 6px;
}

.admin-session-state {
    padding: 6px 9px;

    border:
        1px solid #795f19;

    border-radius: 3px;

    background: #392d0e;

    color: #ffe18a;

    font-size: 9px;

    font-weight: 900;
}

.admin-session-state.open {
    border-color: #208558;

    background: #0a4933;

    color: #5ce1a2;
}

.admin-logout-button {
    height: 31px;

    padding:
        0 10px;

    border:
        1px solid #80505a;

    border-radius: 4px;

    background: #371a21;

    color: #e69ba5;

    font-size: 9px;

    font-weight: 900;
}

.admin-login-view {
    min-height: 0;

    display: flex;

    align-items: center;

    justify-content: center;
}

.admin-login-box {
    width: 360px;

    padding: 26px;

    border:
        1px solid #68551d;

    border-radius: 7px;

    background: #091d27;

    text-align: center;
}

.admin-lock-icon {
    font-size: 38px;
}

.admin-login-box h3 {
    margin:
        10px 0 5px;

    color: #ffe187;

    font-size: 17px;
}

.admin-login-box p {
    margin:
        0 0 16px;

    color: #7d99a5;

    font-size: 10px;

    line-height: 1.5;
}

.admin-login-box label {
    display: block;

    text-align: left;

    color: #8da3ad;

    font-size: 9px;

    font-weight: 900;
}

.admin-login-box input {
    width: 100%;
    height: 40px;

    margin-top: 5px;

    padding:
        0 10px;

    border:
        1px solid #5f542c;

    border-radius: 4px;

    background: #04131b;

    color: white;

    font-size: 12px;
}

.admin-primary-button {
    width: 100%;
    height: 40px;

    margin-top: 10px;

    border:
        1px solid #8a6d1b;

    border-radius: 4px;

    background: #56430e;

    color: #ffe59b;

    font-size: 10px;

    font-weight: 900;
}

.admin-login-box small {
    display: block;

    margin-top: 9px;

    color: #637d89;

    font-size: 8px;
}

.admin-app-view {
    min-height: 0;

    display: grid;

    grid-template-rows:
        46px
        1fr;
}

.admin-tabs {
    display: flex;

    align-items: end;

    gap: 3px;

    padding:
        5px 8px 0;

    border-bottom:
        1px solid #173d4d;

    background: #061722;
}

.admin-tab {
    height: 36px;

    padding:
        0 14px;

    border:
        1px solid #173d4d;

    border-bottom: none;

    border-radius:
        4px 4px 0 0;

    background: #0b222d;

    color: #7c9ba8;

    font-size: 9px;

    font-weight: 900;
}

.admin-tab.active {
    border-color: #8a6d1c;

    background: #33290e;

    color: #ffe28b;
}

.admin-content {
    min-height: 0;

    overflow-y: auto;

    padding: 11px;
}

.admin-section-title {
    margin-bottom: 9px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;
}

.admin-section-title h3 {
    margin: 0;

    font-size: 14px;
}

.admin-section-title p {
    margin:
        4px 0 0;

    color: #6d8c99;

    font-size: 9px;
}

.admin-tool-row {
    display: flex;

    align-items: center;

    gap: 5px;
}

.admin-tool-row label {
    color: #75919d;

    font-size: 9px;
}

.admin-tool-row input,
.admin-tool-row select {
    height: 33px;

    padding:
        0 7px;

    border:
        1px solid #1b4d61;

    border-radius: 3px;

    background: #051620;

    color: white;

    font-size: 10px;
}

.admin-save-button {
    min-height: 35px;

    padding:
        0 14px;

    border:
        1px solid #238460;

    border-radius: 4px;

    background: #0b5039;

    color: #bff8db;

    font-size: 9px;

    font-weight: 900;
}

.admin-info-box {
    margin-bottom: 8px;

    border:
        1px solid #18495d;

    background: #07212c;

    color: #84a6b4;
}

.admin-important-box {
    margin-bottom: 8px;

    border:
        1px solid #745e1c;

    background: #27220e;

    color: #c9b979;
}

.admin-info-box strong,
.admin-important-box strong {
    color: #e7f4f8;
}

.admin-grid-header,
.admin-gate-row {
    display: grid;

    grid-template-columns:
        40px
        minmax(180px, 1.6fr)
        110px
        120px
        160px;

    gap: 6px;

    align-items: center;
}

.admin-grid-header {
    padding: 6px 8px;

    color: #6e8e9d;

    font-size: 8px;

    font-weight: 900;
}

.admin-gate-row {
    min-height: 50px;

    margin-bottom: 5px;

    padding: 6px 8px;

    border:
        1px solid #153f51;

    border-radius: 4px;

    background: #061923;
}

.admin-gate-row input,
.admin-gate-row select {
    width: 100%;
    height: 34px;

    padding:
        0 7px;

    border:
        1px solid #1c5064;

    border-radius: 3px;

    background: #04131b;

    color: white;

    font-size: 10px;
}

.admin-index {
    text-align: center;

    color: #658796;

    font-size: 10px;

    font-weight: 900;
}

.sensor-admin-card,
.calibration-card,
.system-card {
    border:
        1px solid #174659;

    border-radius: 5px;

    background: #061a24;
}

.sensor-admin-card {
    margin-bottom: 8px;

    padding: 10px;
}

.sensor-admin-head {
    margin-bottom: 8px;

    display: flex;

    align-items: center;

    justify-content: space-between;
}

.sensor-admin-head strong {
    font-size: 12px;
}

.sensor-role-badge {
    padding:
        4px 7px;

    border:
        1px solid #206279;

    border-radius: 3px;

    background: #082e3c;

    color: #9ee8f5;

    font-size: 8px;

    font-weight: 900;
}

.sensor-fields {
    display: grid;

    grid-template-columns:
        1.25fr
        1fr
        1.15fr
        1.15fr
        1fr
        70px;

    gap: 7px;
}

.admin-field {
    min-width: 0;
}

.admin-field label {
    display: block;

    min-height: 25px;

    margin-bottom: 3px;

    color: #708e9c;

    font-size: 8px;

    font-weight: 900;

    line-height: 1.4;
}

.admin-field input,
.admin-field select {
    width: 100%;
    height: 35px;

    padding:
        0 7px;

    border:
        1px solid #1a4e63;

    border-radius: 3px;

    background: #04131c;

    color: white;

    font-size: 10px;
}

.admin-check {
    width: 18px !important;
    height: 18px !important;

    accent-color: #23c47d;
}

.sensor-help {
    margin-top: 8px;

    padding-top: 7px;

    border-top:
        1px solid #123b4a;

    color: #617f8d;

    font-size: 8px;

    line-height: 1.55;
}

.calibration-grid {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(
                0,
                1fr
            )
        );

    gap: 9px;
}

.calibration-card {
    padding: 11px;
}

.calibration-card h4 {
    margin: 0;

    font-size: 13px;
}

.calibration-card p {
    margin:
        4px 0 9px;

    color: #6f8d99;

    font-size: 9px;
}

.calibration-values {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            1fr
        );

    gap: 5px;
}

.calibration-value {
    padding: 7px;

    border:
        1px solid #143d4f;

    border-radius: 3px;

    background: #04141c;
}

.calibration-value span {
    display: block;

    min-height: 26px;

    color: #668594;

    font-size: 8px;
}

.calibration-value strong {
    display: block;

    margin-top: 2px;

    font-size: 11px;
}

.calibration-form {
    margin-top: 8px;

    display: grid;

    grid-template-columns:
        1fr
        auto;

    gap: 5px;
}

.calibration-form input {
    min-width: 0;

    height: 36px;

    padding:
        0 8px;

    border:
        1px solid #285a6d;

    border-radius: 3px;

    background: #04141c;

    color: white;

    font-size: 10px;
}

.calibration-button,
.dry-button {
    border-radius: 3px;

    font-size: 9px;

    font-weight: 900;
}

.calibration-button {
    padding:
        0 10px;

    border:
        1px solid #1c7c62;

    background: #0a4a36;

    color: #b7f4d6;
}

.dry-button {
    width: 100%;
    height: 36px;

    margin-top: 8px;

    border:
        1px solid #84651c;

    background: #46370e;

    color: #ffe590;
}

.system-card-grid {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            1fr
        );

    gap: 8px;

    margin-bottom: 10px;
}

.system-card {
    padding: 11px;
}

.system-card span {
    display: block;

    color: #6b8997;

    font-size: 8px;
}

.system-card strong {
    display: block;

    margin-top: 4px;

    font-size: 13px;
}

.password-box {
    max-width: 480px;

    padding: 11px;

    border:
        1px solid #574a20;

    border-radius: 5px;

    background: #1b190c;
}

.password-box h4 {
    margin:
        0 0 8px;

    color: #ffe28d;

    font-size: 12px;
}

.password-box input {
    width: 100%;
    height: 36px;

    margin-bottom: 6px;

    padding:
        0 8px;

    border:
        1px solid #605224;

    border-radius: 3px;

    background: #0c120c;

    color: white;

    font-size: 10px;
}


/* =========================================================
   TOAST
========================================================= */

.toast {
    position: fixed;

    z-index: 5000;

    left: 50%;
    bottom: 42px;

    min-width: 280px;

    max-width: 80vw;

    padding:
        10px 15px;

    transform:
        translateX(-50%)
        translateY(20px);

    border:
        1px solid #2a667c;

    border-radius: 5px;

    background: #092633;

    color: #d7eff7;

    text-align: center;

    font-size: 10px;

    font-weight: 800;

    opacity: 0;

    pointer-events: none;

    transition: .18s;
}

.toast.show {
    opacity: 1;

    transform:
        translateX(-50%)
        translateY(0);
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1250px) {

    .top-status-chip {
        display: none;
    }

    .history-toolbar {
        grid-template-columns:
            repeat(
                4,
                minmax(
                    0,
                    1fr
                )
            );
    }

    .sensor-fields {
        grid-template-columns:
            repeat(
                3,
                1fr
            );
    }
}


@media (max-width: 1050px) {

    .gate-grid {
        grid-template-columns:
            1fr;

        grid-auto-rows:
            154px;
    }

    .gate-card {
        height: 154px;

        min-height: 154px;

        max-height: 154px;
    }
}


/* =========================================================
   100% ZOOM — SCADA READABILITY AND BALANCE
========================================================= */

.panel {
    box-shadow:
        inset 0 1px 0 rgba(77, 191, 224, .05),
        0 5px 18px rgba(0, 0, 0, .18);
}

.section-eyebrow,
.chip-label,
.brand-subtitle {
    font-size:
        clamp(
            8px,
            .55vw,
            10px
        );
}

.top-status-chip strong,
.auto-strip-state,
.water-state,
.excel-button {
    font-size:
        clamp(
            9px,
            .62vw,
            11px
        );
}

.gate-grid {
    grid-auto-rows: 164px;
    gap: 8px;
    padding: 8px;
    scrollbar-gutter: stable;
}

.gate-card {
    height: 164px;
    min-height: 164px;
    max-height: 164px;
    padding: 8px;

    border-color: #1a4d61;

    box-shadow:
        inset 0 1px 0 rgba(0, 216, 255, .04),
        0 3px 10px rgba(0, 0, 0, .2);
}

.gate-name strong {
    font-size:
        clamp(
            12px,
            .78vw,
            14px
        );
}

.gate-name small,
.gate-metric span,
.motor-interlock-left small {
    font-size:
        clamp(
            8px,
            .55vw,
            10px
        );
}

.gate-metric strong {
    font-size:
        clamp(
            15px,
            1vw,
            18px
        );
}

.gate-status,
.limit-pill,
.process-pill,
.queue-pill,
.gate-command,
.stop-command,
.exact-command,
.open-setting,
.close-setting {
    font-size:
        clamp(
            8px,
            .55vw,
            10px
        );
}

.gate-card-body {
    height: 43px;
}

.gate-controls {
    height: 33px;
}

.gate-command,
.stop-command,
.exact-command,
.open-setting,
.close-setting {
    height: 31px;
}

.sensor-summary-grid {
    gap: 7px;
    padding: 7px;
}

.sensor-summary {
    padding: 8px 9px;
    border-color: #1a4c60;
}

.sensor-name {
    max-width: 190px;

    font-size:
        clamp(
            10px,
            .68vw,
            12px
        );
}

.sensor-summary small,
.auto-threshold-bar span {
    font-size:
        clamp(
            8px,
            .52vw,
            9px
        );
}

.water-number {
    font-size:
        clamp(
            18px,
            1.22vw,
            22px
        );
}

.water-number.small {
    font-size:
        clamp(
            16px,
            1.02vw,
            19px
        );
}

.chart-legend,
.chart-label {
    font-size:
        clamp(
            9px,
            .55vw,
            10px
        );
}

.auto-threshold-bar strong {
    font-size:
        clamp(
            10px,
            .65vw,
            12px
        );
}

.quick-test button {
    height: 27px;
    font-size: 9px;
}

.history-toolbar {
    grid-template-columns:
        1.15fr
        1.15fr
        .65fr
        .85fr
        1.25fr
        1.25fr
        1.35fr;

    gap: 5px;
    padding: 6px 7px;
}

.history-toolbar input,
.history-toolbar select,
.history-quick-button,
.history-clear-button {
    height: 33px;

    font-size:
        clamp(
            9px,
            .58vw,
            11px
        );
}

.history-date-field span,
.history-period-info {
    font-size:
        clamp(
            8px,
            .52vw,
            9px
        );
}

.history-list {
    scrollbar-gutter: stable;
}

.history-time {
    font-size: 9px;
}

.history-gate,
.history-main strong {
    font-size:
        clamp(
            10px,
            .62vw,
            11px
        );
}

.history-main span,
.history-result {
    font-size:
        clamp(
            8px,
            .52vw,
            9px
        );
}

#historySearch[readonly] {
    cursor: text;
}

#historySearch::-webkit-search-cancel-button {
    cursor: pointer;
}

@media (max-width: 1250px) {

    .history-toolbar {
        grid-template-columns:
            repeat(
                4,
                minmax(
                    0,
                    1fr
                )
            );
    }
}

@media (max-height: 760px) {

    .app-shell {
        grid-template-rows:
            58px
            1fr
            28px;
    }

    .topbar {
        padding: 5px 9px;
    }

    .auto-main-button,
    .top-action-button,
    .admin-top-button {
        height: 38px;
    }

    .gate-grid {
        grid-auto-rows: 158px;
    }

    .gate-card {
        height: 158px;
        min-height: 158px;
        max-height: 158px;
    }

    .right-column {
        grid-template-rows:
            55%
            45%;
    }
}

/* =========================================================
   MOBILE SCADA LAYOUT — 2026-09-27
   Desktop (>900px) layout is unchanged.
========================================================= */

@media (max-width: 900px) {

    html {
        width: 100%;
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        background: #020a10;
    }

    body {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        margin: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    .app-shell {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    /* ---------- TOP BAR ---------- */

    .topbar {
        position: sticky;
        top: 0;
        z-index: 300;
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 7px;
        padding: 8px;
        background: rgba(3, 16, 25, .985);
        backdrop-filter: blur(8px);
    }

    .brand-block {
        width: 100%;
        min-width: 0;
        gap: 8px;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
        font-size: 17px;
    }

    .brand-block > div:last-child {
        min-width: 0;
    }

    .brand-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 13px;
        letter-spacing: .45px;
    }

    .brand-subtitle {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 8px;
    }

    .top-status-chip {
        display: none;
    }

    .top-status-area {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        align-items: stretch;
    }

    .auto-main-button,
    .top-action-button,
    .admin-top-button {
        width: 100%;
        min-width: 0;
        height: 44px;
        padding: 0 7px;
        font-size: 9px;
    }

    .clock-block {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
        padding: 6px 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        border: 1px solid #163f51;
        border-radius: 5px;
        background: #061720;
        text-align: center;
    }

    .clock-block strong {
        font-size: 13px;
    }

    .clock-block span {
        margin-top: 0;
        font-size: 9px;
    }

    /* ---------- MAIN ---------- */

    .main-grid {
        width: 100%;
        min-width: 0;
        display: block;
        padding: 8px;
        overflow: visible;
    }

    .left-column,
    .right-column {
        width: 100%;
        min-width: 0;
        min-height: 0;
        display: block;
    }

    .left-column > *,
    .right-column > * {
        margin-bottom: 8px;
    }

    .panel {
        width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    /* ---------- AUTO / MOTOR ---------- */

    .auto-strip {
        min-height: 0;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }

    .auto-strip-title {
        font-size: 13px;
        line-height: 1.25;
    }

    .auto-strip-summary {
        font-size: 9px;
    }

    .auto-strip-state {
        width: 100%;
        max-width: none;
        padding: 9px 10px;
    }

    .motor-interlock-panel {
        min-height: 0;
        flex-direction: column;
        align-items: stretch;
        padding: 9px;
    }

    .motor-interlock-left {
        min-width: 0;
    }

    .motor-interlock-left strong {
        font-size: 11px;
    }

    .motor-interlock-left small {
        font-size: 9px;
        line-height: 1.35;
    }

    .motor-interlock-stats {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .motor-interlock-stats > div {
        min-width: 0;
        padding: 7px 4px;
    }

    /* ---------- ESP32 STAND ---------- */

    .hardware-stand-panel {
        width: 100%;
        min-width: 0;
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 14px;
    }

    .hardware-stand-info strong {
        font-size: 13px;
    }

    .hardware-stand-info small {
        overflow-wrap: anywhere;
        line-height: 1.4;
    }

    .hardware-stand-status {
        min-width: 0;
        width: 100%;
        text-align: left;
    }

    .hardware-stand-controls {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
    }

    .hardware-command {
        width: 100%;
        min-width: 0;
        height: 48px;
        padding: 0 5px;
        font-size: 12px;
    }

    /* ---------- GATES ---------- */

    .gate-panel {
        display: block;
    }

    .gate-grid {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        gap: 8px;
        padding: 8px;
        overflow: visible;
    }

    .gate-card {
        width: 100%;
        height: auto;
        min-height: 205px;
        max-height: none;
        padding: 9px;
        overflow: visible;
    }

    .gate-card-header {
        height: auto;
        min-height: 31px;
    }

    .gate-name strong {
        max-width: 62vw;
        font-size: 13px;
    }

    .gate-name small {
        font-size: 9px;
    }

    .gate-card-body {
        height: auto;
        min-height: 46px;
    }

    .gate-metric {
        padding: 6px 7px;
    }

    .gate-metric span {
        font-size: 8px;
    }

    .gate-metric strong {
        font-size: 16px;
    }

    .gate-progress-labels {
        height: 15px;
        font-size: 8px;
    }

    .gate-progress {
        height: 7px;
    }

    .gate-status-line {
        height: auto;
        min-height: 28px;
        margin-top: 5px;
    }

    .gate-status,
    .limit-pill,
    .process-pill,
    .queue-pill {
        max-width: 74%;
        padding: 5px 6px;
        font-size: 8px;
    }

    .gate-controls {
        height: auto;
        margin-top: 5px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    .command-pair {
        grid-template-columns: minmax(0, 1fr) 30px;
        gap: 3px;
    }

    .gate-command,
    .stop-command,
    .exact-command,
    .open-setting,
    .close-setting {
        width: 100%;
        height: 42px;
        font-size: 9px;
    }

    .gate-command small {
        font-size: 8px;
    }

    /* ---------- WATER ---------- */

    .water-panel {
        display: block;
    }

    .sensor-summary-grid {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 8px;
    }

    .sensor-summary {
        min-height: 68px;
        padding: 9px;
    }

    .sensor-name {
        max-width: 54vw;
        font-size: 10px;
    }

    .sensor-summary small {
        font-size: 8px;
    }

    .water-number,
    .water-number.small {
        font-size: 18px;
    }

    .water-chart-wrap {
        width: auto;
        height: 220px;
        min-height: 220px;
        margin: 0 8px 8px;
    }

    .auto-threshold-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
        padding: 7px 8px;
    }

    .auto-threshold-bar > div {
        padding: 7px;
    }

    .quick-test {
        grid-column: 1 / -1;
    }

    .quick-test button {
        height: 34px;
        font-size: 9px;
    }

    /* ---------- HISTORY ---------- */

    .history-panel {
        display: block;
    }

    .history-top {
        min-height: 52px;
        gap: 7px;
    }

    .excel-button {
        min-width: 112px;
        height: 36px;
        padding: 0 8px;
    }

    .history-toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
    }

    .history-toolbar input,
    .history-toolbar select,
    .history-quick-button,
    .history-clear-button {
        min-width: 0;
        height: 38px;
        font-size: 10px;
    }

    #historySearch {
        grid-column: 1 / -1;
    }

    .history-period-info {
        min-height: 30px;
        padding: 7px 8px;
        font-size: 9px;
    }

    .history-list {
        padding: 7px;
        overflow: visible;
    }

    .history-item {
        min-height: 0;
        padding: 8px;
        display: grid;
        grid-template-columns: 72px minmax(0, 1fr) 66px;
        gap: 6px;
        align-items: center;
    }

    .history-time {
        grid-column: 1;
        grid-row: 1;
        font-size: 9px;
    }

    .history-gate {
        grid-column: 2;
        grid-row: 1;
        font-size: 10px;
    }

    .history-result {
        grid-column: 3;
        grid-row: 1;
        font-size: 8px;
    }

    .history-main {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .history-main strong {
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: 10px;
    }

    .history-main span {
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: 8px;
        line-height: 1.4;
    }

    /* ---------- FOOTER ---------- */

    .footer-status {
        width: 100%;
        min-height: 0;
        padding: 8px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px 8px;
        font-size: 8px;
    }

    /* ---------- MODALS / ADMIN ---------- */

    .modal-overlay,
    .admin-overlay {
        align-items: flex-start;
        padding: 8px;
        overflow-y: auto;
    }

    .modal-card {
        width: 100%;
        max-width: 100%;
        max-height: calc(100dvh - 16px);
    }

    .modal-body {
        overflow-y: auto;
    }

    .admin-window {
        width: 100%;
        max-width: 100%;
        height: calc(100dvh - 16px);
        max-height: calc(100dvh - 16px);
        grid-template-rows: auto 1fr;
    }

    .admin-header {
        min-height: 58px;
        padding: 8px;
        gap: 6px;
    }

    .admin-header h2 {
        font-size: 13px;
    }

    .admin-header-actions {
        gap: 4px;
    }

    .admin-session-state,
    .admin-logout-button {
        font-size: 8px;
    }

    .admin-login-box {
        width: 100%;
        max-width: 360px;
        margin: 12px;
        padding: 18px;
    }

    .admin-app-view {
        grid-template-rows: auto 1fr;
    }

    .admin-tabs {
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        align-items: stretch;
        padding: 5px 6px 4px;
        scrollbar-width: thin;
    }

    .admin-tab {
        flex: 0 0 auto;
        height: 38px;
        padding: 0 10px;
        border-bottom: 1px solid #173d4d;
        border-radius: 4px;
        white-space: nowrap;
    }

    .admin-content {
        padding: 8px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .admin-section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-tool-row {
        width: 100%;
        flex-wrap: wrap;
    }

    .admin-grid-header {
        display: none;
    }

    .admin-gate-row {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 6px;
        padding: 8px;
    }

    .admin-gate-row > *:nth-child(n+3) {
        grid-column: 2;
    }

    .sensor-fields {
        grid-template-columns: 1fr;
    }

    .admin-field label {
        min-height: 0;
    }

    .calibration-grid {
        grid-template-columns: 1fr;
    }

    .calibration-values {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .calibration-form {
        grid-template-columns: 1fr;
    }

    .calibration-button {
        min-height: 38px;
    }

    .system-card-grid {
        grid-template-columns: 1fr;
    }

    .position-input-grid {
        grid-template-columns: 1fr;
    }

    /* Keep wide content from forcing the phone viewport wider. */
    img,
    svg,
    canvas,
    table,
    input,
    select,
    button {
        max-width: 100%;
    }
}


@media (max-width: 420px) {

    .main-grid {
        padding: 6px;
    }

    .topbar {
        padding: 6px;
    }

    .hardware-stand-panel {
        padding: 11px;
    }

    .hardware-command {
        height: 46px;
        font-size: 11px;
    }

    .panel-header,
    .history-top {
        padding-left: 8px;
        padding-right: 8px;
    }

    .gate-card {
        min-height: 210px;
        padding: 8px;
    }

    .gate-controls {
        grid-template-columns: 1fr;
    }

    .command-pair {
        grid-template-columns: minmax(0, 1fr) 34px;
    }

    .gate-command,
    .stop-command,
    .exact-command,
    .open-setting,
    .close-setting {
        height: 44px;
    }

    .sensor-name {
        max-width: 50vw;
    }

    .history-toolbar {
        grid-template-columns: 1fr;
    }

    #historySearch {
        grid-column: auto;
    }

    .history-item {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .history-time {
        grid-column: 1;
        grid-row: 1;
    }

    .history-gate {
        grid-column: 2;
        grid-row: 1;
    }

    .history-result {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: start;
        min-width: 70px;
    }

    .history-main {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .footer-status {
        grid-template-columns: 1fr;
    }

    .auto-threshold-bar {
        grid-template-columns: 1fr;
    }

    .quick-test {
        grid-column: auto;
    }
}

/* =========================================================
   MOBILE SCROLL FIX V2 — 2026-09-28
   Android Chrome: force the page itself to be vertically
   scrollable instead of behaving like a fixed 100vh SCADA.
========================================================= */

@media (max-width: 900px) {

    html,
    body {
        width: 100% !important;
        height: auto !important;
        min-height: 100dvh !important;
        max-height: none !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
        position: static !important;
    }

    body {
        display: block !important;
        overscroll-behavior-y: auto !important;
        touch-action: pan-y pinch-zoom !important;
    }

    .app-shell {
        width: 100% !important;
        height: auto !important;
        min-height: 100dvh !important;
        max-height: none !important;
        display: block !important;
        overflow: visible !important;
        position: static !important;
    }

    .topbar {
        position: relative !important;
        top: auto !important;
    }

    .main-grid {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        display: block !important;
        overflow: visible !important;
    }

    .left-column,
    .right-column {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        display: block !important;
        overflow: visible !important;
    }

    .gate-panel,
    .water-panel,
    .history-panel {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
    }

    .gate-grid,
    .history-list {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .gate-card {
        height: auto !important;
        max-height: none !important;
    }

    .footer-status {
        position: static !important;
    }
}
/* Multi-abonent login va kabinet */
.login-page,.cabinet-page{min-height:100vh;margin:0;background:radial-gradient(circle at top,#12324a,#07131d 65%);color:#eaf7ff;font-family:Arial,sans-serif}.login-card{width:min(420px,calc(100% - 32px));box-sizing:border-box;margin:8vh auto;padding:32px;background:rgba(12,33,48,.96);border:1px solid #28516b;border-radius:18px;box-shadow:0 24px 70px #0008}.login-card h1{margin:8px 0}.login-card label{display:block;margin:18px 0 7px;font-size:12px;color:#8fcbe9}.login-card input,.cabinet-wrap input,.cabinet-wrap select{width:100%;box-sizing:border-box;padding:12px;border:1px solid #35627d;border-radius:8px;background:#0a1d2a;color:#fff}.login-card button{width:100%;margin-top:22px}.login-logo{margin-bottom:14px}.login-help{color:#a9c1ce}.login-error{min-height:22px;color:#ff8f8f;margin-top:10px}.cabinet-header{display:flex;justify-content:space-between;gap:20px;align-items:center;padding:18px clamp(16px,4vw,48px);background:#0b1c29;border-bottom:1px solid #24465b}.cabinet-header span{display:block;color:#89b9d1;font-size:13px;margin-top:5px}.cabinet-header a,.cabinet-header button,.cabinet-wrap button{display:inline-block;padding:10px 14px;border:1px solid #337596;border-radius:7px;background:#12364a;color:white;text-decoration:none;cursor:pointer}.cabinet-wrap{max-width:1200px;margin:24px auto;padding:0 16px}.cabinet-panel{background:#0c2130;border:1px solid #23475d;border-radius:14px;padding:20px;margin-bottom:18px;overflow:auto}.cabinet-panel select{max-width:520px}.cabinet-tabs{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:18px}.admin-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.admin-grid form,.user-form,.role-box{display:grid;gap:10px;padding:16px;background:#102b3c;border-radius:10px;margin-bottom:14px}.cabinet-wrap table{width:100%;border-collapse:collapse;margin-top:16px}.cabinet-wrap th,.cabinet-wrap td{text-align:left;padding:10px;border-bottom:1px solid #29495b}.check-list,.permission-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:8px}.check-list input,.permission-grid input{width:auto}@media(max-width:700px){.cabinet-header{align-items:flex-start;flex-direction:column}.admin-grid{grid-template-columns:1fr}.cabinet-panel{padding:14px}.cabinet-wrap table{font-size:12px}}
.site-switcher{max-width:240px;padding:9px;border:1px solid #34627c;border-radius:8px;background:#0c2535;color:#e9f8ff}

/* Kabinet zoom qilinganda butun sahifa tabiiy pastga scroll bo'ladi. */
html:has(body.cabinet-page) {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
}
body.cabinet-page {
    width: 100%;
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}
.cabinet-header {
    position: sticky;
    top: 0;
    z-index: 20;
}
.cabinet-wrap {
    padding-bottom: 48px;
}
.permission-item {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px;
    border: 1px solid #285267;
    border-radius: 8px;
    background: rgba(6, 28, 40, .72);
}
.permission-item input {
    flex: 0 0 auto;
    margin-top: 3px;
}
.permission-item span {
    min-width: 0;
    display: grid;
    gap: 3px;
}
.permission-item strong {
    color: #e7f8ff;
    font-size: 12px;
}
.permission-item small {
    color: #7fa9ba;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

/* Eski admin modalida ham zoom paytida tashqi scroll yo'qolmaydi. */
.admin-overlay.show {
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
}
.admin-overlay.show .admin-window {
    max-height: calc(100dvh - 24px);
    margin: auto;
}

/* =========================================================
   PREMIUM HYDRO SCADA — DESKTOP ONLY
   Faqat vizual bezak. Layout, transform va animatsiya yo'q.
========================================================= */
@media (min-width: 901px) {
    :root {
        --premium-cyan: #18dcff;
        --premium-blue: #087fa8;
        --premium-deep: #03131d;
        --premium-line: rgba(41, 157, 193, .48);
        --premium-glow: rgba(24, 220, 255, .13);
    }

    body {
        background:
            radial-gradient(circle at 76% 4%, rgba(19, 103, 133, .30), transparent 34%),
            radial-gradient(circle at 12% 96%, rgba(0, 91, 125, .18), transparent 32%),
            linear-gradient(145deg, #020b11, #03151f 48%, #020a10);
    }

    .topbar {
        border-bottom: 1px solid rgba(24, 220, 255, .58);
        background:
            linear-gradient(90deg, rgba(2, 12, 19, .99), rgba(5, 43, 58, .98) 45%, rgba(2, 17, 25, .99));
        box-shadow:
            0 8px 28px rgba(0, 0, 0, .42),
            inset 0 -1px rgba(70, 226, 255, .11);
    }

    .brand-block {
        border-right: 1px solid rgba(57, 154, 186, .22);
        padding-right: 18px;
    }

    .water-brand {
        border: 1px solid rgba(82, 232, 255, .82);
        border-radius: 10px 3px 10px 3px;
        background:
            radial-gradient(circle at 32% 20%, rgba(75, 235, 255, .28), transparent 42%),
            linear-gradient(145deg, #0a4358, #031a27);
        box-shadow:
            0 0 0 1px rgba(0, 216, 255, .07),
            0 0 22px rgba(0, 216, 255, .16),
            inset 0 1px rgba(255, 255, 255, .12);
    }

    .water-brand svg {
        filter:
            drop-shadow(0 2px 3px rgba(0, 0, 0, .42))
            drop-shadow(0 0 4px rgba(29, 223, 255, .22));
    }

    .brand-title {
        color: #f4fcff;
        font-weight: 900;
        letter-spacing: 1.25px;
        text-shadow: 0 0 16px rgba(24, 220, 255, .15);
    }

    .brand-subtitle {
        color: #69b7cf;
        letter-spacing: 1.18px;
    }

    .top-status-chip,
    .site-switcher,
    .top-action-button,
    .admin-top-button,
    .auto-main-button {
        border-color: rgba(44, 132, 160, .7);
        border-radius: 3px 9px 3px 9px;
        background: linear-gradient(145deg, rgba(11, 49, 64, .96), rgba(4, 24, 35, .98));
        box-shadow: inset 0 1px rgba(111, 228, 255, .06);
    }

    .top-action-button:hover,
    .admin-top-button:hover {
        border-color: #27c9ef;
        color: #dffaff;
        background: linear-gradient(145deg, #0d4b61, #062938);
    }

    .main-grid {
        background:
            linear-gradient(rgba(18, 110, 140, .025) 1px, transparent 1px),
            linear-gradient(90deg, rgba(18, 110, 140, .025) 1px, transparent 1px);
        background-size: 28px 28px;
    }

    .panel,
    .auto-strip,
    .motor-interlock-panel {
        border-color: var(--premium-line);
        border-radius: 3px 13px 3px 13px;
        background:
            linear-gradient(145deg, rgba(7, 34, 47, .985), rgba(3, 18, 27, .99));
        box-shadow:
            0 12px 32px rgba(0, 0, 0, .22),
            inset 0 1px rgba(105, 226, 255, .045);
    }

    .panel-header {
        border-bottom-color: rgba(38, 120, 147, .52);
        background: linear-gradient(90deg, rgba(13, 61, 79, .72), rgba(5, 27, 38, .18));
    }

    .section-eyebrow {
        color: #5fa7bf;
        letter-spacing: 1.18px;
    }

    .panel-header h2,
    .auto-strip-title {
        color: #eefbff;
        letter-spacing: .36px;
    }

    .motor-interlock-panel {
        border-color: rgba(194, 153, 34, .58);
        background: linear-gradient(90deg, rgba(62, 48, 8, .58), rgba(5, 29, 39, .96) 44%);
    }

    .gate-card {
        border-color: rgba(32, 117, 145, .72);
        border-radius: 3px 11px 3px 11px;
        background:
            linear-gradient(145deg, rgba(10, 46, 61, .98), rgba(4, 23, 33, .99));
        box-shadow:
            0 8px 22px rgba(0, 0, 0, .28),
            inset 0 1px rgba(103, 224, 255, .045);
    }

    .gate-card.motor-active {
        border-color: rgba(24, 220, 255, .82);
        box-shadow:
            0 0 0 1px rgba(24, 220, 255, .12),
            0 0 24px rgba(24, 220, 255, .14);
    }

    .gate-name strong,
    .gate-metric strong {
        color: #f1fcff;
    }

    .gate-progress {
        border-color: rgba(44, 133, 163, .62);
        background: #020f17;
        box-shadow: inset 0 2px 7px rgba(0, 0, 0, .52);
    }

    .gate-progress-bar {
        background: linear-gradient(90deg, #04a8d1, #22e0ff);
        box-shadow: 0 0 12px rgba(24, 220, 255, .32);
    }

    .gate-command,
    .stop-command,
    .exact-command {
        border-radius: 3px 8px 3px 8px;
        box-shadow: inset 0 1px rgba(255, 255, 255, .09), 0 5px 12px rgba(0, 0, 0, .18);
    }

    .open-command {
        background: linear-gradient(145deg, #087f53, #09a96c);
        border-color: #14c882;
    }

    .close-command {
        background: linear-gradient(145deg, #076b9c, #078fc8);
        border-color: #19b9ea;
    }

    .stop-command {
        background: linear-gradient(145deg, #9b2938, #d83d4f);
        border-color: #ef6170;
    }

    .water-metric,
    .water-footer-item {
        border-color: rgba(34, 111, 137, .62);
        background: linear-gradient(145deg, rgba(7, 34, 46, .9), rgba(3, 21, 30, .92));
    }

    .water-metric strong {
        color: #22ddff;
        text-shadow: 0 0 12px rgba(24, 220, 255, .18);
    }

    .water-chart-wrap,
    .history-list {
        border-color: rgba(30, 101, 126, .55);
        background: linear-gradient(180deg, rgba(2, 18, 27, .9), rgba(2, 13, 20, .96));
    }

    .history-item {
        border-color: rgba(31, 95, 117, .52);
        background: linear-gradient(90deg, rgba(7, 35, 47, .76), rgba(4, 23, 32, .68));
    }

    .footer-status {
        border-top-color: rgba(24, 220, 255, .32);
        background: linear-gradient(90deg, #020b10, #041a24, #020b10);
        color: #83b6c7;
    }

    ::-webkit-scrollbar-thumb {
        background: linear-gradient(#16718d, #0b4257);
        border-radius: 10px;
    }
}

/* Suv inshooti logotipi */
.water-brand svg {
    width: 36px;
    height: 36px;
    display: block;
    filter: drop-shadow(0 3px 5px rgba(0, 216, 255, .22));
}
.hydro-dam-deck,
.hydro-dam-piers {
    fill: none;
    stroke: #eefcff;
    stroke-width: 2.15;
    stroke-linecap: square;
    stroke-linejoin: miter;
}
.hydro-dam-gates {
    fill: rgba(32, 204, 237, .18);
    stroke: #39def8;
    stroke-width: 1.7;
}
.hydro-dam-water {
    fill: none;
    stroke: #26ddff;
    stroke-width: 2.8;
    stroke-linecap: round;
}
.water-logo-drop {
    fill: url(#gidroDrop);
    stroke: #80efff;
    stroke-width: 1.6;
}
.water-logo-drop.login-drop { fill: url(#gidroDropLogin); }
.water-logo-wave,
.water-logo-dam {
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.water-logo-wave { stroke: #b9f6ff; }

/* Milliy-modern gidro emblema: ko'k suv, yashil oqim, nozik qizil aksent. */
.uz-logo-drop {
    fill: url(#uzHydroDrop);
    stroke: #85efff;
    stroke-width: 1.5;
}
.uz-logo-drop.login-drop { fill: url(#uzHydroDropLogin); }
.uz-logo-crescent {
    fill: #ffffff;
    opacity: .96;
}
.uz-logo-star {
    fill: #ffffff;
}
.uz-logo-gate {
    fill: none;
    stroke: #f5fdff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.uz-logo-redline {
    fill: none;
    stroke: #ef4050;
    stroke-width: 1.6;
    stroke-linecap: round;
}
.uz-logo-wave {
    fill: none;
    stroke: #31d48d;
    stroke-width: 2.8;
    stroke-linecap: round;
}

/* Desktop uchun statik, barqaror premium SCADA bezagi. Layout va tugma
   geometriyasiga tegmaydi; mobil qoidalari o'z holida qoladi. */
@media (min-width: 901px) {
    body {
        background: radial-gradient(circle at 70% 12%, #0b3345 0, #031019 38%, #02090e 100%);
    }
    .topbar {
        background: linear-gradient(90deg, #02111a, #062634 52%, #02111a);
        border-bottom-color: #08789a;
        box-shadow: 0 8px 24px rgba(0, 0, 0, .34), inset 0 -1px rgba(0, 216, 255, .14);
    }
    .water-brand {
        border-color: rgba(65, 224, 255, .78);
        border-radius: 12px;
        background: radial-gradient(circle at 36% 24%, rgba(47, 226, 255, .24), rgba(5, 60, 80, .48) 48%, rgba(2, 28, 40, .85));
        box-shadow: 0 0 0 1px rgba(0, 216, 255, .08), 0 5px 18px rgba(0, 0, 0, .32), inset 0 1px rgba(255, 255, 255, .12);
    }
    .brand-title {
        color: #f0fbff;
        letter-spacing: 1px;
    }
    .panel,
    .auto-strip,
    .motor-interlock-panel {
        border-color: #15556d;
        background: linear-gradient(145deg, rgba(7, 31, 43, .98), rgba(3, 18, 27, .99));
        box-shadow: 0 10px 28px rgba(0, 0, 0, .22), inset 0 1px rgba(104, 221, 255, .04);
    }
    .panel-header {
        background: linear-gradient(90deg, rgba(11, 48, 63, .62), rgba(4, 25, 35, .2));
        border-bottom-color: #174d61;
    }
    .top-status-chip,
    .site-switcher,
    .top-action-button,
    .admin-top-button,
    .auto-main-button {
        background: linear-gradient(145deg, #0b2c3b, #061b26);
        border-color: #1c5f79;
        box-shadow: inset 0 1px rgba(112, 225, 255, .05);
    }
    .gate-card {
        background: linear-gradient(145deg, #092b3a, #061a25);
        border-color: #17627c;
        box-shadow: 0 8px 20px rgba(0, 0, 0, .24);
    }
    .gate-card.motor-active {
        box-shadow: 0 0 0 1px rgba(0, 216, 255, .25), 0 0 22px rgba(0, 216, 255, .12);
    }
    .water-chart-wrap,
    .history-list {
        background: linear-gradient(180deg, rgba(2, 18, 27, .72), rgba(2, 13, 20, .88));
    }
    .footer-status {
        background: #020d14;
        border-top-color: #12536b;
    }
}
/* ADMIN — QURILMALAR VA IP MANZILLAR */
.hardware-network-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:12px}
.hardware-network-summary>div{padding:12px 14px;border:1px solid #25516a;border-radius:8px;background:linear-gradient(180deg,#0d2a3b,#091e2b)}
.hardware-network-summary span,.hardware-network-summary strong{display:block}
.hardware-network-summary span{margin-bottom:5px;color:#6fa9c7;font-size:10px;font-weight:800;letter-spacing:.08em}
.hardware-network-summary strong{color:#5de6ff;font-family:Consolas,monospace;font-size:16px}
.hardware-device-row{display:grid;grid-template-columns:150px repeat(3,minmax(155px,1fr));gap:10px;align-items:end;margin-bottom:10px;padding:14px;border:1px solid #28556e;border-radius:10px;background:#0b2433}
.hardware-device-row.unbound{border-color:#b57a27;box-shadow:inset 3px 0 0 #d89932}
.hardware-device-row.bound{border-color:#23765d}
.hardware-device-row label{color:#7eafc8;font-size:10px;font-weight:800;letter-spacing:.05em}
.hardware-device-row input,.hardware-device-row select{width:100%;box-sizing:border-box;margin-top:6px;padding:10px;border:1px solid #35647d;border-radius:6px;background:#071b27;color:#e9f8ff}
.hardware-top-actions{display:flex;gap:9px;align-items:center}
.hardware-delete-button{padding:9px 12px;border:1px solid #a94a4a;border-radius:6px;background:#351719;color:#ffd8d8;font-weight:800;cursor:pointer}
.hardware-delete-button:hover{background:#642125}
.hardware-device-status{align-self:stretch;display:flex;flex-direction:column;justify-content:center;padding:9px;border-left:3px solid #d89932;background:#172a32}
.hardware-device-status.online{border-left-color:#23d79a}
.hardware-device-status strong{color:#ffc15c}.hardware-device-status.online strong{color:#38e8aa}
.hardware-device-status small{margin-top:4px;color:#7997a6;font-size:9px}
.hardware-device-status code{display:block;max-width:100%;margin-top:7px;color:#9fd8ed;font-size:9px;overflow-wrap:anywhere}
.hardware-device-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;padding-top:4px}
.hardware-device-actions button{min-height:40px}
.hardware-check-label{display:flex;align-items:center;gap:8px;min-height:38px}.hardware-check-label input{width:auto;margin:0}
.hardware-admin-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:14px}
.admin-save-button.secondary{border-color:#35647d;background:#123247}
.hardware-empty-state{padding:28px;border:1px dashed #35647d;border-radius:8px;color:#88aabd;text-align:center}
@media(max-width:1100px){.hardware-device-row{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.hardware-network-summary,.hardware-device-row{grid-template-columns:1fr}.hardware-admin-actions{flex-direction:column}.hardware-device-actions{display:grid;grid-template-columns:1fr}.hardware-device-actions button{width:100%}}

/* JAM xavfsizlik indikatori */
.jam-safety-indicator{display:flex;align-items:center;gap:9px;min-width:174px;padding:7px 11px;border:1px solid #28516b;border-radius:7px;background:#0a1e2b;box-sizing:border-box}
.jam-safety-indicator .jam-safety-lamp{width:13px;height:13px;border-radius:50%;flex:0 0 13px;box-shadow:0 0 10px currentColor}
.jam-safety-indicator small,.jam-safety-indicator strong{display:block;white-space:nowrap}.jam-safety-indicator small{font-size:8px;letter-spacing:.09em;color:#83aac0}.jam-safety-indicator strong{margin-top:2px;font-size:10px}
.jam-safety-indicator.ready{color:#39e6a3;border-color:#238660}.jam-safety-indicator.ready .jam-safety-lamp{background:#39e6a3}
.jam-safety-indicator.alarm{color:#ff5252;border-color:#d43b3b;background:#351317;animation:jamAlarmPulse .75s infinite alternate}.jam-safety-indicator.alarm .jam-safety-lamp{background:#ff3b3b}
.jam-safety-indicator.offline{color:#f0ad4e;border-color:#8b672d}.jam-safety-indicator.offline .jam-safety-lamp{background:#f0ad4e}
@keyframes jamAlarmPulse{from{box-shadow:0 0 0 rgba(255,59,59,0)}to{box-shadow:0 0 15px rgba(255,59,59,.55)}}

/* Katta kanal JAM holati — faqat 20_evd kartasi */
#gateGrid .gate-card{grid-column:span 2;width:100%;min-height:205px}
#gateGrid .gate-card.jam-emergency{border:2px solid #ff3535;background:linear-gradient(145deg,#3b1118,#170a10);box-shadow:0 0 22px rgba(255,40,40,.55)}
#gateGrid .gate-card.jam-ready{border-color:#1d9b70;box-shadow:0 0 10px rgba(35,215,154,.18)}
.gate-permission-status{display:flex;align-items:center;justify-content:center;gap:6px;width:104px;min-width:104px;height:24px;padding:0 7px;border:1px solid #7b622d;border-radius:5px;color:#f0ad4e;background:#2b2415;box-sizing:border-box}
.gate-permission-status span{width:7px;height:7px;border-radius:50%;background:currentColor;flex:0 0 7px}
.gate-permission-status strong{font-size:9px;line-height:1;white-space:nowrap;letter-spacing:.035em}
.gate-permission-status.ready{color:#39e6a3;border-color:#238660;background:#0b3328}
.gate-permission-status.alarm{color:#fff;border-color:#ff5252;background:#c6222f}
.gate-permission-status.offline{color:#f0ad4e;border-color:#7b622d;background:#2b2415}
.gate-jam-banner{order:-1;display:flex;justify-content:space-between;align-items:center;gap:10px;margin:0 0 9px;padding:9px 12px;border-radius:6px;border:1px solid currentColor}
.gate-jam-banner strong{font-size:13px;letter-spacing:.05em}.gate-jam-banner span{font-size:9px;font-weight:800;letter-spacing:.04em}
.gate-jam-banner.ready{color:#37e6a5;background:#0b3328}.gate-jam-banner.alarm{color:#fff;background:#d62532;border-color:#ff727b}.gate-jam-banner.offline{color:#ffd073;background:#3b2a0d}
@media(max-width:700px){#gateGrid .gate-card{grid-column:span 1}.gate-jam-banner{align-items:flex-start;flex-direction:column}}

/* Every discovered gate shares one stable card layout. */
#gateGrid{grid-template-columns:minmax(0,1fr);grid-auto-rows:auto;gap:12px;align-content:start}
#gateGrid .gate-card{grid-column:1;width:100%;height:auto;min-height:170px;max-height:none;box-sizing:border-box;padding:10px;overflow:hidden;border-width:2px}
#gateGrid .gate-card-header{display:grid;grid-template-columns:minmax(0,1fr) 116px auto;height:32px;gap:10px;margin-bottom:7px}
#gateGrid .gate-name strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#gateGrid .gate-permission-status{width:116px;min-width:116px;height:26px;animation:none}
#gateGrid .gate-icons{display:flex;gap:5px;align-items:center}
#gateGrid .gate-card.jam-ready{background:linear-gradient(145deg,#082c26,#061c23);border-color:#1d9b70}
#gateGrid .gate-card.jam-emergency{border-color:#ff3535;background:linear-gradient(145deg,#3b1118,#170a10);box-shadow:0 0 12px rgba(255,40,40,.3)}
@media(max-width:420px){#gateGrid .gate-card-header{grid-template-columns:minmax(0,1fr) 116px; height:auto;min-height:32px}#gateGrid .gate-icons{grid-column:2;justify-content:flex-end}}
