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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a1929;
    color: #fff;
    overflow-x: hidden;
}

.header {
    background: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.header h1 {
    font-size: 28px;
    margin: 0 0 8px 0;
}

.header p {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

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

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    color: #60a5fa;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid #60a5fa;
    border-radius: 6px;
    transition: all 0.2s;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.nav-link:hover {
    background: #60a5fa;
    color: #fff;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    border: 1px solid #60a5fa;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #1e293b;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
    border-radius: 6px;
    z-index: 1001;
    border: 1px solid #334155;
}

.dropdown-content::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 0;
    right: 0;
    height: 6px;
}

.dropdown-content a {
    color: #60a5fa;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    transition: background 0.2s;
}

.dropdown-content a:first-child {
    border-radius: 6px 6px 0 0;
}

.dropdown-content a:last-child {
    border-radius: 0 0 6px 6px;
}

.dropdown-content a:hover {
    background: #334155;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.header-status {
    text-align: right;
    color: #94a3b8;
    font-size: 12px;
}

.header-status #update-time {
    color: #60a5fa;
    font-weight: bold;
    font-size: 14px;
    margin-top: 4px;
}

.container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    padding: 20px;
}

.sidebar {
    background: #1e293b;
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #334155;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #60a5fa;
}

.stat-label {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
}

#map {
    height: 700px;
    min-height: 700px;
    max-height: 700px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    background: #0f172a;
    flex-shrink: 0;
    position: relative;
}

.home-button {
    background: #1e293b;
    border: 2px solid #60a5fa;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-button:hover {
    background: #60a5fa;
    transform: scale(1.05);
}

.home-button:active {
    transform: scale(0.95);
}

.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    background: #1e293b;
    border-radius: 12px;
    padding: 20px;
    min-height: 400px;
    max-height: 400px;
    overflow: hidden;
}

.chart-container {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
}

.chart-container canvas {
    flex: 1;
    max-height: 320px;
    max-width: 100%;
}

.chart-container h3 {
    margin-bottom: 10px;
    font-size: 16px;
    color: #94a3b8;
}

.event-list {
    max-height: 400px;
    overflow-y: auto;
}

.event-item {
    background: #334155;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}

.event-item.clickable {
    cursor: pointer;
    transition: background 0.2s;
}

.event-item.clickable:hover {
    background: #475569;
}

.event-item .ship-name {
    font-weight: bold;
    color: #60a5fa;
}

.event-item .time {
    color: #94a3b8;
    font-size: 11px;
}

.direction-ew {
    color: #fbbf24;
}

.direction-we {
    color: #34d399;
}

.section-title {
    font-size: 18px;
    margin: 20px 0 12px 0;
    color: #94a3b8;
}

.info-text {
    font-size: 11px;
    color: #64748b;
    margin: -8px 0 8px 0;
    font-style: italic;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0f172a;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.loading {
    text-align: center;
    color: #94a3b8;
    padding: 20px;
}

#weather-card {
    text-align: left;
    font-size: 13px;
}

#weather-card > div {
    margin-bottom: 8px;
}

#weather-card > div:last-child {
    color: #94a3b8;
    font-size: 11px;
    margin-top: 10px;
    margin-bottom: 0;
}

.legend-box {
    background: #1e293b;
    font-size: 14px;
    line-height: 1.8;
}

.legend-box > div:last-child {
    margin-top: 10px;
    color: #94a3b8;
    font-size: 13px;
}

.ship-marker {
    background: transparent !important;
    border: none !important;
}

.stationary-ship {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        filter: drop-shadow(0 0 0 rgba(251, 191, 36, 0));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.8));
    }
}

/* Statistics Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.modal-body {
    padding: 24px;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-item .stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #60a5fa;
    margin-bottom: 8px;
}

.stat-item .stat-label {
    font-size: 13px;
    color: #94a3b8;
}

.modal-body h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #e2e8f0;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.stats-table thead {
    background: rgba(59, 130, 246, 0.1);
}

.stats-table th {
    padding: 12px;
    text-align: left;
    font-size: 13px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-table td {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.stats-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.stats-table td:first-child {
    font-weight: bold;
    color: #60a5fa;
    width: 40px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 15px;
    }

    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 22px;
    }

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

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .nav-links {
        gap: 8px;
    }

    .nav-link {
        font-size: 12px;
        padding: 4px 8px;
    }

    .sidebar {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-label {
        font-size: 11px;
    }

    #map {
        height: 400px;
        min-height: 400px;
        max-height: 400px;
    }

    .charts {
        grid-template-columns: 1fr;
        padding: 15px;
        min-height: auto;
        max-height: none;
    }

    .chart-container canvas {
        max-height: 250px;
    }

    .event-list {
        max-height: 300px;
    }

    .event-item {
        padding: 10px;
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-body {
        padding: 16px;
    }

    .stats-summary {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-item {
        padding: 15px;
    }

    .stat-item .stat-value {
        font-size: 24px;
    }

    .stats-table {
        font-size: 12px;
    }

    .stats-table th,
    .stats-table td {
        padding: 8px 6px;
    }
}

