:root {
    /* Brand Colors */
    --color-primary: #0064C8;
    --color-secondary: #0046A0;
    --color-primary-gradient: linear-gradient(90deg, #002D72 0%, #00509D 100%);
    
    /* Cloud Provider Colors */
    --color-aws: #FF9900;
    --color-azure: #0078D4;
    --color-gcp: #4285F4;
    --color-alibaba: #FF6900;
    --color-huawei: #FF0000;
    --color-tencent: #00A4FF;
    --color-baidu: #2932E1;
    
    /* UI Colors */
    --bg-body: #f5f5f5;
    --bg-white: #ffffff;
    --bg-dark: #0a0e27;
    --bg-map: #e8f4f8;
    --bg-hover: #f8f9fa;
    --bg-selected: #e3f2fd;
    
    --text-main: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --text-white: #ffffff;
    
    --border-color: #e0e0e0;
    --border-light: #eeeeee;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Layout */
    --sidebar-width: 350px;
    --header-height: auto;
    
    /* Z-Index */
    --z-legend: 100;
    --z-sidebar: 100;
    --z-popup: 2000;
    --z-loading: 1000;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll, manage in sub-containers */
}

.container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr;
    background: var(--bg-white);
}

/* Header */
header {
    background: var(--color-primary-gradient);
    color: var(--text-white);
    padding: var(--spacing-lg) var(--spacing-xl);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.notice-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    backdrop-filter: blur(6px);
}

@media (max-width: 768px) {
    .notice-banner {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    .github-link {
        width: 32px;
        height: 32px;
        margin-left: auto;
    }
    
    .header-title-row {
        position: relative;
        padding-right: 0;
    }
}

.notice-banner a {
    color: #FFECB3;
    text-decoration: underline;
}

.notice-banner a:hover {
    color: #ffffff;
}

.notice-banner .banner-icon {
    font-size: 1.05rem;
    line-height: 1;
    margin-top: 2px;
}

.notice-banner .banner-text {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    flex: 1;
}

.notice-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: var(--spacing-xs);
    line-height: 1;
    border-radius: 4px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.notice-close-btn:hover,
.notice-close-btn:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
    outline: none;
}

.notice-hidden {
    display: none !important;
}

.header-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    position: relative;
}

.github-link {
    /* Desktop: Positioned relative to flex container or absolute within header-title-row */
    color: var(--text-white);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    opacity: 0.8;
    transition: all 0.2s ease;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    z-index: 10;
}

@media (min-width: 769px) {
    .header-title-row {
        justify-content: flex-start; /* Title left, Github icon next to it or far right */
    }
    .header-title-row h1 {
        flex: 1;
    }
    .github-link {
        margin-left: var(--spacing-md);
    }
}

.github-link:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.github-link svg {
    fill: currentColor;
    width: 24px;
    height: 24px;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.view-mode-selector {
    display: flex;
    gap: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.1);
    padding: var(--spacing-xs);
    border-radius: 8px;
}

.view-mode-btn {
    background: transparent;
    border: none;
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.view-mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.view-mode-btn.active {
    background: var(--bg-white);
    color: var(--color-primary);
    font-weight: 600;
}

.filters {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.filter-select,
.filter-input {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-main);
    font-size: 0.9rem;
    min-width: 150px;
}

.filter-input {
    min-width: 200px;
}

.filter-select:focus,
.filter-input:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.filter-input::placeholder {
    color: var(--text-light);
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    overflow: hidden;
    position: relative;
}

main.full-width {
    grid-template-columns: 1fr;
}

.main-content {
    position: relative;
    height: 100%;
    overflow: hidden;
}

.view-container {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}

.view-container.active {
    display: block;
}

/* Globe View */
#globe-view {
    background: var(--bg-dark);
}

#globe-canvas {
    width: 100%;
    height: 100%;
}

.legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: var(--spacing-md);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    max-width: 200px;
    backdrop-filter: blur(10px);
    z-index: var(--z-legend);
}

.legend-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Map View */
#map-view {
    background: var(--bg-map);
}

#map {
    width: 100%;
    height: 100%;
}

/* Table View */
#table-view {
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
}

.table-container {
    padding: var(--spacing-xl);
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-header-wrapper {
    flex-shrink: 0;
    background: var(--bg-white);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    overflow-y: hidden;
}

.table-body-wrapper {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    background: var(--bg-white);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.table-header,
.table-body {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    table-layout: fixed;
}

.table-header thead tr {
    background: var(--color-primary-gradient);
}

.table-header th {
    background: transparent;
    color: var(--text-white);
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.table-body tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s ease;
    background: var(--bg-white);
}

.table-body td {
    padding: var(--spacing-md);
    font-size: 0.9rem;
    color: var(--text-main);
}

.table-body tbody tr:hover {
    background: var(--bg-hover);
}

.table-body tbody tr.selected {
    background: var(--bg-selected);
    border-left: 4px solid var(--color-primary);
}

/* Channels Tags */
.channels {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.channel-tag {
    background: var(--bg-selected);
    color: #1976d2; /* Keep specific blue for tags for now */
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Info Sidebar */
.info-sidebar {
    background: var(--bg-white);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-sidebar);
    overflow: hidden;
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--color-primary-gradient);
    color: var(--text-white);
    flex-shrink: 0;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-light);
    text-align: center;
    padding: var(--spacing-xl);
}

#region-info-content h3 {
    margin-top: 0;
    margin-bottom: var(--spacing-lg);
    color: var(--color-primary);
    font-size: 1.5rem;
    font-weight: 600;
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
    word-wrap: break-word;
}

.info-item {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.info-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.info-item label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item .value {
    font-size: 1rem;
    color: var(--text-main);
    word-wrap: break-word;
    line-height: 1.5;
}

/* Loading Indicator */
.globe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    z-index: var(--z-loading);
    pointer-events: none;
}

.globe-loading.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: var(--text-white);
    font-size: 1rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

/* Overlapping Popup */
.overlapping-popup {
    position: fixed;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: var(--z-popup);
    min-width: 280px;
    max-width: 90vw;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
}

.overlapping-popup.hidden {
    display: none;
}

.popup-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--color-primary-gradient);
    color: var(--text-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.popup-close-btn {
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.5rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    line-height: 1;
}

.popup-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-content {
    padding: var(--spacing-sm);
    overflow-y: auto;
}

.overlapping-marker-item {
    padding: 0.75rem var(--spacing-md);
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.overlapping-marker-item:hover {
    background: var(--bg-hover);
}

.overlapping-marker-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.overlapping-marker-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.overlapping-marker-provider {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Region Info Modal (mobile) */
.region-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-popup);
}

.region-modal.hidden {
    display: none;
}

.region-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.region-modal-content {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 24px);
    max-width: 520px;
    max-height: 80vh;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.region-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--color-primary-gradient);
    color: var(--text-white);
}

.region-modal-header h3 {
    margin: 0;
    font-size: 1rem;
}

.region-modal-close {
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.4rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.region-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.region-modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.region-modal-body .info-item {
    border-bottom: 1px solid var(--border-light);
}

.region-modal-body .info-item:last-child {
    border-bottom: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 300px;
    }

    main {
        grid-template-columns: 1fr;
    }

    .info-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Switch to column layout on mobile */
    .container {
        grid-template-rows: auto 1fr;
    }
    
    main {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr;
        grid-template-rows: none;
        height: 100%;
    }
    
    .info-sidebar {
        display: none; /* Use modal on mobile */
    }
    
    header h1 {
        font-size: 1.25rem;
        line-height: 1.3;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    
    .header-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .view-mode-selector,
    .filters,
    .filter-select,
    .filter-input {
        width: 100%;
    }
    
    .view-mode-selector {
        justify-content: center;
    }
    
    .main-content {
        position: relative;
        flex: 1 1 auto;
        min-height: 55vh;
        max-height: 70vh;
    }

    .view-container {
        height: 100%;
    }

    .table-container {
        padding: var(--spacing-md);
    }

    .table-header,
    .table-body {
        min-width: 720px;
    }

    .table-header-wrapper,
    .table-body-wrapper {
        -webkit-overflow-scrolling: touch;
    }

    .legend {
        left: 8px;
        right: 8px;
        bottom: 10px;
        transform: none;
        width: calc(100% - 16px);
        max-width: none;
        display: flex;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 0.25rem;
        padding: 4px 6px;
        overflow-x: auto;
    }

    .legend-title {
        width: auto;
        text-align: center;
        margin: 0;
        font-size: 0.6rem;
        letter-spacing: 0.05rem;
        padding-right: 4px;
    }

    .legend-item {
        margin-bottom: 0;
        font-size: 0.62rem;
        gap: 0.2rem;
    }

    .legend-color {
        width: 10px;
        height: 10px;
        border-width: 1px;
    }

    .overlapping-popup {
        width: 90vw;
        min-width: 0;
        max-height: 60vh;
        font-size: 0.85rem;
    }

    .popup-header h3 {
        font-size: 0.9rem;
    }

    .overlapping-marker-item {
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
    }
}

/* Globe Overlay Control */
.globe-overlay-control {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: var(--z-legend);
    background: rgba(255, 255, 255, 0.95);
    padding: var(--spacing-xs);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.globe-style-select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
}

.globe-style-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.globe-style-select option {
    background: var(--bg-white);
    color: var(--text-main);
}

@media (max-width: 768px) {
    .globe-overlay-control {
        top: 12px;
        right: 12px;
        left: auto;
        bottom: auto;
        transform: none;
        max-width: 180px;
        padding: 6px 10px;
    }

    .globe-style-select {
        font-size: 0.85rem;
        padding: 6px 10px;
    }
}
