:root {
    --bg: #edf4fb;
    --panel: rgba(248, 251, 255, 0.95);
    --panel-border: rgba(148, 163, 184, 0.18);
    --text: #172554;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 24%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.10), transparent 20%),
        linear-gradient(180deg, #f8fbff 0%, #e7eef8 100%);
}

.hidden {
    display: none !important;
}

.tool-header {
    margin-top: 24px;
}

.tool-header-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 24px;
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    background: rgba(248, 251, 255, 0.92);
    box-shadow: var(--shadow);
}

.tool-brand-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-update-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.tool-brand {
    color: var(--text);
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 800;
    white-space: nowrap;
}

.tool-nav {
    display: flex;
    gap: 18px;
    margin-left: auto;
    flex-wrap: wrap;
}

.tool-nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tool-nav a:hover {
    color: var(--accent-dark);
    background: rgba(148, 163, 184, 0.12);
}

.tool-nav a.active {
    color: #eff6ff;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
}

.page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 48px;
}

.invest-footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto 56px;
    padding: 0 8px;
    color: var(--muted);
    text-align: center;
    font-size: 0.94rem;
}

.footer-records {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 28px;
}

.footer-record {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.footer-record-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.invest-footer a {
    color: inherit;
    text-decoration: none;
}

.invest-footer a:hover,
.invest-footer a:focus-visible {
    text-decoration: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.38);
}

.modal-card {
    position: relative;
    width: min(720px, calc(100% - 24px));
    margin: 72px auto 0;
    padding: 20px;
    border-radius: 24px;
    border: 1px solid var(--panel-border);
    background: rgba(248, 251, 255, 0.98);
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-status {
    margin: 14px 0 12px;
    color: var(--accent-dark);
    font-weight: 700;
}

.modal-progress {
    margin-bottom: 14px;
}

.modal-progress-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.modal-progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(107, 114, 128, 0.18);
}

.modal-progress-bar {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    transition: width 0.2s ease;
}

.modal-log {
    max-height: 420px;
    overflow: auto;
    padding: 14px;
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.10);
    font-family: "Cascadia Code", "Consolas", monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-log-line + .modal-log-line {
    margin-top: 6px;
}

.modal-log-line.error {
    color: #b91c1c;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.modal-secondary {
    color: var(--text);
    background: rgba(107, 114, 128, 0.14);
}

.modal-done {
    min-width: 92px;
}

.modal-done:disabled {
    color: #6b7280;
    background: #d1d5db;
    border-color: #d1d5db;
    cursor: not-allowed;
    opacity: 1;
}

.panel {
    margin-top: 22px;
    padding: 22px;
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.view-panel.hidden {
    display: none;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.45rem;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.panel-header p {
    margin: 8px 0 0;
    color: var(--muted);
}

.controls {
    display: grid;
    gap: 12px;
    align-items: start;
    margin-top: 18px;
}

.compare-controls {
    grid-template-columns: 48px minmax(760px, 1fr);
}

.compare-controls-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.dca-controls {
    grid-template-columns: 96px minmax(260px, 1fr);
}

.dca-controls label {
    white-space: nowrap;
}

.compare-picker {
    position: relative;
}

.compare-picker {
    display: grid;
    gap: 12px;
}

.custom-range-panel {
    display: block;
}

.custom-range-panel .flatpickr-input[readonly] {
    cursor: pointer;
}

.flatpickr-calendar {
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange {
    background: #2563eb;
    border-color: #2563eb;
}

.flatpickr-day.inRange {
    box-shadow: -5px 0 0 #dbeafe, 5px 0 0 #dbeafe;
}

.compare-clear-button {
    min-width: 88px;
    white-space: nowrap;
}

.picker-input-wrap {
    position: relative;
}

.picker-display,
.text-input,
.portfolio-asset-select,
.portfolio-weight-input {
    width: 100%;
    min-height: 46px;
    padding: 10px 44px 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.88);
    font: inherit;
}

.picker-display {
    color: var(--text);
    line-height: 24px;
    cursor: pointer;
}

.text-input,
.portfolio-asset-select,
.portfolio-weight-input {
    padding-right: 12px;
    color: var(--text);
}

.picker-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    min-height: 32px;
    width: 32px;
    padding: 0;
    border-radius: 10px;
    color: var(--accent-dark);
    background: rgba(148, 163, 184, 0.14);
}

.compare-picker.open .picker-toggle {
    background: rgba(148, 163, 184, 0.22);
}

label {
    padding-top: 10px;
    color: var(--accent-dark);
    font-weight: 700;
}

button {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    font: inherit;
    min-height: 46px;
    padding: 0 16px;
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
    cursor: pointer;
}

.asset-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 15;
    display: grid;
    gap: 8px;
    max-height: 380px;
    padding: 10px;
    overflow: auto;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(31, 41, 55, 0.10);
}

.picker-categories {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    margin-left: -10px;
    margin-right: -10px;
    padding: 6px 10px 8px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(226, 232, 240, 0.88);
    backdrop-filter: blur(8px);
}

.picker-category {
    min-height: 30px;
    padding: 0 10px;
    color: var(--text);
    background: rgba(226, 232, 240, 0.72);
}

.picker-category.active {
    color: #eff6ff;
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
}

.picker-group {
    display: grid;
    gap: 8px;
}

.asset-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.96);
    cursor: pointer;
    text-align: center;
}

.asset-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.asset-option span {
    color: var(--text);
    font-weight: 400;
}

.asset-option-check {
    width: 16px;
    height: 16px;
    border: 1.5px solid rgba(148, 163, 184, 0.72);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    flex: 0 0 auto;
}

.asset-option input:checked + .asset-option-check {
    border-color: var(--accent);
    background: radial-gradient(circle at center, var(--accent) 0 45%, rgba(255, 255, 255, 0.98) 50%);
}

.normalize-switch {
    min-height: 52px;
    padding: 0 4px 0 18px;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.normalize-switch-label {
    line-height: 1;
}

.normalize-switch-track {
    position: relative;
    width: 58px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.42);
    transition: background-color 0.18s ease;
}

.normalize-switch-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
    transition: transform 0.18s ease;
}

.normalize-switch.active {
    border-color: rgba(37, 99, 235, 0.24);
    background: rgba(239, 246, 255, 0.96);
}

.normalize-switch.active .normalize-switch-track {
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
}

.normalize-switch.active .normalize-switch-thumb {
    transform: translateX(26px);
}

.range-group {
    display: grid;
    grid-template-columns: repeat(6, minmax(88px, 1fr)) minmax(116px, 1.3fr);
    gap: 8px;
    width: 100%;
}

.range-button {
    min-height: 38px;
    min-width: 0;
    padding: 0 8px;
    color: var(--text);
    background: rgba(226, 232, 240, 0.72);
    font-size: 0.95rem;
    white-space: nowrap;
}

.range-button.active {
    color: #eff6ff;
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
}

button:hover {
    filter: brightness(1.03);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    filter: grayscale(0.2);
}

input:disabled,
select:disabled,
.picker-display.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: rgba(226, 232, 240, 0.72);
}

.meta {
    min-height: 24px;
    margin: 14px 0 8px;
    color: var(--muted);
}

.chart {
    min-height: 690px;
}

.chart.touch-scroll-chart,
.chart.touch-scroll-chart .plot-container,
.chart.touch-scroll-chart .svg-container,
.chart.touch-scroll-chart .main-svg {
    touch-action: pan-y pinch-zoom !important;
}

.chart-shell {
    position: relative;
}

.chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 20px;
    background: rgba(248, 250, 252, 0.78);
    backdrop-filter: blur(2px);
    z-index: 5;
}

.chart-spinner {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 3px solid rgba(37, 99, 235, 0.16);
    border-top-color: var(--accent);
    animation: chart-spin 0.8s linear infinite;
}

.chart-loading-text {
    color: var(--accent-dark);
    font-weight: 700;
    letter-spacing: 0.01em;
}

@keyframes chart-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.compare-stats {
    margin-top: 20px;
}

.stats-card {
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
}

.stats-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.stats-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.stats-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.stats-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stats-select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    color: var(--text);
    font-weight: 700;
}

.stats-select {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    font: inherit;
}

.stats-view-switch {
    display: inline-flex;
    padding: 4px;
    border-radius: 14px;
    background: rgba(226, 232, 240, 0.72);
}

.stats-view-button {
    min-height: 34px;
    padding: 0 14px;
    color: var(--text);
    background: transparent;
    border-color: transparent;
}

.stats-view-button.active {
    color: #eff6ff;
    background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
}

.stats-table-wrap {
    margin-top: 14px;
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 0.96rem;
}

.stats-table th,
.stats-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    white-space: nowrap;
}

.stats-table th {
    color: var(--accent-dark);
    font-weight: 800;
    background: rgba(239, 246, 255, 0.9);
}

.stats-table tbody tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.66);
}

.stats-table tbody tr:hover {
    background: rgba(219, 234, 254, 0.4);
}

.stats-chart {
    min-height: 420px;
    margin-top: 16px;
}

.stats-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.stats-chart-panel {
    padding: 14px 16px 10px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(248, 250, 252, 0.8);
}

.stats-chart-panel .stats-chart {
    min-height: 340px;
    margin-top: 0;
}

.correlation-card {
    margin-top: 18px;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.76);
}

.correlation-matrix-wrap {
    margin-top: 14px;
    overflow-x: auto;
}

.correlation-matrix {
    width: 100%;
    min-width: 720px;
    border-collapse: separate;
    border-spacing: 4px;
    table-layout: fixed;
}

.correlation-matrix th,
.correlation-matrix td {
    min-width: 108px;
    padding: 11px 10px;
    text-align: center;
    border-radius: 8px;
    white-space: nowrap;
}

.correlation-matrix thead th,
.correlation-matrix tbody th {
    color: var(--text);
    font-weight: 600;
    background: rgba(248, 250, 252, 0.92);
    border: none;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.82);
}

.correlation-matrix tbody th {
    text-align: center;
}

.correlation-matrix thead th {
    font-size: 0.92rem;
}

.correlation-corner {
    color: var(--muted) !important;
    letter-spacing: 0.02em;
}

.corr-cell {
    font-weight: 700;
    border: none;
    box-shadow: none;
}

.annual-returns-card {
    margin-top: 18px;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.76);
}

.annual-returns-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 14px 12px;
    margin-top: 16px;
}

.annual-returns-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.annual-summary-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.annual-summary-chip.positive {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fecaca;
}

.annual-summary-chip.negative {
    color: #166534;
    background: #dcfce7;
    border-color: #bbf7d0;
}

.annual-return-entry {
    display: grid;
    gap: 8px;
}

.annual-return-item {
    min-height: 78px;
    padding: 16px 10px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid transparent;
    box-shadow: 0 8px 18px -12px rgba(15, 23, 42, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
}

.annual-return-item.positive {
    color: #991b1b;
    background: #fecaca;
    border-color: #fca5a5;
}

.annual-return-item.negative {
    color: #166534;
    background: #bbf7d0;
    border-color: #86efac;
}

.annual-return-item.neutral {
    color: var(--muted);
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.annual-return-rate {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.annual-return-year {
    font-size: 1.0rem;
    font-weight: 700;
    line-height: 1;
    color: rgba(71, 85, 105, 0.92);
    text-align: center;
}

.annual-return-empty {
    grid-column: 1 / -1;
    padding: 16px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.92);
    color: var(--muted);
}

.metric-guide {
    margin-top: 8px;
    padding-top: 6px;
}

.trade-history {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.trade-history h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--accent-dark);
}

.trade-history p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.trade-history-section {
    margin-top: 14px;
}

.trade-history-table {
    min-width: 860px;
}

.trade-history-table-wrap {
    max-height: 440px;
    overflow: auto;
}

.trade-history-tab {
    white-space: nowrap;
}

.metric-guide h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--accent-dark);
}

.metric-guide-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.metric-guide-item {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(248, 250, 252, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.metric-guide-item strong {
    color: var(--text);
}

.metric-guide-item span {
    color: var(--muted);
    line-height: 1.65;
    font-size: 0.94rem;
}

.error-text {
    color: #b91c1c;
}

.portfolio-layout {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.15fr);
    gap: 20px;
    align-items: start;
}

.dca-layout {
    display: grid;
    grid-template-columns: minmax(420px, 1.2fr) minmax(280px, 0.8fr);
    gap: 20px;
    margin-top: 18px;
    align-items: start;
}

.dca-form-card,
.dca-note-card {
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
}

.dca-note-card h3 {
    margin: 0;
}

.dca-note-card p {
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.dca-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.portfolio-card {
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.72);
}

.philosophy-panel {
    background: var(--panel);
}

.philosophy-panel .panel-header {
    align-items: end;
}

.philosophy-panel .quote-panel-header,
.philosophy-panel .knowledge-grid {
    margin-top: 24px;
}

.philosophy-panel .panel-header h2 {
    color: var(--text);
    font-size: 1.45rem;
    letter-spacing: 0;
}

.philosophy-panel .panel-header p {
    max-width: 680px;
    margin-top: 10px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--muted);
}

.knowledge-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.knowledge-section {
    padding: 20px 20px 18px;
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.74);
}

.knowledge-section h4 {
    margin: 0;
    color: #10213d;
    font-size: 1.08rem;
    line-height: 1.6;
}

.knowledge-section p {
    margin: 12px 0 0;
    color: #334155;
    font-size: 0.98rem;
    line-height: 1.9;
}

.knowledge-list {
    margin: 14px 0 0;
    padding-left: 20px;
    color: #334155;
}

.knowledge-list li + li {
    margin-top: 8px;
}

.knowledge-list li {
    line-height: 1.8;
}

.quote-panel-header p {
    max-width: 720px;
    margin: -6px 0 18px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--muted);
}

.quote-grid {
    counter-reset: philosophy-quote;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.quote-grid.masonry-active {
    align-items: start;
}

.quote-column {
    display: grid;
    gap: 20px;
    align-content: start;
}

.quote-card {
    counter-increment: philosophy-quote;
    position: relative;
    display: block;
    width: auto;
    margin: 0;
    padding: 24px 26px 22px;
    border-radius: 26px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.94) 100%);
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
}

.quote-card-body {
    display: grid;
    gap: 14px;
}

.quote-text {
    margin: 0;
    padding: 0;
    color: #172033;
    font-size: clamp(1.16rem, 2vw, 1.34rem);
    line-height: 1.72;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.quote-translation {
    margin: 0;
    padding-top: 14px;
    border-top: 1px dashed rgba(148, 163, 184, 0.32);
    color: #334155;
    line-height: 1.9;
    font-size: 1.08rem;
}

.quote-meta {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.7;
    text-align: right;
    justify-self: end;
    font-weight: 500;
}

.portfolio-card-header h3,
.portfolio-item-header h4 {
    margin: 0;
}

.portfolio-card-header p,
.portfolio-item-header p,
.empty-state {
    margin: 6px 0 0;
    color: var(--muted);
}

.portfolio-list {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.portfolio-item {
    padding: 16px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.portfolio-item-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.portfolio-item-main {
    min-width: 0;
    flex: 1 1 auto;
}

.portfolio-holdings {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.portfolio-holding-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
}

.portfolio-form {
    display: grid;
    gap: 18px;
    margin-top: 20px;
}

.portfolio-form-label {
    padding-top: 0;
    margin-top: 10px;
}

.portfolio-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    color: var(--accent-dark);
}

.portfolio-rows {
    display: grid;
    gap: 10px;
}

.portfolio-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.7fr) auto;
    gap: 10px;
}

.portfolio-form-actions {
    display: flex;
    justify-content: flex-end;
}

.secondary-button,
.ghost-button,
.danger-button {
    min-height: 40px;
}

.secondary-button {
    color: var(--text);
    background: rgba(226, 232, 240, 0.9);
}

.ghost-button {
    color: var(--text);
    background: rgba(248, 250, 252, 0.96);
}

.danger-button {
    min-width: 88px;
    white-space: nowrap;
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

.empty-state {
    padding: 16px;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.92);
}

@media (max-width: 1180px) {
    .annual-returns-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .tool-header-inner {
        min-height: auto;
        padding: 18px;
        flex-wrap: wrap;
    }

    .tool-nav {
        order: 3;
        width: 100%;
        margin-left: 0;
        overflow: auto;
    }

    .page {
        width: min(100% - 20px, 1120px);
        padding-top: 0;
    }

    .tool-header {
        margin-top: 12px;
    }

    .invest-footer {
        width: min(100% - 20px, 1120px);
        margin-bottom: 40px;
    }

    .panel {
        padding: 18px;
        border-radius: 18px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .compare-controls {
        grid-template-columns: 1fr;
    }

    .compare-controls-main {
        grid-template-columns: 1fr;
    }

    .custom-range-panel {
        grid-template-columns: 1fr;
    }

    label {
        padding-top: 0;
    }

    .range-group {
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .range-button {
        min-width: 84px;
    }

    .stats-card {
        padding: 16px;
    }

    .stats-header,
    .stats-toolbar {
        align-items: flex-start;
    }

    .stats-chart-grid {
        grid-template-columns: 1fr;
    }

    .annual-returns-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px 10px;
    }

    .metric-guide-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-layout {
        grid-template-columns: 1fr;
    }

    .dca-layout {
        grid-template-columns: 1fr;
    }

.quote-card {
        padding: 22px 18px 20px;
    }

    .quote-grid {
        grid-template-columns: 1fr;
    }

    .quote-column {
        gap: 16px;
    }

    .portfolio-item-header,
    .portfolio-form-header,
    .portfolio-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .portfolio-row {
        grid-template-columns: 1fr;
    }
}
