body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
}

header {
    background: #35424a;
    color: #ffffff;
    padding: 10px 0 0;
    text-align: center;
}

.tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 12px;
    padding: 0 20px;
}

.tab-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: background 0.2s;
}

.tab-btn:hover { background: rgba(255,255,255,0.25); }
.tab-btn.active { background: #f4f4f4; color: #35424a; font-weight: bold; }

.tab-content { display: none; }
.tab-content.active { display: block; }

h1 {
    margin: 0;
}

h2 {
    color: #35424a;
    margin-top: 0;
}

main {
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    padding: 0 20px;
    box-sizing: border-box;
}

section {
    background: white;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-container {
    text-align: center;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 20px 0;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.pie-wrapper {
    position: relative;
    width: 600px;
    max-width: 100%;
    height: 400px;
    margin: 20px auto;
}

.table-container {
    overflow-x: auto;
}

.container {
    width: 80%;
    margin: auto;
    overflow: hidden;
}

#investment-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

#investment-table th, #investment-table td {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;
}

#investment-table th {
    background-color: #35424a;
    color: white;
}

#investment-table tr:nth-child(even) {
    background-color: #f2f2f2;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.table th, .table td {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;
}

.table th {
    background-color: #35424a;
    color: white;
}

.table tr:nth-child(even) {
    background-color: #f2f2f2;
}

.footer {
    text-align: center;
    padding: 10px 0;
    background: #35424a;
    color: #ffffff;
    position: relative;
    bottom: 0;
    width: 100%;
}
/* ── Dashboard ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.dash-card {
    background: white;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dash-breakdown-card { grid-column: 1 / -1; }

.dash-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 10px;
    font-weight: 600;
}

.dash-total {
    font-size: 2.4rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.dash-daily { margin-bottom: 12px; }
.dash-updated { font-size: 12px; color: #aaa; }

.gauge-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
}

#gauge-benchmark-tooltip {
    display: none;
    margin: 10px 0 4px;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    border-left: 4px solid transparent;
    animation: benchmarkFadeIn 0.4s ease;
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}

#gauge-benchmark-tooltip.bm-winning {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-left-color: #16a34a;
    color: #14532d;
}

#gauge-benchmark-tooltip.bm-losing {
    background: linear-gradient(135deg, #fff7f7, #fee2e2);
    border-left-color: #dc2626;
    color: #7f1d1d;
}

#gauge-benchmark-tooltip.bm-neutral {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-left-color: #94a3b8;
    color: #334155;
}

@keyframes benchmarkFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dash-mini-wallets {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.dash-mini-card {
    border-left: 4px solid #2E86AB;
}

.dash-mini-total {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 4px;
}

.gauge-wrapper-mini {
    position: relative;
    width: 100%;
    height: 140px;
    margin-top: 8px;
    overflow: hidden;
}

/* ── Mini chart grid (3 columns) ── */
.mini-charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 0 20px 20px;
}

.mini-chart-section {
    padding: 16px;
    margin-bottom: 0;
}

.mini-chart-section h3 {
    margin: 0 0 8px;
    color: #35424a;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chart-wrapper-mini {
    position: relative;
    width: 100%;
    height: 200px;
}

.pie-wrapper-mini {
    position: relative;
    width: 100%;
    height: 220px;
}

/* ── Holdings sub-tabs ── */
.holdings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.holdings-tab-btn {
    background: #e9ecef;
    color: #35424a;
    border: none;
    padding: 7px 18px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.holdings-tab-btn:hover { background: #d0d4d8; }
.holdings-tab-btn.active { background: #35424a; color: white; font-weight: bold; }

.holdings-content { display: none; }
.holdings-content.active { display: block; }

.holdings-table {
    width: 100%;
    border-collapse: collapse;
}

.holdings-table th, .holdings-table td {
    border: 1px solid #ddd;
    text-align: left;
    padding: 8px;
    font-size: 13px;
}

.holdings-table th { background: #35424a; color: white; }
.holdings-table tr:nth-child(even) { background: #f9f9f9; }

.dash-drawdown {
    margin: 10px 0 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #bdc3c7;
}

/* ── Statistics Tab ── */
.stats-section {
    background: white;
    border-radius: 10px;
    padding: 24px 28px;
    margin: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.stats-section h2 {
    margin: 0 0 18px;
    font-size: 1.1rem;
    color: #35424a;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}
#returns-table-wrap table thead th {
    padding: 8px 10px;
    text-align: right;
    font-size: 12px;
    letter-spacing: 0.5px;
}
#returns-table-wrap table thead th:first-child { text-align: left; }
#returns-table-wrap table tbody tr:nth-child(even) { background: #f9fafb; }
#returns-table-wrap table tbody tr:hover { background: #eef2ff; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.stat-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px 18px;
    border-left: 4px solid #2E86AB;
}
.stat-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #222;
}
.stat-sub {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

/* ── Pie chart + HTML legend layout ── */
.pie-with-legend {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.pie-with-legend .pie-wrapper {
    width: 400px;
    height: 400px;
    margin: 0;
}
.pie-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    justify-content: center;
    padding: 4px 16px 8px;
    max-width: 700px;
}
.pie-legend-mini {
    max-width: 100%;
    padding: 6px 4px 4px;
    gap: 4px 12px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 5px 10px 5px 0;
    overflow: hidden;
}
.legend-color-bar {
    width: 6px;
    min-width: 6px;
    height: 36px;
    border-radius: 3px 0 0 3px;
    flex-shrink: 0;
}
.legend-logo-wrap {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.legend-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
.legend-text {
    flex: 1;
    color: #333;
    font-weight: 500;
}
.legend-pct {
    font-weight: 700;
    color: #555;
    min-width: 40px;
    text-align: right;
}

/* ── Transaction table filters ── */
.col-filter {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 3px 6px;
    font-size: 11px;
    font-weight: normal;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}
.col-filter::placeholder { color: #bbb; }

/* ── Transaction filter UI ── */
.tx-th {
    position: relative;
    white-space: nowrap;
}
.filter-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: normal;
    background: #eef2f5;
    border: 1px solid #ccd0d5;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    color: #444;
}
.filter-btn.filter-active {
    background: #2980b9;
    border-color: #2471a3;
    color: #fff;
}
.filter-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    background: #fff;
    border: 1px solid #ccd0d5;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    padding: 12px 14px;
    min-width: 220px;
    font-weight: normal;
    color: #333;
}
.filter-popup.open { display: block; }
.filter-popup label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
}
.filter-popup label input[type="date"] {
    margin-top: 3px;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid #ccd;
    border-radius: 4px;
}
.filter-clear {
    margin-top: 8px;
    padding: 3px 10px;
    font-size: 11px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
}
.op-pill {
    display: inline-block;
    margin: 3px 3px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid var(--op-color);
    border-radius: 12px;
    background: #fff;
    color: var(--op-color);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.op-pill.active {
    background: var(--op-color);
    color: #fff;
}

/* ── Dual range slider ── */
.range-slider {
    position: relative;
    height: 20px;
    margin: 10px 0 6px;
}
.range-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 4px;
    background: #dde;
    border-radius: 2px;
}
.range-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: #2980b9;
    border-radius: 2px;
}
.range-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #2980b9;
    border-radius: 50%;
    cursor: grab;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.range-thumb:active { cursor: grabbing; background: #e8f4fb; }

/* ── Transaction Activity Calendar ── */
.cal-year-btn {
    padding: 4px 12px;
    border: 1px solid #ccd0d5;
    border-radius: 16px;
    background: #f0f2f5;
    color: #444;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
}
.cal-year-btn.active {
    background: #2E86AB;
    border-color: #2471a3;
    color: #fff;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px 24px;
}
.cal-month {
    font-size: 12px;
}
.cal-month-name {
    font-weight: 700;
    color: #35424a;
    margin-bottom: 4px;
    font-size: 13px;
}
.cal-dow-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 2px;
}
.cal-dow {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    font-weight: 600;
}
.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    font-size: 10px;
    color: #888;
    background: #f8f9fa;
    cursor: default;
}
.cal-day.empty {
    background: transparent;
}
.cal-day.cal-active {
    font-weight: 600;
    cursor: pointer;
}
.cal-day.cal-active:not([class*="cal-i"]),
.cal-day.cal-i0 { color: #444; }
.cal-day.cal-i1 { background: #aed6f1; color: #1a5276; }
.cal-day.cal-i2 { background: #5dade2; color: #fff; }
.cal-day.cal-i3 { background: #2E86AB; color: #fff; }
.cal-day.cal-i4 { background: #1a5276; color: #fff; }
.cal-day.cal-i5 { background: #0d2b3e; color: #fff; }

.cal-legend-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.cal-legend-swatch.cal-i1 { background: #aed6f1; }
.cal-legend-swatch.cal-i2 { background: #5dade2; }
.cal-legend-swatch.cal-i3 { background: #2E86AB; }
.cal-legend-swatch.cal-i4 { background: #1a5276; }
.cal-legend-swatch.cal-i5 { background: #0d2b3e; }

/* ── Day transactions modal ── */
.cal-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.cal-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 740px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #35424a;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.cal-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.8;
}
.cal-modal-close:hover { opacity: 1; }
#cal-modal-body {
    overflow-y: auto;
    padding: 16px 20px;
}

.cal-frame-deposit    { box-shadow: inset 0 0 0 2px #27ae60; }
.cal-frame-withdrawal { box-shadow: inset 0 0 0 2px #c0392b; }

/* ── WIG Index Chart ──────────────────────────────────────── */
.wig-chart-card {
    grid-column: 1 / -1;
    padding: 16px 20px 0;
}
.wig-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.wig-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.wig-title {
    font-size: 15px;
    font-weight: 600;
    color: #222;
}
.wig-change-badge {
    font-size: 13px;
    font-weight: 600;
}
.wig-ohlc-legend {
    font-size: 12px;
    color: #555;
    font-variant-numeric: tabular-nums;
}
.wig-ohlc-l {
    color: #999;
    margin-right: 2px;
    font-size: 11px;
}
.wig-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.wig-range-btns, .wig-type-btns {
    display: flex;
    gap: 2px;
}
.wig-type-btns {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    gap: 0;
}
.wig-range-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.12s;
}
.wig-range-btn:hover  { background: #f0f2ff; color: #3949ab; }
.wig-range-btn.active { background: #3949ab; color: #fff; border-radius: 6px; }
.wig-type-btn {
    padding: 4px 12px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.12s;
}
.wig-type-btn:hover  { background: #f0f2ff; color: #3949ab; }
.wig-type-btn.active { background: #3949ab; color: #fff; }
.wig-chart-wrapper {
    position: relative;
    height: 380px;
}
