:root {
    --ok: #22c55e;
    --down: #ef4444;
    --warn: #f59e0b;
    --unknown: #475569;
}

main {
    max-width: 820px;
    margin: 0 auto;
    padding: clamp(24px, 6vw, 48px) clamp(14px, 4vw, 20px) 64px;
    /* Keep content clear of the notch when the page is opened in landscape. */
    padding-left: max(clamp(14px, 4vw, 20px), env(safe-area-inset-left));
    padding-right: max(clamp(14px, 4vw, 20px), env(safe-area-inset-right));
}

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

.languages {
    margin-bottom: clamp(18px, 4vw, 28px);
}

header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: clamp(22px, 5vw, 36px);
}

header img {
    width: 40px;
    height: 40px;
    flex: none;
}

header h1 {
    font-size: clamp(1.05rem, 4.5vw, 1.35rem);
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.01em;
}

header .back {
    margin-left: auto;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--muted);
    white-space: nowrap;
}

header .back:hover {
    color: var(--neon);
}

.panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

/* Overall banner */
#banner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: clamp(16px, 4vw, 22px) clamp(16px, 4.5vw, 24px);
    margin-bottom: clamp(16px, 4vw, 26px);
    border-left: 4px solid var(--unknown);
}

#banner.ok { border-left-color: var(--ok); }
#banner.down { border-left-color: var(--down); }
#banner.stale { border-left-color: var(--warn); }

/* The sub-line wraps to several lines on a phone, so the dot is pinned to the
   headline rather than centred against a block whose height varies. */
#banner .dot {
    width: 12px;
    height: 12px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--unknown);
    flex: none;
}

#banner.ok .dot { background: var(--ok); box-shadow: 0 0 12px var(--ok); }
#banner.down .dot { background: var(--down); box-shadow: 0 0 12px var(--down); }
#banner.stale .dot { background: var(--warn); box-shadow: 0 0 12px var(--warn); }

#banner .headline {
    font-weight: 600;
    font-size: 1.05rem;
}

#banner .sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 3px;
}

/* Service rows */
.service {
    padding: clamp(16px, 4vw, 20px) clamp(16px, 4.5vw, 24px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.service:first-child {
    border-top: none;
}

.service-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-bottom: 12px;
}

.service-head .name {
    font-weight: 600;
}

.service-head .state {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.state.ok { color: var(--ok); }
.state.down { color: var(--down); }
.state.unknown { color: var(--muted); }

.bars {
    display: flex;
    gap: 2px;
    height: 30px;
    align-items: stretch;
}

/* min-width is what makes this safe: below it the row would overflow the panel
   instead of shrinking, so the day count is trimmed in JS to whatever fits. */
.bars .bar {
    flex: 1 1 0;
    min-width: 3px;
    border-radius: 2px;
    background: var(--unknown);
    opacity: 0.35;
}

.bars .bar.ok { background: var(--ok); opacity: 0.85; }
.bars .bar.partial { background: var(--warn); opacity: 0.9; }
.bars .bar.down { background: var(--down); opacity: 0.9; }

.bars-legend {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 6px;
}

.bars-legend span {
    white-space: nowrap;
}

/* title= tooltips never appear on a touch screen, so a tapped bar reports itself here. */
.bar-note {
    font-size: 0.72rem;
    color: var(--text);
    margin-top: 6px;
    min-height: 1em;
}

/* Detail panel */
#detail {
    margin-top: clamp(16px, 4vw, 26px);
    padding: clamp(16px, 4vw, 22px) clamp(16px, 4.5vw, 24px);
}

#detail h2 {
    font-size: 0.95rem;
    margin: 0 0 4px;
    font-weight: 600;
}

#detail .hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0 0 16px;
}

.env + .env {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.env-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-bottom: 14px;
}

h3.env-name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.env-age {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    border: 1px solid currentColor;
}

.pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.pill.good { color: var(--ok); background: rgba(34, 197, 94, 0.1); }
.pill.warn { color: var(--warn); background: rgba(245, 158, 11, 0.1); }
.pill.bad { color: var(--down); background: rgba(239, 68, 68, 0.12); }
.pill.neutral { color: var(--muted); }

.env-head .pill {
    font-size: 0.85rem;
    padding: 5px 13px;
}

.attention {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.attention.clear {
    background: rgba(34, 197, 94, 0.07);
    border-color: rgba(34, 197, 94, 0.25);
}

.attention-title {
    font-size: 0.85rem;
    font-weight: 600;
}

.attention.clear .attention-title {
    color: var(--ok);
}

.attention ul {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.attention li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px 12px;
    font-size: 0.82rem;
    padding-left: 10px;
    border-left: 3px solid var(--down);
}

.attention li.warn {
    border-left-color: var(--warn);
}

.attention-where {
    color: var(--text);
    overflow-wrap: anywhere;
}

.attention-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.attention li.bad .attention-value { color: var(--down); }
.attention li.warn .attention-value { color: var(--warn); }

.gauges {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
    gap: 12px 20px;
    margin-bottom: 14px;
}

.gauge-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.8rem;
    margin-bottom: 5px;
    overflow-wrap: anywhere;
}

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

.gauge-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.gauge-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--unknown);
}

.gauge.good .gauge-fill { background: var(--ok); }
.gauge.warn .gauge-fill { background: var(--warn); }
.gauge.bad .gauge-fill { background: var(--down); }
.gauge.warn .gauge-value { color: var(--warn); }
.gauge.bad .gauge-value { color: var(--down); }

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.tile {
    padding: 9px 11px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 0;
}

.tile-label {
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 2px;
}

.tile-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.tile.good .tile-value { color: var(--ok); }
.tile.warn .tile-value { color: var(--warn); }
.tile.bad .tile-value { color: var(--down); }
.tile.warn { border-color: rgba(245, 158, 11, 0.4); }
.tile.bad { border-color: rgba(239, 68, 68, 0.45); }

.nested {
    display: grid;
    gap: 10px;
}

.group-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 4px 0 8px;
}

details.card {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

details.card > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 14px;
    cursor: pointer;
    list-style: none;
}

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

details.card > summary::after {
    content: "";
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

details.card[open] > summary::after {
    transform: rotate(-135deg);
}

.card-title {
    font-weight: 600;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.card-body {
    padding: 4px 14px 14px;
}

.chips-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 0.8rem;
}

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

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    font-size: 0.76rem;
    overflow-wrap: anywhere;
}

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

.chip.warn {
    color: var(--warn);
    background: rgba(245, 158, 11, 0.12);
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

table.compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

table.compact th,
table.compact td {
    padding: 7px 11px;
    text-align: left;
    white-space: nowrap;
}

table.compact th {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
}

table.compact tr + tr td {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

table.compact td.warn { color: var(--warn); }
table.compact td.bad { color: var(--down); }

form.config {
    display: grid;
    gap: 10px;
    max-width: 420px;
}

form.config fieldset {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 4px 14px 14px;
    margin: 0;
    display: grid;
    gap: 10px;
}

form.config legend {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0 6px;
}

form.config label {
    font-size: 0.78rem;
    color: var(--muted);
}

/* 16px exactly: iOS Safari zooms the viewport on focus for anything smaller, and it
   does not zoom back out afterwards. */
form.config input {
    width: 100%;
    padding: 11px 12px;
    margin-top: 5px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

form.config input:focus {
    outline: none;
    border-color: rgba(0, 242, 254, 0.6);
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-top: 4px;
}

button {
    min-height: 44px;
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

button.link {
    border: none;
    background: none;
    padding: 0;
    min-height: 44px;
    color: var(--muted);
    font-size: 0.78rem;
    text-decoration: underline;
}

/* Hover styling is gated so a tap on a touch screen does not leave the button stuck
   in its hover state until the next tap elsewhere. */
@media (hover: hover) {
    button:hover {
        border-color: rgba(0, 242, 254, 0.6);
        background: rgba(6, 182, 212, 0.15);
    }

    button.link:hover {
        background: none;
        color: var(--neon);
    }
}

footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
}

[hidden] {
    display: none !important;
}

@media (max-width: 560px) {
    .tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .env-age {
        flex-basis: 100%;
        margin-left: 0;
    }

    .bars {
        height: 34px;
    }

    .buttons {
        gap: 10px 14px;
    }

    .buttons button:not(.link) {
        flex: 1 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    button,
    details.card > summary::after {
        transition: none;
    }
}
