:root {
    --bg: #0d121c;
    --surface: #141b29;
    --line: #232d41;
    --text: #e7ecf4;
    --muted: #8a96ab;

    --ok: #3ecf8e;
    --warn: #f2b84b;
    --bad: #f0626b;
    --idle: #5b677c;

    --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.page {
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 20px 56px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 36px;
}

.logo { height: 34px; width: auto; display: block; }

.header-label { color: var(--muted); font-size: 15px; }

/* Overall banner */
.banner {
    --accent: var(--idle);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 26px 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    margin-bottom: 44px;
}

.banner.is-ok   { --accent: var(--ok); }
.banner.is-warn { --accent: var(--warn); }
.banner.is-bad  { --accent: var(--bad); }

.banner-dot {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent);
}

.banner-title {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.banner-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 15px;
}

.banner-subtitle.is-stale { color: var(--warn); }

/* Groups */
.group { margin-bottom: 32px; }

.group-title { font-size: 15px; font-weight: 500; }

.group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 6px 4px;
    background: none;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.group-toggle:hover { color: var(--text); }
.group-toggle:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }

.group-name { flex: 1; }

.group-summary { font-size: 13px; font-weight: 400; }
.group-summary.is-bad { color: var(--bad); }

.group-list {
    margin-top: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

/* Service rows */
.service { padding: 18px 22px; }

.service-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.service + .service { border-top: 1px solid var(--line); }

.service-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok);
}

.service.is-down .service-dot { background: var(--bad); }

.service-info { flex: 1; min-width: 0; }

.service-name { font-size: 16px; font-weight: 500; }

.service-description {
    color: var(--muted);
    font-size: 14px;
    margin-top: 1px;
}

.service-meta {
    text-align: right;
    flex: none;
}

.service-state { font-size: 14px; font-weight: 500; color: var(--ok); }
.service.is-down .service-state { color: var(--bad); }

.service-latency {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

.service-latency.is-slow { color: var(--warn); }
.service-latency.is-very-slow { color: var(--bad); }

/* States */
.error-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--bad);
    border-radius: 10px;
    padding: 22px 26px;
}

.error-card strong { display: block; margin-bottom: 4px; }
.error-card span { color: var(--muted); font-size: 14px; }

.footer {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

/* Expand / collapse */
.service-main.is-toggle {
    cursor: pointer;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}

.service-main.is-toggle:focus-visible {
    outline: 2px solid var(--muted);
    outline-offset: 6px;
}

.chevron {
    flex: none;
    width: 8px;
    height: 8px;
    margin: 0 4px 3px 2px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .2s ease, border-color .2s ease;
}

[aria-expanded="true"] > .chevron {
    transform: translateY(3px) rotate(-135deg);
}

.service-main.is-toggle:hover .chevron,
.group-toggle:hover .chevron { border-color: var(--text); }

.history-panel,
.group-panel {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows .25s ease;
}

.history-panel.is-collapsed,
.group-panel.is-collapsed { grid-template-rows: 0fr; }

.history-inner,
.group-inner { overflow: hidden; min-height: 0; }

@media (prefers-reduced-motion: reduce) {
    .history-panel, .group-panel, .chevron { transition: none; }
}

/* Uptime history */
.history { margin-top: 16px; padding-left: 26px; }

.history-bars {
    display: flex;
    gap: 2px;
    height: 30px;
}

.bar {
    flex: 1;
    min-width: 0;
    border-radius: 2px;
    background: var(--line);
    cursor: default;
}

.bar.is-ok   { background: var(--ok); }
.bar.is-warn { background: var(--warn); }
.bar.is-bad  { background: var(--bad); }
.bar.is-none { background: var(--line); }

.bar:hover { opacity: .75; }

.history-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.history-uptime { color: var(--text); font-weight: 500; }

.tooltip {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 12px;
    background: #1c2638;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.tooltip[hidden] { display: none; }
.tooltip span { color: var(--muted); }

@media (max-width: 560px) {
    .history { padding-left: 0; }
    .history-bars { gap: 1px; }
    .page { padding: 28px 16px 40px; }
    .banner { padding: 22px 20px; gap: 16px; }
    .banner-title { font-size: 22px; }
    .service { padding: 16px 18px; }
    .service-main { gap: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
    .banner.is-ok .banner-dot { animation: breathe 3s ease-in-out infinite; }
    @keyframes breathe {
        0%, 100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent); }
        50%      { box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 6%, transparent); }
    }
}
