:root {
    --navy: #0B1F3A;
    --amber: #FFB300;
    --amber-light: #FFE7A0;
    --rule: #64748B;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    line-height: 1.25;
    color: #000;
    background: #fff;
}

/* Layout */

.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 6px;
    display: grid;
    gap: 6px;
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "header" "wind" "levels" "waves" "controls";
}

@media (display-mode: standalone) {
    .page {
        padding-top: 24px;
    }
}

@media (orientation: landscape) and (min-width: 600px) {
    .page {
        grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
        grid-template-areas: "header header" "wind waves" "controls levels";
    }
}

.report {
    display: contents;
}

.header {
    grid-area: header;
}

.wind {
    grid-area: wind;
}

.waves {
    grid-area: waves;
}

.controls {
    grid-area: controls;
}

.levels {
    grid-area: levels;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 6px;
    align-items: start;
}

/* Header */

.header-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    column-gap: 8px;
}

h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
}

.header time {
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.old-data {
    margin: 4px 0 0;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--amber);
    font-weight: 800;
}

/* Readings tables */

.readings {
    border: 2px solid var(--navy);
    border-radius: 4px;
    overflow: hidden;
}

.readings h2 {
    margin: 0;
    padding: 0 8px;
    background: var(--navy);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    line-height: 22px;
}

.readings table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.readings th,
.readings td {
    padding: 2px 6px;
    border-bottom: 1px solid var(--rule);
    font-size: 14px;
    font-weight: 700;
    text-align: right;
}

.readings tbody tr:last-child > *,
.readings td[rowspan] {
    border-bottom: 0;
}

.readings tbody th {
    text-align: left;
}

.label-column {
    width: 100px;
}

.unit {
    font-weight: 500;
}

.note {
    display: block;
    font-size: 12px;
    font-weight: 500;
}

.readings .value {
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

@media (min-width: 900px) {
    .readings .value {
        font-size: 32px;
    }
}

.warning {
    background: var(--amber-light);
}

.status {
    display: block;
    font-size: 13px;
    font-weight: 800;
}

td > .status {
    font-size: 15px;
}

.icon {
    width: 15px;
    height: 15px;
    margin-right: 2px;
    vertical-align: text-bottom;
    fill: currentColor;
}

.empty {
    margin: 0;
    padding: 8px;
    font-weight: 700;
}

.unavailable {
    grid-area: wind;
    margin: 0;
    padding: 8px;
    border: 2px solid var(--navy);
    border-radius: 4px;
    font-weight: 800;
}

/* Controls */

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.refresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 6px 16px;
    border: 0;
    border-radius: 4px;
    background: var(--navy);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
}

.refresh svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.refresh.htmx-request svg {
    animation: spin 1s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .refresh.htmx-request svg {
        animation: none;
    }
}

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

.auto-refresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    font-weight: 700;
    cursor: pointer;
}

.auto-refresh input {
    width: 24px;
    height: 24px;
    margin: 0;
    accent-color: var(--navy);
}

.refresh:focus-visible,
.auto-refresh input:focus-visible {
    outline: 3px solid var(--amber);
    outline-offset: 2px;
}
