/* ============================================
           LAYOUT
        ============================================ */
.main-content {
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    padding-top: max(20px, env(safe-area-inset-top));
}

.mobile-header {
    padding-top: max(15px, env(safe-area-inset-top));
}

.user-email a {
    text-decoration: none;
    word-break: break-all;
}

    .mobile-header .logo {
        padding-bottom: 0;
    }

.dashboard-content {
    padding-bottom: max(30px, env(safe-area-inset-bottom));
}

a {
    color: #076735;
}

    a:hover {
        color: #054d28;
    }

/* ============================================
           PAGE HEADER
        ============================================ */
.page-header {
    flex-wrap: wrap;
}

.page-heading {
    flex: 1;
    min-width: 0;
}

.page-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 2px 0 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #fff;
    color: #076735;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    flex-shrink: 0;
}

    .back-link:hover {
        background: #eff5f0;
        color: #076735;
    }

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ============================================
           BUTTONS
        ============================================ */
.btn {
    display: inline-flex;
    justify-content: center;
    min-height: 40px;
}

.btn-primary:hover,
.btn-primary:focus {
    background: #054d28;
    color: #fff;
}

.btn-outline-primary {
    color: #076735;
    border: 1px solid #076735;
    background: #fff;
}

    .btn-outline-primary:hover {
        background: #eff5f0;
        color: #076735;
        border-color: #076735;
    }

.btn-danger {
    background: #dc2626;
    color: #fff;
}

    .btn-danger:hover {
        background: #b91c1c;
        color: #fff;
    }

.btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    display: flex;
    width: 100%;
    gap: 6px;
}

    .btn-block + .btn-block {
        margin-top: 6px;
    }

.btn-outline-success {
    color: #4ce4de;
    border: 1px solid #4ce4de;
    background: #fff;
}

    .btn-outline-success:hover {
        background: #4ce4de;
        color: #fff;
    }

.btn-outline-danger {
    color: #dc2626;
    border: 1px solid #dc2626;
    background: #fff;
}

    .btn-outline-danger:hover {
        background: #dc2626;
        color: #fff;
    }

.action-btn {
    margin-top: 0;
    width: 36px;
    height: 36px;
    background: #eff5f0;
    color: #076735;
}

    .action-btn.danger {
        background: #fee2e2;
    }

        .action-btn.danger i {
            color: #b91c1c;
        }

.dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    font-size: 14px;
}

.dropdown-item {
    border-radius: 6px;
    padding: 9px 12px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 10px;
}

    .dropdown-item i {
        color: #076735;
        width: 16px;
        text-align: center;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        background: #eff5f0;
        color: #076735;
    }

/* ============================================
           CARDS & FORMS
        ============================================ */
.content-card {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.content-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #191D23;
    margin-bottom: 16px;
}

.form-card {
    max-width: 760px;
}

.form-group {
    margin-bottom: 16px;
}

    .form-group > label,
    .control-label {
        display: block;
        margin-bottom: 6px;
        color: #374151;
        font-weight: 500;
    }

.form-control,
.form-select {
    min-height: 44px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #111827;
}

    .form-control:focus,
    .form-select:focus {
        border-color: #076735;
        background-color: #fff;
        color: #111827;
    }

    .form-control:disabled,
    .form-control[readonly] {
        background-color: #f3f4f6;
        color: #6b7280;
    }

select.disabled {
    pointer-events: none;
    background-color: #f3f4f6;
    color: #6b7280;
}

select[multiple].form-control,
select[multiple].form-select {
    min-height: 120px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 0;
    min-height: 32px;
}

    .form-check .form-check-input {
        margin: 0;
        width: 20px;
        height: 20px;
        float: none;
    }

    .form-check .form-check-label {
        margin: 0;
    }

.row > [class*="col"] > .form-group {
    margin-bottom: 0;
}

.share-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e5e7eb;
}

    .share-row > select {
        flex: 1 1 160px;
        min-width: 0;
    }

    .share-row .share-input {
        width: 96px;
        flex-shrink: 0;
    }

        .share-row .share-input label {
            font-size: 12px;
            color: #6b7280;
            margin-bottom: 4px;
            display: block;
        }

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.field-validation-error,
.validation-summary-errors {
    color: #b91c1c;
    font-size: 13px;
}

    .validation-summary-errors ul {
        list-style: none;
        padding: 0;
        margin: 0 0 12px;
    }

.alert {
    border-radius: 10px;
    border: none;
    font-size: 14px;
}

.text-muted-sm {
    color: #6b7280;
    font-size: 13px;
}

.note {
    display: block;
    color: #6b7280;
    font-size: 13px;
    margin-top: 14px;
}

/* ============================================
           DETAILS LIST
        ============================================ */
.details-list {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    gap: 14px 20px;
    margin: 0;
}

    .details-list dt {
        color: #6b7280;
        font-weight: 500;
        font-size: 13px;
    }

    .details-list dd {
        margin: 0;
        font-weight: 500;
        color: #111827;
        word-break: break-word;
    }

.danger-note {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fef2f2;
    color: #991b1b;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
           TABLES
        ============================================ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table td {
    vertical-align: middle;
}

.data-table th,
.data-table td {
    padding-left: 10px;
    padding-right: 10px;
}

.data-table tbody tr:hover {
    transform: none;
    background: #f9fafb;
}

.data-table tbody tr.row-locked td {
    background: #fef2f2;
}

.data-table .cell-actions {
    white-space: nowrap;
}

@media (min-width: 769px) {
    .data-table td.cell-title {
        white-space: nowrap;
        font-weight: 500;
    }

    .data-table td.hide-mobile.text-muted-sm {
        max-width: 110px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.data-table a {
    text-decoration: none;
}

    .data-table a:hover {
        text-decoration: underline;
    }

.data-table td.cell-wrap {
    white-space: normal;
    word-break: break-word;
    min-width: 220px;
}

.data-table td.cell-code {
    font-family: SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    max-width: 480px;
}

.empty-state {
    text-align: center;
    color: #6b7280;
    padding: 30px 10px;
}

/* DataTables */
div.dataTables_wrapper {
    min-height: 220px;
}

.dataTables_wrapper .row {
    margin-left: 0;
    margin-right: 0;
    row-gap: 10px;
}

    .dataTables_wrapper .row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
    }

div.dataTables_wrapper div.dataTables_filter {
    text-align: right;
}

    div.dataTables_wrapper div.dataTables_filter label {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: #6b7280;
        font-size: 13px;
        margin: 0;
    }

    div.dataTables_wrapper div.dataTables_filter input {
        margin-left: 0 !important;
        min-width: 240px;
        min-height: 40px;
        padding: 8px 14px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #fff;
        color: #111827;
    }

div.dataTables_wrapper div.dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 13px;
    margin: 0;
}

div.dataTables_wrapper div.dataTables_length select {
    min-height: 40px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background-color: #fff;
    color: #111827;
}

div.dataTables_wrapper div.dataTables_info {
    color: #6b7280;
    font-size: 13px;
    padding-top: 0 !important;
}

div.dataTables_wrapper div.dataTables_paginate .pagination {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
}

.dataTables_wrapper .page-link {
    color: #076735;
    border: 1px solid #e5e7eb;
    border-radius: 8px !important;
    min-width: 36px;
    text-align: center;
    font-size: 13px;
}

.dataTables_wrapper .page-item.active .page-link {
    background: #076735;
    border-color: #076735;
    color: #fff;
}

.dataTables_wrapper .page-item.disabled .page-link {
    color: #9ca3af;
}

.dataTables_wrapper table.dataTable {
    margin-top: 12px !important;
    margin-bottom: 12px !important;
    border-collapse: collapse !important;
}

    .dataTables_wrapper table.dataTable > thead > tr > th {
        border-bottom: 2px solid #e5e7eb;
    }

div.dataTables_processing {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    color: #076735;
    padding: 14px !important;
    z-index: 5;
}

    div.dataTables_processing > div:last-child > div {
        background: #076735;
    }

/* ============================================
           TABS
        ============================================ */
.page-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

    .page-tabs::-webkit-scrollbar {
        display: none;
    }

    .page-tabs .nav-link {
        border: none;
        border-bottom: 2px solid transparent;
        color: #6b7280;
        font-size: 14px;
        font-weight: 500;
        padding: 12px 6px;
        margin-right: 12px;
        background: none;
        white-space: nowrap;
    }

        .page-tabs .nav-link.active {
            color: #076735;
            border-bottom-color: #076735;
            background: none;
        }

/* ============================================
           TOASTR
        ============================================ */
#toast-container.toast-top-full-width {
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    width: auto;
}

    #toast-container.toast-top-full-width > div {
        width: 100%;
    }

/* ============================================
           METER DASHBOARD
        ============================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

    .status-pill .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: currentColor;
    }

    .status-pill.on {
        background: #d1fae5;
        color: #065f46;
    }

    .status-pill.warn {
        background: #fef3c7;
        color: #92400e;
    }

.meter-hero {
    background: linear-gradient(135deg, #076735 0%, #0b8a48 100%);
    color: #fff;
    border-radius: 16px;
    padding: 22px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: flex-end;
    box-shadow: 0 6px 20px rgba(7, 103, 53, 0.25);
    margin-bottom: 16px;
}

    .meter-hero .hero-label {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        font-weight: 500;
        opacity: 0.9;
    }

    .meter-hero .hero-value {
        font-size: 34px;
        font-weight: 700;
        line-height: 1.2;
        margin-top: 6px;
    }

    .meter-hero .hero-meta {
        display: flex;
        flex-direction: column;
        gap: 2px;
        font-size: 13px;
        text-align: right;
    }

        .meter-hero .hero-meta .hero-meta-label {
            opacity: 0.85;
        }

        .meter-hero .hero-meta strong {
            font-weight: 600;
        }

        .meter-hero .hero-meta #timeago {
            opacity: 0.85;
            font-size: 12px;
        }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

    .kpi-card > div:last-child {
        min-width: 0;
    }

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #eff5f0;
    color: #076735;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.kpi-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.kpi-value {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    word-break: break-word;
}

.relay-control .checkbox label {
    margin: 4px 0 0;
}

    .relay-control .checkbox label .toggle {
        margin: 0;
    }

.toggle.btn {
    display: inline-block;
    border-radius: 999px;
    min-width: 84px;
    min-height: 32px;
    padding: 0;
    border: none;
}

.toggle .btn {
    display: block;
    min-height: 0;
    border: none;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.6;
}

.toggle .toggle-on {
    background: #076735;
    color: #fff;
}

.toggle .toggle-off {
    background: #e5e7eb;
    color: #374151;
}

.toggle .toggle-handle {
    display: none;
}

.toggle.disabled,
.toggle[disabled] {
    opacity: 0.6;
}

.metric-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.metric-group {
    background: #f9fafb;
    border-radius: 10px;
    padding: 14px 16px;
}

.metric-group-title {
    font-size: 12px;
    font-weight: 600;
    color: #076735;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    font-size: 14px;
    border-bottom: 1px dashed #e5e7eb;
}

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

    .metric-row .metric-name {
        color: #6b7280;
    }

    .metric-row .metric-value {
        font-weight: 600;
        color: #111827;
        white-space: nowrap;
    }

    .metric-row .metric-unit {
        color: #9ca3af;
        font-weight: 500;
        font-size: 12px;
        margin-left: 3px;
    }

.chart-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.date-fields {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

    .date-fields > div {
        flex: 1;
        min-width: 140px;
    }

    .date-fields label {
        font-size: 12px;
        color: #6b7280;
        display: block;
        margin-bottom: 4px;
    }

.chart-box {
    position: relative;
    height: 300px;
}

.segmented {
    display: inline-flex;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

    .segmented button {
        border: none;
        background: transparent;
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 500;
        color: #374151;
        min-width: 72px;
    }

        .segmented button.active {
            background: #fff;
            color: #076735;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

        .segmented button:disabled {
            opacity: 0.6;
        }

/* ============================================
           STATUS PAGES (logout, access denied...)
        ============================================ */
.status-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    text-align: center;
    max-width: 440px;
    width: 100%;
    margin: 40px auto;
}

    .status-card .status-icon {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 28px;
        margin-bottom: 18px;
        background: #eff5f0;
        color: #076735;
    }

        .status-card .status-icon.danger {
            background: #fee2e2;
            color: #b91c1c;
        }

    .status-card h1 {
        font-size: 20px;
        font-weight: 600;
        color: #191D23;
        margin-bottom: 8px;
    }

    .status-card p {
        color: #6b7280;
        font-size: 14px;
        margin-bottom: 24px;
    }

    .status-card .btn-primary {
        background: #076735;
        color: #fff;
        border-radius: 10px;
        padding: 10px 24px;
    }

/* ============================================
           LOGIN
        ============================================ */
body.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    padding: 20px;
}

    body.login-body .login-card {
        width: 100%;
        max-width: 440px;
        min-height: 0;
    }

    body.login-body .login-card h2 {
        margin-bottom: 2rem;
    }

    body.login-body .form-control {
        min-height: 52px;
        font-size: 16px;
    }

    body.login-body .form-check {
        padding-left: 0;
    }

@media (max-width: 576px) {
    body.login-body {
        padding: 16px;
    }

        body.login-body .login-card {
            padding: 2.25rem 1.25rem;
            border-radius: 16px;
        }

        body.login-body .imgLogo {
            width: 130px;
            margin-bottom: 1.5rem;
        }

        body.login-body .login-card h2 {
            margin-bottom: 1.5rem;
        }

        body.login-body .input-group {
            margin-bottom: 1rem;
        }

        body.login-body .btn-login {
            font-size: 18px;
            padding: 0.9rem;
        }
}

/* ============================================
           MOBILE
        ============================================ */
@media (max-width: 768px) {
    .dashboard-content {
        padding-top: 20px;
    }

    .content-card,
    .item-table-section {
        padding: 7px;
    }

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

    .header-actions {
        width: 100%;
        margin-left: 0;
    }

        .header-actions .btn {
            flex: 1;
        }

    .form-actions .btn {
        flex: 1;
    }

    .form-control,
    .form-select,
    div.dataTables_wrapper div.dataTables_filter input,
    div.dataTables_wrapper div.dataTables_length select {
        font-size: 16px;
    }

    .details-list {
        grid-template-columns: 1fr;
        gap: 2px;
    }

        .details-list dd {
            margin-bottom: 12px;
        }

    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_filter label,
    div.dataTables_wrapper div.dataTables_filter input {
        width: 100%;
        min-width: 0;
        text-align: left;
    }

    div.dataTables_wrapper div.dataTables_length {
        display: none;
    }

    div.dataTables_wrapper div.dataTables_info {
        text-align: center;
    }

    div.dataTables_wrapper div.dataTables_paginate .pagination {
        justify-content: center;
    }

    .hide-mobile {
        display: none !important;
    }

    /* Tables become cards on small screens */
    .table-stack thead {
        display: none;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100% !important;
    }

        .table-stack tr {
            display: flex;
            flex-direction: column;
            background: #fff;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            padding: 10px 14px;
            margin-bottom: 12px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
        }

        .table-stack td {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            border: none !important;
            padding: 7px 0 !important;
            text-align: right;
            white-space: normal;
            word-break: break-word;
        }

            .table-stack td::before {
                content: attr(data-label);
                color: #6b7280;
                font-size: 13px;
                font-weight: 500;
                text-align: left;
                flex-shrink: 0;
                max-width: 45%;
            }

            .table-stack td.cell-title {
                order: -1;
                font-size: 15px;
                font-weight: 600;
                color: #4ce4de;
                text-align: left;
            }

                .table-stack td.cell-title::before,
                .table-stack td.cell-actions::before,
                .table-stack td[data-label=""]::before,
                .table-stack td.dataTables_empty::before {
                    display: none;
                }

            .table-stack td.cell-actions {
                order: 99;
                justify-content: flex-start;
                flex-wrap: wrap;
                border-top: 1px solid #f3f4f6 !important;
                margin-top: 6px;
                padding-top: 12px !important;
            }

                .table-stack td.cell-actions .action-buttons {
                    flex-wrap: wrap;
                }

                .table-stack td.cell-actions .btn-block {
                    flex: 1;
                    width: auto;
                }

                    .table-stack td.cell-actions .btn-block + .btn-block {
                        margin-top: 0;
                    }

            .table-stack td.dataTables_empty {
                justify-content: center;
                text-align: center;
            }

            .table-stack td.empty-state {
                justify-content: center;
            }

            .table-stack td:empty,
            .table-stack td.cell-actions:not(:has(*)) {
                display: none;
            }

    .table-stack tbody tr:hover {
        background: #fff;
    }

    .table-stack tbody tr.row-locked {
        border-color: #fecaca;
        background: #fef2f2;
    }

        .table-stack tbody tr.row-locked td {
            background: transparent;
        }

    .modal-footer .btn {
        width: 100%;
    }

    .meter-hero {
        padding: 20px;
        align-items: flex-start;
    }

        .meter-hero .hero-value {
            font-size: 30px;
        }

        .meter-hero .hero-meta {
            text-align: left;
            width: 100%;
            padding-top: 12px;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi-card {
        flex-direction: row;
        align-items: flex-start;
        gap: 10px;
        padding: 6px;
    }

    .kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .kpi-card.relay-control {
        /*   grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;*/
    }

        .kpi-card.relay-control > div:last-child {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }

        .kpi-card.relay-control .checkbox label {
            margin: 0;
        }

    .metric-groups {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .metric-group {
        padding: 6px;
    }

    .chart-box {
        height: 240px;
    }

    .segmented {
        display: flex;
        width: 100%;
    }

        .segmented button {
            flex: 1;
            min-width: 0;
            padding: 8px 6px;
        }
}

@media (max-width: 420px) {
    .metric-groups {
        grid-template-columns: 1fr;
    }
}


.action-btn i,
.nav-links a i {
    color: #4ce4de !important;
}

.nav-links a.active {
    color: #4ce4de !important;
}



.nav-links a {
    color: #4ce4de !important;
}
.btn-primary {
    background: #4ce4de !important;
}
.btn-outline-primary {
    border: #4ce4de !important;
    color: #4ce4de !important;
}

.dropdown-item i {
    color: #4ce4de !important;
}
.btn.show {
    background-color: #4ce4de !important;
}

.meter-hero {
    background: linear-gradient(135deg, #4ce4de 0%, #0761a8 100%);
}
.kpi-icon {
    color: #4ce4de !important;
}
.toggle .toggle-on {
    background: #4ce4de !important;
}
.status-pill.on {
    background: #e0fbfa !important;
    color: #0f766e !important;
}

.segmented button.active {
    color: #4ce4de !important;
}
.dataTables_wrapper .page-item.active .page-link {
    background: #4ce4de !important;
    border-color: #4ce4de !important;
}
.dataTables_wrapper .page-link {
    color: #4ce4de !important;
}

.menu-toggle, .org-selector select {
    color: #4ce4de !important;
}
.btn-login, .btn-login:hover {
    background-color: #4ce4de !important;
}

.mobile-header{
    padding: 5px 20px !important;
   
}
.relay-control .checkbox label .toggle {
    width: 60px !important;
}

@media (max-width: 768px) {
    /* ... existing styles ... */

    .meter-hero {
        padding: 6px 6px !important;
        align-items: stretch !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        border-radius: 16px !important;
        gap: 0 !important;
        box-shadow: 0 8px 24px rgba(7, 97, 168, 0.25) !important;
    }

        .meter-hero > div:first-child {
            display: flex;
            flex-direction: column;
            justify-content: center;
            min-width: 0;
            flex: 1;
        }

        .meter-hero .hero-label {
            font-size: 13px !important;
            font-weight: 500 !important;
            opacity: 0.95 !important;
            order: -1;
        }

        .meter-hero .hero-value {
            font-size: clamp(18px, 6.4vw, 28px) !important;
            font-weight: 700 !important;
            line-height: 1.15 !important;
            margin-top: 4px !important;
            white-space: nowrap;
        }

        .meter-hero .hero-meta {
            text-align: left !important;
            width: auto !important;
            padding-top: 0 !important;
            border-top: none !important;
            border-left: 1px solid rgba(255, 255, 255, 0.3) !important;
            padding-left: 12px !important;
            margin-left: 12px !important;
            display: flex !important;
            flex-direction: column !important;
            justify-content: center !important;
            gap: 2px !important;
            font-size: 12px !important;
            flex: 0 1 auto;
            min-width: 0;
            max-width: 48%;
        }

            .meter-hero .hero-meta .hero-meta-label {
                opacity: 0.9 !important;
                font-size: 12px !important;
                white-space: nowrap;
            }

            .meter-hero .hero-meta strong {
                font-size: 12px !important;
                font-weight: 600 !important;
                line-height: 1.3;
                white-space: normal;
            }

            .meter-hero .hero-meta #timeago {
                font-size: 12px !important;
                opacity: 0.85 !important;
            }
}

/* ============================================
   PREVIOUS INVOICES
   ============================================ */
.invoices-card {
    margin-bottom: 20px;
}

.invoices-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.invoices-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #191D23;
}

    .invoices-title i {
        color: #4ce4de;
        font-size: 18px;
    }

.invoices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.invoice-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    min-width: 0;
}

    .invoice-item:hover {
        background: #eff5f0;
        border-color: #4ce4de;
        color: inherit;
        text-decoration: none;
        transform: translateY(-1px);
        box-shadow: 0 3px 10px rgba(76, 228, 222, 0.2);
    }

.invoice-icon {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: #fff;
    color: #4ce4de;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

.invoice-body {
    flex: 1;
    min-width: 0;
}

.invoice-period {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invoice-amount {
    font-size: 15px;
    font-weight: 700;
    color: #4ce4de;
    margin-top: 2px;
}

.invoice-arrow {
    color: #9ca3af;
    font-size: 11px;
    flex-shrink: 0;
    align-self: center; /* force vertical centering */
    display: flex; /* kills inline baseline issues */
    align-items: center;
    justify-content: center;
    line-height: 1;
    /
}
/* Mobile */
@media (max-width: 768px) {
    .invoices-card {
        padding: 14px !important;
    }

    /* Keep invoices side-by-side */
    .invoices-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .invoice-item {
        flex-direction: row; /* icon on top, text below */
        align-items: flex-start;
        gap: 8px;
        padding: 4px;
        text-align: left;
    }

    .invoice-icon {
        width: 26px;
        height: 34px;
        font-size: 14px;
    }


    .invoice-period {
        font-size: 11px;
    }

    .invoice-amount {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .invoices-title {
        font-size: 15px;
    }
    .label {
        color: #4ce4de;
    }
}

/* ============================================
   MOBILE HEADER CONTENT
   ============================================ */
.mobile-header .mobile-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 96px;
    max-height: 36px;
}

.mobile-header.has-content {
    gap: 10px;
}

    .mobile-header.has-content .logo {
        flex-shrink: 0;
    }

    .mobile-header.has-content .mobile-logo {
        max-width: 80px;
        max-height: 28px;
    }

.mobile-header-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

    .mobile-header-content .back-link {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        background: #f3f4f6;
        box-shadow: none;
    }

    .mobile-header-content .header-title {
        flex: 1;
        min-width: 0;
        margin: 0;
        font-size: 17px;
        font-weight: 600;
        color: #191D23;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-header-content .status-pill {
        flex-shrink: 0;
        padding: 4px 9px;
        font-size: 11px;
    }

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

@media (max-width: 340px) {
    .mobile-header-content .status-pill {
        font-size: 0;
        gap: 0;
        padding: 6px;
    }
}

/* ============================================
   FIT-TO-SCREEN METER DASHBOARD
   ============================================ */
body.page-fit .main-content {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.page-fit .mobile-header {
    position: relative;
    flex-shrink: 0;
}

body.page-fit .meter-dashboard {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 28px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
}

    body.page-fit .meter-dashboard > * {
        flex-shrink: 0;
        margin-bottom: 0 !important;
    }

    body.page-fit .meter-dashboard .meter-hero {
        padding: 16px 20px;
    }

        body.page-fit .meter-dashboard .meter-hero .hero-value {
            font-size: 30px;
        }

    body.page-fit .meter-dashboard .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }

    body.page-fit .meter-dashboard .kpi-card {
        gap: 10px;
        padding: 12px 14px;
    }

    body.page-fit .meter-dashboard .kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

@media (min-width: 769px) and (max-width: 1199px) {
    body.page-fit .meter-dashboard .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    body.page-fit .meter-dashboard .kpi-icon {
        display: none;
    }
}

/* Largest height the consumption chart may take; it still shrinks on short screens */
body.page-fit {
    --chart-max: 150px;
}

@media (min-width: 769px) {
    body.page-fit {
        --chart-max: 220px;
    }
}

@media (min-width: 1200px) {
    body.page-fit {
        --chart-max: 260px;
    }
}

body.page-fit .dash-bottom {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

body.page-fit .graph-card {
    flex: 0 1 auto;
    min-height: 170px;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding: 14px 16px;
}

    body.page-fit .graph-card .chart-box {
        flex: 0 1 auto;
        min-height: 0;
        height: var(--chart-max);
        position: relative;
    }

        body.page-fit .graph-card .chart-box canvas {
            position: absolute;
            top: 0;
            left: 0;
        }

body.page-fit .invoices-card {
    flex-shrink: 0;
    margin-bottom: 0;
}

.graph-card .chart-toolbar {
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 10px;
}

    .graph-card .chart-toolbar .content-card-title {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.graph-card .segmented {
    display: inline-flex;
    width: auto;
    padding: 3px;
    flex-shrink: 0;
}

    .graph-card .segmented button {
        flex: none;
        min-width: 0;
        padding: 5px 10px;
        font-size: 12px;
    }

.graph-card .export-btn {
    width: 34px;
    min-height: 32px;
    padding: 0 !important;
    align-items: center;
    flex-shrink: 0;
}

.graph-card .date-fields {
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 8px;
}

    .graph-card .date-fields > div {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .graph-card .date-fields label {
        margin: 0;
        white-space: nowrap;
    }

    .graph-card .date-fields .form-control {
        min-height: 36px;
        height: 36px;
        padding: 4px 8px;
    }

@media (min-width: 1200px) {
    body.page-fit .dash-bottom {
        flex-direction: row;
    }

    body.page-fit .graph-card {
        min-width: 0;
    }

    body.page-fit .invoices-card {
        width: 320px;
        min-height: 0;
        overflow-y: auto;
    }

        body.page-fit .invoices-card .invoices-grid {
            grid-template-columns: 1fr;
        }
}

@media (max-width: 768px) {
    body.page-fit .meter-dashboard {
        gap: 8px;
        padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    }

        body.page-fit .meter-dashboard .meter-hero {
            padding: 10px 14px !important;
        }

            body.page-fit .meter-dashboard .meter-hero .hero-value {
                font-size: clamp(18px, 6.4vw, 28px) !important;
            }

        body.page-fit .meter-dashboard .kpi-grid {
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 8px;
        }

        body.page-fit .meter-dashboard .kpi-card {
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
        }

        body.page-fit .meter-dashboard .kpi-icon {
            width: 32px;
            height: 32px;
            font-size: 14px;
        }

        body.page-fit .meter-dashboard .kpi-label {
            font-size: 11px;
        }

        body.page-fit .meter-dashboard .kpi-value {
            font-size: 14px;
        }

        body.page-fit .meter-dashboard .metric-groups {
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 6px;
        }

        body.page-fit .meter-dashboard .metric-group-title {
            font-size: 10px;
            margin-bottom: 2px;
        }

        body.page-fit .meter-dashboard .metric-row {
            font-size: 12px;
            padding: 3px 0;
        }

    body.page-fit .dash-bottom {
        gap: 8px;
    }

    body.page-fit .graph-card {
        min-height: 150px;
        padding: 10px 12px;
    }

    body.page-fit .invoices-card {
        padding: 10px 12px !important;
    }

        body.page-fit .invoices-card .invoices-header {
            margin-bottom: 8px;
        }

        body.page-fit .invoices-card .invoices-title {
            font-size: 14px;
        }

        body.page-fit .invoices-card .invoice-item {
            align-items: center;
            gap: 6px;
            padding: 6px;
        }

        body.page-fit .invoices-card .invoice-icon {
            width: 24px;
            height: 24px;
            font-size: 12px;
            border-radius: 6px;
        }

        body.page-fit .invoices-card .invoice-arrow {
            display: none;
        }

        body.page-fit .invoices-card .invoice-amount {
            font-size: 13px;
            overflow: visible;
        }

    body.page-fit .graph-card .chart-toolbar {
        gap: 8px;
    }

        body.page-fit .graph-card .chart-toolbar .content-card-title {
            font-size: 14px;
        }

    body.page-fit .graph-card .segmented button {
        padding: 4px 8px;
    }

    body.page-fit .graph-card .date-fields {
        gap: 8px;
    }

        body.page-fit .graph-card .date-fields label {
            display: none;
        }

        body.page-fit .graph-card .date-fields .form-control {
            width: 100%;
            min-width: 0;
            padding: 4px 6px;
        }
}

/* Short screens (landscape phones, small laptops) */
@media (max-height: 560px) {
    body.page-fit .meter-dashboard {
        gap: 6px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

        body.page-fit .meter-dashboard .meter-hero {
            padding: 8px 14px !important;
        }

            body.page-fit .meter-dashboard .meter-hero .hero-value {
                font-size: 22px !important;
            }

        body.page-fit .meter-dashboard .kpi-grid {
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 6px;
        }

        body.page-fit .meter-dashboard .kpi-card {
            padding: 6px 10px;
        }

    body.page-fit .graph-card {
        min-width: 0;
        min-height: 120px;
    }
}

@media (max-height: 560px) and (orientation: landscape) {
    body.page-fit .dash-bottom {
        flex-direction: row;
    }

    body.page-fit .invoices-card {
        width: 38%;
        min-height: 0;
        overflow-y: auto;
    }

        body.page-fit .invoices-card .invoices-grid {
            grid-template-columns: 1fr;
        }
}

@media (max-width: 359px) {
    body.page-fit .invoices-card .invoice-icon {
        display: none;
    }
}

/* Phones with limited height: tighter spacing */
@media (max-width: 768px) and (max-height: 760px) {
    body.page-fit .meter-dashboard .kpi-grid {
        gap: 6px;
    }

    body.page-fit .meter-dashboard .kpi-card {
        padding: 6px 10px;
    }

        body.page-fit .meter-dashboard .kpi-card > div:last-child {
            min-width: 0;
        }

    body.page-fit .meter-dashboard .relay-control .toggle.btn {
        min-height: 24px;
        height: 24px !important;
    }

    body.page-fit .meter-dashboard .relay-control .toggle .btn {
        font-size: 11px;
        line-height: 24px;
        padding-top: 0;
        padding-bottom: 0;
    }

    body.page-fit .meter-dashboard .meter-hero .hero-meta .hero-meta-label {
        display: none;
    }

    body.page-fit .meter-dashboard .meter-hero .hero-meta strong {
        font-size: 11px !important;
    }

        body.page-fit .meter-dashboard .meter-hero .hero-meta strong::before {
            content: "\f017";
            font-family: "Font Awesome 6 Free";
            font-weight: 400;
            margin-right: 4px;
        }

    body.page-fit .invoices-card .invoices-header {
        margin-bottom: 6px;
    }

        body.page-fit .invoices-card .invoices-header .btn {
            min-height: 0;
            padding: 2px 8px !important;
            font-size: 12px;
        }

    body.page-fit .invoices-card .invoice-item {
        padding: 5px 6px;
    }

    body.page-fit .invoices-card .invoice-period,
    body.page-fit .invoices-card .invoice-amount {
        line-height: 1.25;
        margin-top: 0;
    }

    body.page-fit .graph-card .chart-toolbar {
        margin-bottom: 6px;
    }

    body.page-fit .graph-card .date-fields {
        margin-bottom: 6px;
    }

    body.page-fit .meter-dashboard .metric-row {
        font-size: 11px;
        padding: 2px 0;
    }
}

@media (max-width: 400px) {
    body.page-fit .graph-card .chart-toolbar .content-card-title {
        display: none;
    }

    body.page-fit .graph-card .segmented {
        margin-right: auto;
    }
}

/* Wide graph card: dates share the toolbar row */
@media (orientation: landscape) and (max-height: 500px) {
    body.page-fit .graph-card {
        display: grid;
        grid-template-columns: max-content minmax(0, 1fr) auto auto;
        grid-template-rows: auto minmax(0, 1fr);
        column-gap: 12px;
        row-gap: 10px;
        align-items: center;
    }

        body.page-fit .graph-card .chart-toolbar {
            display: contents;
        }

        body.page-fit .graph-card .content-card-title {
            grid-column: 1;
            grid-row: 1;
            overflow: visible;
        }

        body.page-fit .graph-card #inputDateRow {
            grid-column: 2;
            grid-row: 1;
            min-width: 0;
        }

        body.page-fit .graph-card .segmented {
            grid-column: 3;
            grid-row: 1;
        }

        body.page-fit .graph-card .export-btn {
            grid-column: 4;
            grid-row: 1;
        }

        body.page-fit .graph-card .date-fields {
            margin-bottom: 0;
            justify-content: flex-end;
        }

            body.page-fit .graph-card .date-fields > div {
                flex: 0 1 190px;
            }

            body.page-fit .graph-card .date-fields .form-control {
                width: 100%;
                min-width: 0;
            }

        body.page-fit .graph-card .chart-box {
            grid-column: 1 / -1;
            grid-row: 2;
            align-self: stretch;
        }
}

/* Landscape phones: use the mobile header instead of the fixed sidebar */
@media (orientation: landscape) and (max-height: 500px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        position: fixed;
        z-index: 2000;
    }

        .sidebar.active {
            transform: translateX(0);
            box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
        }

    .main-content {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1990;
        display: none;
    }

        .sidebar-overlay.active {
            display: block;
        }

    .desktop-only {
        display: none !important;
    }

    body.page-fit .meter-dashboard .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }

    body.page-fit .meter-dashboard .kpi-icon {
        display: none;
    }

    body.page-fit .graph-card .chart-toolbar .content-card-title {
        display: none;
    }

    body.page-fit .graph-card .date-fields label {
        display: none;
    }

        body.page-fit .graph-card .date-fields > div {
            flex-basis: 150px;
        }

    body.page-fit .meter-dashboard .meter-hero .hero-meta .hero-meta-label {
        display: none;
    }

    body.page-fit .meter-dashboard .meter-hero .hero-meta strong::before {
        content: "\f017";
        font-family: "Font Awesome 6 Free";
        font-weight: 400;
        margin-right: 4px;
    }

    body.page-fit .invoices-card {
        width: 30%;
        padding: 10px 12px;
    }

        body.page-fit .invoices-card .invoices-header {
            margin-bottom: 6px;
        }

            body.page-fit .invoices-card .invoices-header .btn {
                min-height: 0;
                padding: 2px 8px !important;
                font-size: 12px;
            }

        body.page-fit .invoices-card .invoices-grid {
            gap: 4px;
        }

        body.page-fit .invoices-card .invoice-item {
            padding: 5px 8px;
        }

        body.page-fit .invoices-card .invoice-icon,
        body.page-fit .invoices-card .invoice-arrow {
            display: none;
        }

        body.page-fit .invoices-card .invoice-body {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 8px;
        }

        body.page-fit .invoices-card .invoice-amount {
            margin-top: 0;
            font-size: 13px;
        }
}

/* Side-by-side layouts: cards keep their natural height but never exceed the remaining space */
@media (min-width: 1200px), (orientation: landscape) and (max-height: 560px) {
    body.page-fit .dash-bottom {
        flex: 1 1 auto;
        align-items: flex-start;
    }

        body.page-fit .dash-bottom > .content-card {
            max-height: 100%;
        }

    body.page-fit .graph-card {
        flex: 1 1 auto;
        min-height: 0;
    }
}

@media (min-width: 1200px) {
    body.page-fit .invoices-card {
        padding: 14px 16px;
    }

        body.page-fit .invoices-card .invoice-item {
            padding: 8px 10px;
        }

        body.page-fit .invoices-card .invoice-icon {
            width: 32px;
            height: 32px;
            font-size: 14px;
        }
}

/* Landscape phones are short: the chart fills whatever height is left */
@media (orientation: landscape) and (max-height: 560px) {
    body.page-fit .dash-bottom {
        align-items: stretch;
    }

    body.page-fit .graph-card .chart-box {
        flex: 1 1 auto;
        height: auto;
    }
}

/* Mobile portrait: two readings per row */
@media (max-width: 768px) and (orientation: portrait) {
    body.page-fit .meter-dashboard .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 359px) and (orientation: portrait) {
    body.page-fit .meter-dashboard .kpi-card.relay-control > div:last-child {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}
