/* uptime radar – status page */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1b1f24;
    --muted: #5f6b7a;
    --border: #dde1e6;
    --accent: #2563eb;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --amber: #a16207;
    --amber-bg: #fef3c7;
    --gray-bg: #e5e7eb;
    --hour-none: #d7dbe0;
    --hour-ok: #22c55e;
    --hour-partial: #f59e0b;
    --hour-down: #dc2626;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418;
        --surface: #1a1e24;
        --text: #e6e8eb;
        --muted: #9aa4b1;
        --border: #2c323a;
        --accent: #60a5fa;
        --green: #4ade80;
        --green-bg: #12301f;
        --red: #f87171;
        --red-bg: #3b1515;
        --amber: #fbbf24;
        --amber-bg: #3a2c0b;
        --gray-bg: #2c323a;
        --hour-none: #2f353d;
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

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

h1 {
    margin: 0;
    font-size: 1.4rem;
}

h2 {
    margin: 2rem 0 .75rem;
    font-size: 1.1rem;
}

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

main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

main.narrow {
    max-width: 420px;
    padding-top: 12vh;
}

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

.small {
    display: block;
    font-size: .82rem;
}

.good {
    color: var(--green);
}

.fair {
    color: var(--amber);
}

.bad {
    color: var(--red);
    font-weight: 600;
}

/* top bar */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1280px;
    margin: 0 auto;
    padding: .9rem 1rem;
}

.topbar p {
    margin: .2rem 0 0;
    font-size: .9rem;
}

/* forms */

button {
    padding: .55rem 1.1rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    cursor: pointer;
}

button.secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.login {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.login h1 {
    margin-bottom: .5rem;
}

.login input[type="password"] {
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

/* notices */

.notice {
    margin: 0 0 1rem;
    padding: .75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid;
}

.notice-error {
    background: var(--red-bg);
    border-color: var(--red);
}

.notice-warning {
    background: var(--amber-bg);
    border-color: var(--amber);
}

/* summary tiles */

.summary {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tile {
    display: flex;
    flex-direction: column;
    min-width: 120px;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--hour-none);
    border-radius: 8px;
}

.tile-count {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tile-label {
    color: var(--muted);
    font-size: .88rem;
}

.tile.state-down { border-top-color: var(--hour-down); }
.tile.state-pending,
.tile.state-warning { border-top-color: var(--hour-partial); }
.tile.state-up { border-top-color: var(--hour-ok); }

/* tables */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

th,
td {
    padding: .6rem .75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.site a {
    display: block;
    overflow-wrap: anywhere;
    font-size: .88rem;
}

.reason {
    display: block;
    margin-top: .25rem;
    color: var(--red);
    font-size: .88rem;
}

.note {
    display: block;
    margin-top: .25rem;
    color: var(--amber);
    font-size: .88rem;
}

.reason-cell {
    overflow-wrap: anywhere;
}

.uptime span {
    display: block;
}

/* status badges */

.badge {
    display: inline-block;
    padding: .1rem .55rem;
    border-radius: 999px;
    background: var(--gray-bg);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
}

.state-up .badge { background: var(--green-bg); color: var(--green); }
.state-down .badge,
.badge-down { background: var(--red-bg); color: var(--red); }
.state-pending .badge,
.state-warning .badge { background: var(--amber-bg); color: var(--amber); }

tr.state-down td:first-child { box-shadow: inset 4px 0 0 var(--hour-down); }
tr.state-pending td:first-child,
tr.state-warning td:first-child { box-shadow: inset 4px 0 0 var(--hour-partial); }
tr.state-paused { opacity: .6; }

/* 24 hour bar */

.hours {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    min-width: 168px;
    height: 26px;
}

.hour { border-radius: 2px; background: var(--hour-none); }
.hour-ok { background: var(--hour-ok); }
.hour-partial { background: var(--hour-partial); }
.hour-down { background: var(--hour-down); }

footer {
    margin-top: 2rem;
    text-align: center;
}

/* small screens: rows become cards */

@media (max-width: 860px) {
    table,
    thead,
    tbody,
    tr,
    td {
        display: block;
    }

    table {
        background: none;
        border: 0;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    tr {
        margin-bottom: .75rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
        overflow: hidden;
    }

    td {
        display: grid;
        grid-template-columns: 7.5rem 1fr;
        gap: .5rem;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .8rem;
        font-weight: 600;
    }

    td > * {
        grid-column: 2;
    }

    td.num {
        text-align: left;
        white-space: normal;
    }

    .badge {
        justify-self: start;
    }

    .uptime {
        display: flex;
        flex-wrap: wrap;
        gap: .25rem 1rem;
    }

    .uptime span::before {
        content: attr(data-period) ": ";
        color: var(--muted);
        font-weight: 400;
    }

    .tile {
        flex: 1 1 90px;
        min-width: 90px;
    }

    tr.state-down td:first-child,
    tr.state-pending td:first-child,
    tr.state-warning td:first-child {
        box-shadow: none;
    }

    tr.state-down { border-left: 4px solid var(--hour-down); }
    tr.state-pending,
    tr.state-warning { border-left: 4px solid var(--hour-partial); }

    .topbar-inner {
        align-items: flex-start;
    }
}

/* favorites */

.site-head {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.fav-form {
    margin: 0;
}

.fav {
    padding: 0 .2rem;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 1.15rem;
    line-height: 1;
}

.fav.is-locked {
    cursor: default;
}

.fav:hover,
.fav.is-fav,
.fav-icon {
    color: #eab308;
}

/* same column widths in the favorites table and the table of all other sites */
@media (min-width: 861px) {
    table.sites {
        table-layout: fixed;
    }

    table.sites th:nth-child(1) { width: 9.5rem; }
    table.sites th:nth-child(3) { width: 10rem; }
    table.sites th:nth-child(4) { width: 11.5rem; }
    table.sites th:nth-child(5) { width: 13rem; }
    table.sites th:nth-child(6) { width: 7rem; }

    table.sites td.site {
        overflow-wrap: anywhere;
    }
}

/* toolbar: filter, sort, view switch */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem;
    margin: 1.5rem 0 0;
    padding: .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.toolbar-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
}

.toolbar-filter {
    flex: 1 1 14rem;
}

.toolbar input,
.toolbar select {
    min-height: 2.3rem;
    padding: .4rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
    font-weight: 400;
}

.toolbar button {
    min-height: 2.3rem;
}

.views {
    display: flex;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.views a {
    padding: .5rem .85rem;
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
}

.views a + a {
    border-left: 1px solid var(--border);
}

.views a:hover {
    background: var(--bg);
}

.views a.is-active {
    background: var(--accent);
    color: #fff;
}

.filter-info {
    margin: .75rem 0 0;
    font-size: .9rem;
}

/* compact view: one dense line per site */

.view-compact th,
.view-compact td {
    padding: .3rem .6rem;
    font-size: .88rem;
    vertical-align: middle;
}

.view-compact .small,
.view-compact .note,
.view-compact .hide-compact,
.view-compact .site a,
.view-compact .uptime span:not(:first-child) {
    display: none;
}

.view-compact .reason {
    margin-top: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.view-compact .hours {
    height: 14px;
}

.view-compact .fav {
    font-size: 1rem;
}

/* cards view on large screens (small screens always show cards) */

@media (min-width: 861px) {
    .view-cards table.sites,
    .view-cards table.sites tr,
    .view-cards table.sites td {
        display: block;
    }

    .view-cards table.sites {
        background: none;
        border: 0;
        overflow: visible;
    }

    .view-cards table.sites thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .view-cards table.sites tbody {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
        gap: .75rem;
    }

    .view-cards table.sites tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
        overflow: hidden;
    }

    .view-cards table.sites td {
        display: grid;
        grid-template-columns: 6.5rem 1fr;
        gap: .5rem;
        text-align: left;
        white-space: normal;
        border-bottom: 1px solid var(--border);
    }

    .view-cards table.sites tbody tr td:last-child {
        border-bottom: 0;
    }

    .view-cards table.sites td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .8rem;
        font-weight: 600;
    }

    .view-cards table.sites td > * {
        grid-column: 2;
    }

    .view-cards .badge {
        justify-self: start;
    }

    .view-cards .uptime {
        display: flex;
        flex-wrap: wrap;
        gap: .25rem 1rem;
    }

    .view-cards .uptime span::before {
        content: attr(data-period) ": ";
        color: var(--muted);
        font-weight: 400;
    }

    .view-cards table.sites tr td:first-child {
        box-shadow: none;
    }

    .view-cards table.sites tr.state-down { border-left: 4px solid var(--hour-down); }
    .view-cards table.sites tr.state-pending,
    .view-cards table.sites tr.state-warning { border-left: 4px solid var(--hour-partial); }
}

@media (max-width: 860px) {
    .toolbar {
        gap: .6rem;
    }

    .toolbar-filter {
        flex: 1 1 100%;
    }

    .toolbar-field:not(.toolbar-filter) {
        flex: 1 1 10rem;
        min-width: 0;
    }

    .toolbar select {
        width: 100%;
        min-width: 0;
    }

    .views {
        flex: 1 1 100%;
        margin-left: 0;
    }

    .views a {
        flex: 1;
        text-align: center;
    }
}
