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

:root {
    --color-bg: #0a0a0a;
    --color-surface: #141414;
    --color-surface-hover: #1a1a1a;
    --color-border: #232323;
    --color-border-subtle: #1c1c1c;
    --color-text: #fafafa;
    --color-text-secondary: #a0a0a0;
    --color-text-muted: #666;
    --color-green: #22c55e;
    --color-green-bg: rgba(34, 197, 94, 0.08);
    --color-green-border: rgba(34, 197, 94, 0.2);
    --color-red: #ef4444;
    --color-red-bg: rgba(239, 68, 68, 0.08);
    --color-red-border: rgba(239, 68, 68, 0.2);
    --color-yellow: #eab308;
    --color-yellow-bg: rgba(234, 179, 8, 0.08);
    --color-yellow-border: rgba(234, 179, 8, 0.2);
    --color-blue: #3b82f6;
    --color-purple: #a855f7;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    padding: 40px 0 32px;
    border-bottom: 1px solid var(--color-border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--color-blue), var(--color-purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
}

h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.overall-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    transition: all 0.3s ease;
}

.overall-status.operational {
    background: var(--color-green-bg);
    border-color: var(--color-green-border);
    color: var(--color-green);
}

.overall-status.degraded {
    background: var(--color-yellow-bg);
    border-color: var(--color-yellow-border);
    color: var(--color-yellow);
}

.overall-status.down {
    background: var(--color-red-bg);
    border-color: var(--color-red-border);
    color: var(--color-red);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    position: relative;
}

.overall-status.operational .status-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.3;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.8); opacity: 0; }
}

/* Main */
main {
    padding: 24px 0 48px;
}

.last-updated {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.refresh-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

.refresh-btn.spinning svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Service Cards */
.services-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: all 0.2s ease;
}

.service-card:hover {
    background: var(--color-surface-hover);
    border-color: #2a2a2a;
}

.service-card.operational {
    border-left: 3px solid var(--color-green);
}

.service-card.degraded {
    border-left: 3px solid var(--color-yellow);
}

.service-card.down {
    border-left: 3px solid var(--color-red);
}

.service-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.service-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.service-icon.ml {
    background: rgba(168, 85, 247, 0.12);
    color: var(--color-purple);
}

.service-icon.rails {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-red);
}

.service-icon.halo {
    background: rgba(59, 130, 246, 0.12);
    color: var(--color-blue);
}

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

.service-info h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.service-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 1px;
}

.service-status {
    flex-shrink: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge.checking {
    background: var(--color-surface);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.status-badge.operational {
    background: var(--color-green-bg);
    color: var(--color-green);
    border: 1px solid var(--color-green-border);
}

.status-badge.degraded {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
    border: 1px solid var(--color-yellow-border);
}

.status-badge.down {
    background: var(--color-red-bg);
    color: var(--color-red);
    border: 1px solid var(--color-red-border);
}

.service-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

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

.detail-value {
    color: var(--color-text-secondary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.detail-value.endpoint {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Endpoint & component rows */
.endpoint-row {
    padding-top: 4px;
}

.endpoint-row .detail-label {
    color: var(--color-text-secondary);
}

.endpoint-separator {
    height: 1px;
    background: var(--color-border-subtle);
    margin: 6px 0;
}

.component-icon {
    font-size: 11px;
    margin-right: 2px;
}

/* Incident Log */
.incident-history {
    margin-top: 40px;
}

.incident-history h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.log-entries {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
}

.log-entries::-webkit-scrollbar {
    width: 4px;
}

.log-entries::-webkit-scrollbar-track {
    background: transparent;
}

.log-entries::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.empty-log {
    padding: 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border-subtle);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.log-dot.green { background: var(--color-green); }
.log-dot.red { background: var(--color-red); }
.log-dot.yellow { background: var(--color-yellow); }

.log-message {
    flex: 1;
    color: var(--color-text-secondary);
}

.log-time {
    color: var(--color-text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* Footer */
footer {
    padding: 24px 0;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

footer p {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 0 16px;
    }

    header {
        padding: 24px 0;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .service-card {
        padding: 16px;
    }

    .service-header {
        flex-wrap: wrap;
    }

    .service-status {
        width: 100%;
        margin-top: 8px;
    }
}
