/* ========================================
   ENDOW - Endowment Fund Management App
   Styles adapted from INVES
   ======================================== */

/* CSS Variables */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #dbeafe;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================
   Login Overlay
   ======================================== */

.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--gray-50);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    padding: 32px;
    width: 340px;
    max-width: 90vw;
    text-align: center;
}

.login-box h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--gray-800);
}

.login-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.15s;
}

.login-box input:focus {
    border-color: var(--primary);
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.login-box button:hover {
    background: var(--primary-dark);
}

.login-box button:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 10px;
    display: none;
}

.login-success {
    color: var(--success);
    font-size: 13px;
    margin-bottom: 10px;
    display: none;
}

.auth-toggle {
    margin-top: 16px;
    font-size: 13px;
    color: var(--gray-600);
}

.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.auth-forgot {
    margin-top: 12px;
    font-size: 13px;
}

.auth-forgot a {
    color: var(--primary-dark);
    text-decoration: none;
    cursor: pointer;
}

.auth-forgot a:hover {
    text-decoration: underline;
}

/* ========================================
   Body & Layout
   ======================================== */

body {
    font-family: var(--font-family);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-sign-out {
    padding: 0.5rem 1rem;
    background: var(--gray-600);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-sign-out:hover {
    background: var(--gray-700);
}

/* Default button */
button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--primary-dark);
}

/* ========================================
   Sub Tab Navigation
   ======================================== */

.tab-nav {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: transparent;
    color: var(--gray-600);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-weight: 500;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

.fund-sub-tabs {
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}

.fund-sub-tabs .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.fund-tab-content,
.endow-tab-content {
    display: none;
}

.fund-tab-content.active,
.endow-tab-content.active {
    display: block;
}

/* ========================================
   Sections
   ======================================== */

.section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.section-header h3 {
    margin: 0;
}

.section-desc {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ========================================
   Data Tables
   ======================================== */

.table-container {
    overflow-x: auto;
    max-height: 70vh;
    overflow: auto;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 var(--gray-200);
}

.data-table td.left,
.data-table th.left {
    text-align: left;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table td.positive { color: var(--success); }
.data-table td.negative { color: var(--danger); }

.data-table .section-header {
    background: var(--gray-700);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table .metric-label {
    font-weight: 500;
    color: var(--gray-700);
}

/* Returns Table Styling */
.data-table thead tr.subheader th {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    padding-top: 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}

.data-table tfoot .totals-row {
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    border-top: 2px solid var(--gray-300);
}

.data-table tfoot .totals-row td {
    padding: 12px 8px;
    font-size: 13px;
}

.data-table th[colspan="2"] {
    text-align: center;
    border-bottom: none;
    padding-bottom: 4px;
}

.data-table td[title] {
    cursor: help;
    border-bottom: 1px dotted var(--gray-400);
}

/* Matrix Table */
.matrix-table th,
.matrix-table td {
    text-align: center;
    min-width: 80px;
}

.matrix-table td.zero {
    color: var(--gray-400);
}

.matrix-table .total-row {
    background: var(--gray-100);
    font-weight: 600;
}

.matrix-table .total-row td {
    border-top: 2px solid var(--gray-300);
}

/* ========================================
   Modal Styles
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-wide {
    max-width: 700px;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--gray-800);
}

/* ========================================
   Form Styles
   ======================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.813rem;
    color: var(--gray-700);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* ========================================
   Button Variants
   ======================================== */

.btn-primary {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    padding: 0.5rem 1rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-warning {
    padding: 0.5rem 1rem;
    background: var(--warning);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-success {
    padding: 0.5rem 1rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    cursor: pointer;
}

.btn-xs:hover {
    background: var(--gray-200);
}

/* ========================================
   Fund Management Styles
   ======================================== */

.fund-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.fund-price-header {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 1rem;
}

.price-date-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.price-date-selector label {
    color: var(--gray-600);
}

.price-date-selector input[type="date"] {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.exchange-rate-label {
    color: var(--gray-500);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* ========================================
   Fund Summary Cards
   ======================================== */

.fund-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.fund-card {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.fund-card .label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fund-card .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-top: 0.25rem;
}

.fund-card .value.positive {
    color: var(--success);
}

.fund-card .value.negative {
    color: var(--danger);
}

/* ========================================
   Partner Holdings
   ======================================== */

.partner-holdings {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.partner-holdings h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
}

.partner-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.partner-stats span {
    color: var(--gray-600);
}

.partner-stats strong {
    color: var(--gray-800);
}

/* ========================================
   Partner Allocation (Transaction Modal)
   ======================================== */

#tx-partner-allocation {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    max-height: 250px;
    overflow-y: auto;
}

.allocation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.allocation-table th {
    text-align: left;
    padding: 0.5rem;
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-600);
    position: sticky;
    top: 0;
}

.allocation-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--gray-100);
}

.allocation-table tr:last-child td {
    border-bottom: none;
}

.partner-name-cell {
    font-weight: 500;
}

.partner-cash-cell {
    color: var(--success);
}

.partner-cash-cell.negative {
    color: var(--danger);
}

.allocation-table .allocation-input {
    width: 100px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
}

.allocation-table .allocation-input:focus {
    border-color: var(--primary);
    outline: none;
}

.allocation-actions {
    white-space: nowrap;
}

.allocation-summary {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.allocation-summary .remaining-negative {
    color: var(--danger);
}

.allocation-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* ========================================
   Partner Accordion (Performance Tab)
   ======================================== */

.partner-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.partner-row:hover {
    background-color: var(--gray-100) !important;
}

.partner-row.expanded {
    background-color: var(--gray-50);
}

.partner-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-100);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.partner-row:hover .partner-toggle {
    background: var(--primary-light);
    color: var(--primary);
}

.partner-row.expanded .partner-toggle {
    background: var(--primary);
    color: white;
    transform: rotate(90deg);
}

/* ========================================
   Benchmark Summary Row
   ======================================== */

.benchmark-summary-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: stretch;
}

.benchmark-summary-card {
    flex: 1;
    min-width: 120px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

.benchmark-summary-card.fund-card {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eff6ff 0%, white 100%);
}

.bsc-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.bsc-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
    font-family: 'Monaco', 'Consolas', monospace;
}

.bsc-value.positive { color: var(--success); }
.bsc-value.negative { color: var(--danger); }

.bsc-sub {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

.bsc-sub.positive { color: var(--success); font-weight: 600; }
.bsc-sub.negative { color: var(--danger); font-weight: 600; }

.bsc-separator {
    width: 1px;
    background: var(--gray-200);
    align-self: stretch;
    margin: 4px 4px;
}

/* ========================================
   TWR Details Panel
   ======================================== */

.twr-details-row {
    display: none;
}

.twr-details-row.visible {
    display: table-row;
}

.twr-details-row td {
    padding: 0 !important;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.twr-details-panel {
    padding: 20px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Metric Cards
   ======================================== */

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.metric-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

.metric-card.accent {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eff6ff 0%, white 100%);
}

.metric-card.outperform {
    border-color: var(--success);
    background: linear-gradient(135deg, #f0fdf4 0%, white 100%);
}

.metric-card.underperform {
    border-color: var(--danger);
    background: linear-gradient(135deg, #fef2f2 0%, white 100%);
}

.metric-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    font-family: 'Monaco', 'Consolas', monospace;
    line-height: 1.3;
}

.metric-value.positive { color: var(--success); }
.metric-value.negative { color: var(--danger); }

.metric-sub {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

.metric-sub.positive { color: var(--success); font-weight: 600; }
.metric-sub.negative { color: var(--danger); font-weight: 600; }

/* ========================================
   Detail Layout (Two-Column)
   ======================================== */

.detail-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.detail-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
}

.detail-section.full-width {
    margin-bottom: 16px;
}

.detail-section-title {
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section-title .badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.detail-section-title .badge.gips {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: #0369a1;
}

/* ========================================
   Split Allocation Visualization
   ======================================== */

.split-visualization {
    padding: 14px 16px;
}

.split-bar {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gray-100);
    margin-bottom: 8px;
}

.split-partner {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    transition: width 0.3s ease;
}

.split-fund {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    transition: width 0.3s ease;
}

.split-label {
    color: white;
    font-size: 10px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    padding: 0 6px;
}

.split-amounts {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Monaco', 'Consolas', monospace;
}

.legend-partner { color: #2563eb; }
.legend-fund { color: #ea580c; }

/* ========================================
   Calculation Steps
   ======================================== */

.calc-steps {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.calc-step {
    padding: 7px 10px;
    border-radius: 5px;
    font-size: 12px;
    line-height: 1.4;
    border-left: 3px solid transparent;
}

.calc-step.step-info       { background: #f0f9ff; border-color: #0ea5e9; }
.calc-step.step-benchmark  { background: #fefce8; border-color: #eab308; }
.calc-step.step-total      { background: #f0fdf4; border-color: #22c55e; }
.calc-step.step-calculation { background: #faf5ff; border-color: #a855f7; }
.calc-step.step-partner    { background: #eff6ff; border-color: #3b82f6; }
.calc-step.step-fund       { background: #fff7ed; border-color: #f97316; }
.calc-step.step-result     { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); border-color: #10b981; font-weight: 600; }

.calc-step-text {
    color: var(--gray-700);
}

/* ========================================
   Benchmark Detail Grid
   ======================================== */

.benchmark-detail-grid {
    padding: 12px 16px;
}

.bd-row {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 8px;
    padding: 5px 0;
    align-items: baseline;
    font-size: 12px;
}

.bd-label {
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.3px;
}

.bd-value {
    color: var(--gray-700);
}

.bd-value.bd-mono {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
}

.bd-value.bd-highlight {
    font-weight: 700;
    color: var(--gray-800);
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
}

.bd-date {
    color: var(--gray-400);
    font-size: 11px;
}

.bd-divider {
    border-top: 1px dashed var(--gray-200);
    margin: 4px 0;
    grid-column: 1 / -1;
}

.bd-result {
    padding-top: 0;
}

.bd-fallback {
    padding: 14px 16px;
    color: var(--gray-500);
    font-size: 12px;
    font-style: italic;
}

/* ========================================
   TWR Formula
   ======================================== */

.twr-formula {
    padding: 12px 16px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    color: var(--gray-700);
    overflow-x: auto;
    line-height: 1.5;
    word-break: break-all;
}

/* ========================================
   Sub-Period Nested Accordion
   ======================================== */

.subperiods-accordion {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.period-accordion-item {
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    overflow: hidden;
}

.period-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    transition: background-color 0.15s ease;
}

.period-header.clickable { cursor: pointer; }
.period-header.clickable:hover {
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-50) 100%);
}

.period-header.expanded {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-bottom: 1px solid var(--gray-200);
}

.period-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.period-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 9px;
    color: var(--gray-500);
    background: var(--gray-100);
    border-radius: 3px;
    transition: all 0.15s ease;
}

.period-header:hover .period-toggle {
    background: var(--primary-light);
    color: var(--primary);
}

.period-header.expanded .period-toggle {
    background: var(--primary);
    color: white;
    transform: rotate(90deg);
}

.period-toggle-placeholder { width: 16px; height: 16px; }

.period-header .period-num {
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 10px;
}

.period-header .date-range {
    font-size: 12px;
    color: var(--gray-600);
}

.period-cf {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.period-cf.cf-deposit { background: #dcfce7; color: #166534; }
.period-cf.cf-withdrawal { background: #fee2e2; color: #991b1b; }

.period-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.period-value {
    font-family: 'Monaco', 'Consolas', monospace;
    color: var(--gray-700);
    font-weight: 500;
}

.period-arrow {
    color: var(--gray-400);
    font-size: 9px;
}

.period-return {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 55px;
    text-align: center;
    font-size: 11px;
}

.period-return.return-positive { background: #dcfce7; color: #166534; }
.period-return.return-negative { background: #fee2e2; color: #991b1b; }

/* Period Details */
.period-details {
    display: none;
    padding: 12px;
    background: #f8fafc;
    animation: slideDown 0.2s ease-out;
}

.period-details.visible { display: block; }

.period-formula {
    background: white;
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--primary);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.period-formula .formula-label { font-weight: 600; color: var(--gray-600); }
.period-formula .formula-text {
    font-family: 'Monaco', 'Consolas', monospace;
    color: var(--gray-700);
    background: var(--gray-50);
    padding: 2px 8px;
    border-radius: 4px;
}
.period-formula .formula-calc {
    color: var(--gray-600);
    font-family: 'Monaco', 'Consolas', monospace;
}
.period-formula .positive { color: var(--success); }
.period-formula .negative { color: var(--danger); }

.period-cf-info {
    font-size: 11px;
    color: var(--gray-500);
    font-style: italic;
    margin-bottom: 12px;
    padding: 6px 10px;
    background: var(--gray-50);
    border-radius: 4px;
    border-left: 3px solid var(--primary);
}

.no-subperiods {
    text-align: center;
    padding: 20px;
    color: var(--gray-500);
    font-style: italic;
}

/* Holdings Evolution Table */
.holdings-table-wrap {
    overflow-x: auto;
}

.holdings-evolution {
    overflow-x: auto;
}

.holdings-evolution-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.holdings-evolution-table th {
    background: var(--gray-100);
    padding: 8px 10px;
    text-align: right;
    font-weight: 600;
    color: var(--gray-600);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.holdings-evolution-table th.left {
    text-align: left;
}

.holdings-evolution-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-100);
    text-align: right;
    color: var(--gray-700);
}

.holdings-evolution-table td.left {
    text-align: left;
}

.holdings-evolution-table tr:last-child td {
    border-bottom: none;
}

.holdings-evolution-table tr:hover {
    background: #fafafa;
}

.holdings-evolution-table .cash-row {
    background: #fefce8;
}

.holdings-evolution-table .cash-row:hover {
    background: #fef9c3;
}

.holdings-evolution-table .positive {
    color: var(--success);
    font-weight: 600;
}

.holdings-evolution-table .negative {
    color: var(--danger);
    font-weight: 600;
}

/* Ticker Cell */
.ticker-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ticker-badge {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    border-radius: 4px;
    color: var(--gray-700);
}

.ticker-badge.cash {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.shares-changed-badge {
    font-size: 9px;
    padding: 1px 4px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 3px;
    font-weight: 600;
}

.shares-cell {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 10px;
    color: var(--gray-600);
}

.price-cell {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: 500;
}

.value-cell {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: 500;
}

/* ========================================
   Transaction Type Badges
   ======================================== */

.tx-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tx-type-deposit {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
}

.tx-type-buy {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1d4ed8;
}

.tx-type-sell {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.tx-type-withdrawal {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.tx-type-cash {
    background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
    color: #7c3aed;
}

/* Notes expand button & row */
.btn-notes {
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 7px;
    color: var(--gray-500);
    line-height: 1;
}
.btn-notes:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}
.notes-row {
    display: none;
}
.notes-row.show {
    display: table-row;
}
.notes-cell {
    background: var(--gray-50);
    padding: 8px 16px;
    font-size: 13px;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
    font-style: italic;
}

/* Change Requests */
.change-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.change-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}
.change-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}
.change-item:last-child { border-bottom: none; }
.change-item-done {
    opacity: 0.55;
}
.change-item-done .change-text {
    text-decoration: line-through;
}
.change-check {
    padding-top: 2px;
}
.change-check input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}
.change-check input[type="checkbox"]:disabled {
    cursor: default;
}
.change-body {
    flex: 1;
    min-width: 0;
}
.change-text {
    font-size: 0.875rem;
    color: var(--gray-800);
    word-break: break-word;
}
.change-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 0.25rem;
}

.data-table tr.cash-type {
    background: #faf5ff;
}

.data-table tr.cash-type:hover {
    background: #f3e8ff;
}

/* ========================================
   Transaction Filters
   ======================================== */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    flex-wrap: wrap;
}

.filter-bar .filter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 16px;
    flex-shrink: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 140px;
}

.filter-group select:hover {
    border-color: var(--gray-300);
    background-color: var(--gray-50);
}

.filter-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-group select.filter-active {
    border-color: var(--primary);
    background-color: rgba(59, 130, 246, 0.05);
    font-weight: 500;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-left: auto;
}

.btn-clear-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-filters:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    color: var(--gray-700);
}

.btn-clear-filters:active {
    transform: scale(0.98);
}

.filter-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border-radius: 20px;
}

.filter-summary.has-filter {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.filter-summary .count {
    font-weight: 700;
}

/* ========================================
   Loading, Error, Notification
   ======================================== */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--gray-500);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid #fecaca;
}

.no-data {
    color: var(--gray-500);
    text-align: center;
    padding: 2rem;
}

.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--gray-800);
    color: white;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background: var(--danger);
}

.notification.success {
    background: var(--success);
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
    display: none !important;
}

.positive { color: var(--success); }
.negative { color: var(--danger); }

/* ========================================
   Footer
   ======================================== */

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* ========================================
   Responsive: Tablet (max-width: 1024px)
   ======================================== */

@media (max-width: 1024px) {
    .detail-metrics {
        grid-template-columns: repeat(3, 1fr);
    }

    .detail-columns {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Responsive: Mobile (max-width: 768px)
   ======================================== */

@media (max-width: 768px) {
    .tab-nav {
        padding: 0.4rem 0.5rem;
        gap: 0.15rem;
    }

    .fund-sub-tabs .tab-btn {
        padding: 0.5rem 0.65rem;
        font-size: 0.8rem;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .fund-tab-content .data-table,
    .endow-tab-content .data-table,
    .partner-holdings .data-table {
        font-size: 0.75rem;
        min-width: 580px;
    }

    .fund-tab-content .data-table th,
    .fund-tab-content .data-table td,
    .endow-tab-content .data-table th,
    .endow-tab-content .data-table td,
    .partner-holdings .data-table th,
    .partner-holdings .data-table td {
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }

    .matrix-table {
        min-width: 500px;
    }

    .matrix-table th,
    .matrix-table td {
        min-width: 55px;
        font-size: 0.7rem;
        padding: 0.3rem 0.35rem;
    }

    .fund-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .fund-actions button {
        width: 100%;
        min-height: 44px;
    }

    .fund-price-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .price-date-selector {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .fund-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .fund-card {
        padding: 0.6rem;
    }

    .fund-card .value {
        font-size: 1rem;
    }

    .partner-holdings {
        padding: 0.6rem;
        overflow-x: auto;
    }

    .partner-stats {
        gap: 0.5rem;
        font-size: 0.78rem;
    }

    .btn-sm {
        min-height: 36px;
        min-width: 36px;
        padding: 0.35rem 0.6rem;
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
    }

    .allocation-table .allocation-input {
        width: 70px;
        font-size: 0.8rem;
    }

    .filter-bar {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .filter-bar .filter-icon {
        display: none;
    }

    .filter-group select {
        min-width: 120px;
    }

    .filter-actions {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
        justify-content: space-between;
    }

    .benchmark-summary-row {
        gap: 8px;
    }

    .benchmark-summary-card {
        min-width: 90px;
    }

    .bsc-value {
        font-size: 16px;
    }

    .period-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .period-header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .holdings-evolution-table {
        font-size: 10px;
    }

    .holdings-evolution-table th,
    .holdings-evolution-table td {
        padding: 6px 8px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Responsive: Small Mobile (max-width: 640px)
   ======================================== */

@media (max-width: 640px) {
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .tab-nav {
        padding: 0.5rem;
    }

    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .main-content {
        padding: 1rem;
    }

    .section {
        padding: 1rem;
    }

    .detail-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}
