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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ECECEE;
    min-height: 100vh;
}

/* Compact Sticky header */
.header-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #141C36;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

header {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.logo-container {
    flex-shrink: 0;
}

.percipio-logo {
    height: 28px;
    width: auto;
}

/* Status Summary */
.status-summary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.status-summary .status-indicator {
    font-size: 1.3em;
    line-height: 1;
}

.status-summary.status-operational {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.status-summary.status-operational .status-indicator {
    color: #28a745;
}

.status-summary.status-impaired {
    background: #ffedd5;
    color: #9a3412;
    border: 2px solid #fed7aa;
}

.status-summary.status-impaired .status-indicator {
    color: #c2410c;
}

.status-summary.status-down {
    background: #fff5f7;
    color: #8a1e36;
    border: 2px solid #ffcdd7;
}

.status-summary.status-down .status-indicator {
    color: #FF375A;
}

.status-summary.status-maintenance {
    background: #e8f2ff;
    color: #2c5aa0;
    border: 2px solid #b3d1ff;
}

.status-summary.status-maintenance .status-indicator {
    color: #5B8DEE;
}

/* Region Selector */
.region-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.region-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.region-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.region-btn.active {
    background: white;
    color: #141C36;
    border-color: white;
}

/* Content container */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
}

/* Page intro/description */
.page-intro {
    text-align: center;
    padding: 24px 30px 0 30px;
    background: white;
}

.page-intro p {
    color: #6c757d;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

/* Feature Status List */
.features-section {
    padding: 30px;
}

.section-title {
    font-size: 1.3rem;
    margin-bottom: 24px;
    color: #141C36;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 24px;
    background: #6b7280;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Status Legend */
.status-legend {
    background: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.legend-icon.operational {
    background: #28a745;
    color: white;
}

.legend-icon.impaired {
    background: #c2410c;
    color: white;
}

.legend-icon.down {
    background: #FF375A;
    color: white;
}

.legend-icon.maintenance {
    background: #5B8DEE;
    color: white;
}

/* Feature Grid - 2 columns */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.feature-card {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.status-icon.operational {
    background: #28a745;
    color: white;
}

.status-icon.impaired {
    background: #c2410c;
    color: white;
}

.status-icon.down {
    background: #FF375A;
    color: white;
}

.status-icon.maintenance {
    background: #5B8DEE;
    color: white;
}

.feature-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.feature-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.operational {
    background: #28a745;
}

.status-dot.impaired {
    background: #c2410c;
}

.status-dot.down {
    background: #FF375A;
}

.status-dot.maintenance {
    background: #5B8DEE;
}

.status-text.operational {
    color: #28a745;
}

.status-text.impaired {
    color: #9a3412;
}

.status-text.down {
    color: #FF375A;
}

.status-text.maintenance {
    color: #5B8DEE;
}

/* Active Incidents Section */
.active-incidents-section {
    padding: 30px;
    padding-top: 40px;
    padding-bottom: 0;
}

.active-incidents-group {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.active-incidents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: #fff;
    border-bottom: 2px solid #e9ecef;
}

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

.active-icon {
    font-size: 28px;
}

.active-badge {
    background: #FF375A;
    color: white;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
}

.active-incidents-content {
    padding: 20px;
}

/* No active incidents message */
.no-active-message {
    padding: 32px;
    text-align: center;
    background: #f0fdf4;
    border-left: 4px solid #28a745;
    border-radius: 4px;
}

.no-active-message .check-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

.no-active-message h3 {
    color: #166534;
    font-size: 1.2rem;
    margin: 0 0 8px 0;
}

.no-active-message p {
    color: #15803d;
    margin: 0;
    font-size: 0.95rem;
}

/* Collapsible Month Groups */
.incidents-section {
    padding: 30px;
    background: transparent;
}

.month-group {
    margin-bottom: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.month-header:hover {
    background: #f8f9fa;
}

.month-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
}

.month-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #6c757d;
}

.incident-count {
    background: #e9ecef;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.collapse-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.month-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.month-group.expanded .month-content {
    max-height: 3000px;
}

.month-group.expanded .collapse-icon {
    transform: rotate(180deg);
}

.incidents-list {
    padding: 20px;
}

/* Individual Incidents - Base Styles */
.incident {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 4px;
    background: #fafbfc;
}

.incident:last-child {
    margin-bottom: 0;
}

/* Active Incidents - Full colored borders (all sides) */
.incidents-list .incident {
    border: 1px solid #e1e4e8;
    background: white;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.incidents-list .incident:last-child {
    margin-bottom: 0;
}

.incidents-list .incident.impaired {
    border: 2px solid #c2410c;
}

.incidents-list .incident.down {
    border: 2px solid #FF375A;
}

.incidents-list .incident.operational {
    border: 2px solid #28a745;
}

.incidents-list .incident.maintenance {
    border: 2px solid #5B8DEE;
}

/* Incident History - Grey left border only */
.incidents-section .incident {
    border: 1px solid #e1e4e8 !important;
    border-left: 4px solid #d1d5db !important;
}

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

.incident-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}

.incident-id {
    background: #e9ecef;
    color: #495057;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    border: 1px solid #dee2e6;
}

.incident-meta {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.incident-description {
    color: #495057;
    line-height: 1.6;
}

.incident-resolved {
    margin-top: 12px;
    padding: 8px 12px;
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Incident Updates Timeline */
.incident-updates {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.updates-title {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    color: #666;
    font-weight: 600;
}

.incident-update-item {
    margin-bottom: 10px;
    padding-left: 15px;
    border-left: 3px solid #ddd;
}

.update-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.update-time {
    font-size: 0.85em;
    color: #888;
}

.update-severity {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.update-severity.down {
    background: #FF375A;
    color: white;
}

.update-severity.impaired {
    background: #c2410c;
    color: white;
}

.update-severity.operational {
    background: #28a745;
    color: white;
}

.update-severity.maintenance {
    background: #5B8DEE;
    color: white;
}

.update-description {
    margin: 0;
    font-size: 0.9em;
    color: #495057;
}

.no-incidents {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 1.1rem;
}

.error {
    text-align: center;
    color: #dc3545;
    padding: 20px;
}

@media (max-width: 768px) {
    header {
        flex-wrap: wrap;
        padding: 12px 20px;
    }

    .logo-container {
        order: 1;
    }

    .region-selector {
        order: 2;
    }

    .status-summary {
        order: 3;
        width: 100%;
        margin: 8px 0 0 0;
        max-width: 100%;
        font-size: 0.85rem;
    }

    .percipio-logo {
        height: 28px;
    }
    
    .region-btn {
        padding: 5px 12px;
        font-size: 0.75rem;
    }
    
    .region-label {
        font-size: 0.8rem;
    }
    
    .page-intro {
        padding: 20px;
    }
    
    .page-intro p {
        font-size: 0.9rem;
    }
    
    .features-section {
        padding: 20px;
    }
    
    .active-incidents-section {
        padding: 20px;
        padding-top: 30px;
    }
    
    .incidents-section {
        padding: 20px;
    }
    
    .incident-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .feature-card {
        flex-direction: row;
        align-items: center;
    }
    
    .status-legend {
        gap: 16px;
        padding: 12px 16px;
    }
    
    .month-header {
        padding: 12px 16px;
    }
    
    .month-title {
        font-size: 1.1rem;
    }
    
    .incidents-list {
        padding: 16px;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
}

/* Mobile - very small screens */
@media (max-width: 480px) {
    /* Stack header vertically on very small screens */
    header {
        flex-direction: column;
        gap: 12px;
        padding: 15px;
    }
    
    .logo-container {
        width: 100%;
        text-align: center;
        order: 1;
    }
    
    .status-summary {
        width: 100%;
        text-align: center;
        padding: 10px 15px;
        order: 2;
    }
    
    .region-selector-container {
        width: 100%;
        justify-content: center;
        order: 3;
    }
    
    /* Reduce container padding further */
    .container {
        padding: 0 15px 20px 15px;
    }
    
    /* Reduce section padding */
    .features-section,
    .incidents-section {
        padding: 15px;
    }
    
    .active-incidents-section {
        padding: 15px;
        padding-top: 25px;
    }
    
    /* Reduce incident card padding */
    .incident {
        padding: 15px;
        margin: 8px;
    }
    
    /* Smaller page intro text */
    .page-intro p {
        font-size: 0.9rem;
    }
}

/* ============================================
   DARK MODE STYLES
   Automatically respects user's system preference
   ============================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: #0d1117;
        color: #c9d1d9;
    }

    /* Status summary - high contrast for dark mode */
    .status-summary.status-operational {
        background: #0d2818;
        color: #a3f3a3;
        border-color: #3fb950;
        font-weight: 700;
    }

    .status-summary.status-operational .status-indicator {
        color: #a3f3a3;
        font-weight: 700;
    }

    .status-summary.status-impaired {
        background: #431407;
        color: #fdba74;
        border-color: #c2410c;
        font-weight: 700;
    }

    .status-summary.status-impaired .status-indicator {
        color: #fb923c;
        font-weight: 700;
    }

    .status-summary.status-down {
        background: #3d0c0c;
        color: #ff9b9b;
        border-color: #da3633;
        font-weight: 700;
    }

    .status-summary.status-down .status-indicator {
        color: #ff9b9b;
        font-weight: 700;
    }

    .status-summary.status-maintenance {
        background: #0f1e36;
        color: #a3ccff;
        border-color: #58a6ff;
        font-weight: 700;
    }

    .status-summary.status-maintenance .status-indicator {
        color: #a3ccff;
        font-weight: 700;
    }

    /* Content container */
    .container {
        background: #161b22;
    }

    /* Page intro */
    .page-intro {
        background: #161b22;
    }

    .page-intro p {
        color: #8b949e;
    }

    /* Section titles */
    .section-title {
        color: #c9d1d9;
    }
    
    .section-title::before {
        background: #9ca3af;
    }
    
    /* Status Legend */
    .status-legend {
        background: #161b22;
        border-color: #30363d;
    }
    
    .legend-item {
        color: #c9d1d9;
    }

    /* Feature cards */
    .feature-card {
        background: #0d1117;
        border-color: #30363d;
    }
    
    .feature-name {
        color: #c9d1d9;
    }

    .feature-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    }

    .feature-card.impaired {
        border-left-color: #c2410c;
        background: #431407;
    }

    .feature-card.down {
        border-left-color: #da3633;
        background: #2a1616;
    }

    .feature-card.maintenance {
        border-left-color: #58a6ff;
        background: #1c2430;
    }

    .feature-name {
        color: #c9d1d9;
    }

    /* Status text in feature cards - default operational color */
    .feature-card .status-text {
        color: #7ee787;
    }

    .feature-card .status-text.impaired {
        color: #fb923c;
    }

    .feature-card .status-text.down {
        color: #ff7b72;
    }

    .feature-card .status-text.maintenance {
        color: #79c0ff;
    }

    /* Active Incidents Section - Dark Mode */
    .active-incidents-group {
        background: #21262d;
    }
    
    .active-incidents-header {
        background: #21262d;
        border-bottom-color: #30363d;
    }
    
    .active-incidents-content {
        background: #21262d;
    }
    
    .no-active-message {
        background: #0d2818;
        border-left-color: #3fb950;
    }
    
    .no-active-message h3 {
        color: #a3f3a3;
    }
    
    .no-active-message p {
        color: #7ee787;
    }

    /* Incidents section */
    .incidents-section {
        background: transparent;
    }

    /* Month groups */
    .month-group {
        background: #21262d;
        box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }

    .month-header {
        background: #21262d;
        border-bottom-color: #30363d;
    }

    .month-header:hover {
        background: #2a2f38;
    }

    .month-title {
        color: #c9d1d9;
    }

    .month-meta {
        color: #8b949e;
    }

    .incident-count {
        background: #30363d;
        color: #c9d1d9;
    }

    /* Individual incidents - base dark mode */
    .incident {
        background: #161b22;
    }
    
    /* Keep grey borders for history in dark mode */
    .incidents-section .incident {
        border: 1px solid #30363d !important;
        border-left: 4px solid #30363d !important;
    }
    
    /* But preserve colored borders for active incidents in dark mode */
    .incidents-list .incident {
        background: #0d1117;
    }
    
    .incidents-list .incident.impaired {
        border-color: #c2410c;
    }
    
    .incidents-list .incident.down {
        border-color: #FF375A;
    }
    
    .incidents-list .incident.operational {
        border-color: #28a745;
    }
    
    .incidents-list .incident.maintenance {
        border-color: #5B8DEE;
    }

    .incident-title {
        color: #c9d1d9;
    }

    .incident-id {
        background: #21262d;
        color: #c9d1d9;
        border-color: #30363d;
    }

    .incident-meta {
        color: #8b949e;
    }

    .incident-description {
        color: #8b949e;
    }

    .incident-resolved {
        background: #1a472a;
        color: #7ee787;
    }

    /* Incident updates */
    .incident-updates {
        border-top-color: #30363d;
    }

    .updates-title {
        color: #8b949e;
    }

    .incident-update-item {
        border-left-color: #30363d;
    }

    .update-time {
        color: #8b949e;
    }

    .update-description {
        color: #8b949e;
    }

    /* No incidents message */
    .no-incidents {
        color: #8b949e;
    }

    /* Error message */
    .error {
        color: #ff7b72;
    }
}
