:root {
    color-scheme: light;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --bg-gradient: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.9), rgba(148, 163, 184, 0.4)), radial-gradient(circle at 80% 0%, rgba(186, 230, 253, 0.6), rgba(59, 130, 246, 0.12));
    --card-gradient: linear-gradient(150deg, rgba(249, 250, 251, 0.92), rgba(229, 231, 235, 0.62));
    --card-border: rgba(255, 255, 255, 0.65);
    --glass-shadow: 0 32px 70px rgba(15, 23, 42, 0.28);
    --card-radius: 28px;
    --text-strong: rgba(17, 24, 39, 0.94);
    --text-muted: rgba(71, 85, 105, 0.78);
    --badge-border: rgba(148, 163, 184, 0.38);
    --badge-gradient: linear-gradient(135deg, rgba(129, 140, 248, 0.32), rgba(236, 72, 153, 0.26));
    --divider-strong: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(51, 65, 85, 0.28), rgba(255, 255, 255, 0.08));
    --divider-muted: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(148, 163, 184, 0.35), rgba(255, 255, 255, 0.04));
    --dot-healthy-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12);
    --dot-unhealthy-shadow: 0 0 0 6px rgba(248, 113, 113, 0.18);
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-gradient);
    color: var(--text-strong);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 32px 6vw 18px;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.5rem);
    letter-spacing: 0.02em;
}

.page-header p {
    margin: 6px 0 0;
    color: rgba(71, 85, 105, 0.7);
    font-weight: 500;
}

.logout-form {
    margin: 0;
}

.logout-button {
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(139, 92, 246, 0.1));
    color: rgba(37, 99, 235, 0.95);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.logout-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 25px rgba(59, 130, 246, 0.25);
}

.error-banner {
    margin: 0 6vw 20px;
    padding: 12px 18px;
    border-radius: 16px;
    border: 1px solid rgba(248, 113, 113, 0.4);
    background: linear-gradient(135deg, rgba(254, 226, 226, 0.85), rgba(254, 205, 211, 0.6));
    color: rgba(136, 19, 55, 0.96);
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(248, 113, 113, 0.2);
}

.error-banner.hidden {
    display: none;
}

.filter-wrapper {
    margin: 0 6vw 24px;
    padding: 14px 20px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(226, 232, 240, 0.48));
    box-shadow: 0 18px 40px rgba(30, 64, 175, 0.12);
    backdrop-filter: blur(12px);
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.filter-label {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(30, 41, 59, 0.82);
    text-transform: uppercase;
}

.filter-reset {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.18), rgba(203, 213, 225, 0.1));
    color: rgba(71, 85, 105, 0.9);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.filter-reset:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(148, 163, 184, 0.24);
}

.filter-reset.hidden {
    display: none;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-empty {
    font-size: 0.85rem;
    color: rgba(100, 116, 139, 0.8);
    font-style: italic;
}

.filter-chip {
    --chip-bg-color: rgba(148, 163, 184, 0.18);
    --chip-border-color: rgba(148, 163, 184, 0.35);
    --chip-shadow-color: rgba(96, 165, 250, 0.25);
    --chip-text-color: rgba(30, 41, 59, 0.85);
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--chip-border-color);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), var(--chip-bg-color));
    color: var(--chip-text-color);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.filter-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px var(--chip-shadow-color);
}

.filter-chip.active {
    border-color: transparent;
    background: linear-gradient(135deg, var(--chip-bg-color), var(--chip-shadow-color));
    color: rgba(17, 24, 39, 0.98);
    box-shadow: 0 16px 34px var(--chip-shadow-color);
    transform: translateY(-1px) scale(1.02);
    padding-right: 28px;
}

.filter-chip.active::after {
    content: "✓";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(17, 24, 39, 0.95);
}

main {
    padding: 0 6vw 56px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 26px;
}

.service-card {
    position: relative;
    padding: 18px 20px 18px;
    border-radius: 22px;
    border: 1px solid var(--card-border);
    box-shadow: 0 24px 55px rgba(15, 23, 42, 0.24);
    backdrop-filter: blur(14px);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card-healthy {
    background: var(--card-gradient);
    box-shadow: 0 26px 60px rgba(34, 197, 94, 0.18);
}

.card-unhealthy {
    background: linear-gradient(160deg, rgba(254, 226, 226, 0.92), rgba(248, 113, 113, 0.25));
    border: 1px solid rgba(248, 113, 113, 0.55);
    box-shadow: 0 30px 68px rgba(248, 113, 113, 0.28);
}

.service-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.18), rgba(148, 163, 184, 0.1));
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.service-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 36px 80px rgba(15, 23, 42, 0.32);
}

.service-card:hover::after {
    opacity: 1;
}

.card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.dot-healthy {
    background: linear-gradient(135deg, #34d399, #4ade80);
    box-shadow: var(--dot-healthy-shadow);
}

.dot-unhealthy {
    background: linear-gradient(135deg, #ef4444, #fb923c);
    box-shadow: var(--dot-unhealthy-shadow);
}

.title-block {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.service-title {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: 0.01em;
    color: var(--text-strong);
}

.service-title a {
    color: inherit;
    text-decoration: none;
}

.service-title a:hover {
    text-decoration: none;
}

.service-subtitle {
    margin-top: 2px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.info-pill {
    width: 28px;
    height: 28px;
    border-radius: 12px;
    border: 1px solid rgba(203, 213, 225, 0.6);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.65), rgba(226, 232, 240, 0.35));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: rgba(30, 64, 175, 0.85);
    box-shadow: inset 0 2px 4px rgba(148, 163, 184, 0.18);
}

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

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
    color: rgba(30, 41, 59, 0.82);
    letter-spacing: 0.04em;
}

.badge-primary {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.9), rgba(244, 63, 94, 0.85));
    border: 1px solid rgba(244, 114, 182, 0.8);
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.25);
}

.badge-secondary {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.28), rgba(56, 189, 248, 0.18));
    border: 1px solid rgba(148, 163, 184, 0.38);
    color: rgba(30, 41, 59, 0.82);
}

.badge-muted {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.25), rgba(203, 213, 225, 0.18));
    border: 1px solid rgba(203, 213, 225, 0.32);
    color: rgba(100, 116, 139, 0.9);
    font-style: italic;
}

.card-divider {
    height: 1px;
    margin: 14px 0;
    background: var(--divider-strong);
}

.card-divider.muted {
    margin-top: 18px;
    background: var(--divider-muted);
}

.metric-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.metric {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(226, 232, 240, 0.45));
    border: 1px solid rgba(226, 232, 240, 0.65);
    box-shadow: inset 0 1px 3px rgba(148, 163, 184, 0.18);
}

.metric-address {
    grid-column: 1 / -1;
}

.metric-remark {
    grid-column: 1 / -1;
    padding: 10px 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(226, 232, 240, 0.42));
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: inset 0 1px 2px rgba(148, 163, 184, 0.15);
}

.metric-inline {
    grid-column: 1 / -1;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.metric-inline .kv-pair {
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-key {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(30, 41, 59, 0.75);
    text-transform: uppercase;
}

.metric-sep {
    font-size: 0.85rem;
    color: rgba(148, 163, 184, 0.9);
}

.metric-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(30, 41, 59, 0.94);
    word-break: break-word;
}

.metric-value a {
    color: inherit;
    text-decoration: none;
}

.metric-value a:hover {
    text-decoration: underline;
}

.metric-error .metric-value {
    color: #ef4444;
}

.metric-error {
    background: linear-gradient(135deg, rgba(254, 226, 226, 0.85), rgba(254, 202, 202, 0.55));
    border-color: rgba(248, 113, 113, 0.45);
    grid-column: 1 / -1;
}

.service-remark {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-align: left;
    word-break: break-word;
    white-space: pre-wrap;
    opacity: 0.96;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.1rem;
    color: rgba(71, 85, 105, 0.72);
    padding: 36px 0;
}

@media (max-width: 720px) {
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }

    .filter-wrapper {
        margin: 0 18px 20px;
    }

    .metric-grid {
        gap: 12px;
    }

    main {
        padding: 0 18px 40px;
    }
}
