:root {
    color-scheme: light dark;
    --paper: #f3f6fa;
    --surface: #ffffff;
    --ink: #14263f;
    --ink-soft: #55647a;
    --rule: #d3dbe6;
    --airmail-red: #c8322b;
    --airmail-blue: #1f4f9c;
    --bad: #b3261e;
    --bad-wash: #fcecea;
    --warn: #8a5300;
    --warn-wash: #fdf3df;
    --wait: #1f4f9c;
    --ok: #256b52;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #101a2a;
        --surface: #182537;
        --ink: #e8eef6;
        --ink-soft: #a3b1c4;
        --rule: #31425a;
        --airmail-red: #d9534c;
        --airmail-blue: #5c8fdd;
        --bad: #ff9c94;
        --bad-wash: #3b2027;
        --warn: #edbd6c;
        --warn-wash: #372d1d;
        --wait: #93b8ee;
        --ok: #79cfae;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.45 Inter, system-ui, sans-serif;
}

/* The envelope edge of an airmail letter. */
.airmail {
    height: 10px;
    background: repeating-linear-gradient(
        -45deg,
        var(--airmail-red) 0 18px,
        var(--paper) 18px 30px,
        var(--airmail-blue) 30px 48px,
        var(--paper) 48px 60px
    );
}

.top, .breakdown, .filter, body > main:not(.login), footer {
    width: min(100% - 2rem, 1320px);
    margin-inline: auto;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    min-height: 3.5rem;
    margin-top: 2.25rem;
}

h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    line-height: 1.1;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

.breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    padding: 0;
    margin-top: 0.75rem;
    margin-bottom: 0;
    list-style: none;
}

.breakdown li { color: var(--tone, var(--ink-soft)); }

.filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1.25rem;
    margin-top: 1.75rem;
    margin-bottom: 1.5rem;
}

label { display: block; font-size: 0.875rem; color: var(--ink-soft); }

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    font-size: 1rem;
    color: var(--ink);
}

.check input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--airmail-blue); }

input[type="date"], input[type="password"] {
    display: block;
    min-height: 2.5rem;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--ink-soft);
    border-radius: 3px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

button {
    min-height: 2.5rem;
    padding: 0.375rem 1rem;
    border: 1px solid var(--airmail-blue);
    border-radius: 3px;
    background: var(--airmail-blue);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button.quiet {
    border-color: transparent;
    background: none;
    color: var(--ink-soft);
    font-weight: 400;
    text-decoration: underline;
    white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--airmail-blue); outline-offset: 2px; }

.tone-bad { --tone: var(--bad); --wash: var(--bad-wash); }
.tone-warn { --tone: var(--warn); --wash: var(--warn-wash); }
.tone-wait { --tone: var(--wait); }
.tone-ok { --tone: var(--ok); }

.log { width: 100%; border-collapse: collapse; }
.log th, .log td { padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }

.log thead th {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--rule);
}

.day th {
    padding-top: 1.75rem;
    padding-left: 0;
    font-size: 1.125rem;
    border-bottom: 2px solid var(--ink);
}

.log thead + tbody .day th { padding-top: 1rem; }

.row td { border-bottom: 1px solid var(--rule); overflow-wrap: break-word; }
.subject { overflow-wrap: anywhere; }
.time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.status { min-width: 15rem; width: 26%; }
.label { display: block; color: var(--tone); font-weight: 700; }
.reason { display: block; margin-top: 0.125rem; font-size: 0.875rem; overflow-wrap: anywhere; }

/* Delivered mail recedes, so that problems are what the eye finds first. */
.row.tone-ok td:not(.status) { color: var(--ink-soft); }
.row.tone-ok .label { font-weight: 400; }

.row.tone-bad, .row.tone-warn { background: var(--wash); }
.row.tone-bad .time, .row.tone-warn .time { box-shadow: inset 4px 0 0 var(--tone); }

.message {
    width: fit-content;
    margin-block: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-left: 4px solid var(--bad);
    background: var(--bad-wash);
    color: var(--ink);
}

.empty { color: var(--ink-soft); }
footer { margin-top: 2rem; margin-bottom: 2.5rem; font-size: 0.875rem; color: var(--ink-soft); }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.login { width: min(100% - 2rem, 22rem); margin: 18vh auto 2rem; }
.login h1 { margin-bottom: 1.5rem; font-size: 2rem; }
.login input { width: 100%; margin-top: 0.25rem; }
.login button { margin-top: 1rem; }

@media (max-width: 1100px) {
    .log thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .log, .log tbody, .log tr, .log td, .log th { display: block; }
    .row { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); padding: 0.625rem 0.5rem; border-bottom: 1px solid var(--rule); }
    .log td, .row td { padding: 0; border: 0; }
    .row .time { box-shadow: none !important; grid-row: span 4; }
    .row .status { grid-column: 2; grid-row: 1; width: auto; min-width: 0; }
    .row .to { grid-column: 2; font-weight: 700; }
    .row .subject { grid-column: 2; }
    .row .sender { grid-column: 2; font-size: 0.875rem; color: var(--ink-soft); }
    .row.tone-bad, .row.tone-warn { border-left: 4px solid var(--tone); }
    .signout { flex-shrink: 0; }
}
