:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f5f1;
    color: #17201b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgb(253 191 79 / 18%), transparent 30rem),
        #f3f5f1;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.masthead {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #cdd5cd;
}

.eyebrow {
    margin: 0 0 6px;
    color: #49745d;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.65rem, 4vw, 2.65rem);
    font-weight: 500;
    letter-spacing: -0.045em;
    line-height: 0.95;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: #526158;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d28b28;
    box-shadow: 0 0 0 5px rgb(210 139 40 / 14%);
}

.status-dot.online {
    background: #2f8a58;
    box-shadow: 0 0 0 5px rgb(47 138 88 / 14%);
}

.status-dot.error {
    background: #b44335;
    box-shadow: 0 0 0 5px rgb(180 67 53 / 14%);
}

.status-dot.stale,
.status-dot.loading {
    background: #d28b28;
    box-shadow: 0 0 0 5px rgb(210 139 40 / 14%);
}

.status-dot.offline {
    background: #707973;
    box-shadow: 0 0 0 5px rgb(112 121 115 / 14%);
}

.hero-reading {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(220px, 0.6fr);
    gap: 18px;
    margin: 24px 0 18px;
}

.power-card,
.summary-card,
.metric-card,
.chart-panel {
    border: 1px solid #d5dbd4;
    border-radius: 18px;
    background: rgb(255 255 255 / 82%);
    box-shadow: 0 16px 44px rgb(32 54 40 / 7%);
}

.power-card {
    padding: clamp(24px, 5vw, 48px);
    background: #183d2d;
    color: #f7fbf7;
}

.power-value {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-top: 28px;
}

.power-value strong {
    font-size: clamp(3.6rem, 12vw, 8rem);
    font-weight: 560;
    letter-spacing: -0.07em;
    line-height: 0.8;
}

.power-value span {
    color: #b8d7c6;
    font-size: 1.2rem;
}

.summary-card {
    display: grid;
    align-content: center;
    gap: 22px;
    padding: 28px;
}

.summary-card p,
.metric-card p {
    margin: 0;
    color: #66736b;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.summary-card strong,
.metric-card strong {
    display: block;
    margin-top: 5px;
    color: #17201b;
    font-size: 1.35rem;
}

.balance-dashboard-card {
    background: #183d2d;
}

.balance-dashboard-card p {
    color: #b8d7c6;
}

.balance-dashboard-card strong,
.balance-dashboard-card a {
    color: #fff;
    text-decoration: none;
}

.balance-dashboard-card a:hover {
    text-decoration: underline;
}

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

.metric-card {
    padding: 20px;
}

.metric-card.wide {
    grid-column: span 2;
}

.metric-card.pv-card {
    grid-column: span 2;
}

.metric-card.pv-card strong {
    white-space: nowrap;
}

.actions,
.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
}

.button,
button,
input,
select {
    border: 1px solid #b8c3ba;
    border-radius: 999px;
    background: #fff;
    color: #1c3528;
    font: inherit;
}

.button,
button {
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
}

.button:hover,
button:hover:not(:disabled) {
    border-color: #49745d;
    background: #f7faf7;
}

.button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgb(47 125 85 / 24%);
    outline-offset: 2px;
}

.button.disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.button.active {
    border-color: #183d2d;
    background: #183d2d;
    color: #fff;
    cursor: pointer;
}

.navigation-divider {
    align-self: stretch;
    width: 1px;
    min-height: 30px;
    margin: 0 4px;
    background: #cdd5cd;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

input {
    padding: 9px 14px;
}

select {
    padding: 9px 12px;
}

.month-select {
    width: 10rem;
    text-transform: capitalize;
}

.chart-panel {
    position: relative;
    margin-top: 22px;
    padding: clamp(16px, 3vw, 28px);
}

.chart-wrap {
    position: relative;
    height: min(56vh, 480px);
}

.chart-summary {
    margin: 14px 0 0;
    color: #526158;
    font-size: 0.9rem;
}

.status-message {
    min-height: 1.5em;
    margin: 14px 0 0;
    color: #a53629;
}

.status-message[data-tone="warning"] {
    color: #875b12;
}

.status-message[data-tone="info"] {
    color: #526158;
}

.chart-panel.is-loading .chart-wrap {
    opacity: 0.32;
}

.chart-panel.is-loading::after {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #cbd4cc;
    border-top-color: #2f7d55;
    border-radius: 50%;
    content: "";
    animation: spin 0.8s linear infinite;
}

.log-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 22px;
}

.balance-summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.balance-summary .balance-primary {
    background: #183d2d;
}

.balance-summary .balance-primary p {
    color: #b8d7c6;
}

.balance-summary .balance-primary strong {
    color: #fff;
}

.balance-note {
    margin: 20px 0 0;
    color: #526158;
    line-height: 1.55;
}

.baseline-label,
.interval-warning {
    display: block;
    margin-top: 3px;
    color: #66736b;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.interval-warning {
    color: #875b12;
}

.balance-table {
    min-width: 1080px;
    font-size: 0.82rem;
}

.form-panel {
    margin-top: 22px;
    padding: clamp(20px, 4vw, 32px);
    border: 1px solid #d5dbd4;
    border-radius: 18px;
    background: rgb(255 255 255 / 82%);
    box-shadow: 0 16px 44px rgb(32 54 40 / 7%);
}

.form-panel h2 {
    margin: 0 0 18px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.5rem;
    font-weight: 500;
}

.form-panel > p {
    color: #875b12;
}

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

.form-field {
    display: grid;
    gap: 7px;
    color: #364a3e;
    font-size: 0.88rem;
    font-weight: 650;
}

.form-field:first-of-type,
.form-actions {
    grid-column: 1 / -1;
}

.form-field input {
    width: 100%;
}

.form-field input[readonly] {
    background: #edf1ed;
    color: #526158;
}

.month-control {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.month-control input {
    width: auto;
    min-width: 10rem;
}

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

.inline-form {
    margin: 0;
}

.compact-table {
    margin-top: 22px;
}

.table-action {
    display: inline-block;
    padding: 6px 12px;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.table-actions form {
    margin: 0;
}

.danger-button {
    border-color: #c99087;
    color: #8f2f24;
}

.danger-button:hover:not(:disabled) {
    border-color: #b44335;
    background: #fff1ef;
}

.logs-shell {
    width: min(1120px, calc(100% - 32px));
}

.logs-shell .table-panel {
    width: calc(100vw - 24px);
    margin-left: calc(50% - 50vw + 12px);
}

.log-summary article,
.table-panel {
    border: 1px solid #d5dbd4;
    border-radius: 14px;
    background: rgb(255 255 255 / 82%);
    box-shadow: 0 12px 32px rgb(32 54 40 / 6%);
}

.log-summary article {
    padding: 18px;
}

.log-summary p {
    margin: 0 0 5px;
    color: #66736b;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table-panel {
    margin-top: 16px;
    overflow: hidden;
}

.table-scroll {
    max-height: 68vh;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.logs-shell table {
    table-layout: fixed;
    font-size: clamp(0.58rem, 0.72vw, 0.76rem);
}

.logs-shell th,
.logs-shell td {
    overflow: hidden;
    padding: 7px 4px;
    text-overflow: ellipsis;
}

.logs-shell th:first-child,
.logs-shell td:first-child {
    width: 142px;
}

.logs-shell th:nth-child(3),
.logs-shell td:nth-child(3) {
    width: 100px;
}

.logs-shell th:nth-child(n + 13):nth-child(-n + 18),
.logs-shell td:nth-child(n + 13):nth-child(-n + 18) {
    width: 70px;
}

th,
td {
    padding: 9px 12px;
    border-bottom: 1px solid #e0e5e0;
    text-align: right;
}

th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    text-align: left;
}

th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #e8eee9;
    color: #364a3e;
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

th:first-child {
    z-index: 3;
}

td:first-child {
    z-index: 1;
    background: #fff;
}

tbody tr:hover td:not([style]) {
    background: #f4f7f4;
}

.empty-cell {
    padding: 32px;
    color: #66736b;
    text-align: center;
}

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

@media (max-width: 800px) {
    .masthead,
    .hero-reading {
        align-items: start;
        grid-template-columns: 1fr;
    }

    .masthead {
        display: grid;
    }

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

    .log-summary {
        grid-template-columns: 1fr;
    }

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

    .navigation-divider {
        flex-basis: 100%;
        width: 0;
        min-height: 0;
        margin: 0;
    }

    .logs-shell .table-scroll {
        overflow-x: auto;
    }

    .logs-shell table {
        min-width: 1280px;
    }
}

@media (max-width: 480px) {
    .shell {
        width: min(100% - 20px, 1120px);
        padding-top: 20px;
    }

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

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

    .month-control input {
        order: -1;
        width: 100%;
    }

    .metric-card.wide {
        grid-column: auto;
    }

    .metric-card.pv-card {
        grid-column: auto;
    }

    .metric-card.pv-card strong {
        font-size: 1.15rem;
    }

    .logs-shell .table-panel {
        width: calc(100vw - 12px);
        margin-left: calc(50% - 50vw + 6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chart-panel.is-loading::after {
        animation: none;
    }
}
