* {
    box-sizing: border-box;
}


body {
    margin: 0;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    color: #111827;
}


.app-body,
.login-body {
    background: #f3f5f7;
}


/* LOGIN */

.login-page {
    min-height: 100vh;

    display: flex;

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


.login-card {
    width: 380px;

    background: white;

    padding: 35px;

    border-radius: 10px;

    box-shadow:
        0 2px 12px
        rgba(0, 0, 0, .10);
}


.login-card h1 {
    margin-top: 0;
    margin-bottom: 5px;
}


.subtitle {
    color: #6b7280;

    margin-bottom: 25px;
}


.login-card label {
    display: block;

    margin-top: 15px;
    margin-bottom: 6px;

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


.login-card input {
    width: 100%;

    padding: 11px;

    border: 1px solid #ccc;

    border-radius: 5px;

    font-size: 15px;
}


.login-card button {
    width: 100%;

    margin-top: 22px;

    padding: 12px;

    border: 0;

    border-radius: 5px;

    background: #222;

    color: white;

    font-size: 15px;

    cursor: pointer;
}


.login-card button:hover {
    background: #000;
}


/* APP SHELL */

.topbar {
    height: 65px;

    background: white;

    border-bottom: 1px solid #ddd;

    display: flex;

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

    padding: 0 30px;
}


.brand,
.page-title {
    font-size: 22px;
    font-weight: bold;
}


.user-area {
    display: flex;

    align-items: center;

    gap: 15px;
}


.secondary-button {
    border: 1px solid #ccc;

    background: white;

    padding: 8px 13px;

    border-radius: 5px;

    cursor: pointer;
}


.secondary-button:hover {
    background: #f3f4f6;
}


.container {
    max-width: 1400px;

    margin: auto;

    padding: 30px;
}


.summary-grid {
    display: grid;

    gap: 18px;

    margin-bottom: 28px;
}


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


.summary-grid.four {
    grid-template-columns:
        repeat(4, 1fr);
}


.content-grid {
    display: grid;

    gap: 18px;
}


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


.content-grid.two {
    grid-template-columns:
        repeat(2, 1fr);
}


/* CARDS */

.card {
    background: white;

    border-radius: 9px;

    padding: 20px;

    box-shadow:
        0 1px 4px
        rgba(0, 0, 0, .08);
}


.clickable {
    cursor: pointer;
}


.clickable:hover {
    box-shadow:
        0 3px 10px
        rgba(0, 0, 0, .14);
}


.card-title {
    font-size: 18px;

    font-weight: bold;
}


.card-footer {
    margin-top: 18px;
}


.label {
    color: #6b7280;

    font-size: 12px;
}


.big {
    margin-top: 7px;

    font-size: 29px;

    font-weight: bold;
}


.medium-value {
    margin-top: 8px;

    font-size: 19px;

    font-weight: bold;
}


.power-value {
    margin-top: 15px;

    font-size: 27px;

    font-weight: bold;
}


.unit {
    font-size: 14px;

    color: #4b5563;
}


.muted {
    color: #6b7280;

    font-size: 12px;
}


.device-meta {
    margin-top: 12px;
}


.split-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 15px;
}


.device-row {
    margin-top: 10px;

    display: flex;

    justify-content: space-between;

    border-top: 1px solid #eee;

    padding-top: 10px;

    font-size: 13px;
}


.section-card {
    margin-bottom: 28px;
}


.detail-row {
    display: flex;

    justify-content: space-between;

    gap: 20px;

    padding: 10px 0;

    border-bottom: 1px solid #eee;
}


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


/* MEASUREMENTS */

.measurement-grid {
    display: grid;

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

    gap: 14px;
}


.measurement-item {
    border: 1px solid #e5e7eb;

    border-radius: 7px;

    padding: 15px;

    background: #fafafa;
}


.measurement-value {
    margin-top: 6px;
    margin-bottom: 5px;

    font-size: 20px;

    font-weight: bold;
}


/* STATUS */

.status {
    font-size: 12px;

    font-weight: bold;
}


.status-online {
    color: #15803d;
}


.status-delayed {
    color: #b45309;
}


.status-error {
    color: #b91c1c;
}


.status-offline {
    color: #6b7280;
}


/* ERRORS */

#error,
#pageError {
    margin-top: 15px;
}


.error-box {
    padding: 15px;

    border-radius: 6px;

    background: #fee2e2;

    color: #991b1b;
}


/* MOBILE */

@media (
    max-width: 1000px
) {

    .measurement-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }
}


@media (
    max-width: 900px
) {

    .summary-grid.three,
    .summary-grid.four,
    .content-grid.three,
    .content-grid.two {
        grid-template-columns: 1fr;
    }


    .topbar {
        padding: 0 15px;
    }


    .container {
        padding: 20px;
    }


    .measurement-grid {
        grid-template-columns: 1fr;
    }
}
/* HISTORY CHART */

.chart-header {
    display: flex;

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

    gap: 20px;

    margin-bottom: 20px;
}


.chart-header h2 {
    margin: 0;
}


.chart-controls {
    display: flex;

    align-items: center;

    gap: 12px;
}


.chart-controls select {
    padding: 8px 10px;

    border: 1px solid #d1d5db;

    border-radius: 5px;

    background: white;
}


.range-buttons {
    display: flex;

    gap: 5px;
}


.range-button {
    padding: 8px 11px;

    border: 1px solid #d1d5db;

    border-radius: 5px;

    background: white;

    cursor: pointer;
}


.range-button.active {
    background: #222;

    color: white;

    border-color: #222;
}


.chart-wrapper {
    height: 360px;

    position: relative;
}


.chart-empty-message {
    height: 100%;

    display: none;

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

    color: #6b7280;

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

    text-align: center;
}


@media (
    max-width: 700px
) {

    .chart-header {
        align-items: flex-start;
        flex-direction: column;
    }


    .chart-controls {
        align-items: flex-start;
        flex-direction: column;
    }


    .chart-wrapper {
        height: 300px;
    }
}

/* DATA FRESHNESS */

.freshness-label {
    margin-top: 6px;

    color: #6b7280;

    font-size: 11px;

    font-weight: normal;
}

/* DASHBOARD ALERTS */

.dashboard-heading {
    display: flex;

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

    gap: 20px;

    margin-bottom: 22px;
}


.dashboard-heading h2 {
    margin-top: 0;
    margin-bottom: 4px;
}


.dashboard-section {
    margin-top: 32px;
}


.fleet-health {
    font-size: 12px;

    font-weight: bold;
}


.fleet-health.healthy,
.site-health.healthy {
    color: #15803d;
}


.fleet-health.warning,
.site-health.warning {
    color: #b45309;
}


.site-health {
    font-size: 11px;

    font-weight: bold;

    white-space: nowrap;
}


.alert-list {
    display: flex;

    flex-direction: column;

    gap: 10px;

    margin-top: 12px;
}


.alert-item {
    background: white;

    border-radius: 8px;

    padding: 16px 18px;

    display: flex;

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

    gap: 20px;

    border-left: 5px solid #d1d5db;

    box-shadow:
        0 1px 4px
        rgba(0, 0, 0, .08);

    cursor: pointer;
}


.alert-item:hover {
    box-shadow:
        0 3px 10px
        rgba(0, 0, 0, .13);
}


.alert-warning {
    border-left-color: #d97706;
}


.alert-critical {
    border-left-color: #dc2626;
}


.alert-offline {
    border-left-color: #6b7280;
}


.alert-main {
    min-width: 0;
}


.alert-type {
    font-size: 13px;

    font-weight: bold;

    margin-bottom: 5px;
}


.alert-location {
    font-size: 14px;

    font-weight: bold;

    margin-bottom: 4px;
}


.alert-location span {
    color: #9ca3af;

    padding: 0 4px;
}


.alert-time {
    min-width: 110px;

    text-align: right;

    color: #6b7280;

    font-size: 11px;
}


.alert-time strong {
    display: block;

    margin-top: 3px;

    color: #111827;

    font-size: 12px;
}


.empty-alerts {
    background: white;

    border-radius: 8px;

    padding: 22px;

    display: flex;

    align-items: center;

    gap: 14px;

    box-shadow:
        0 1px 4px
        rgba(0, 0, 0, .08);
}


.empty-alert-icon {
    width: 34px;
    height: 34px;

    border-radius: 50%;

    display: flex;

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

    background: #dcfce7;

    color: #15803d;

    font-size: 18px;

    font-weight: bold;
}


@media (
    max-width: 700px
) {

    .dashboard-heading {
        align-items: flex-start;

        flex-direction: column;
    }


    .alert-item {
        align-items: flex-start;

        flex-direction: column;
    }


    .alert-time {
        text-align: left;
    }
}

/* ALERT HISTORY */

.history-heading {
    display: flex;

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

    gap: 20px;

    margin-bottom: 22px;
}


.history-heading h2 {
    margin-top: 0;
    margin-bottom: 4px;
}


.history-count {
    font-size: 13px;

    font-weight: bold;

    color: #6b7280;
}


.alert-filter-card {
    margin-bottom: 20px;
}


.alert-filters {
    display: flex;

    align-items: flex-end;

    gap: 18px;
}


.filter-group {
    display: flex;

    flex-direction: column;

    gap: 6px;

    min-width: 180px;
}


.filter-group label {
    color: #6b7280;

    font-size: 11px;

    font-weight: bold;
}


.filter-group select {
    padding: 9px 10px;

    border: 1px solid #d1d5db;

    border-radius: 5px;

    background: white;
}


.history-list {
    display: flex;

    flex-direction: column;

    gap: 12px;
}


.history-alert {
    border-left: 5px solid #d1d5db;

    cursor: pointer;
}


.history-alert:hover {
    box-shadow:
        0 3px 10px
        rgba(0, 0, 0, .13);
}


.history-alert-top {
    display: flex;

    justify-content: space-between;

    align-items: flex-start;

    gap: 20px;
}


.history-alert-title {
    font-size: 14px;

    font-weight: bold;

    margin-bottom: 5px;
}


.history-location {
    font-size: 13px;

    font-weight: bold;
}


.history-location span {
    padding: 0 5px;

    color: #9ca3af;
}


.history-status {
    padding: 5px 8px;

    border-radius: 5px;

    font-size: 10px;

    font-weight: bold;
}


.history-status-open {
    background: #ffedd5;

    color: #c2410c;
}


.history-status-resolved {
    background: #dcfce7;

    color: #15803d;
}


.history-message {
    margin-top: 12px;

    color: #4b5563;

    font-size: 12px;
}


.history-times {
    margin-top: 16px;

    padding-top: 13px;

    border-top: 1px solid #eee;

    display: grid;

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

    gap: 20px;
}


.history-times span {
    display: block;

    color: #6b7280;

    font-size: 10px;

    margin-bottom: 4px;
}


.history-times strong {
    font-size: 12px;
}


.history-empty {
    color: #6b7280;

    text-align: center;
}


@media (
    max-width: 700px
) {

    .history-heading {
        align-items: flex-start;

        flex-direction: column;
    }


    .alert-filters {
        align-items: stretch;

        flex-direction: column;
    }


    .filter-group {
        width: 100%;
    }


    .history-alert-top {
        flex-direction: column;
    }


    .history-times {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   GLOBAL TOP NAVIGATION
   ========================================= */

.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    white-space: nowrap;
}

.topbar-navigation {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.topbar-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 30px;

    padding:
        0 12px;

    border-radius: 6px;

    color: #374151;

    text-decoration: none;

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

.topbar-nav-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.topbar-nav-link.active {
    background: #111827;
    color: white;
}

.user-area {
    margin-left: auto;
}

/* =========================================
   CONTEXTUAL TOP NAVIGATION
   ========================================= */

.topbar-context {
    display: flex;
    align-items: center;
    gap: 7px;

    min-width: 0;

    font-size: 13px;
}

.topbar-context-link {
    color: #374151;

    text-decoration: none;

    font-weight: 600;

    white-space: nowrap;
}

.topbar-context-link:hover {
    color: #111827;

    text-decoration: underline;
}

.topbar-context-current {
    color: #111827;

    font-weight: 700;

    white-space: nowrap;
}

.topbar-context-separator {
    color: #9ca3af;

    font-size: 12px;
}

@media (max-width: 900px) {

    .topbar {
        gap: 12px;
    }

    .topbar-context {
        overflow: hidden;
    }

    .topbar-context-link,
    .topbar-context-current {
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }

}

/* =========================================
   ADMINISTRATION
   ========================================= */

.admin-card {
    max-width: 850px;
}


.admin-card h2 {
    margin-top: 0;
}


.form-grid {
    display: grid;

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

    gap: 20px 24px;

    margin-top: 25px;
}


.form-field {
    display: flex;

    flex-direction: column;

    gap: 7px;
}


.form-field label {
    color: #374151;

    font-size: 13px;

    font-weight: 600;
}


.form-field input,
.form-field select {
    width: 100%;

    box-sizing: border-box;

    padding: 10px 11px;

    border: 1px solid #d1d5db;

    border-radius: 6px;

    background: white;

    color: #111827;

    font-size: 14px;
}


.form-field input:focus,
.form-field select:focus {
    outline: 2px solid #d1d5db;

    outline-offset: 1px;
}


.form-field input[readonly] {
    background: #f3f4f6;

    color: #4b5563;
}


.form-actions {
    margin-top: 24px;
}


.primary-button {
    border: 1px solid #111827;

    border-radius: 6px;

    padding: 10px 16px;

    background: #111827;

    color: white;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;
}


.primary-button:hover {
    background: #000;
}


.primary-button:disabled {
    opacity: 0.5;

    cursor: default;
}


.warning-box {
    margin: 18px 0 22px;

    padding: 12px 14px;

    border: 1px solid #f59e0b;

    border-radius: 6px;

    background: #fffbeb;

    color: #92400e;
}


.credential-value {
    margin: 5px 0 12px;

    padding: 12px;

    border: 1px solid #d1d5db;

    border-radius: 6px;

    background: #f9fafb;

    font-family: monospace;

    font-size: 14px;

    overflow-wrap: anywhere;
}


.result-label {
    margin-top: 22px;
}


.config-output {
    padding: 16px;

    border: 1px solid #d1d5db;

    border-radius: 6px;

    background: #f9fafb;

    overflow-x: auto;
}


.error-box {
    margin-bottom: 20px;

    padding: 12px 14px;

    border: 1px solid #fecaca;

    border-radius: 6px;

    background: #fef2f2;

    color: #b91c1c;
}


@media (max-width: 700px) {

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

.admin-section-header {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 20px;
}


.admin-section-header h2 {
    margin: 0;
}


.logger-list {
    margin-top: 22px;
}


.logger-management-row {
    display: grid;

    grid-template-columns:
        1.4fr 1.2fr 1fr auto; 

    gap: 24px;

    align-items: center;

    padding: 16px 0;

    border-top: 1px solid #e5e7eb;
}

.logger-management-actions {
    display: flex;

    justify-content: flex-end;

    gap: 8px;
}


.decommission-button {
    color: #b91c1c;
}


.decommission-button:disabled {
    color: #9ca3af;

    cursor: not-allowed;

    opacity: 0.6;
}

.logger-management-row:first-child {
    border-top: 0;
}


.logger-management-name {
    font-weight: 700;
}


.logger-management-status {
    font-size: 13px;

    font-weight: 700;
}


@media (max-width: 700px) {

    .logger-management-row {
        grid-template-columns: 1fr;

        gap: 8px;
    }
}

.status-decommissioned {
    color: #991b1b;
}