/* Root element - ensure it can expand */
#etfmp-root {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
}

/* Container */
.etfmp-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    border: 1px solid #dce5ea;
    background: #f9fbfc;
    border-radius: 12px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-sizing: border-box;
}

/* Headings */
.etfmp-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.etfmp-subtitle {
    font-size: 0.95rem;
    color: #4b5563;
    margin-bottom: 16px;
}

/* Grid layout */
.etfmp-row {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    margin-bottom: 20px;
    align-items: start;
}

.etfmp-field {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Labels & inputs */
.etfmp-label {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
    min-height: 2.6em;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.etfmp-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 8px;
    height: 2.4em;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: flex;
    align-items: flex-start;
}

.etfmp-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
    min-height: 38px;
}

.etfmp-slider {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 4px;
}

/* Sliders basic appearance (theme-proof) */
.etfmp-slider[type="range"] {
    appearance: none;
    height: 4px;
    border-radius: 999px;
    background: #e5e7eb;
}
.etfmp-slider[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #1d4ed8;
    cursor: pointer;
}
.etfmp-slider[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #1d4ed8;
    cursor: pointer;
}

/* Summary box */
.etfmp-result-box {
    padding: 15px;
    margin-top: 8px;
    background: #eef7ff;
    border-left: 4px solid #3182ce;
    border-radius: 6px;
    font-size: 0.9rem;
}

.etfmp-strong {
    font-weight: 700;
    font-size: 1rem;
}

/* New Summary Wrapper */
.etfmp-summary-wrapper {
    margin-top: 24px;
    padding: 20px;
    background: #f9fbfc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* Comparison Grid */
.etfmp-comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Comparison Cards */
.etfmp-comparison-card {
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.etfmp-card-etf {
    border-top: 4px solid #2563eb;
}

.etfmp-card-managed {
    border-top: 4px solid #f97316;
}

.etfmp-card-header {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 12px;
    color: #111827;
}

.etfmp-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.etfmp-card-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 16px;
}

.etfmp-card-metric {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid #f3f4f6;
    font-size: 0.9rem;
}

.etfmp-card-metric:first-of-type {
    border-top: none;
    padding-top: 0;
}

.etfmp-metric-label {
    color: #6b7280;
}

.etfmp-metric-value {
    font-weight: 600;
    color: #111827;
}

/* Highlight Box */
.etfmp-highlight-box {
    padding: 20px;
    background: linear-gradient(135deg, #eef7ff 0%, #dbeafe 100%);
    border-radius: 8px;
    border: 2px solid #3182ce;
    margin-top: 20px;
}

.etfmp-highlight-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #1e40af;
    margin-bottom: 16px;
    text-align: center;
}

.etfmp-highlight-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.etfmp-highlight-metric {
    text-align: center;
    padding: 12px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.etfmp-highlight-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 4px;
}

.etfmp-highlight-label {
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.3;
}

/* Chart */
.etfmp-chart-wrapper {
    margin-top: 24px;
    padding: 16px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.etfmp-chart-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.etfmp-chart-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #4b5563;
}

.etfmp-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.etfmp-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Canvas responsive sizing */
.etfmp-chart {
    width: 100%;
    max-width: 100%;
    height: 300px;
    display: block;
}

/* Table */
.etfmp-table-wrapper {
    margin-top: 24px;
    overflow-x: auto;
}

.etfmp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.etfmp-table th,
.etfmp-table td {
    padding: 6px 8px;
    border: 1px solid #d5dce1;
    background: #ffffff;
    text-align: right;
    white-space: nowrap;
}

.etfmp-table th:first-child,
.etfmp-table td:first-child {
    text-align: left;
}

.etfmp-table thead th {
    background: #e5f0f5;
    font-weight: 600;
}

/* Buttons */
.etfmp-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.etfmp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f9fafb;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: #111827;
    transition: all 0.2s;
}

.etfmp-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.etfmp-btn-primary {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.etfmp-btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

/* Small text */
.etfmp-note {
    margin-top: 6px;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.5;
}

/* Preset return level buttons */
.etfmp-preset-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    min-height: 36px;
}

.etfmp-preset-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
    position: relative;
}

.etfmp-preset-btn:hover {
    border-color: #cbd5e1;
    background: #f9fafb;
    transform: translateY(-1px);
}

.etfmp-preset-btn.etfmp-preset-active {
    border-width: 3px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.etfmp-preset-low {
    border-color: #fca5a5;
    color: #dc2626;
}

.etfmp-preset-low.etfmp-preset-active {
    background: #fee2e2;
    border-color: #dc2626;
    color: #991b1b;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2);
}

.etfmp-preset-medium {
    border-color: #fcd34d;
    color: #d97706;
}

.etfmp-preset-medium.etfmp-preset-active {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.2);
}

.etfmp-preset-high {
    border-color: #6ee7b7;
    color: #059669;
}

.etfmp-preset-high.etfmp-preset-active {
    background: #d1fae5;
    border-color: #059669;
    color: #047857;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.2);
}

/* Responsive width adjustments */
@media (max-width: 1440px) {
    .etfmp-container {
        max-width: calc(100% - 40px);
        margin-left: 20px;
        margin-right: 20px;
    }
}

@media (max-width: 1024px) {
    .etfmp-row {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .etfmp-container {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: 16px;
    }
    
    .etfmp-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .etfmp-container {
        padding: 14px;
    }
    
    .etfmp-comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .etfmp-highlight-metrics {
        grid-template-columns: 1fr;
    }
    
    .etfmp-preset-buttons {
        flex-direction: column;
    }
    
    .etfmp-preset-btn {
        width: 100%;
    }
}

/* Print styles */
@media print {
    .etfmp-container {
        max-width: 100%;
        border: none;
        box-shadow: none;
        padding: 0;
    }
    
    .etfmp-input,
    .etfmp-slider,
    .etfmp-btn {
        display: none;
    }
    
    .etfmp-summary-wrapper,
    .etfmp-comparison-card,
    .etfmp-highlight-box {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .etfmp-chart-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .etfmp-table-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .etfmp-comparison-grid {
        grid-template-columns: 1fr 1fr;
    }
}
