:root {
    --bg: #f6f3ea;
    --panel: rgba(255, 255, 255, 0.88);
    --ink: #1d2939;
    --muted: #526071;
    --line: rgba(29, 41, 57, 0.12);
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #d97706;
    --danger: #b42318;
    --shadow: 0 18px 50px rgba(38, 57, 77, 0.12);
}

html, body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(217, 119, 6, 0.18), transparent 24%),
        radial-gradient(circle at right 20%, rgba(15, 118, 110, 0.14), transparent 18%),
        linear-gradient(180deg, #fbf7ef 0%, #f4efe5 100%);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    min-height: 100vh;
    display: block;
}

.shell-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
}

.content-area,
.warning-list,
.auth-form,
.meter-grid,
.grid-two,
.status-grid,
.button-row {
    display: grid;
    gap: 1rem;
}

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

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

.meter-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.status-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.button-row {
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
}

.app-header {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-subtitle,
.eyebrow,
.status-label,
.history-title {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: var(--muted);
}

.panel,
.meter-card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 1.4rem;
    box-shadow: var(--shadow);
}

.hero,
.panel,
.meter-card {
    padding: 1.4rem;
}

.status-value,
.meter-previous {
    font-weight: 700;
}

.lead,
.meter-number,
.history-empty,
.status-text {
    color: var(--muted);
}

.logout-button,
.primary-link,
.secondary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.85rem 1.2rem;
    font-weight: 600;
    border: none;
}

.logout-button,
.primary-link {
    background: var(--primary);
    color: #fff;
}

.secondary-link {
    background: rgba(15, 118, 110, 0.08);
    color: var(--primary-strong);
}

.field {
    display: grid;
    gap: 0.45rem;
}

.check-field {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1rem;
    color: var(--ink);
}

.check-field input {
    margin-top: 0.2rem;
}

.field-compact {
    max-width: 220px;
}

.field input,
.field .form-control,
.admin-textarea {
    border-radius: 0.95rem;
    border: 1px solid var(--line);
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.85);
}

.admin-textarea {
    resize: vertical;
    min-height: 96px;
}

.meter-head,
.history-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.history-block {
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 0.4rem;
}

.field-error,
.warning-item {
    color: var(--danger);
    font-size: 0.9rem;
}

.install-panel {
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(217, 119, 6, 0.12));
}

.login-wrap {
    display: flex;
    justify-content: center;
}

.login-page {
    display: grid;
    gap: 1.5rem;
}

.login-panel {
    width: min(100%, 520px);
}

.page-footer {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

.page-footer .install-panel {
    width: min(100%, 520px);
}

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

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

.meters-table th,
.meters-table td {
    padding: 0.9rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

.meters-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

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

.meter-input {
    min-width: 180px;
}

.submit-panel {
    margin-top: 1rem;
}

.admin-panel .button-row {
    margin-top: 1rem;
}

.admin-button {
    min-width: 210px;
    min-height: 48px;
    border-radius: 0.95rem;
    font-weight: 600;
}

.admin-filter-grid {
    margin-bottom: 1rem;
}

.admin-search-field {
    grid-column: span 2;
}

.admin-summary-grid {
    margin-bottom: 1rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.86rem;
}

.status-badge-ok {
    background: rgba(15, 118, 110, 0.12);
    color: var(--primary-strong);
}

.status-badge-miss {
    background: rgba(180, 35, 24, 0.12);
    color: var(--danger);
}

#blazor-error-ui {
    background: var(--danger);
    bottom: 0;
    color: #fff;
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

@media (max-width: 840px) {
    .grid-two,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .button-row {
        grid-auto-flow: row;
    }

    .admin-button,
    .logout-button,
    .primary-link,
    .secondary-link {
        width: 100%;
    }

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

    .admin-search-field {
        grid-column: auto;
    }
}

#blazor-error-ui .reload {
    color: #fff;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

@media (max-width: 900px) {
    .grid-two {
        grid-template-columns: 1fr;
    }

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

    .app-header {
        display: grid;
    }
}

@media (max-width: 680px) {
    .shell-content {
        padding: 0 0.75rem 2rem;
    }

    .app-header {
        padding: 1rem 0.75rem 0.75rem;
    }

    .panel,
    .meter-card {
        padding: 1rem;
        border-radius: 1rem;
    }

    .page-footer .install-panel {
        width: 100%;
    }

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

    .meters-table thead {
        display: none;
    }

    .meters-table tr {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--line);
    }

    .meters-table tbody tr:last-child {
        border-bottom: none;
    }

    .meters-table td {
        border-bottom: none;
        padding: 0.35rem 0;
    }

    .meters-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.2rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-size: 0.72rem;
        color: var(--muted);
    }

    .meter-input {
        min-width: 0;
        width: 100%;
    }
}
