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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header h1 {
    font-size: 1.8em;
    margin-bottom: 8px;
}

.header p {
    opacity: 0.9;
    font-size: 1em;
}

.controls {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.view-mode-controls,
.date-controls,
.date-picker-controls,
.compare-dates-controls,
.maturity-controls,
.action-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.compare-dates-controls,
.event-analysis-controls {
    width: 100%;
    justify-content: space-around;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 6px;
    margin-top: 10px;
}

.event-analysis-controls {
    flex-direction: column;
    align-items: flex-start;
}

.event-date-picker-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    max-width: 500px;
}

.event-date-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-input-hint {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
    padding: 4px 0;
    line-height: 1.4;
}

.event-suggestions {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
}

.event-suggestions:hover {
    border-color: #5568d3;
    background: #f8f9fa;
}

.event-suggestions:focus {
    outline: none;
    border-color: #5568d3;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.event-info {
    margin-top: 10px;
    padding: 8px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
    font-size: 0.9em;
    color: #1976d2;
}

.event-info p {
    margin: 0 0 8px 0;
}

.event-info p:last-child {
    margin-bottom: 0;
}

.event-reference {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(25, 118, 210, 0.2);
}

.event-reference small {
    font-size: 0.85em;
    line-height: 1.5;
}

.event-reference a {
    color: #1565c0;
    text-decoration: underline;
}

.event-reference a:hover {
    color: #0d47a1;
    text-decoration: none;
}

.date-picker-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 200px;
}

.quick-date-btn {
    padding: 6px 12px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    margin-top: 5px;
}

.quick-date-btn:hover {
    background: #667eea;
    color: white;
}

.date-error {
    font-size: 0.75em;
    min-height: 16px;
    margin-top: 4px;
}

.date-error-text {
    color: #dc3545;
}

.date-warning {
    color: #ffc107;
}

.date-controls strong,
.maturity-controls strong {
    min-width: 100px;
}

.maturity-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.maturity-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.maturity-checkbox-label:hover {
    background: #f0f0f0;
    border-color: #667eea;
}

.maturity-checkbox-label input[type="checkbox"] {
    margin-right: 4px;
    cursor: pointer;
}

.view-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.view-btn:hover {
    background: #f8f9fa;
}

.view-btn.active {
    background: #667eea;
    color: white;
}

#date-selector {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 0.9em;
}

.refresh-btn,
.download-btn {
    padding: 10px 20px;
    border: none;
    background: #28a745;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-btn:hover,
.download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.refresh-btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.download-btn {
    background: #667eea;
}

.download-btn:hover {
    background: #5568d3;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.status {
    padding: 15px 20px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    margin: 0 20px;
    margin-top: 15px;
    border-radius: 4px;
    display: none;
}

.status.error {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.status.success {
    background: #d4edda;
    border-left-color: #28a745;
    color: #155724;
}

.stats-info {
    padding: 15px 20px;
    background: #e9ecef;
    color: #495057;
    font-size: 0.9em;
}

.chart-container {
    padding: 20px;
}

.chart-wrapper {
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.chart-wrapper h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

canvas {
    max-width: 100%;
    height: 400px !important;
}

.loading-spinner {
    text-align: center;
    padding: 60px;
    font-size: 1.2em;
    color: #667eea;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.table-container {
    padding: 20px;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    min-width: 600px;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

th.number {
    text-align: right;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: #f8f9fa;
    transition: background 0.2s;
}

tbody tr:last-child td {
    border-bottom: none;
}

.number {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.empty-cell {
    color: #999;
    font-style: italic;
}

.attribution {
    padding: 20px;
    background: #f8f9fa;
    border-top: 2px solid #e0e0e0;
    margin-top: 20px;
    font-size: 0.85em;
    color: #495057;
    line-height: 1.6;
}

.attribution h3 {
    font-size: 1em;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

.attribution p {
    margin: 5px 0;
}

.attribution a {
    color: #667eea;
    text-decoration: none;
}

.attribution a:hover {
    text-decoration: underline;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .header p {
        font-size: 0.9em;
    }

    .controls {
        padding: 10px;
    }

    .view-mode-controls,
    .date-controls,
    .date-picker-controls,
    .compare-dates-controls,
    .maturity-controls,
    .action-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .compare-dates-controls,
    .event-analysis-controls {
        flex-direction: column;
    }
    
    .date-picker-group,
    .event-date-picker-group {
        width: 100%;
    }

    .date-controls strong,
    .maturity-controls strong {
        min-width: auto;
    }

    .maturity-checkboxes {
        width: 100%;
    }

    .maturity-checkbox-label {
        flex: 1 1 auto;
        min-width: 120px;
    }

    .view-btn,
    .refresh-btn,
    .download-btn {
        width: 100%;
        justify-content: center;
    }

    #date-selector {
        width: 100%;
    }

    canvas {
        height: 300px !important;
    }

    .chart-container {
        padding: 15px;
    }

    .table-container {
        padding: 15px;
    }

    table {
        font-size: 0.85em;
    }

    th, td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3em;
    }

    canvas {
        height: 250px !important;
    }
}

