/*
 * ACE Coolers: one plain stylesheet, no build step.
 * Look: flat, sharp corners, cool white and light gray. Phone first.
 */

:root {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --line: #dde3e9;
    --line-strong: #c3ccd5;
    --text: #1b2631;
    --muted: #5d6b78;
    --accent: #1f5f8b;
    --accent-dark: #174a6d;
    --ok: #1d7a46;
    --ok-bg: #e3f3e9;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --gap: 12px;
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
    color: var(--accent);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 14px;
}

/* ---- Top bar and admin menu ---- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    min-height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.menu {
    position: relative;
}

.menu summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    font-weight: 600;
    user-select: none;
}

.menu summary::-webkit-details-marker {
    display: none;
}

.menu[open] summary {
    background: var(--bg);
}

.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    display: flex;
    flex-direction: column;
}

.menu-panel a,
.menu-panel button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-top: 1px solid var(--line);
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu-panel a:hover,
.menu-panel button:hover {
    background: var(--bg);
}

.menu-user {
    margin: 0;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--muted);
}

/* ---- Page ---- */

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.page-title {
    margin: 4px 0 12px;
    font-size: 22px;
}

/* ---- Home tiles ---- */

.tiles {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap);
}

@media (min-width: 640px) {
    .tiles {
        grid-template-columns: repeat(3, 1fr);
    }
}

.tile {
    display: flex;
    flex-direction: column;
    min-height: 128px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
}

.tile-label {
    font-weight: 600;
}

.tile-count {
    margin-top: auto;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
}

.tile-note,
.tile-soon {
    font-size: 13px;
    color: var(--muted);
}

.tile-soon {
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
}

.tile-needs-attention {
    border-top-color: var(--muted);
}

.tile-needs-attention.is-alert {
    border-top-color: var(--bad);
    background: var(--bad-bg);
}

/* ---- Forms and buttons ---- */

.guest .page {
    padding-top: 12vh;
}

.login {
    max-width: 380px;
    margin: 0 auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
}

.login-title {
    margin: 0;
    font-size: 24px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-weight: 600;
    font-size: 14px;
}

.field input {
    font: inherit;
    font-size: 16px; /* 16px stops phones zooming in on focus */
    font-weight: 400;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
}

.field input:focus,
.button:focus-visible,
.menu summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.check input {
    width: 18px;
    height: 18px;
}

.error {
    margin: -8px 0 0;
    color: var(--bad);
    font-size: 14px;
}

.button {
    font: inherit;
    font-weight: 600;
    padding: 11px 16px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.button.primary:hover {
    background: var(--accent-dark);
}

.button[disabled] {
    opacity: 0.6;
}

.actions {
    margin: 16px 0;
}

.notice {
    margin: 8px 0 0;
    font-size: 14px;
}

/* ---- Health ---- */

.checks {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
}

.checks th,
.checks td {
    padding: 12px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.checks th {
    width: 34%;
    font-weight: 600;
}

.status {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 8px;
    font-size: 13px;
    font-weight: 700;
}

.status.ok {
    color: var(--ok);
    background: var(--ok-bg);
}

.status.bad {
    color: var(--bad);
    background: var(--bad-bg);
}

.check-detail {
    overflow-wrap: anywhere;
}

/* ---- Change log ---- */

.log-entry {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
}

.log-entry time {
    display: block;
    font-size: 13px;
}

.log-values {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 2px 12px;
    margin: 8px 0 0;
    font-size: 14px;
}

.log-values dt {
    color: var(--muted);
}

.log-values dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.pagination {
    list-style: none;
    display: flex;
    gap: 8px;
    padding: 0;
}

.page-link {
    font: inherit;
    padding: 8px 14px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    cursor: pointer;
}

.page-item.disabled .page-link {
    color: var(--muted);
    cursor: default;
}
