:root {
    --bg-base: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --status-up: #10b981;
    --status-down: #ef4444;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

.background-mesh {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 50% 50%, rgba(37, 99, 235, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
    z-index: -1;
    animation: mesh-rotate 60s linear infinite;
}

@keyframes mesh-rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.global-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    font-weight: 600;
    transition: all 0.3s ease;
}

.global-status.all-up {
    color: var(--status-up);
    border-color: rgba(16, 185, 129, 0.3);
}

.global-status.some-down {
    color: var(--status-down);
    border-color: rgba(239, 68, 68, 0.3);
}

.global-status.loading {
    color: var(--text-secondary);
}

.pulse-ring {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 0 0 rgba(currentColor, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(currentColor, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(currentColor, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(currentColor, 0);
    }
}

/* Controls */
.grid-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.glass-input {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    outline: none;
    width: 300px;
    max-width: 100%;
    backdrop-filter: blur(10px);
    transition: border-color 0.2s;
}

.glass-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
}

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.glass-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.glass-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Accordion Styles */
.accordion-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.accordion-group {
    padding: 0;
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.group-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.group-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.group-status-dot {
    transition: background-color 0.3s, box-shadow 0.3s;
}

.group-status-dot.all-up {
    background-color: var(--status-up);
    box-shadow: 0 0 8px var(--status-up);
}

.group-status-dot.some-down {
    background-color: var(--status-down);
    box-shadow: 0 0 8px var(--status-down);
}

.accordion-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.accordion-group.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease;
    background: rgba(0, 0, 0, 0.1);
}

.accordion-group.active .accordion-content {
    max-height: 5000px;
    /* large enough for content */
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Grid & Cards (Nested in Accordion) */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Adjust card styles when nested */
.accordion-content .glass-panel {
    background: var(--card-bg);
    /* Slight contrast */
    box-shadow: none;
}

.accordion-content .glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--glass-shadow);
    padding: .5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.service-card[data-status="UP"] {
    border-top: 3px solid var(--status-up);
}

.service-card[data-status="DOWN"] {
    border-top: 3px solid var(--status-down);
    background: rgba(30, 41, 59, 0.8);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.service-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.service-card[data-status="UP"] .status-dot {
    background-color: var(--status-up);
    box-shadow: 0 0 8px var(--status-up);
}

.service-card[data-status="UP"] .status-text {
    color: var(--status-up);
}

.service-card[data-status="DOWN"] .status-dot {
    background-color: var(--status-down);
    box-shadow: 0 0 8px var(--status-down);
}

.service-card[data-status="DOWN"] .status-text {
    color: var(--status-down);
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.metric {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.metric-label {
    color: var(--text-secondary);
}

.metric-value {
    font-family: monospace;
    color: var(--text-primary);
}

.card-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.75rem;
}

.history-container {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 30px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.history-bar {
    flex: 1;
    min-width: 4px;
    border-radius: 2px;
    transition: all 0.2s;
    position: relative;
    opacity: 0.7;
}

.history-bar.up {
    background-color: var(--status-up);
    height: 100%;
}

.history-bar.down {
    background-color: var(--status-down);
    height: 30%;
}

.history-bar:hover {
    opacity: 1;
    cursor: pointer;
}

.history-bar .tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.7rem;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-bar:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.footer-meta {
    text-align: right;
}

/* Animations loading state */
.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 1em;
    width: 100%;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

footer {
    margin-top: 4rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
}

/* ==== Daily history bars (card footer) ==== */
.history-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.day-bar {
    flex: 1;
    min-width: 5px;
    border-radius: 2px;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    position: relative;
    opacity: 0.75;
}

.day-bar.up {
    background-color: var(--status-up);
    height: 100%;
}

.day-bar.down {
    background-color: var(--status-down);
    height: 100%;
}

.day-bar.no-data {
    background-color: rgba(255, 255, 255, 0.1);
    height: 100%;
    cursor: default;
}

.day-bar:hover {
    opacity: 1;
    transform: scaleY(1.1);
}

.day-bar .tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.7rem;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.day-bar:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* ==== Drill-down Modal ==== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    width: min(760px, 95vw);
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 1rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.modal-close-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-checks-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
}

.check-row.up {
    border-left: 3px solid var(--status-up);
}

.check-row.down {
    border-left: 3px solid var(--status-down);
}

.check-row .check-time {
    flex: 1;
    color: var(--text-secondary);
}

.check-row .check-status {
    font-weight: 700;
    min-width: 50px;
}

.check-row.up .check-status {
    color: var(--status-up);
}

.check-row.down .check-status {
    color: var(--status-down);
}

.check-row .check-rt {
    font-family: monospace;
    color: var(--text-primary);
}

/* ==== 15-min slot timeline (modal) ==== */
.slot-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.slot-row {
    display: flex;
    align-items: stretch;
    gap: 1px;
    height: 28px;
    margin-bottom: 0.5rem;
}

.slot-bar {
    flex: 1;
    border-radius: 2px;
    position: relative;
    cursor: default;
    transition: opacity 0.15s;
    opacity: 0.8;
}

.slot-bar.up {
    background-color: var(--status-up);
}

.slot-bar.down {
    background-color: var(--status-down);
    cursor: pointer;
}

.slot-bar.no-data {
    background-color: rgba(255, 255, 255, 0.07);
}

.slot-bar:hover {
    opacity: 1;
}

.slot-bar .tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.7rem;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.slot-bar:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.slot-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.75rem 0 1rem;
}

.slot-summary strong {
    color: var(--text-primary);
}

.slot-down-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.modal-checks-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 260px;
    overflow-y: auto;
}