@font-face { font-family: 'BTG Pactual'; src: url('/static/fonts/BTGPactualOffice-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; }
@font-face { font-family: 'BTG Pactual'; src: url('/static/fonts/BTGPactualOffice-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'BTG Pactual'; src: url('/static/fonts/BTGPactualOffice-SemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; }
@font-face { font-family: 'BTG Pactual'; src: url('/static/fonts/BTGPactualOffice-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'BTG Pactual'; src: url('/static/fonts/BTGPactualOffice-ExtraBold.ttf') format('truetype'); font-weight: 800; font-style: normal; }
@font-face { font-family: 'BTG Pactual'; src: url('/static/fonts/BTGPactualOffice-Black.ttf') format('truetype'); font-weight: 900; font-style: normal; }

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

input, select, button, textarea {
    font-family: inherit;
}

body {
    font-family: 'BTG Pactual', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #f4f5f7;
    color: #191919;
    font-size: 14px;
    line-height: 1.45;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #001F62;
    color: #fff;
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.header-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

/* Portfolio Tabs */
.tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: #0a2a6e;
}

.tab {
    padding: 11px 28px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: rgba(255, 255, 255, 0.85); }
.tab.active { color: #fff; border-bottom-color: #195AB4; }

/* Main */
main {
    padding: 16px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.portfolio-section { display: none; }
.portfolio-section.active { display: block; }

/* Section Divider */
.section-divider {
    margin: 28px 0;
    border-top: 3px solid #e8eff9;
}

/* Section Header */
.section-header {
    font-size: 15px;
    font-weight: 700;
    color: #001F62;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #195AB4;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* LIVE Badge */
.live-badge {
    display: inline-block;
    background: #16a34a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Month Selector */
.month-selector {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 31, 98, 0.08);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 700;
    color: #001F62;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 6px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    color: #191919;
    background: #fff;
    outline: none;
    min-width: 130px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-group select:focus {
    border-color: #195AB4;
    box-shadow: 0 0 0 2px rgba(25, 90, 180, 0.15);
}

.month-nav-btn {
    padding: 6px 12px;
    background: #001F62;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.month-nav-btn:hover { background: #195AB4; }
.month-nav-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ── Top Row: KPIs + Changes all inline ── */
.top-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

.kpi-box {
    flex: 1 1 0;
    min-width: 130px;
    background: #fff;
    border-radius: 6px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0, 31, 98, 0.08);
    border-left: 3px solid #195AB4;
}

.kpi-box.positive { border-left-color: #16a34a; }
.kpi-box.negative { border-left-color: #dc2626; }

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: #001F62;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.kpi-value.positive { color: #16a34a; }
.kpi-value.negative { color: #dc2626; }

.kpi-sub {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* Changes Box (inline with KPIs) */
.changes-box {
    flex: 1 1 auto;
    background: #fff;
    border-radius: 6px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0, 31, 98, 0.08);
    border-left: 3px solid #d97706;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.changes-items {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.change-item {
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
}

.change-in { background: #ecfdf5; color: #16a34a; }
.change-out { background: #fef2f2; color: #dc2626; }
.change-arrow { font-size: 9px; }
.change-ticker { font-size: 9px; color: #888; margin-left: 2px; }

/* Card */
.card {
    background: #fff;
    border-radius: 6px;
    padding: 16px 18px;
    box-shadow: 0 1px 4px rgba(0, 31, 98, 0.08);
    margin-bottom: 12px;
}

.card-title {
    font-size: 13px;
    font-weight: 700;
    color: #001F62;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #195AB4;
}

.card-compact {
    padding: 12px 14px;
}

.card-compact .card-title {
    margin-bottom: 8px;
    padding-bottom: 5px;
    font-size: 12px;
}

/* ── Two-Column Layout: merged card + bar chart ── */
.portfolio-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.portfolio-col-main,
.portfolio-col-bar {
    min-width: 0;
}

/* Pie + Stocks merged inside one card */
.pie-stocks-grid {
    display: grid;
    grid-template-columns: 50% 1fr;
    gap: 8px;
    align-items: start;
}

.pie-side {
    position: relative;
    height: 320px;
}

.stocks-side {
    overflow-y: auto;
    max-height: 320px;
}

/* Card Title Row with Toggle */
.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #195AB4;
}

.card-compact .card-title-row {
    margin-bottom: 8px;
    padding-bottom: 5px;
}

.card-title-row .card-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Chart View Toggle */
.chart-toggle {
    display: flex;
    background: #f0f2f5;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.toggle-btn {
    padding: 4px 10px;
    border: none;
    background: none;
    font-size: 10px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.toggle-btn.active {
    background: #001F62;
    color: #fff;
    border-radius: 3px;
}

.toggle-btn:hover:not(.active) {
    background: #e2e5ea;
    color: #555;
}

/* Bar Chart Container */
.bar-container {
    height: 320px;
    position: relative;
}

/* Stock List */
.stock-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}

.stock-list-item:last-child { border-bottom: none; }
.stock-list-item:hover { background: #f4f8ff; }

.stock-list-item.active {
    background: #e6eef8;
    border-left: 3px solid #001F62;
    padding-left: 5px;
}

.stock-list-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stock-list-company {
    font-weight: 700;
    color: #001F62;
    font-size: 12px;
    line-height: 1.3;
}

.stock-list-ticker {
    font-size: 11px;
    color: #999;
}

.stock-list-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    flex-shrink: 0;
}

.stock-price { font-size: 12px; color: #555; font-weight: 600; }
.stock-entry-price { font-size: 10px; color: #aaa; }
.stock-perf { font-size: 12px; font-weight: 700; }
.stock-perf.positive { color: #16a34a; }
.stock-perf.negative { color: #dc2626; }

/* Description Panel */
.description-panel {
    margin-bottom: 12px;
    min-height: 50px;
}

.desc-placeholder {
    color: #aaa;
    font-style: italic;
    text-align: center;
    padding: 12px;
}

.desc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.desc-company { font-size: 18px; font-weight: 800; color: #001F62; }
.desc-ticker { font-size: 13px; color: #888; }
.desc-text { font-size: 14px; line-height: 1.7; color: #444; }

/* Historical Performance Table */
.perf-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.perf-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.perf-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #001F62;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    padding: 8px 8px;
    text-align: center;
    border-bottom: 2px solid #195AB4;
    white-space: nowrap;
}

.perf-table thead th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 3;
    background: #001F62;
}

.perf-table tbody td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    transition: background 0.15s;
}

.perf-table tbody td:first-child {
    text-align: left;
    font-weight: 700;
    position: sticky;
    left: 0;
    background: inherit;
    z-index: 1;
    color: #001F62;
}

.perf-table tbody tr:nth-child(even) { background: #f9f9f9; }
.perf-table tbody tr:nth-child(odd) { background: #fff; }
.perf-table tbody tr:hover { background: #e6eef8; }

.perf-table td.clickable { cursor: pointer; position: relative; }
.perf-table td.clickable:hover { background: #d0dff0 !important; font-weight: 600; }

.perf-table td.val-positive { color: #16a34a; font-weight: 600; }
.perf-table td.val-negative { color: #dc2626; font-weight: 600; }

.perf-table td.summary-col {
    border-left: 2px solid #d0d0d0;
    font-weight: 700;
}

.perf-table td.accum-col {
    background: #f0f4fa !important;
    font-weight: 700;
    color: #001F62;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 280px;
    margin-bottom: 8px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 14px;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #195AB4;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    header { padding: 12px 16px; }
    header h1 { font-size: 16px; }
    .tabs { padding: 0 12px; }
    .tab { padding: 9px 16px; font-size: 13px; }
    main { padding: 8px; }
    .month-selector { flex-direction: column; align-items: stretch; }
    .filter-group select { min-width: 100%; }
    .portfolio-columns { grid-template-columns: 1fr; }
    .top-row { flex-direction: column; }
    .pie-stocks-grid { grid-template-columns: 1fr; }
    .stocks-side { max-height: none; }
    .pie-side { height: 240px; }
}
