:root {
    --bg: #faf9f6;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f4f1;
    --border: #e2e0d9;
    --text: #1a1a19;
    --text-muted: #6b6a64;
    --text-dim: #9b9a93;
    --green: #3db86a;
    --green-bg: rgba(61, 184, 106, 0.08);
    --yellow: #e6a82a;
    --yellow-bg: rgba(230, 168, 42, 0.08);
    --orange: #e86235;
    --orange-bg: rgba(232, 98, 53, 0.08);
    --red: #e04343;
    --red-bg: rgba(224, 67, 67, 0.08);
    --blue: #2c84db;
    --blue-bg: rgba(44, 132, 219, 0.08);
    --purple: #7c5cbf;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s ease;
    --no-data: #d1d0cb;
}

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

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 32px;
}

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

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

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.logo-sub {
    font-weight: 400;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-updated {
    font-size: 14px;
    color: var(--text-dim);
}

.btn-refresh {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.btn-refresh:hover {
    background: var(--bg-card-hover);
    color: var(--text);
    border-color: var(--text-dim);
}

/* Overall Status Banner */
.overall-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.overall-status.operational {
    background: var(--green-bg);
    border-color: rgba(61, 184, 106, 0.2);
}

.overall-status.degraded {
    background: var(--yellow-bg);
    border-color: rgba(230, 168, 42, 0.2);
}

.overall-status.partial_outage {
    background: var(--orange-bg);
    border-color: rgba(232, 98, 53, 0.2);
}

.overall-status.major_outage {
    background: var(--red-bg);
    border-color: rgba(224, 67, 67, 0.2);
}

.overall-status.maintenance {
    background: var(--blue-bg);
    border-color: rgba(44, 132, 219, 0.2);
}

.overall-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.overall-text {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Service List */
.service-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 48px;
}

.category {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
    transition: border-color var(--transition);
    position: relative;
}

.category:hover {
    border-color: #ccc9c0;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.01);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.category-header:hover {
    background: rgba(0,0,0,0.02);
}

.collapse-chevron {
    margin-left: 8px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
    color: var(--text-dim);
}

.category.collapsed .collapse-chevron {
    transform: rotate(-90deg);
}

.category-body {
    overflow: visible;
    max-height: none;
    transition: opacity 0.25s ease;
    opacity: 1;
}

.category.collapsed .category-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    display: none;
}

.category.collapsed .category-header {
    border-bottom-color: transparent;
}

.category-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: rgba(124, 92, 191, 0.08);
    color: var(--purple);
}

.category-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.category-badge {
    margin-left: auto;
    font-size: 13px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
}

.service-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: background var(--transition);
}

.service-item:last-child {
    border-bottom: none;
}

.service-item:hover {
    background: rgba(0,0,0,0.015);
}

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

.service-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

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

/* Uptime Timeline */
.category-timeline {
    padding: 12px 20px 16px;
    border-bottom: 1px solid var(--border);
    overflow: visible;
    position: relative;
}

.service-timeline {
    padding: 4px 20px 14px;
    overflow: visible;
    position: relative;
}

.timeline-bar {
    display: flex;
    gap: 2px;
    height: 30px;
    position: relative;
}

.timeline-day {
    flex: 1;
    border-radius: 2px;
    min-width: 0;
    cursor: pointer;
    transition: opacity 0.15s ease;
    position: relative;
    z-index: 1;
}

.timeline-day:hover {
    opacity: 0.75;
    z-index: 9999;
}

.timeline-day.tl-operational { background: var(--green); }
.timeline-day.tl-degraded { background: var(--yellow); }
.timeline-day.tl-partial_outage { background: var(--orange); }
.timeline-day.tl-major_outage { background: var(--red); }
.timeline-day.tl-maintenance { background: var(--blue); }
.timeline-day.tl-no_data { background: var(--no-data); }

.timeline-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-dim);
}

.timeline-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text);
    font-size: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    pointer-events: none;
    min-width: 180px;
    white-space: nowrap;
}

.timeline-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
}

.timeline-day:hover .timeline-tooltip {
    display: block;
}

/* Keep tooltip on screen */
.timeline-day:nth-child(-n+5):hover .timeline-tooltip {
    left: 0;
    transform: none;
}
.timeline-day:nth-child(-n+5):hover .timeline-tooltip::after {
    left: 8px;
    transform: none;
}
.timeline-day:nth-last-child(-n+5):hover .timeline-tooltip {
    left: auto;
    right: 0;
    transform: none;
}
.timeline-day:nth-last-child(-n+5):hover .timeline-tooltip::after {
    left: auto;
    right: 8px;
    transform: none;
}

.tt-date {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text);
}

.tt-status {
    font-size: 12px;
    font-weight: 500;
}

.tt-status.tt-operational { color: var(--green); }
.tt-status.tt-major_outage { color: var(--red); }
.tt-status.tt-partial_outage { color: var(--orange); }
.tt-status.tt-degraded { color: var(--yellow); }
.tt-status.tt-no_data { color: var(--text-dim); }

.tt-incident {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.tt-severity {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 1px 6px;
    border-radius: 3px;
}

.tt-sev-critical { color: var(--red); background: var(--red-bg); }
.tt-sev-major { color: var(--orange); background: var(--orange-bg); }
.tt-sev-minor { color: var(--yellow); background: var(--yellow-bg); }

.tt-duration {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.tt-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

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

/* Status Colors */
.status-operational .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-operational { color: var(--green); background: var(--green-bg); }

.status-degraded .status-dot { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-degraded { color: var(--yellow); background: var(--yellow-bg); }

.status-partial_outage .status-dot { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.status-partial_outage { color: var(--orange); background: var(--orange-bg); }

.status-major_outage .status-dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-major_outage { color: var(--red); background: var(--red-bg); }

.status-maintenance .status-dot { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.status-maintenance { color: var(--blue); background: var(--blue-bg); }

/* Category badge colors */
.badge-operational { color: var(--green); background: var(--green-bg); }
.badge-degraded { color: var(--yellow); background: var(--yellow-bg); }
.badge-partial_outage { color: var(--orange); background: var(--orange-bg); }
.badge-major_outage { color: var(--red); background: var(--red-bg); }
.badge-maintenance { color: var(--blue); background: var(--blue-bg); }

/* Active Incidents (top banner) */
.active-incidents-section {
    margin-bottom: 32px;
}

.active-incidents-section .section-title {
    color: var(--red);
}

.incident-active {
    border-left: 3px solid var(--orange);
}

.incident-active-critical {
    border-left-color: var(--red);
    background: rgba(224, 67, 67, 0.05);
}

.incident-active-major {
    border-left-color: var(--orange);
    background: rgba(232, 98, 53, 0.05);
}

.incident-active-minor {
    border-left-color: var(--yellow);
    background: rgba(230, 168, 42, 0.05);
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    animation: pulse 1.5s ease-in-out infinite;
}

.pulse-critical { background: var(--red); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
.pulse-major { background: var(--orange); box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.6); }
.pulse-minor { background: var(--yellow); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    70% { box-shadow: 0 0 0 8px transparent; opacity: 0.7; }
    100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

/* Incidents */
.incidents-section {
    margin-bottom: 48px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.incident-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.incident-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color var(--transition);
}

.incident-card:hover {
    border-color: #ccc9c0;
}

.incident-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.incident-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.incident-severity {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.severity-minor { color: var(--yellow); background: var(--yellow-bg); }
.severity-major { color: var(--orange); background: var(--orange-bg); }
.severity-critical { color: var(--red); background: var(--red-bg); }

.incident-meta {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.incident-affected {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.affected-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(124, 92, 191, 0.06);
    color: var(--purple);
    border: 1px solid rgba(124, 92, 191, 0.12);
}

.incident-updates {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.incident-update {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
}

.update-time {
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 80px;
    font-size: 12px;
}

.update-status {
    font-weight: 600;
    text-transform: capitalize;
    min-width: 90px;
}

.update-message {
    color: var(--text-muted);
    flex: 1;
}

.no-incidents {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-dim);
    font-size: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.no-incidents-icon {
    font-size: 28px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-dim);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

.footer p {
    font-size: 14px;
    color: var(--text-dim);
}

.footer-sub {
    margin-top: 4px;
    font-size: 13px !important;
    opacity: 0.5;
}

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

    .header {
        padding: 24px 0 16px;
    }

    .logo {
        font-size: 18px;
    }

    .overall-status {
        padding: 16px;
    }

    .overall-text {
        font-size: 16px;
    }

    .service-item {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .status-badge {
        font-size: 12px;
    }

    .category-header {
        padding: 12px 16px;
    }

    .incident-header {
        flex-direction: column;
    }

    .incident-update {
        flex-direction: column;
        gap: 4px;
    }

    .service-timeline {
        padding: 4px 16px 12px;
    }

    .timeline-bar {
        height: 24px;
    }
}

/* ========== ADMIN STYLES ========== */
.admin-container {
    max-width: 1100px;
}

.admin-nav {
    display: flex;
    gap: 8px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.admin-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.admin-nav a:hover, .admin-nav a.active {
    color: var(--text);
    background: var(--bg-card);
}

.login-box {
    max-width: 400px;
    margin: 80px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.login-box h2 {
    font-size: 20px;
    margin-bottom: 24px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--purple);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--purple);
    color: white;
}

.btn-primary:hover {
    background: #7c3aed;
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text);
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

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

.admin-card-title {
    font-size: 16px;
    font-weight: 600;
}

.admin-service-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-wrap: wrap;
}

.admin-service-row:last-child {
    border-bottom: none;
}

.admin-service-name {
    flex: 1;
    font-size: 14px;
    min-width: 150px;
}

.admin-service-row select {
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.toast-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.incident-status-tag {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
}

.tag-investigating { color: var(--yellow); background: var(--yellow-bg); }
.tag-identified { color: var(--orange); background: var(--orange-bg); }
.tag-monitoring { color: var(--blue); background: var(--blue-bg); }
.tag-resolved { color: var(--green); background: var(--green-bg); }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-grid input[type="checkbox"] {
    width: auto;
    accent-color: var(--purple);
}
