:root {
    --bg-color: #060608;
    --card-bg: rgba(255, 255, 255, 0.02);
    --border-color: rgba(255, 255, 255, 0.05);
    --text-primary: #F3F4F6;
    --text-secondary: rgba(156, 163, 175, 0.6);
    --status-up: #10B981;
    --status-degraded: #F59E0B;
    --status-down: #EF4444;
    --accent: #6366F1;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Outfit', -apple-system, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-y: auto;
    padding: 4rem 1.5rem;
}

.container {
    width: 100%;
    max-width: 1100px;
}

header {
    margin-bottom: 4rem;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, #FFFFFF 40%, #818CF8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 1.1rem;
    font-weight: 300;
}

/* --- Global Heartbeat Badge --- */
.global-last-seen {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: -0.5px;
}

.pulse-indicator {
    width: 6px;
    height: 6px;
    background-color: var(--status-up);
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    box-shadow: 0 0 10px var(--status-up);
    animation: blink 2s infinite ease-in-out;
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* --- System Card Grid --- */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 850px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1.75rem;
    padding: 2.25rem;
    backdrop-filter: blur(16px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s ease, box-shadow 0.4s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* --- Auto-Refresh Progress Bar --- */
.refresh-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.refresh-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: refresh-progress 60s linear infinite;
    opacity: 0.6;
}

@keyframes refresh-progress {
    0% { width: 0%; }
    100% { width: 100%; }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card h3 {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.status-ring {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 14px;
    position: relative;
}

.status-ring::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    animation: ring-pulse 2.5s infinite cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.5;
}

@keyframes ring-pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    100% { transform: scale(1.9); opacity: 0; }
}

.status-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.25rem 0.65rem;
    border-radius: 0.5rem;
    letter-spacing: 0.5px;
}

/* --- Card Status Themes --- */
.status-Operational .status-ring { color: var(--status-up); background: var(--status-up); }
.status-Operational .status-badge { color: var(--status-up); background: rgba(16, 185, 129, 0.15); }

.status-Degraded .status-ring { color: var(--status-degraded); background: var(--status-degraded); }
.status-Degraded .status-badge { color: var(--status-degraded); background: rgba(245, 158, 11, 0.15); }

.status-Down .status-ring { color: var(--status-down); background: var(--status-down); }
.status-Down .status-badge { color: var(--status-down); background: rgba(239, 68, 68, 0.15); }

/* --- Heartbeat Chiclets --- */
.chiclet-container {
    display: flex;
    gap: 3px;
    margin-bottom: 2rem;
    padding: 4px 0;
    align-items: flex-end;
    justify-content: flex-end;
    height: 24px;
    overflow: hidden;
}

.chiclet {
    width: 4px;
    height: 100%;
    min-height: 10px;
    border-radius: 2px;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s;
    flex-shrink: 0;
}

.chiclet:hover {
    transform: scaleY(1.3);
    cursor: crosshair;
}

.chiclet-Operational { background: var(--status-up); opacity: 0.5; }
.chiclet-Degraded { background: var(--status-degraded); }
.chiclet-Down { background: var(--status-down); }

.day-separator {
    width: 4px;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 1px;
    align-self: center;
    border-radius: 1px;
}

/* --- Service Panel Alignments --- */
.service-list {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.015);
    padding: 0.85rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.02);
    transition: background-color 0.2s;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.service-item:hover {
    background: rgba(255, 255, 255, 0.035);
}

.service-meta-left {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 12px;
    box-shadow: 0 0 6px currentColor;
    flex-shrink: 0;
}

.dot-Operational { color: var(--status-up); background-color: var(--status-up); }
.dot-Degraded { color: var(--status-degraded); background-color: var(--status-degraded); }
.dot-Down { color: var(--status-down); background-color: var(--status-down); }
.dot-Timeout { color: var(--status-degraded); background-color: var(--status-degraded); }

.service-name {
    margin-right: 6px;
}

.service-status-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-text-Operational { color: var(--status-up); }
.status-text-Degraded { color: var(--status-degraded); }
.status-text-Down { color: var(--status-down); }
.status-text-Timeout { color: var(--status-degraded); }

/* --- Telemetry Metrics Syntax --- */
.service-meta-right {
    display: flex;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 0 0;
}

.service-latency {
    color: var(--text-primary);
    font-weight: 500;
}

.service-latency.dim {
    color: var(--text-secondary);
    opacity: 0.5;
}

.divider {
    color: rgba(255, 255, 255, 0.15);
    margin: 0 8px;
    font-weight: 400;
}

/* --- HTTP Response Code Badges --- */
.response-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
}

.code-ok {
    color: var(--status-up);
    background: rgba(16, 185, 129, 0.12);
}

.code-redirect {
    color: var(--status-degraded);
    background: rgba(245, 158, 11, 0.12);
}

.code-error {
    color: var(--status-down);
    background: rgba(239, 68, 68, 0.12);
}

/* --- SSL Certificate Expiry Badge --- */
.cert-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    letter-spacing: -0.3px;
}

.cert-ok {
    color: var(--status-up);
    background: rgba(16, 185, 129, 0.12);
}

.cert-warning {
    color: var(--status-degraded);
    background: rgba(245, 158, 11, 0.15);
}

.cert-critical {
    color: var(--status-down);
    background: rgba(239, 68, 68, 0.15);
    animation: cert-flash 1.5s infinite ease-in-out;
}

@keyframes cert-flash {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* --- Card Active Footers --- */
.card-footer {
    display: flex;
    align-items: center;
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.04);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    flex-wrap: wrap;
    gap: 0 0;
}

.uptime-pct {
    color: var(--status-up);
    font-weight: 600;
}

.footer-sep {
    color: rgba(255, 255, 255, 0.1);
    margin: 0 8px;
}

.incident-summary {
    opacity: 0.7;
}

.footer-spacer {
    flex: 1;
}

.card-timer {
    color: rgba(255, 255, 255, 0.6);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    body {
        padding: 2rem 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }

    .service-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .service-meta-right {
        padding-left: 18px;
    }
}
