:root {
    color-scheme: light;
    --page: #f4f6f8;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #77818d;
    --line: #e7eaee;
    --green: #13a66a;
    --green-soft: #e8f7f0;
    --red: #dc4c64;
    --red-soft: #fcecef;
    --amber: #d89516;
    --shadow: 0 18px 50px rgba(23, 32, 42, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    min-height: 100%;
    background: var(--page);
}

body {
    height: 100%;
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    color: var(--text);
    background: var(--page);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.shell {
    width: min(920px, calc(100% - 36px));
    height: 100dvh;
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    font-size: 14px;
    font-weight: 720;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand-mark {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    color: white;
    border-radius: 10px;
    background: #17202a;
    font-size: 13px;
    font-weight: 800;
}

.environment {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 11px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-size: 10px;
}

.environment strong {
    color: var(--text);
    font-size: 10px;
    letter-spacing: 0.08em;
}

.environment-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

main {
    min-height: 0;
    padding: clamp(14px, 2.5vh, 26px) 0 clamp(12px, 2vh, 22px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(16px, 2.6vh, 28px);
}

.overview {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.overview-main {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 20px;
    min-height: 108px;
    padding: 20px 24px;
}

.status-orb {
    width: 15px;
    height: 15px;
    border: 4px solid var(--green-soft);
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 5px var(--green-soft);
}

.status-orb.is-unhealthy {
    border-color: var(--red-soft);
    background: var(--red);
    box-shadow: 0 0 0 5px var(--red-soft);
}

.status-orb.is-loading {
    border-color: #fff4dd;
    background: var(--amber);
    box-shadow: 0 0 0 5px #fff4dd;
    animation: pulse 1.2s ease-in-out infinite;
}

.kicker {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
}

.overview h1 {
    margin: 0;
    font-size: clamp(24px, 4vw, 34px);
    font-weight: 690;
    letter-spacing: -0.04em;
}

.overview-copy > p:last-child {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
    background: #fbfcfd;
}

.metric {
    padding: 12px 20px;
    border-left: 1px solid var(--line);
}

.metric:first-child {
    border-left: 0;
}

.metric span,
.metric strong {
    display: block;
}

.metric span {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
}

.metric strong {
    font-size: 14px;
    font-weight: 680;
}

.services {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
}

.section-heading h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 720;
}

.section-heading span {
    color: var(--muted);
    font-size: 10px;
}

.service-list {
    width: 100%;
    height: 100%;
    max-height: 360px;
    min-height: 0;
    align-self: start;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--line);
}

.service-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 10px 14px;
    min-width: 0;
    min-height: 0;
    padding: clamp(11px, 1.8vh, 18px);
    background: var(--surface);
    transition: background 140ms ease;
}

.service-row:hover {
    background: #fafbfc;
}

.service-identity {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 11px;
}

.service-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px var(--green-soft);
}

.is-unhealthy .service-dot {
    background: var(--red);
    box-shadow: 0 0 0 4px var(--red-soft);
}

.service-name,
.service-key,
.service-reason {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-name {
    margin: 0;
    font-size: 13px;
    font-weight: 670;
}

.service-key {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 9px;
}

.status-badge {
    width: fit-content;
    padding: 5px 8px;
    color: var(--green);
    border-radius: 999px;
    background: var(--green-soft);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.is-unhealthy .status-badge {
    color: var(--red);
    background: var(--red-soft);
}

.response-time {
    align-self: end;
    color: var(--muted);
    font-size: 11px;
}

.response-time strong {
    margin-right: 3px;
    color: var(--text);
    font-size: 13px;
}

.service-reason {
    align-self: end;
    margin: 0;
    color: var(--muted);
    font-size: 10px;
    text-align: right;
}

.is-unhealthy .service-reason {
    color: var(--red);
}

.skeleton {
    min-height: 0;
    background: linear-gradient(100deg, #fff 30%, #f4f6f8 50%, #fff 70%);
    background-size: 220% 100%;
    animation: shimmer 1.5s infinite;
}

.empty-row {
    display: flex;
    justify-content: center;
    color: var(--muted);
    font-size: 12px;
}

footer {
    display: flex;
    justify-content: flex-end;
    min-height: 38px;
    color: #a0a8b1;
    border-top: 1px solid var(--line);
    font-size: 9px;
}

footer span {
    max-width: 100%;
    padding-top: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes pulse {
    50% { opacity: 0.45; }
}

@keyframes shimmer {
    to { background-position-x: -220%; }
}

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

@media (max-width: 520px) {
    .shell {
        width: min(100% - 24px, 920px);
    }

    .environment span:last-child {
        display: none;
    }

    main {
        padding-top: 10px;
        gap: 12px;
    }

    .overview-main {
        grid-template-columns: auto 1fr;
        min-height: 88px;
        padding: 16px 18px;
    }

    .metrics {
        grid-template-columns: repeat(3, 1fr);
    }

    .metric {
        padding: 9px 10px;
    }

    .service-list {
        grid-template-columns: 1fr;
    }

    .service-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-rows: minmax(0, 1fr);
        gap: 8px;
        padding: 5px 12px;
    }

    .service-key,
    .service-reason {
        display: none;
    }
}

@media (max-height: 720px) {
    .topbar {
        min-height: 52px;
    }

    main {
        padding-top: 8px;
        padding-bottom: 8px;
        gap: 10px;
    }

    .overview-main {
        min-height: 76px;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .metrics .metric {
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .service-key {
        display: none;
    }

    footer {
        min-height: 28px;
    }

    footer span {
        padding-top: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
