:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: #f5f7f8;
    color: #172026;
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

a {
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: progress;
    opacity: 0.72;
}

h1,
h2,
p {
    margin: 0;
}

.loading-screen,
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(15, 118, 110, 0.14), transparent 44%),
        linear-gradient(320deg, rgba(37, 99, 235, 0.13), transparent 42%),
        #f5f7f8;
}

.loading-mark {
    width: 56px;
    height: 56px;
    border: 5px solid #d8e1e5;
    border-top-color: #0f766e;
    border-radius: 50%;
    animation: spin 900ms linear infinite;
}

.login-panel {
    width: min(420px, 100%);
    padding: 32px;
    border: 1px solid #d9e2e7;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 22px 70px rgba(23, 32, 38, 0.12);
}

.eyebrow {
    color: #0f766e;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.login-panel h1,
.dashboard-header h1 {
    margin-top: 6px;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 28px;
}

.login-form label,
.filter-row label {
    display: grid;
    gap: 7px;
    color: #52616b;
    font-size: 0.85rem;
    font-weight: 700;
}

.login-form input,
.filter-row select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #c9d4da;
    border-radius: 6px;
    padding: 0 12px;
    background: #ffffff;
    color: #172026;
}

.login-form input:focus,
.filter-row select:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
}

.login-form button,
.primary-link,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    padding: 0 16px;
    font-weight: 800;
    text-decoration: none;
}

.login-form button,
.primary-link {
    background: #172026;
    color: #ffffff;
}

.primary-link {
    margin-top: 22px;
}

.ghost-button {
    border: 1px solid #c9d4da;
    background: #ffffff;
    color: #172026;
}

.form-error {
    color: #b42318;
    font-weight: 700;
}

.dashboard-shell {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    background: #eef3f1;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px clamp(16px, 3vw, 34px);
    background: #ffffff;
    border-bottom: 1px solid #d9e2e7;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    border: 1px solid #d9e2e7;
    border-radius: 8px;
    padding: 3px;
    background: #f6f9fa;
}

.header-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border-radius: 6px;
    padding: 0 12px;
    color: #52616b;
    font-weight: 800;
    text-decoration: none;
}

.header-nav a[aria-current="page"] {
    background: #172026;
    color: #ffffff;
}

.connection {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border-radius: 999px;
    padding: 0 12px;
    background: #e8eef2;
    color: #52616b;
    font-weight: 800;
}

.connection.live {
    background: #dff6e8;
    color: #137333;
}

.connection.reconnecting,
.connection.connecting {
    background: #fff2cc;
    color: #8a5a00;
}

.dashboard-grid {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
}

.map-region {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid #d9e2e7;
}

.gps-map {
    width: 100%;
    height: 100%;
    min-height: 0;
}

.data-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    align-content: stretch;
    gap: 18px;
    padding: 20px;
    background: #ffffff;
}

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

.metric-band div,
.latest-panel,
.recent-panel,
.logs-table-wrap {
    border: 1px solid #d9e2e7;
    border-radius: 8px;
    background: #ffffff;
}

.metric-band div {
    display: grid;
    gap: 6px;
    padding: 14px;
}

.metric-band span {
    color: #52616b;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-band strong {
    font-size: 1.2rem;
}

.latest-panel,
.recent-panel {
    padding: 16px;
}

.recent-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.latest-panel h2,
.recent-panel h2 {
    font-size: 1rem;
    margin-bottom: 14px;
}

.latest-panel dl {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px 12px;
    margin: 0;
}

.latest-panel dt {
    color: #52616b;
    font-weight: 800;
}

.latest-panel dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.empty-state {
    color: #52616b;
}

.point-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 8px;
    padding-right: 4px;
}

.point-row {
    width: 100%;
    display: grid;
    gap: 6px;
    border: 1px solid #e4ebef;
    border-radius: 6px;
    padding: 10px;
    background: #f9fbfc;
    color: #172026;
    text-align: left;
}

.point-row:hover {
    border-color: #0f766e;
    background: #f3faf8;
}

.point-row span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.point-row small {
    color: #52616b;
}

.auth-state {
    margin-top: 18px;
}

.logs-shell {
    display: block;
    overflow: auto;
}

.logs-content {
    display: grid;
    gap: 18px;
    padding: 20px clamp(16px, 3vw, 34px) 34px;
}

.logs-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.logs-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) repeat(2, minmax(180px, 0.7fr));
    gap: 12px;
    padding: 16px;
    border: 1px solid #d9e2e7;
    border-radius: 8px;
    background: #ffffff;
}

.logs-toolbar label {
    display: grid;
    gap: 7px;
    color: #52616b;
    font-size: 0.85rem;
    font-weight: 700;
}

.logs-toolbar input,
.logs-toolbar select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #c9d4da;
    border-radius: 6px;
    padding: 0 12px;
    background: #ffffff;
    color: #172026;
}

.logs-toolbar input:focus,
.logs-toolbar select:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
}

.logs-error {
    padding: 14px 16px;
    border: 1px solid #fecdca;
    border-radius: 8px;
    background: #fffbfa;
}

.logs-empty {
    min-height: 220px;
    display: grid;
    place-items: center;
    border: 1px solid #d9e2e7;
    border-radius: 8px;
    background: #ffffff;
}

.logs-empty .loading-mark {
    width: 44px;
    height: 44px;
    border-width: 4px;
}

.logs-table-wrap {
    overflow: auto;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
}

.logs-table th,
.logs-table td {
    padding: 13px 14px;
    border-bottom: 1px solid #e4ebef;
    text-align: left;
    vertical-align: top;
}

.logs-table th {
    color: #52616b;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    background: #f9fbfc;
}

.logs-table td {
    overflow-wrap: anywhere;
}

.logs-table tr:last-child td {
    border-bottom: 0;
}

.log-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.log-badge.danger {
    background: #fee4e2;
    color: #b42318;
}

.log-badge.success {
    background: #dff6e8;
    color: #137333;
}

.log-badge.info {
    background: #dbeafe;
    color: #1d4ed8;
}

.log-badge.warning {
    background: #fff2cc;
    color: #8a5a00;
}

.log-badge.auth {
    background: #ece8ff;
    color: #53389e;
}

.log-badge.neutral {
    background: #e8eef2;
    color: #52616b;
}

#blazor-error-ui {
    color-scheme: light only;
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    max-width: min(520px, calc(100vw - 32px));
    border-radius: 8px;
    padding: 14px 42px 14px 16px;
    background: #7f1d1d;
    color: #ffffff;
    box-shadow: 0 14px 34px rgba(23, 32, 38, 0.22);
}

#blazor-error-ui a {
    color: #ffffff;
    font-weight: 800;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 14px;
    top: 12px;
    cursor: pointer;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 980px) {
    .dashboard-shell {
        height: auto;
        max-height: none;
        overflow: visible;
    }

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

    .map-region,
    .gps-map {
        height: 58vh;
        min-height: 58vh;
    }

    .data-panel {
        grid-template-rows: none;
        overflow: visible;
    }

    .point-list {
        overflow: visible;
        padding-right: 0;
    }

    .logs-metrics,
    .logs-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .logs-toolbar label:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .dashboard-header,
    .header-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .login-panel {
        padding: 24px;
    }

    .metric-band {
        grid-template-columns: 1fr;
    }

    .latest-panel dl {
        grid-template-columns: 1fr;
    }

    .point-row span {
        flex-direction: column;
    }

    .header-nav {
        width: 100%;
    }

    .header-nav a,
    .header-actions .ghost-button {
        flex: 1;
    }

    .logs-content {
        padding: 16px;
    }

    .logs-metrics,
    .logs-toolbar {
        grid-template-columns: 1fr;
    }

    .logs-toolbar label:first-child {
        grid-column: auto;
    }

    .logs-table,
    .logs-table tbody,
    .logs-table tr,
    .logs-table td {
        display: block;
    }

    .logs-table thead {
        display: none;
    }

    .logs-table tr {
        padding: 12px 14px;
        border-bottom: 1px solid #e4ebef;
    }

    .logs-table tr:last-child {
        border-bottom: 0;
    }

    .logs-table td {
        display: grid;
        grid-template-columns: 86px minmax(0, 1fr);
        gap: 12px;
        padding: 7px 0;
        border-bottom: 0;
    }

    .logs-table td::before {
        content: attr(data-label);
        color: #52616b;
        font-size: 0.78rem;
        font-weight: 800;
        text-transform: uppercase;
    }
}
