:root {
    --g950: #132A1E;
    --g900: #1a4a2f;
    --g800: #1f6b42;
    --g700: #267449;
    --g600: #32965b;
    --ink: #182820;
    --muted: #738078;
    --border: #e5ece7;
    --canvas: #f6f8f6;
    --shadow: 0 7px 24px rgba(26, 62, 40, .055)
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px
}

body.dashboard-page {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font: 14px Inter, "Segoe UI", Roboto, Arial, sans-serif
}

.dashboard-page * {
    box-sizing: border-box
}

.dashboard-page a {
    color: inherit;
    text-decoration: none
}

.app-shell {
    min-height: 100vh
}

.sidebar {
    width: 260px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 24px 14px 18px;
    background: var(--g950);
    color: #e8f0e9;
    border-right: 1px solid #1c3526;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 24px;
    border-bottom: 1px solid #1e3a2a;
    margin-bottom: 20px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 20px;
    background: #1e3d2a;
    border: 1px solid #2a4e39;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 4px
}

.brand-copy strong {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.brand-copy small {
    color: #6b8f7a;
    font-size: 9px;
    letter-spacing: 1.2px;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-label {
    margin: 8px 10px 10px;
    color: #5a7d6a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.side-nav {
    display: grid;
    gap: 4px;
    margin-bottom: 28px
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 8px;
    color: #8aa898;
    font-weight: 500;
    font-size: 14px;
    transition: .15s ease;
    border: 1px solid transparent;
}

.nav-link:hover {
    background: #1a3223;
    color: #e8f5e9;
}

.nav-link.active {
    color: #ffffff;
    background: #1e3d2a;
    border: 1px solid #274d36;
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    opacity: 0.9;
}

.nav-link.active .nav-icon {
    opacity: 1;
}

.sidebar-device {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border: 1px solid #1e3a2a;
    background: #162d1f;
    border-radius: 10px;
}

.device-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f0c14b;
    box-shadow: 0 0 0 3px rgba(240,193,75,0.15);
}

.sidebar-device div,
.sidebar-bottom div:last-child {
    display: grid;
    gap: 3px;
    min-width: 0
}

.sidebar-device strong {
    font-size: 11px;
    line-height: 1.4;
    font-weight: 600;
}

.sidebar-device small,
.sidebar-bottom small {
    color: #6b8f7a;
    font-size: 10px
}

.sidebar-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 14px 10px 4px;
    border-top: 1px solid #1e3a2a;
}

.sidebar-help-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #1e3d2a;
    border: 1px solid #2a4e39;
    color: #a8ccb5;
    font-weight: 700;
    font-size: 12px;
}

.sidebar-bottom strong {
    font-size: 11px;
    font-weight: 600;
}

.main-content {
    margin-left: 260px;
    padding: 30px clamp(20px, 3.2vw, 48px) 20px;
    max-width: 1800px
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 26px
}

.eyebrow {
    margin: 0 0 8px 0;
    padding: 0;
    color: #5a7d6a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-align: left;
}

.topbar h1 {
    margin: 0;
    color: #f9fafa;
    font-size: clamp(25px, 2.2vw, 30px);
    line-height: 1.2;
    letter-spacing: -0.8px;
    font-weight: 800;
}

.page-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6
}

.topbar-right {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 9px
}

.live-pill,
.date-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    color: #526359;
    font-size: 11px;
    font-weight: 650
}

.live-pill span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3ca663;
    box-shadow: 0 0 0 4px #e5f5e9
}

.overview-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 23px;
    margin-bottom: 32px;
    border-radius: 16px;
    border: 1px solid #dcebe0;
    background: linear-gradient(110deg, #eaf6ed, #f7fbf7 66%, #fff)
}

.overview-intro {
    display: flex;
    align-items: center;
    gap: 14px
}

.overview-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: white;
    color: var(--g700);
    font-size: 23px;
    box-shadow: 0 3px 10px #17452f0d
}

.overview-intro h2 {
    margin: 0 0 5px;
    font-size: 15px
}

.overview-intro p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5
}

.overview-status {
    min-width: 245px;
    padding-left: 24px;
    border-left: 1px solid #d5e6d9;
    display: grid;
    gap: 5px
}

.overview-status-label,
.system-label {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.2px
}

#device-status {
    color: var(--g800);
    font-size: 13px;
    font-weight: 750
}

.overview-status small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5
}

.dashboard-section {
    margin-bottom: 34px
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 17px
}

.section-heading h2 {
    margin: 0;
    color: var(--ink);
    font-size: 20px;
    letter-spacing: -.5px
}

.section-heading p:not(.eyebrow) {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55
}

.section-tag {
    padding: 7px 10px;
    border: 1px solid #d8eadc;
    border-radius: 8px;
    background: #f0f8f1;
    color: var(--g700);
    font-size: 10px;
    font-weight: 750;
    white-space: nowrap
}

.muted-tag {
    background: #f4f6f4;
    border-color: #e6eae7;
    color: #7a857e
}

.ai-tag {
    background: #edf8ef
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px
}

.metric-card,
.panel-card,
.stat-card,
.system-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow)
}

.metric-card {
    min-width: 0;
    padding: 18px 17px 16px
}

.metric-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px
}

.metric-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 11px;
    font-size: 18px
}

.temp-icon {
    background: #fff0e9
}

.humidity-icon {
    background: #eaf4ff
}

.soil-icon {
    background: #eaf7ec
}

.water-icon {
    background: #e9f5f8
}

.metric-label {
    color: #728078;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .8px;
    line-height: 1.45
}

.metric-reading {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-height: 42px;
    flex-wrap: wrap
}

.metric-reading .value {
    color: var(--g950);
    font-size: clamp(27px, 2.3vw, 34px);
    font-weight: 750;
    letter-spacing: -1.2px;
    line-height: 1.15;
    overflow-wrap: anywhere
}

.metric-unit {
    color: #87928b;
    font-size: 11px
}

.metric-footer {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #f0f3f0;
    color: #68766d;
    font-size: 10px;
    line-height: 1.5
}

.irrigation-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px
}

.system-card {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 18px;
    min-width: 0
}

.system-card-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #edf7ef;
    font-size: 21px
}

.alarm-icon {
    background: #fff5df
}

.mode-icon {
    background: #edf3ff
}

.system-card-content {
    display: grid;
    gap: 7px;
    min-width: 0;
    flex: 1
}

.system-value {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.4;
    overflow-wrap: anywhere
}

.system-card-content p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55
}

.system-state-dot {
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 50%;
    background: #c8d2cb
}

.mode-badge {
    padding: 5px 7px;
    border-radius: 6px;
    background: #eaf5ed;
    color: var(--g700);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .5px
}

.pump-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px
}

.pump-btn {
    padding: 7px 12px;
    border: 1px solid #dfe7e1;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer
}

.pump-btn:hover {
    border-color: var(--g700)
}

.pump-btn.active {
    background: var(--g700);
    border-color: var(--g700);
    color: #fff
}

.pump-btn:disabled {
    opacity: .6;
    cursor: wait
}

.filter-control {
    display: flex;
    align-items: center;
    gap: 9px
}

.filter-control label {
    color: #65736a;
    font-size: 11px;
    font-weight: 650
}

.filter-control select {
    min-width: 115px;
    padding: 10px 30px 10px 11px;
    border: 1px solid #dfe7e1;
    border-radius: 9px;
    background: white;
    color: #34443a;
    font: inherit;
    font-size: 11px
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 11px;
    margin-bottom: 15px
}

.stat-card {
    padding: 14px 13px;
    box-shadow: none
}

.stat-card>span {
    display: block;
    min-height: 28px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4
}

.stat-card strong {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 7px;
    color: var(--g900);
    font-size: 21px;
    letter-spacing: -.5px;
    overflow-wrap: anywhere
}

.stat-card strong small {
    color: #8a968e;
    font-size: 10px;
    font-weight: 550
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px
}

.panel-card {
    min-width: 0;
    overflow: hidden
}

.chart-card {
    padding: 19px 19px 13px
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px
}

.panel-heading h3 {
    margin: 0;
    color: var(--ink);
    font-size: 13px
}

.panel-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 10px
}

.chart-unit {
    padding: 5px 7px;
    border-radius: 6px;
    background: #f0f7f1;
    color: var(--g700);
    font-size: 10px;
    font-weight: 750
}

.chart-wrap {
    position: relative;
    height: 245px;
    margin-top: 15px
}

.recommendation-panel {
    display: flex;
    align-items: center;
    gap: 17px;
    position: relative;
    overflow: hidden;
    padding: 22px 24px;
    border: 1px solid #d9ebdd;
    border-radius: 15px;
    background: linear-gradient(105deg, #eaf7ed, #fbfdfb 70%)
}

.ai-emblem {
    width: 43px;
    height: 43px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: white;
    color: var(--g700);
    font-size: 23px;
    box-shadow: 0 4px 12px #16452f0c
}

.recommendation-copy {
    position: relative;
    z-index: 1;
    max-width: 680px
}

.recommendation-copy h3 {
    margin: 6px 0 7px;
    color: var(--g900);
    font-size: 16px
}

.recommendation-copy p {
    margin: 0 0 9px;
    color: #586b5e;
    font-size: 12px;
    line-height: 1.65
}

.recommendation-copy small {
    color: #7a8a7e;
    font-size: 10px
}

.recommendation-illustration {
    margin-left: auto;
    padding: 0 28px;
    font-size: 58px;
    opacity: .78
}

.primary-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 0;
    border-radius: 9px;
    padding: 11px 15px;
    background: var(--g700);
    color: white;
    font: inherit;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
    box-shadow: 0 4px 10px #26744920;
    transition: background .18s, transform .18s
}

.primary-button:hover {
    background: var(--g800);
    transform: translateY(-1px)
}

.primary-button span {
    font-size: 17px;
    line-height: 10px
}

.history-panel {
    padding: 0
}

.table-scroll {
    width: 100%;
    overflow-x: auto
}

#historyTable {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px
}

#historyTable thead {
    background: #f7faf7
}

#historyTable th {
    padding: 14px 17px;
    text-align: left;
    color: #6c7a70;
    font-size: 9px;
    letter-spacing: .8px;
    text-transform: uppercase;
    white-space: nowrap
}

#historyTable td {
    padding: 13px 17px;
    border-top: 1px solid #edf1ed;
    color: #46564b;
    font-size: 11px;
    white-space: nowrap
}

#historyTable tbody tr:hover {
    background: #f9fcf9
}

#historyTable td[colspan] {
    padding: 25px;
    text-align: center;
    color: var(--muted)
}

.page-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px 0 8px;
    border-top: 1px solid #e4eae5;
    color: #87928a;
    font-size: 10px
}

@media(max-width:1250px) {
    .sensor-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr))
    }

    .main-content {
        padding-left: 25px;
        padding-right: 25px
    }
}

@media(max-width:900px) {
    .sidebar {
        width: 76px;
        padding: 22px 10px 15px;
        align-items: center
    }

    .brand {
        padding: 0 0 32px;
        border-bottom: none;
        margin-bottom: 0;
    }

    .brand-copy,
    .sidebar-label {
        display: none
    }

    .side-nav {
        width: 100%
    }

    .nav-link {
        justify-content: center;
        padding: 0;
        font-size: 0;
        min-height: 45px
    }

    .nav-icon {
        font-size: 19px
    }

    .sidebar-device {
        justify-content: center;
        padding: 10px 8px
    }

    .sidebar-device div,
    .sidebar-bottom div:last-child {
        display: none
    }

    .sidebar-bottom {
        justify-content: center;
        padding: 15px 0 2px;
        border-top: none;
    }

    .main-content {
        margin-left: 76px
    }

    .irrigation-grid {
        grid-template-columns: 1fr
    }

    .system-card {
        min-height: 100px
    }
}

@media(max-width:620px) {
    .main-content {
        padding: 22px 14px 16px
    }

    .topbar {
        display: block
    }

    .topbar-right {
        justify-content: flex-start;
        margin-top: 16px
    }

    .overview-strip {
        display: block;
        padding: 17px
    }

    .overview-status {
        min-width: 0;
        margin-top: 17px;
        padding: 13px 0 0;
        border-left: 0;
        border-top: 1px solid #d5e6d9
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column
    }

    .section-heading h2 {
        font-size: 18px
    }

    .sensor-grid {
        grid-template-columns: 1fr 1fr;
        gap: 9px
    }

    .metric-card {
        padding: 13px 11px
    }

    .metric-top {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 13px
    }

    .metric-reading .value {
        font-size: 27px
    }

    .metric-label {
        font-size: 8px
    }

    .metric-footer {
        margin-top: 11px;
        padding-top: 9px;
        font-size: 9px
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

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

    .chart-wrap {
        height: 220px
    }

    .filter-control {
        width: 100%;
        justify-content: space-between
    }

    .filter-control select {
        flex: 1
    }

    .recommendation-panel {
        align-items: flex-start;
        padding: 18px;
        gap: 12px
    }

    .recommendation-illustration {
        display: none
    }

    .ai-emblem {
        width: 35px;
        height: 35px;
        font-size: 19px
    }

    .page-footer {
        display: grid;
        line-height: 1.6
    }
}