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

/* ===================================
   ROOT VARIABLES
=================================== */
:root {
    --bg:       #0a2156;
    --bg2:      #0d2d6e;
    --bg3:      #1040a0;

    --border:   rgba(255,255,255,0.13);

    --text:     #e6edf3;
    --muted:    #90b4e8;

    --cyan:     #60c8ff;
    --cyan-dim: rgba(96,200,255,0.18);

    --green:    #4ade80;
    --red:      #f87171;
    --orange:   #fb923c;
    --yellow:   #facc15;

    --sidebar-w: 220px;
    --header-h: 70px;
}

/* ===================================
   HTML & BODY
=================================== */
html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--text);
    color: var(--text);

    display: flex;
    flex-direction: column;
}

/* ===================================
   TOP HEADER
=================================== */
.topbar {
    height: var(--header-h);

    background: var(--bg2);
    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;

    padding: 0 20px;
    gap: 16px;

    flex-shrink: 0;
    z-index: 100;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;

    min-width: var(--sidebar-w);
    padding-left: 4px;
}

.brand-icon img {
    width: 50px;
    height: 50px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}

.brand-sub {
    font-size: 10px;
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ===================================
   TOPBAR CENTER
=================================== */
.topbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.welcome-text {
    font-size: 13px;
    color: var(--muted);
}

/* ===================================
   TOPBAR RIGHT
=================================== */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;

    margin-left: auto;
    flex-shrink: 0;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;

    background: var(--bg3);
    border: 1px solid var(--border);

    border-radius: 20px;
    padding: 5px 12px;

    font-size: 12px;
    font-weight: 500;

    color: var(--muted);
}

.status-pill .dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: var(--green);
    box-shadow: 0 0 6px var(--green);

    animation: blink 2s ease infinite;
}

.status-pill .dot.warn {
    background: var(--orange);
    box-shadow: 0 0 6px var(--orange);
}

.status-pill span {
    color: var(--text);
}

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

    50% {
        opacity: .4;
    }
}

/* ===================================
   TIME BAR
=================================== */
.timebar {
    background: var(--bg3);

    border-bottom: 1px solid var(--border);

    padding: 8px 24px;

    display: flex;
    align-items: center;
    gap: 20px;

    flex-shrink: 0;

    font-size: 12px;
    color: var(--muted);
}

.timebar-item {
    display: flex;
    align-items: center;
    gap: 7px;
}

.timebar-item svg {
    width: 13px;
    height: 13px;

    stroke: var(--cyan);
    fill: none;
    stroke-width: 2;

    flex-shrink: 0;
}

.timebar-val {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text);

    font-size: 13px;
    font-weight: 500;
}

.timebar-sep {
    width: 1px;
    height: 14px;

    background: var(--border);
}

@media (max-width: 768px) {

    .timebar {
        padding: 7px 14px;
        font-size: 11px;
    }

    .timebar-val {
        font-size: 12px;
    }

}
/* ===================================
   LAYOUT SHELL
=================================== */
.shell {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===================================
   SIDEBAR
=================================== */

.sidebar {
    width: var(--sidebar-w);

    background: var(--bg2);
    border-right: 1px solid var(--border);

    display: flex;
    flex-direction: column;

    padding: 16px 12px;
    gap: 4px;

    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);

    letter-spacing: 0.08em;
    text-transform: uppercase;

    padding: 10px 10px 6px;
}

/* ===================================
   NAVIGATION ITEM
=================================== */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 10px 12px;

    border-radius: 8px;
    border: none;
    background: none;

    width: 100%;
    text-align: left;

    cursor: pointer;

    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;

    color: var(--muted);

    transition: background 0.15s,
                color 0.15s;
}

.nav-item:hover {
    background: var(--bg3);
    color: var(--text);
}

.nav-item.active {
    background: var(--cyan-dim);
    color: var(--cyan);

    border: 1px solid rgba(34,211,238,0.2);
}

.nav-item svg{
    width:17px;
    height:17px;

    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;

    flex-shrink: 0;
}



/* ===================================
   MAIN CONTENT
=================================== */
.main {
    flex: 1;

    overflow-y: auto;

    padding: 8px 20px;

    scrollbar-width: thin;
    scrollbar-color: var(--bg3) transparent;
}

.main::-webkit-scrollbar {
    width: 5px;
}

.main::-webkit-scrollbar-thumb {
    background: var(--bg3);
    border-radius: 4px;
}

/* ===================================
   PAGE
=================================== */
.page {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.page.active {
    display: flex;
}

#page-settings {
    padding-top: 0;
    margin-top: -30px;
}

/* ===================================
   SENSOR GRID
=================================== */
.sensor-grid {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 16px;
}

/* ===================================
   SENSOR CARD
=================================== */
.sensor-card {
    background: var(--bg2);

    border: 1px solid var(--border);
    border-radius: 14px;

    padding: 20px 22px;

    position: relative;
    overflow: hidden;

    transition:
        border-color 0.2s,
        transform 0.2s;
}

.sensor-card:hover {
    border-color: rgba(255,255,255,0.14);
    transform: translateY(-2px);
}

.sensor-card::before {
    content: '';

    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    height: 2px;
}

/* Garis atas warna */
.sensor-card.ph::before {
    background:
      linear-gradient(
        90deg,
        var(--green),
        transparent
      );
}

.sensor-card.do::before {
    background:
      linear-gradient(
        90deg,
        var(--red),
        transparent
      );
}

.sensor-card.temp::before {
    background:
      linear-gradient(
        90deg,
        var(--orange),
        transparent
      );
}

/* ===================================
   SENSOR HEADER
=================================== */
.sensor-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    margin-bottom: 14px;
}

.sensor-label {
    font-size: 12px;
    font-weight: 500;

    color: var(--muted);
}

/* ===================================
   SENSOR ICON
=================================== */
.sensor-icon {
    width: 32px;
    height: 32px;

    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;
}

.sensor-icon svg {
    width: 17px;
    height: 17px;

    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.sensor-icon.ph {
    background:
      rgba(74,222,128,0.12);

    color: var(--green);
}

.sensor-icon.do {
    background:
      rgba(248,113,113,0.12);

    color: var(--red);
}

.sensor-icon.temp {
    background:
      rgba(251,146,60,0.12);

    color: var(--orange);
}

/* ===================================
   SENSOR VALUE
=================================== */
.sensor-val {
    font-family:
      'JetBrains Mono',
      monospace;

    font-size: 36px;
    font-weight: 600;

    color: var(--text);

    line-height: 1;

    margin-bottom: 10px;
}

/* ===================================
   SENSOR BADGE
=================================== */
.sensor-badge {
    display: inline-flex;
    align-items: center;

    padding: 3px 10px;

    border-radius: 20px;

    font-size: 11px;
    font-weight: 600;
}

.badge-good {
    background:
      rgba(74,222,128,0.15);

    color: var(--green);
}

.badge-warn {
    background:
      rgba(250,204,21,0.15);

    color: var(--yellow);
}

.badge-danger {
    background:
      rgba(248,113,113,0.15);

    color: var(--red);
}

.badge-normal {
    background:
      rgba(34,211,238,0.12);

    color: var(--cyan);
}
/* ===================================
   CHART GRID
=================================== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.chart-card {
    background: var(--bg2);

    border: 1px solid var(--border);
    border-radius: 14px;

    padding: 18px 20px;
}

.chart-title {
    font-size: 13px;
    font-weight: 600;

    color: var(--text);

    margin-bottom: 14px;
}

.chart-wrap {
    position: relative;
    height: 180px;
}

/* ===================================
   PAGE HEADER
=================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 4px;
}

.page-heading {
    font-size: 18px;
    font-weight: 700;
}

.page-sub {
    font-size: 13px;
    color: var(--muted);

    margin-top: 2px;
}

.action-row {
    display: flex;
    gap: 8px;
}

/* ===================================
   BUTTON EXPORT
=================================== */
.btn-export {
    background: rgb(4, 199, 20);
    color: var(--text);

    border: 1px solid rgb(4, 199, 20);
    border-radius: 8px;

    padding: 7px 16px;

    font-size: 12px;
    font-weight: 600;

    font-family: 'Inter', sans-serif;
    cursor: pointer;

    transition: background 0.2s;
}

.btn-export:hover {
    background: rgb(4, 59, 25);
}

/* ===================================
   BUTTON REFRESH
=================================== */
.btn-refresh {
    background: var(--bg3);
    color: var(--text);

    border: 1px solid var(--border);
    border-radius: 8px;

    padding: 7px 14px;

    font-size: 12px;
    font-weight: 600;

    font-family: 'Inter', sans-serif;
    cursor: pointer;

    transition: background 0.2s;
}

.btn-refresh:hover {
    background: rgba(25, 0, 248, 0.822);
}

/* ===================================
   TABLE WRAPPER
=================================== */
.table-wrap {
    background: var(--bg2);

    border: 1px solid var(--border);
    border-radius: 14px;

    overflow: hidden;
}

/* ===================================
   TABLE
=================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg3);
}

.data-table th {
    padding: 12px 16px;

    text-align: left;

    font-size: 11px;
    font-weight: 600;

    color: var(--muted);

    letter-spacing: 0.06em;
    text-transform: uppercase;

    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 11px 16px;

    font-size: 13px;
    color: var(--text);

    border-bottom: 1px solid rgba(255,255,255,0.04);

    font-family: 'JetBrains Mono', monospace;
}

.data-table tr:last-child td {
    border-bottom: none;
}

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

.empty-cell {
    text-align: center;

    color: var(--muted);

    font-style: italic;
    font-family: 'Inter', sans-serif;

    padding: 40px;
}

/* ===================================
   SETTINGS GRID
=================================== */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===================================
   SETTINGS CARD
=================================== */
.settings-card {
    background: var(--bg2);

    border: 1px solid var(--border);
    border-radius: 14px;

    padding: 22px 24px;
}

.settings-title {
    font-size: 14px;
    font-weight: 600;

    color: var(--text);

    margin-bottom: 16px;
}

/* ===================================
   SETTINGS ROW
=================================== */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 10px 0;

    border-bottom: 1px solid var(--border);

    font-size: 13px;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    color: var(--muted);
}

.setting-val {
    color: var(--text);

    font-weight: 500;

    font-family:
      'JetBrains Mono',
      monospace;
}

/* ===================================
   TOGGLE SWITCH
=================================== */
.tog {
    position: relative;

    display: inline-block;

    width: 42px;
    height: 24px;

    cursor: pointer;
}

.tog input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tog-sl {
    position: absolute;
    inset: 0;

    background: rgba(255,255,255,0.1);

    border-radius: 24px;

    transition: background 0.25s;
}

.tog-sl::before {
    content: '';

    position: absolute;

    width: 18px;
    height: 18px;

    left: 3px;
    top: 3px;

    background: #fff;

    border-radius: 50%;

    transition: transform 0.25s;
}

.tog input:checked + .tog-sl {
    background: var(--cyan);
}

.tog input:checked + .tog-sl::before {
    transform: translateX(18px);
}
/* ===================================
   INFO GRID
=================================== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ===================================
   BLUE CARD
=================================== */
.bc {
    background: var(--bg2);

    border: 1px solid var(--border);
    border-radius: 16px;

    padding: 16px;

    display: flex;
    flex-direction: column;

    gap: 10px;
}

.bc-title {
    font-size: 12px;
    font-weight: 600;

    color: var(--muted);

    letter-spacing: 0.04em;
}

.bc-inner {
    background: var(--bg);

    border: 1px solid var(--border);
    border-radius: 10px;

    padding: 13px 15px;
}

/* ===================================
   NILAI FUZZY
=================================== */
.fz-row {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 5px 0;

    border-bottom: 1px solid rgba(255,255,255,0.1);

    font-size: 12px;
}

.fz-row:last-child {
    border-bottom: none;
}

.fz-key {
    color: var(--muted);
}

.fz-num {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: #fff;
}

.fz-big {
    font-family: 'JetBrains Mono', monospace;

    font-size: 40px;
    font-weight: 700;

    color: #fff;

    text-align: right;
    line-height: 1;
}

.fz-big-label {
    font-size: 11px;
    color: var(--muted);

    margin-bottom: 4px;
}

/* ===================================
   STATUS KUALITAS AIR
=================================== */
.wq-status-row {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 10px;
    padding: 12px;
}

.wq-dot {
    width: 11px;
    height: 11px;

    border-radius: 50%;
    flex-shrink: 0;

    background: var(--green);
    box-shadow: 0 0 8px var(--green);

    animation: blink 2s ease infinite;
}

.wq-dot.bad {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

.wq-dot.warn {
    background: var(--yellow);
    box-shadow: 0 0 8px var(--yellow);
}

.wq-status-text {
    font-size: 16px;
    font-weight: 700;

    color: #fff;

    letter-spacing: 0.08em;
}

.wq-sub-row {
    display: flex;
    justify-content: space-between;

    padding: 5px 0;

    border-bottom: 1px solid rgba(255,255,255,0.1);

    font-size: 11px;
}

.wq-sub-row:last-child {
    border-bottom: none;
}

.wq-sub-key {
    color: var(--muted);
}

.wq-sub-val {
    color: #fff;

    font-weight: 600;

    font-family:
      'JetBrains Mono',
      monospace;
}

/* ===================================
   KONTROL POMPA
=================================== */
.pump-item {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 10px 14px;

    background: var(--bg);

    border: 1px solid var(--border);
    border-radius: 10px;
}

.pump-info {
}

.pump-name {
    font-size: 13px;
    font-weight: 600;

    color: #fff;
}

.pump-sub {
    font-size: 10px;
    color: var(--muted);

    margin-top: 2px;
}

/* ===================================
   TOGGLE POMPA
=================================== */
.ptog {
    position: relative;

    display: inline-block;

    width: 46px;
    height: 26px;

    cursor: pointer;

    flex-shrink: 0;
}

.ptog input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ptog-sl {
    position: absolute;
    inset: 0;

    background: rgba(255,255,255,0.2);

    border-radius: 26px;

    transition: background 0.25s;
}

.ptog-sl::before {
    content: '';

    position: absolute;

    width: 20px;
    height: 20px;

    left: 3px;
    top: 3px;

    background: #fff;

    border-radius: 50%;

    transition: transform 0.25s;
}

.ptog input:checked + .ptog-sl {
    background: var(--cyan);
}

.ptog input:checked + .ptog-sl::before {
    transform: translateX(20px);
}
/* ===================================
   FOOTER
=================================== */
.footer {
    text-align: center;

    font-size: 11px;
    color: var(--muted);

    padding: 20px;

    margin-top: auto;
}

/* ===================================
   RESPONSIVE MOBILE
   <= 768px
=================================== */
@media (max-width: 768px) {

    :root {
        --sidebar-w: 0px;
    }

    /* Header */
    .topbar {
        padding: 0 14px;
        height: 58px;
    }

    .topbar-brand {
        min-width: unset;
    }

    .brand-sub,
    .welcome-text {
        display: none;
    }

    .status-pill .label-text {
        display: none;
    }

    .page-title {
        font-size: 15px;
    }

    /* Sidebar hilang */
    .sidebar {
        display: none;
    }

    /* Main */
    .main {
        padding: 16px 14px 80px;
    }

    /* Grid menjadi 1 kolom */
    .sensor-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

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

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* ==========================
       BOTTOM NAVIGATION
    ========================== */
    .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    height: 64px;

    background: var(--bg2);
    border-top: 1px solid var(--border);

    align-items: center;
    justify-content: space-around;

    z-index: 200;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 3px;

    width: 90px;
    height: 42px;

    padding: 0;

    border: none;
    background: transparent;

    border-radius: 12px;

    font-size: 10px;
    font-weight: 600;

    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.bottom-nav .nav-item i{
    font-size:22px;
    line-height:1;
    margin-bottom:4px;
}

.bottom-nav .nav-item.active {
    background: var(--cyan-dim);
    color: var(--cyan);

    width: 90px;
    height: 42px;
}

.bottom-nav .nav-item span.label {
    color: inherit;
}
}

/* ===================================
   BOTTOM NAV HIDDEN DESKTOP
=================================== */
.bottom-nav {
    display: none;
}

/* ===================================
   TABLET RESPONSIVE
   769px - 1024px
=================================== */
@media (min-width: 769px)
and (max-width: 1024px) {

    .sensor-grid {
        grid-template-columns:
            repeat(3, 1fr);
    }

    .chart-grid {
        grid-template-columns:
            1fr 1fr;
    }

}