* {
    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: 20px;
    color: #333;
}

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

header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header {
    position: relative;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

.settings-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.settings-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.controls {
    padding: 30px 40px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: #495057;
}

.control-group select,
.custom-range input,
.custom-range button {
    padding: 8px 16px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.control-group select:hover,
.custom-range input:hover,
.custom-range button:hover {
    border-color: #667eea;
}

.custom-range,
.event-range {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.event-range {
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-top: 10px;
}

.custom-range button,
.event-range button {
    background: #667eea;
    color: white;
    border-color: #667eea;
    font-weight: 600;
}

.custom-range button:hover,
.event-range button:hover {
    background: #5568d3;
}

.chart-config-section {
    padding: 40px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.chart-config-section h2 {
    color: #1e3c72;
    margin-bottom: 20px;
    font-size: 2em;
}

.compare-mode-toggle {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.compare-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    color: #495057;
}

.compare-mode-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.asset-config {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.asset-config h3 {
    color: #1e3c72;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.config-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
}

.compare-denominator-section {
    padding: 20px;
    background: #e9ecef;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #667eea;
}

.compare-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    position: relative;
}

.compare-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.update-button, .add-button {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.update-button:hover, .add-button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.add-button {
    background: #28a745;
}

.add-button:hover {
    background: #218838;
}

.remove-button {
    padding: 8px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.remove-button:hover {
    background: #c82333;
}

.share-button {
    padding: 12px 24px;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.share-button:hover {
    background: #138496;
    transform: translateY(-2px);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

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

.input-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.input-group input,
.input-group select {
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: all 0.2s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.custom-ticker {
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: all 0.2s;
    min-width: 200px;
}

.custom-ticker:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.asset-search-container {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.asset-search {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: all 0.2s;
}

.asset-search:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.asset-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.asset-suggestion {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #e9ecef;
}

.asset-suggestion:last-child {
    border-bottom: none;
}

.asset-suggestion:hover {
    background: #f8f9fa;
}

.asset-suggestion.active {
    background: #e7eaf3;
}

.suggestion-name {
    font-weight: 600;
    color: #333;
}

.suggestion-code {
    font-size: 0.9em;
    color: #666;
    margin-left: 8px;
}

.suggestion-desc {
    font-size: 0.85em;
    color: #888;
    margin-top: 4px;
}

.asset-search-group {
    flex: 1;
}

.calculate-button {
    padding: 12px 32px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.calculate-button:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.calculate-button:active {
    transform: translateY(0);
}

.calculator-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.result-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.2s;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.result-card h3 {
    color: #495057;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.result-card p {
    font-size: 1.8em;
    font-weight: 700;
    color: #667eea;
}

.single-chart-container {
    padding: 40px;
    background: white;
}

.chart-container {
    position: relative;
    height: 500px;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chart-container canvas {
    max-height: 100%;
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 40px;
    background: #f8f9fa;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.stat-card h3 {
    color: #495057;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
}

.stat-card p {
    font-size: 2em;
    font-weight: 700;
    color: #667eea;
}

.info-section {
    padding: 40px;
    background: white;
}

.info-section h2 {
    color: #1e3c72;
    margin-bottom: 20px;
}

.info-section p {
    line-height: 1.8;
    color: #495057;
    margin-bottom: 15px;
}

.info-section ul {
    margin-left: 20px;
    margin-top: 10px;
}

.info-section li {
    line-height: 1.8;
    color: #495057;
}

.info-section a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.info-section a:hover {
    text-decoration: underline;
}

.info-section h3 {
    color: #2a5298;
    margin-top: 30px;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.date-range-info {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 4px;
}

.date-range-info .help-text {
    margin: 0;
    color: #495057;
    font-size: 0.95em;
    line-height: 1.6;
}

.data-source-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 30px;
}

.data-source-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border-left: 4px solid #667eea;
    transition: transform 0.2s, box-shadow 0.2s;
}

.data-source-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.data-source-card h4 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.data-source-card ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.data-source-card li {
    padding: 6px 0;
    color: #495057;
    font-size: 0.95em;
    line-height: 1.6;
}

.data-source-card li strong {
    color: #1e3c72;
    font-weight: 600;
}

.tips-list {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 20px 20px 20px 40px;
    border-radius: 4px;
    margin-top: 20px;
}

.tips-list li {
    color: #856404;
    line-height: 2;
    font-size: 0.95em;
}

footer {
    background: #1e3c72;
    color: white;
    padding: 20px;
    text-align: center;
    font-size: 0.9em;
}

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

/* Mobile and Tablet Styles */
@media (max-width: 1024px) {
    .single-chart-container {
        padding: 20px;
    }

    .chart-container {
        height: 300px;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 1em;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        gap: 15px;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .control-group label {
        font-size: 14px;
    }

    .control-group select,
    .custom-range input,
    .custom-range button,
    .event-range button {
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .event-range {
        padding: 15px;
        flex-direction: column;
    }

    .custom-range {
        flex-direction: column;
    }

    .chart-config-section {
        padding: 20px;
    }

    .chart-config-section h2 {
        font-size: 1.5em;
    }

    .asset-config h3 {
        font-size: 1.2em;
    }

    .config-row {
        flex-direction: column;
        align-items: stretch;
    }

    .compare-row {
        flex-direction: column;
        align-items: stretch;
    }

    .compare-controls {
        flex-direction: column;
    }

    .calculator-results {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .result-card {
        padding: 20px;
    }

    .result-card p {
        font-size: 1.5em;
    }

    .chart-container {
        height: 250px;
        padding: 10px;
    }

    .stats-panel {
        grid-template-columns: 1fr;
        padding: 20px;
        gap: 15px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-card h3 {
        font-size: 0.85em;
    }

    .stat-card p {
        font-size: 1.5em;
    }

    .info-section {
        padding: 20px;
    }

    .info-section h2 {
        font-size: 1.5em;
    }

    .info-section h3 {
        font-size: 1.3em;
        margin-top: 25px;
    }

    .info-section p,
    .info-section li {
        font-size: 0.95em;
    }

    .data-source-details {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .data-source-card {
        padding: 15px;
    }

    .data-source-card h4 {
        font-size: 1.1em;
    }

    .date-range-info {
        padding: 12px;
    }

    footer {
        padding: 20px;
        font-size: 0.85em;
    }

    footer p {
        margin-bottom: 10px;
    }
}

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

    .subtitle {
        font-size: 0.9em;
    }

    .chart-config-section {
        padding: 15px;
    }

    .chart-config-section h2 {
        font-size: 1.3em;
    }

    .result-card p {
        font-size: 1.3em;
    }

    .single-chart-container {
        padding: 10px;
    }

    .chart-container {
        height: 220px;
        padding: 8px;
    }

    .stats-panel {
        padding: 15px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card p {
        font-size: 1.3em;
    }

    .info-section {
        padding: 15px;
    }

    .info-section h2 {
        font-size: 1.3em;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s;
}

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

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

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

.wizard-content {
    max-width: 700px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #333;
}

.settings-section {
    margin: 20px 0;
}

.settings-section h3 {
    color: #1e3c72;
    margin-bottom: 15px;
}

.help-text {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
    font-weight: 600;
}

.primary-button, .secondary-button {
    width: 100%;
    padding: 15px 20px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-button {
    background: #667eea;
    color: white;
}

.primary-button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.secondary-button {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
}

.secondary-button:hover {
    background: #e9ecef;
}

/* Wizard Styles */
.wizard-step {
    min-height: 300px;
}

.wizard-step h2 {
    color: #1e3c72;
    margin-bottom: 20px;
}

.benefits-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.benefits-list li {
    padding: 10px;
    margin: 10px 0;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 16px;
}

.instruction-box {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 4px solid #667eea;
}

.instruction-list {
    margin: 15px 0;
    padding-left: 25px;
}

.instruction-list li {
    margin: 12px 0;
    line-height: 1.6;
}

.visual-hint {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.example-key {
    display: block;
    background: #e9ecef;
    padding: 10px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    margin-top: 10px;
    word-break: break-all;
}

.action-button {
    width: 100%;
    padding: 15px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin: 15px 0;
}

.action-button:hover {
    background: #218838;
    transform: translateY(-2px);
}

.note {
    color: #666;
    font-size: 14px;
    font-style: italic;
    margin-top: 10px;
}

.api-input-container {
    margin: 20px 0;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.api-key-input {
    flex: 1;
    min-width: 250px;
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.api-key-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.api-input-container .primary-button,
.api-input-container .secondary-button {
    white-space: nowrap;
    padding: 12px 20px;
}

.validate-button {
    width: 100%;
    padding: 15px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.validate-button:hover {
    background: #5568d3;
}

.validation-status {
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: 600;
}

.validation-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.validation-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.success-box {
    background: #d4edda;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 4px solid #28a745;
}

.success-box p {
    margin: 10px 0;
    color: #155724;
    font-weight: 600;
}

.try-it {
    text-align: center;
    margin: 20px 0;
    font-size: 18px;
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 15px;
}

.wizard-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.back-button {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
}

.back-button:hover {
    background: #e9ecef;
}

.next-button, .finish-button {
    background: #667eea;
    color: white;
}

.next-button:hover, .finish-button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.finish-button {
    width: 100%;
    margin-top: 20px;
}
