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

html {
    overflow-y: scroll;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    color: #1a1a1a;
    background: #fafafa;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav a {
    font-size: 0.9rem;
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    margin-left: 1.5rem;
}

nav a:first-child {
    margin-left: 0;
}

nav a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

header p {
    color: #666;
    font-size: 0.95rem;
}

main {
    max-width: 100%;
    overflow-x: hidden;
}

.data-date {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 2rem;
}

section {
    margin-bottom: 1.75rem;
    overflow-x: hidden;
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
    background: #f4f5f7;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #2563eb;
    border-radius: 0 4px 4px 0;
}

/* Portfolio-specific header colors */
#solar h2, #solar-benchmark h2 { border-left-color: #59a14f; }
#quantum h2, #quantum-benchmark h2 { border-left-color: #4e79a7; }
#robotics h2, #robotics-benchmark h2 { border-left-color: #f28e2b; }
#photonics h2, #photonics-benchmark h2 { border-left-color: #76b7b2; }

.holdings-link {
    font-size: 0.75rem;
    font-weight: 400;
    margin-left: 0.75rem;
}

.portfolio-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.summary {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.performance {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0;
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    border: 1px solid #dee2e6;
    border-bottom: none;
    overflow: visible;
    box-sizing: border-box;
    position: relative;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding-right: 1.5rem;
    border-right: 1px solid #dee2e6;
}

.metric:last-child {
    border-right: none;
    padding-right: 0;
}

/* Metric column widths for consistent alignment */
.metric:nth-child(1) { flex: 0 1 10%; }
.metric:nth-child(2) { flex: 0 1 18%; }
.metric:nth-child(3) { flex: 0 1 18%; }
.metric:nth-child(4) { flex: 0 1 20%; }
.metric:nth-child(5) { flex: 0 1 12%; }
.metric:nth-child(6) { flex: 0 1 12%; }

.metric .label {
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.metric .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
}

.metric .value.positive, td.positive {
    color: #198754;
}

.metric .value.negative, td.negative {
    color: #dc3545;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    margin-top: 1rem;
    table-layout: fixed;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #dee2e6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    font-weight: 500;
    background: #f1f3f4;
    border-bottom: 2px solid #ced4da;
}

/* Column widths: Ticker, Company, Type, Shares Owned, Value, Net */
th:nth-child(1), td:nth-child(1) { width: 10%; font-weight: 600; }
th:nth-child(2), td:nth-child(2) { width: 26%; }
th:nth-child(3), td:nth-child(3) { width: 24%; }
th:nth-child(4), td:nth-child(4) { width: 14%; text-align: right; }
th:nth-child(5), td:nth-child(5) { width: 14%; text-align: right; }
th:nth-child(6), td:nth-child(6) { width: 12%; text-align: right; }

tbody tr:hover {
    background: #f8f9fa;
}

/* Holdings table connects to performance metrics above */
.holdings-table {
    margin-top: 0;
    border-radius: 0 0 8px 8px;
}

/* Benchmark table connects to header above */
.benchmark-table {
    margin-top: 0;
}

.charts-section {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    flex: 1;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
}

.chart-container h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-align: center;
}

/* Reports page */
.report-item {
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.report-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.report-date {
    font-size: 0.8rem;
    color: #6c757d;
}

.report-type {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #fff;
    background: #6c757d;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

.report-item h2 {
    margin-bottom: 0.75rem;
}

.report-item h2 a {
    color: #1a1a1a;
    text-decoration: none;
}

.report-item h2 a:hover {
    color: #2563eb;
}

.report-summary {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.report-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    font-size: 0.75rem;
    color: #495057;
    background: #f1f3f4;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
}

/* Hamburger menu button - hidden on desktop */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    gap: 5px;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #333;
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Table wrapper for horizontal scroll */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

/* Default: hide short names/labels, show full versions */
.benchmark-table .short-name {
    display: none;
}

.benchmark-table .ticker-dash {
    display: inline;
}

.label-short {
    display: none;
}

.label-full {
    display: inline;
}

/* Tablet breakpoint */
@media (max-width: 768px) {
    .table-wrapper {
        margin: 0;
        padding: 0;
    }

    table {
        min-width: 550px;
    }

    /* Benchmark table: hide Investment column, show ticker/short-name only */
    .benchmark-table .name-cell,
    .benchmark-table th:first-child {
        display: none;
    }

    .benchmark-table .ticker-dash {
        display: none;
    }

    .benchmark-table .short-name {
        display: inline;
        font-weight: 600;
    }

    .benchmark-table {
        min-width: auto;
    }

    /* Holdings table: hide Company and Type columns */
    .holdings-table .hide-mobile {
        display: none;
    }

    .holdings-table {
        min-width: auto;
        border-radius: 0 0 8px 8px;
    }

    /* Performance metrics: 2x2 grid with abbreviated labels */
    .performance {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .performance .metric {
        flex: none;
        text-align: center;
        border-right: none;
        padding-right: 0;
    }

    .performance .hide-mobile {
        display: none;
    }

    .label-full {
        display: none;
    }

    .label-short {
        display: inline;
    }
}

/* Mobile breakpoint */
@media (max-width: 600px) {
    body {
        padding: 1rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    header p {
        font-size: 0.85rem;
    }

    h2 {
        font-size: 1rem;
    }

    /* Hamburger menu visible on mobile */
    .menu-toggle {
        display: flex;
    }

    .header-top {
        flex-wrap: wrap;
    }

    nav {
        display: none;
        width: 100%;
        flex-direction: column;
        padding-top: 1rem;
        margin-top: 1rem;
        border-top: 1px solid #e5e5e5;
    }

    nav.menu-open {
        display: flex;
    }

    nav a {
        margin-left: 0;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f0f0f0;
    }

    nav a:last-child {
        border-bottom: none;
    }

    /* Charts stack vertically */
    .charts-section {
        flex-direction: column;
        gap: 1rem;
    }

    /* Metrics horizontal scroll */
    .performance {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 1rem;
        padding: 0.75rem 1rem;
    }

    .metric {
        flex-shrink: 0;
        min-width: 90px;
        padding-right: 1rem;
    }

    .metric .value {
        font-size: 1.1rem;
    }

    /* Table adjustments */
    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.4rem 0.5rem;
    }

    /* Reports page */
    .report-item {
        padding: 1rem;
    }
}

/* Methodology footer */
.methodology {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e5e5;
}

.methodology p {
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.6;
}

/* Benchmarks page */
.benchmark-table {
    table-layout: auto;
}

.benchmark-table th:nth-child(1), .benchmark-table td:nth-child(1) { width: auto; text-align: left; font-weight: normal; }
.benchmark-table th:nth-child(2), .benchmark-table td:nth-child(2) { width: 8%; text-align: left; }
.benchmark-table th:nth-child(3), .benchmark-table td:nth-child(3) { width: 10%; text-align: right; }
.benchmark-table th:nth-child(4), .benchmark-table td:nth-child(4) { width: 10%; text-align: right; }
.benchmark-table th:nth-child(5), .benchmark-table td:nth-child(5) { width: 10%; text-align: right; }
.benchmark-table th:nth-child(6), .benchmark-table td:nth-child(6) { width: 10%; text-align: right; }

.benchmark-table .portfolio-row {
    background: #f0f7ff;
}

.benchmark-table .portfolio-row td {
    border-bottom: 2px solid #dee2e6;
}

/* Benchmark line chart on Overview */
.benchmark-chart-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.benchmark-toggles {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0.75rem;
}

.toggle-label {
    font-size: 0.75rem;
    color: #6c757d;
    margin-right: 0.25rem;
}

.toggle-divider {
    color: #dee2e6;
    margin: 0 0.25rem;
}

.etf-toggle {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
}

.etf-toggle:hover {
    border-color: #adb5bd;
    background: #dee2e6;
}

.etf-toggle.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.etf-toggle.active:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* Chart placeholder for new portfolios */
.chart-placeholder {
    margin-top: 1.5rem;
    padding: 2rem;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    color: #6c757d;
    font-size: 0.875rem;
    font-style: italic;
}

/* Exited Positions dropdown */
.exited-positions-dropdown {
    margin-top: 1rem;
}

.exited-positions-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: #f1f3f4;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    user-select: none;
    transition: background 0.15s ease;
}

.exited-positions-toggle:hover {
    background: #e9ecef;
}

.exited-positions-toggle .toggle-icon {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.exited-positions-dropdown[open] .toggle-icon {
    transform: rotate(90deg);
}

.exited-positions-dropdown[open] .exited-positions-toggle {
    border-radius: 6px 6px 0 0;
    border-bottom: none;
}

.exited-positions-dropdown .table-wrapper {
    margin: 0;
    padding: 0;
}

.exited-table {
    margin-top: 0;
    border-radius: 0 0 6px 6px;
    border-top: none;
    table-layout: auto;
}

/* Exited table column widths: Ticker, Company, Type, Exited, Cost, Proceeds, Gain */
.exited-table th:nth-child(1), .exited-table td:nth-child(1) { width: 8%; font-weight: 600; }
.exited-table th:nth-child(2), .exited-table td:nth-child(2) { width: 24%; }
.exited-table th:nth-child(3), .exited-table td:nth-child(3) { width: 18%; }
.exited-table th:nth-child(4), .exited-table td:nth-child(4) { width: 12%; }
.exited-table th:nth-child(5), .exited-table td:nth-child(5) { width: 12%; text-align: right; }
.exited-table th:nth-child(6), .exited-table td:nth-child(6) { width: 14%; text-align: right; }
.exited-table th:nth-child(7), .exited-table td:nth-child(7) { width: 12%; text-align: right; }

.exited-table tbody tr {
    background: #fafafa;
}

.exited-table tbody tr:hover {
    background: #f1f3f4;
}

/* Exited table mobile: hide Company, Type, Cost columns and remove min-width */
@media (max-width: 768px) {
    .exited-table .hide-mobile {
        display: none;
    }

    .exited-table {
        min-width: auto;
    }
}

/* Core benchmark row styling */
.core-benchmark-row {
    background: #f0f0f0;
    border-left: 3px solid #6b7280;
}

.core-benchmark-row:hover {
    background: #f0f0f0;
}

.core-benchmark-row td {
    font-weight: 500;
}

.core-benchmark-row td.name-cell {
    font-weight: 600;
}

/* Market status indicator */
.market-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: #495057;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

@media (max-width: 500px) {
    .market-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .status-separator {
        display: none;
    }

    .status-date {
        font-size: 0.75rem;
    }
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.status-open {
    background: #198754;
    box-shadow: 0 0 4px rgba(25, 135, 84, 0.5);
}

.status-dot.status-closed {
    background: #dc3545;
}

.status-dot.status-unknown {
    background: #6c757d;
}

.status-text {
    font-weight: 500;
}

.status-separator {
    color: #adb5bd;
}

.status-date {
    font-weight: 400;
}
