/* ============================================
   AUTH STYLES
   ============================================ */

.form-footer {
    margin-top: 12px;
    text-align: center;
}

.text-link {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.text-link:hover {
    color: #5568d3;
    text-decoration: underline;
}

.form-note {
    margin-top: 16px;
    font-size: 12px;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

.error-message {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.error-message:not(:empty) {
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.error-message[style*="color: #28a745"],
.error-message[style*="color:#28a745"] {
    background-color: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb !important;
}

button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.password-strength {
    margin-top: 8px;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    transition: width 0.3s, background-color 0.3s;
}

.password-strength-weak {
    width: 33%;
    background-color: #ef4444;
}

.password-strength-medium {
    width: 66%;
    background-color: #f59e0b;
}

.password-strength-strong {
    width: 100%;
    background-color: #10b981;
}

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

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px 20px 0 20px;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    margin: 0;
}

@media (max-width: 768px) {
    body {
        padding: 10px 10px 0 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px 5px 0 5px;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    width: 100%;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 5px;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-in;
}

.loading-overlay.active {
    display: flex;
}

/* Inline section loader (replaces full-screen overlay on init) */
.section-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    color: #667eea;
    font-size: 14px;
    justify-content: center;
}

.section-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(102, 126, 234, 0.25);
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* Live prices loading bar at top of portfolio section */
.prices-loading-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: #f0f4ff;
    border-radius: 8px;
    font-size: 12px;
    color: #667eea;
    overflow: hidden;
    position: relative;
}

.prices-loading-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.2), transparent);
    animation: prices-sweep 1.4s ease-in-out infinite;
}

@keyframes prices-sweep {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(350%);
    }
}

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#loading-message {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    color: white;
}

@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 8px;
    }
}

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    position: relative;
}

header .logo-header {
    margin-bottom: 20px;
}

header .bull-logo {
    width: 180px;
}

header .logo-text h1 {
    color: white;
    font-size: 2.5rem;
    margin: 0;
}

header .logo-text p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin: 5px 0 0 0;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    display: grid;
    gap: 30px;
    overflow-x: hidden;
    width: 100%;
}

/* Main Tabs - Connected tab style */
.main-tabs {
    display: flex;
    gap: 5px;
    background: transparent;
    padding: 0 30px;
    margin-bottom: 0;
}

.main-tab-btn {
    padding: 12px 24px;
    border: 2px solid #e0e0e0;
    border-bottom: none;
    background: #f8f9fa;
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s ease;
    position: relative;
    margin-bottom: -2px;
}

.main-tab-btn:hover {
    color: #333;
    background: #fff;
}

.main-tab-btn.active {
    color: #333;
    background: white;
    border-color: #e0e0e0;
    z-index: 1;
    font-weight: 600;
}

.main-tab-content {
    display: none;
}

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

section {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 0 8px 8px 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    overflow-x: hidden;
    width: 100%;
}

@media (max-width: 768px) {
    .main-tabs {
        padding: 0 10px;
        gap: 3px;
    }

    .main-tab-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    section {
        padding: 15px;
        border-radius: 0 6px 6px 6px;
    }
}

@media (max-width: 480px) {
    .main-tabs {
        padding: 0 5px;
        gap: 2px;
    }

    .main-tab-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    section {
        padding: 10px;
        border-width: 1px;
    }
}

@media (max-width: 480px) {
    .main-tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    section {
        padding: 15px;
        border-radius: 6px;
    }
}

/* First section (portfolio) connects with tabs */
section.portfolio {
    border-radius: 0 12px 12px 12px;
}

@media (max-width: 768px) {
    section.portfolio {
        border-radius: 0 8px 8px 8px;
    }
}

@media (max-width: 480px) {
    section.portfolio {
        border-radius: 0 6px 6px 6px;
    }
}

.portfolio-container {
    position: relative;
    min-height: 650px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.portfolio-center {
    position: absolute;
    width: 400px;
    height: 400px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.portfolio-cards {
    position: relative;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

@media (max-width: 1024px) {
    .portfolio-container {
        min-height: 600px;
    }

    .portfolio-center {
        width: 300px;
        height: 300px;
    }
}

@media (max-width: 768px) {
    .portfolio-container {
        flex-direction: column;
        min-height: auto;
        padding: 20px;
    }

    .portfolio-center {
        position: relative;
        transform: none;
        top: auto;
        left: auto;
        margin-bottom: 30px;
        width: 280px;
        height: 280px;
    }

    .portfolio-cards {
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .stock-card {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        width: 100%;
        max-width: 100%;
    }

    .stock-card::before {
        display: none;
    }
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 12px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

input,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.stock-card {
    position: absolute;
    background: white;
    border-radius: 10px;
    padding: 15px;
    border: 3px solid;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 220px;
    pointer-events: auto;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.stock-card::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 60px;
    background: currentColor;
    opacity: 0.4;
}

/* Line pointing to chart based on position */
.stock-card[data-position="right"]::before {
    left: -60px;
    top: 50%;
    transform: translateY(-50%);
}

.stock-card[data-position="left"]::before {
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
}

.stock-card[data-position="top"]::before {
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%) rotate(90deg);
}

.stock-card[data-position="bottom"]::before {
    top: -60px;
    left: 50%;
    transform: translateX(-50%) rotate(90deg);
}

.stock-card[data-position="top-right"]::before,
.stock-card[data-position="top-left"]::before,
.stock-card[data-position="bottom-right"]::before,
.stock-card[data-position="bottom-left"]::before {
    width: 80px;
    height: 2px;
}

.stock-card[data-position="top-right"]::before {
    bottom: 20%;
    left: -80px;
    transform: rotate(-35deg);
    transform-origin: right center;
}

.stock-card[data-position="top-left"]::before {
    bottom: 20%;
    right: -80px;
    transform: rotate(35deg);
    transform-origin: left center;
}

.stock-card[data-position="bottom-right"]::before {
    top: 20%;
    left: -80px;
    transform: rotate(35deg);
    transform-origin: right center;
}

.stock-card[data-position="bottom-left"]::before {
    top: 20%;
    right: -80px;
    transform: rotate(-35deg);
    transform-origin: left center;
}

.stock-card:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 20;
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid currentColor;
}

.stock-ticker {
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
}

.stock-percentage {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: currentColor;
    padding: 4px 10px;
    border-radius: 6px;
}

.stock-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-item {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 6px;
}

.detail-label {
    font-size: 0.7rem;
    color: #666;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

@media (max-width: 768px) {
    .stock-card {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        max-width: 100%;
    }

    .stock-card::before {
        display: none;
    }
}

.stock-percentage {
    font-size: 1rem;
    font-weight: 600;
    color: #667eea;
    background: #f0f3ff;
    padding: 3px 10px;
    border-radius: 6px;
}

.stock-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.detail-item {
    background: white;
    padding: 8px 10px;
    border-radius: 6px;
}

.detail-label {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.transaction-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    align-items: center;
}

.transaction-type {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.transaction-type.buy {
    background: #d4edda;
    color: #155724;
}

.transaction-type.sell {
    background: #f8d7da;
    color: #721c24;
}

.transaction-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.transaction-info span {
    color: #555;
}

.btn-delete {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-delete:hover {
    background: #c82333;
}

.loading {
    text-align: center;
    color: #667eea;
    font-style: italic;
}

.error {
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px;
}

@media (max-width: 768px) {
    .stock-details {
        grid-template-columns: 1fr;
    }

    .transaction-item {
        grid-template-columns: 1fr;
    }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none !important;
    padding-top: 20px;
}

.tab-content.active {
    display: block !important;
}

/* CSV Import */
.csv-import-area {
    display: grid;
    gap: 30px;
}

.csv-instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.csv-instructions h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.csv-instructions ul {
    margin: 15px 0;
    padding-left: 20px;
}

.csv-instructions li {
    margin: 8px 0;
    color: #555;
}

.csv-instructions .note {
    margin-top: 15px;
    padding: 10px;
    background: #e7f3ff;
    border-radius: 4px;
    color: #0066cc;
    font-size: 0.9rem;
}

.csv-upload-section {
    text-align: center;
    padding: 30px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
}

.csv-upload-btn {
    display: inline-block;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 15px 30px;
}

#import-status {
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 15px;
    display: block;
}

/* View Options */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    margin: 0;
}

.view-options-inline {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 20px;
}

.option-group-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.option-group-inline label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.option-group-inline select {
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.2s;
}

.option-group-inline select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Filter Dropdown */
.filter-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.filter-dropdown label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
}

.filter-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    min-width: 150px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.filter-dropdown-toggle:hover {
    border-color: #667eea;
}

.filter-dropdown-toggle.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: #666;
    transition: transform 0.2s;
}

.filter-dropdown-toggle.active .dropdown-arrow {
    transform: rotate(180deg);
}

.filter-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.filter-dropdown-menu.active {
    display: block;
}

.filter-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-option:hover {
    background: #f8f9fa;
}

.filter-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 0;
    font-size: 0.9rem;
    color: #333;
}

.filter-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.filter-divider {
    height: 1px;
    background: #e9ecef;
    margin: 4px 0;
}

.filter-select-all {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.filter-select-all label {
    font-weight: 600 !important;
    color: #495057 !important;
}

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-options-inline {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .option-group-inline {
        width: 100%;
    }

    .option-group-inline select {
        flex: 1;
    }
}

/* Authentication */
.auth-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 100;
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
}

.auth-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .auth-container {
        padding: 0;
    }

    .auth-box {
        border-radius: 0;
        padding: 30px 20px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-shadow: none;
        max-width: 100%;
    }
}

/* Logo Header - Image + Text Side by Side */
.logo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.bull-logo {
    width: 150px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

.logo-text h1 {
    color: #667eea;
    margin: 0;
    font-size: 2rem;
    line-height: 1;
}

.logo-text p {
    color: #666;
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    line-height: 1.2;
}

.auth-box .tagline {
    text-align: left;
}

.auth-box h1 {
    color: #667eea;
    text-align: center;
    margin-bottom: 10px;
}

.auth-box p {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.auth-tab {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    margin-bottom: -2px;
}

.auth-tab:hover {
    color: #667eea;
}

.auth-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.error-message {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 10px;
    text-align: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
}

.user-info span {
    color: white;
    font-weight: 500;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.portfolio-selector-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

.portfolio-selector-header label {
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
}

.portfolio-selector-header select {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    cursor: pointer;
    min-width: 120px;
    font-weight: 600;
}

.portfolio-selector-header select:focus {
    outline: none;
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.portfolio-add-btn-header {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.portfolio-add-btn-header:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.portfolio-delete-btn-header {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.portfolio-delete-btn-header:hover {
    background: rgba(220, 53, 69, 0.7);
    border-color: rgba(220, 53, 69, 0.8);
    transform: scale(1.05);
}

.currency-selector-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

.currency-selector-header label {
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
}

.currency-selector-header select {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    cursor: pointer;
    min-width: 80px;
    font-weight: 600;
}

.currency-selector-header select:focus {
    outline: none;
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

#logout-btn,
#settings-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 90px;
}

/* Transactions Table */
/* ============================================
   TRANSACTIONS TABLE - CLEAN REBUILD
   ============================================ */

/* Table Container */
.transactions-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0 0 0;
    padding: 0;
    position: relative;
    width: 100%;
}

/* Base Table Styles */
.transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
}

/* Table Header */
.transactions-table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.transactions-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Sortable Headers */
.transactions-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.transactions-table th.sortable:hover {
    background: #e9ecef;
}

.transactions-table .sort-indicator {
    color: #667eea;
    font-size: 0.7rem;
    margin-left: 4px;
}

/* Table Body Cells */
.transactions-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    position: relative;
}

.transactions-table tbody tr:hover {
    background: #f8f9fa;
}

/* Editable Cells */
.transactions-table td.editable:hover {
    background: #f0f3ff;
}

.transactions-table td.non-editable {
    cursor: default;
}

.edit-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.7rem;
    color: #adb5bd;
    opacity: 0;
    transition: opacity 0.2s;
}

.transactions-table td.editable:hover .edit-indicator {
    opacity: 1;
}

.auto-fetched-price {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #e07b00;
    font-weight: 500;
}

.auto-fetched-icon {
    font-size: 0.75rem;
    opacity: 0.75;
    cursor: help;
    line-height: 1;
}

/* Editing State */
.transactions-table td.editing {
    padding: 0;
}

.transactions-table td.editing input,
.transactions-table td.editing select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #667eea;
    background: #fff;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.transactions-table td.editing input:focus,
.transactions-table td.editing select:focus {
    outline: none;
}

/* Form Inputs */
.transactions-table input,
.transactions-table select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9rem;
}

.transactions-table input:focus,
.transactions-table select:focus {
    outline: none;
    border-color: #667eea;
}

/* New Transaction Row (Footer) */
.transactions-table tfoot tr {
    background: #fff9e6;
}

.transactions-table tfoot td {
    padding: 0;
    border-bottom: 1px solid #e9ecef;
}

.transactions-table tfoot input,
.transactions-table tfoot select {
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    box-sizing: border-box;
    margin: 0;
    font-family: inherit;
}

.transactions-table tfoot input:focus,
.transactions-table tfoot select:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
    background: white;
}

.transactions-table tfoot input[type="number"] {
    text-align: left;
}

/* Action buttons in new row */
.transactions-table tfoot .action-cell {
    padding: 10px 12px;
}

.transactions-table tfoot button {
    padding: 4px 8px;
    font-size: 0.9rem;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.transactions-table tfoot button:hover {
    transform: scale(1.2);
}

/* Transaction Type Colors */
.transactions-table .type-buy {
    color: #28a745;
    font-weight: 600;
}

.transactions-table .type-sell {
    color: #dc3545;
    font-weight: 600;
}

.transactions-table .type-split {
    color: #667eea;
    font-weight: 600;
}

.transactions-table .type-roc {
    color: #fd7e14;
    font-weight: 600;
}

.transactions-table .type-capital_gains_dist {
    color: #20c997;
    font-weight: 600;
}

.transactions-table .type-dividend {
    color: #17a2b8;
    font-weight: 600;
}

.transactions-table .type-drip {
    color: #6f42c1;
    font-weight: 600;
}

.transactions-table .type-reinvested_gains {
    color: #e83e8c;
    font-weight: 600;
}

/* Options Transaction Types - Magenta */
.transactions-table .type-long_call,
.transactions-table .type-long_put,
.transactions-table .type-short_call,
.transactions-table .type-short_put,
.transactions-table .type-option_sell,
.transactions-table .type-option_exercise,
.transactions-table .type-option_expire {
    color: #d946ef;
    font-weight: 600;
}

/* ============================================
   ADD TRANSACTION FORM
   ============================================ */

.add-transaction-form {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.add-transaction-form .form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.add-transaction-form .form-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.btn-toggle-form {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-toggle-form:hover {
    background: #e9ecef;
    color: #333;
}

.add-transaction-form .form-content {
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 600px;
    gap: 32px;
    align-items: stretch;
}

.add-transaction-form .form-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
    min-height: 100%;
}

.add-transaction-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.add-transaction-form .form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.add-transaction-form .form-field label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

.add-transaction-form .form-field input,
.add-transaction-form .form-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.add-transaction-form .form-field input:focus,
.add-transaction-form .form-field select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.add-transaction-form .dynamic-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.add-transaction-form .form-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.add-transaction-form .btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-transaction-form .btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.add-transaction-form .btn-secondary {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-transaction-form .btn-secondary:hover {
    background: #dee2e6;
}

/* Transaction Info Card (Right Side) */
.transaction-info-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.transaction-info-card .info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid #dee2e6;
}

.transaction-info-card .info-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
}

.transaction-info-card .info-title {
    flex: 1;
}

.transaction-info-card .info-title h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.transaction-info-card .info-title p {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    color: #6c757d;
}

.transaction-info-card .info-section {
    margin-bottom: 16px;
}

.transaction-info-card .info-section:last-child {
    margin-bottom: 0;
}

.transaction-info-card .info-section h5 {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transaction-info-card .info-section p {
    margin: 0;
    font-size: 0.95rem;
    color: #333;
    line-height: 1.5;
}

.transaction-info-card .info-example {
    background: white;
    border-left: 3px solid #667eea;
    padding: 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #495057;
    line-height: 1.6;
}

.transaction-info-card .info-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #adb5bd;
}

.transaction-info-card .info-placeholder svg {
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Form collapsed state */
.add-transaction-form.collapsed .form-content {
    display: none;
}

.add-transaction-form.collapsed .form-header {
    border-radius: 8px;
    border-bottom: none;
}

/* Mobile responsive */
@media (max-width: 1024px) {
    .add-transaction-form .form-content {
        grid-template-columns: 1fr;
    }

    .transaction-info-card {
        position: static;
    }
}

/* ============================================
   MOBILE VIEW - BELOW 1200px
   ============================================ */

@media (max-width: 1200px) {
    /* Hide table headers */
    .transactions-table thead {
        display: none;
    }

    .transactions-table tbody, .transactions-table tfoot {
        display: block;
    }

    /* Compact card layout for all rows */
    .transactions-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 12px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background: white;
        padding: 0;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        cursor: pointer;
        transition: all 0.2s;
        overflow: hidden;
    }

    .transactions-table tr:active {
        transform: scale(0.99);
    }

    /* Base cell styles */
    .transactions-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 16px;
        border: none;
        border-bottom: 1px solid #f1f3f5;
        white-space: normal;
        text-align: right;
        font-size: 0.9rem;
    }
    .transactions-table td:last-child {
        border-bottom: none;
    }

    .transactions-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        text-transform: uppercase;
        font-size: 0.75rem;
        letter-spacing: 0.5px;
        margin-right: 15px;
        text-align: left;
    }

    .transactions-table td:nth-child(1) {
        background: #f8f9fa;
        display: flex;
        justify-content: space-between;
        padding: 8px 16px;
    }
    .transactions-table td:nth-child(1)::before {
        content: "Select";
    }

    .transactions-table td:nth-child(4) {
        font-weight: 600;
    }

    .transactions-table td:nth-child(11) {
        font-size: 1rem;
        background: #fdfdfe;
    }

    /* Hide new array of columns */
    .transactions-table td:nth-child(7),
    .transactions-table td:nth-child(8),
    .transactions-table td:nth-child(9),
    .transactions-table td:nth-child(10),
    .transactions-table td:nth-child(12) {
        display: none;
    }

    .transactions-table .edit-indicator {
        display: none;
    }

    .transactions-table tr.expanded {
        border-color: #667eea;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
        cursor: default;
    }

    /* Show hidden columns in expanded view */
    .transactions-table tr.expanded td:nth-child(7),
    .transactions-table tr.expanded td:nth-child(8),
    .transactions-table tr.expanded td:nth-child(9),
    .transactions-table tr.expanded td:nth-child(10),
    .transactions-table tr.expanded td:nth-child(12) {
        display: flex;
        background: #fcfcfc;
    }

    /* Special actions styling */
    .transactions-table tr.expanded td:nth-child(12) {
        justify-content: flex-end;
        background: #f8f9fa;
        border-top: 1px solid #dee2e6;
        padding: 12px 16px;
        gap: 12px;
    }
    .transactions-table tr.expanded td:nth-child(12)::before {
        content: "Actions";
    }

    .transactions-table td input,
    .transactions-table td select {
        width: 60%;
        text-align: right;
    }
    .transactions-table td.editing input,
    .transactions-table td.editing select {
        width: 100%;
        text-align: left;
    }

    .transactions-table .btn-icon {
        font-size: 1rem;
        padding: 8px 12px;
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 6px;
    }
}
}

.table-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}

.action-spacer {
    flex: 1;
}

.sample-link {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.sample-link:hover {
    background: #f0f3ff;
    text-decoration: underline;
}

.import-status {
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    display: none;
}

.import-status:not(:empty) {
    display: block;
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

.btn-add {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-save-all {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save-all:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-cancel-all {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-all:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-delete-multi {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-multi:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-delete-all {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-all:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.btn-import {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-import:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.btn-export {
    background: #28a745;
    color: white;
    border: 1px solid #28a745;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    background: #218838;
    border-color: #1e7e34;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-import-export {
    background: #667eea;
    color: white;
    border: 1px solid #667eea;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-import-export:hover {
    background: #5568d3;
    border-color: #4c5fd1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 2000;
    margin-bottom: 4px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

.dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    color: #6c757d;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: #dc3545;
}

.btn-save {
    background: #28a745;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-save:hover {
    background: #218838;
}

.btn-cancel {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-cancel:hover {
    background: #c82333;
}

.fetching-price {
    color: #667eea;
    font-style: italic;
    font-size: 0.85rem;
}

@media (max-width: 768px) {

    /* Compact filters on mobile */
    .view-options-inline {
        gap: 10px;
        margin-bottom: 15px;
        flex-wrap: wrap;
    }

    .option-group-inline,
    .filter-dropdown {
        min-width: 0 !important;
        flex: 1 1 calc(50% - 5px);
        max-width: none;
    }

    .option-group-inline label,
    .filter-dropdown label {
        font-size: 0.75rem;
        margin-bottom: 4px;
    }

    .option-group-inline select,
    .filter-dropdown-toggle {
        padding: 8px 10px;
        font-size: 0.85rem;
        width: 100%;
    }

    /* Reduce section padding */
    section {
        padding: 15px 10px;
    }

    /* Mobile: Convert table to compact expandable cards */
    .transactions-table-container {
        margin: 15px 0 0 0;
        padding: 0;
        overflow-x: visible;
    }

    .transactions-table {
        display: block;
        min-width: 0;
        width: 100%;
    }



    /* Option details row */
    .option-details-row {
        display: block !important;
        padding: 8px !important;
        margin-top: -8px;
        margin-bottom: 0;
        border: none !important;
        border-radius: 0 0 6px 6px;
        background: #fff3cd !important;
        cursor: default !important;
    }

    .option-details-row td {
        padding: 0 !important;
        display: block !important;
    }

    .option-details-row td::before {
        display: none !important;
    }

    .option-details-expanded {
        font-size: 0.7rem;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .option-badge {
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    .option-info {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .option-status {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Table actions */
    .table-actions {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .table-actions button {
        font-size: 0.85rem;
        padding: 10px 15px;
        flex: 0 1 auto;
    }

    /* Pagination */
    .pagination-container {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .pagination-info {
        font-size: 0.85rem;
        text-align: center;
    }

    .pagination-controls {
        gap: 10px;
    }

    .pagination-controls button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* Modal Dialog */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 2px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #333;
}

.modal-body {
    padding: 16px 20px;
}

/* Import Modal Styles */
.import-modal-wide {
    max-width: 900px !important;
}

.import-instructions {
    margin-bottom: 12px;
}

.import-section {
    background: #fff;
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
}

.import-section h4 {
    color: #1a1a2e;
    margin: 0 0 10px 0;
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

.import-section h5 {
    color: #343a40;
    margin: 10px 0 6px 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.options-section {
    background: #fff;
}

.options-subsection {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f3f5;
}

.options-subsection:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.options-subsection h5 {
    margin-bottom: 8px;
}

.options-subsection h5 .heading-type {
    color: #495057;
    font-weight: 600;
    background: #f1f3f5;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.subsection-note {
    margin: 6px 0 0 0;
    padding: 6px 10px;
    background: #f8f9fa;
    border-left: 2px solid #adb5bd;
    border-radius: 0 4px 4px 0;
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
}

.columns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
    margin: 8px 0;
}

.column-item {
    background: #f8f9fa;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
}

.column-item.optional {
    border-color: #e9ecef;
    opacity: 0.8;
}

.column-item strong {
    display: block;
    color: #343a40;
    font-size: 0.9rem;
    font-weight: 700;
}

.column-item.optional strong {
    color: #868e96;
}

.column-item span {
    display: block;
    color: #868e96;
    font-size: 0.8rem;
    line-height: 1.3;
}

.column-item code {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    color: #495057;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.82rem;
    font-family: 'Courier New', monospace;
    word-break: break-word;
    overflow-wrap: break-word;
}

.csv-example {
    background: #f8f9fa;
    padding: 10px 12px;
    border-radius: 6px;
    margin-top: 8px;
    border: 1px solid #e9ecef;
}

.csv-example strong {
    display: block;
    color: #495057;
    margin-bottom: 6px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.csv-example code {
    display: block;
    background: #1e2433;
    color: #cdd9e5;
    padding: 10px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
}

.csv-example .example-note {
    margin-top: 8px;
    font-size: 0.78rem;
    color: #868e96;
    font-style: italic;
}

.import-instructions h4 {
    color: #343a40;
    margin-bottom: 10px;
    font-size: 1rem;
}

.import-instructions p {
    color: #6c757d;
    margin-bottom: 6px;
    line-height: 1.5;
}

.import-instructions ul {
    margin: 4px 0;
    padding-left: 18px;
}

.import-instructions li {
    margin: 3px 0;
    color: #6c757d;
    line-height: 1.4;
    font-size: 0.875rem;
}

.import-instructions li strong {
    color: #343a40;
}

.import-note {
    background: #f8f9fa;
    border-left: 3px solid #adb5bd;
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
    color: #495057;
    font-size: 0.875rem;
    margin: 8px 0;
    line-height: 1.4;
}

.import-note.info {
    background: #f0f4ff;
    border-left-color: #748ffc;
    color: #364fc7;
}

.import-note.warning {
    background: #fff9db;
    border-left-color: #fcc419;
    color: #7d5a00;
}

.import-note.critical {
    background: #fff5f5;
    border-left-color: #fa5252;
    color: #c92a2a;
}

.import-note.critical strong {
    color: #c92a2a;
    font-size: 0.95rem;
}

.import-note.critical p {
    margin: 6px 0;
}

.import-note ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
}

.import-note li {
    margin: 3px 0;
    font-size: 0.82rem;
}

.import-note a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.sample-downloads {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 12px 0;
    flex-wrap: wrap;
}

.sample-csv-section {
    background: #f8f9fa;
    padding: 12px 14px;
    border-radius: 8px;
    margin: 12px 0;
}

.sample-csv-section h4 {
    color: #343a40;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.csv-preview {
    background: #1e2433;
    color: #cdd9e5;
    padding: 10px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    margin-bottom: 8px;
}

.csv-preview code {
    display: block;
    white-space: pre;
    line-height: 1.5;
}

.btn-download {
    display: inline-block;
    background: #495057;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-download:hover {
    background: #343a40;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.import-upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    margin-top: 12px;
    gap: 10px;
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #2f9e44;
    color: white;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-upload:hover {
    background: #2b8a3e;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(47, 158, 68, 0.3);
}

#import-modal-status {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    width: 100%;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

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

    .sample-downloads {
        flex-direction: column;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }
}

/* Duplicate Detection Modal */
.duplicate-modal-content {
    max-width: 1000px;
}

.duplicate-warning {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px 15px;
    border-radius: 4px;
    color: #856404;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.duplicate-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 20px;
}

.duplicate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.duplicate-table thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

.duplicate-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.85rem;
}

.duplicate-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e9ecef;
}

.duplicate-table tbody tr {
    transition: background 0.2s;
}

.duplicate-table tbody tr:hover {
    background: #f8f9fa;
}

.duplicate-table tbody tr.duplicate-row {
    background: #fff3cd;
}

.duplicate-table tbody tr.duplicate-row:hover {
    background: #ffe69c;
}

.duplicate-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.duplicate-status.status-duplicate {
    background: #fff3cd;
    color: #856404;
}

.duplicate-status.status-new {
    background: #d4edda;
    color: #155724;
}

.duplicate-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.new-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #d4edda;
    color: #155724;
    border: 1px solid #28a745;
}

.duplicate-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .duplicate-table {
        font-size: 0.8rem;
    }

    .duplicate-table th,
    .duplicate-table td {
        padding: 8px 4px;
    }

    .duplicate-actions {
        flex-direction: column;
    }

    .duplicate-actions button {
        width: 100%;
    }
}


/* Portfolio Tabs - Modern Design */
.portfolio-tabs-container {
    display: flex;
    align-items: stretch;
    gap: 12px;
    margin: 0 auto;
    max-width: 1400px;
    padding: 0 20px;
    margin-bottom: -1px;
    background: transparent;
    min-height: 60px;
    padding-bottom: 0;
}

.portfolio-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    /* Firefox */
    align-items: flex-end;
    padding-bottom: 0;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.portfolio-tabs::-webkit-scrollbar {
    display: none;
}

.portfolio-tab {
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
    transition: all 0.2s ease;
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
    margin-bottom: 0;
}

.portfolio-tab:hover {
    color: #667eea;
    background: rgba(255, 255, 255, 0.85);
}

.portfolio-tab.active {
    color: #667eea;
    background: white;
    font-weight: 600;
    border-color: #e0e0e0;
    border-bottom: 1px solid white;
    z-index: 1;
    margin-bottom: -1px;
}

.portfolio-tab-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    font-size: 0.9rem;
    line-height: 1;
    transition: all 0.2s ease;
    margin-left: 4px;
}

.portfolio-tab-edit:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.portfolio-tab-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s ease;
    margin-left: 4px;
}

.portfolio-tab-delete:hover {
    background: #dc3545;
    color: white;
    transform: scale(1.1);
}

.portfolio-add-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #667eea;
    color: white;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    align-self: flex-end;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    margin-bottom: 8px;
    margin-right: 0;
}

.portfolio-add-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.portfolio-add-btn:active {
    transform: translateY(0);
}

.portfolio-add-btn span {
    line-height: 1;
    margin-top: -2px;
}

.portfolio-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.portfolio-section-header h2 {
    margin: 0;
}

.btn-toggle-cards {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle-cards:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.portfolio-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portfolio-card {
    background: white;
    border-radius: 6px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    cursor: pointer;
    overflow: hidden;
}

.portfolio-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.portfolio-card.active {
    border: 2px solid #667eea;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.2);
}

.portfolio-card-header {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 20px;
    padding: 4px 16px;
    transition: background 0.2s;
}

.portfolio-card-header:hover {
    background: #f8f9fa;
}

.portfolio-card.expanded .portfolio-card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 6px 16px 8px 16px;
}

.portfolio-ticker-section {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 120px;
}

.ticker-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.ticker-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    position: relative;
    z-index: 11;
}

.foreign-toggle {
    font-size: 1rem;
    cursor: pointer;
    user-select: none;
    opacity: 0.3;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: 4px;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.foreign-toggle:hover {
    opacity: 0.6;
    transform: scale(1.1);
}

.foreign-toggle.active {
    opacity: 1;
    filter: drop-shadow(0 0 3px rgba(102, 126, 234, 0.6));
}

.foreign-toggle.active:hover {
    opacity: 1;
    transform: scale(1.15);
}

.ticker-info {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.portfolio-ticker-link {
    font-size: 1.05rem;
    font-weight: 700;
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
    line-height: 1;
}

.portfolio-ticker-link:hover {
    color: #667eea;
    text-decoration: underline;
}

.ticker-exchange {
    font-size: 0.7rem;
    color: #999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    margin-top: 2px;
}

.portfolio-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.portfolio-percentage {
    font-size: 1.05rem;
    font-weight: 700;
    color: #667eea;
    line-height: 1;
    min-width: 65px;
    text-align: right;
}

.portfolio-quick-stats {
    display: flex;
    gap: 20px;
    align-items: center;
}

.quick-stat {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.quick-stat-label {
    font-size: 0.7rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    line-height: 1;
}

.quick-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    line-height: 1;
    margin-top: 2px;
}

.card-expand-icon {
    font-size: 0.6rem;
    color: #667eea;
    transition: transform 0.3s;
    user-select: none;
    line-height: 1;
    padding: 4px;
}

.portfolio-card.expanded .card-expand-icon {
    transform: rotate(180deg);
}

.portfolio-progress-bar {
    margin-top: 8px;
    height: 3px;
    background: #e9ecef;
    overflow: hidden;
    border-radius: 0;
}

.portfolio-progress-fill {
    height: 100%;
    background: #28a745;
    transition: width 0.3s ease;
}

.portfolio-details {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 0;
    margin: 0;
    height: 0;
    overflow: hidden;
}

.portfolio-card.expanded .portfolio-details {
    display: grid;
    padding: 16px;
    height: auto;
}

@media (max-width: 1200px) {
    .portfolio-details {
        grid-template-columns: repeat(2, 1fr);
    }

    .portfolio-quick-stats {
        gap: 16px;
    }
}

@media (max-width: 1024px) {
    .portfolio-card-header {
        gap: 10px;
    }

    .portfolio-quick-stats {
        gap: 10px;
    }

    .quick-stat {
        font-size: 0.8rem;
    }

    .quick-stat-label {
        font-size: 0.7rem;
    }

    .quick-stat-value {
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .portfolio-card-header {
        grid-template-columns: auto 1fr auto;
        gap: 8px;
        align-items: center;
        padding: 4px 12px;
    }

    .portfolio-ticker-section {
        flex-shrink: 0;
        min-width: auto;
        gap: 6px;
    }

    .ticker-controls {
        gap: 3px;
    }

    .ticker-checkbox {
        width: 14px;
        height: 14px;
    }

    .foreign-toggle {
        font-size: 0.9rem;
    }

    .portfolio-ticker-link {
        font-size: 0.95rem;
    }

    .ticker-exchange {
        font-size: 0.6rem;
    }

    .portfolio-quick-stats {
        display: flex;
        gap: 8px;
        overflow: visible;
    }

    .quick-stat {
        font-size: 0.75rem;
    }

    .quick-stat-label {
        font-size: 0.65rem;
    }

    .quick-stat-value {
        font-size: 0.8rem;
    }

    /* Hide less important stats on mobile */
    .quick-stat:nth-child(1),
    /* Shares */
    .quick-stat:nth-child(2)

    /* Total ACB */
        {
        display: flex;
    }

    .quick-stat:nth-child(3),
    /* Market Value */
    .quick-stat:nth-child(4)

    /* Total Gains */
        {
        display: none;
    }

    .portfolio-header-right {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    .portfolio-percentage {
        font-size: 0.85rem;
        min-width: 50px;
    }

    .card-expand-icon {
        font-size: 0.6rem;
    }

    .portfolio-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .portfolio-card-header {
        padding: 4px 8px;
        gap: 6px;
    }

    .portfolio-ticker-section {
        gap: 4px;
    }

    .ticker-controls {
        gap: 2px;
    }

    .ticker-checkbox {
        width: 12px;
        height: 12px;
    }

    .foreign-toggle {
        font-size: 0.8rem;
        padding: 1px;
    }

    .portfolio-ticker-link {
        font-size: 0.9rem;
    }

    .portfolio-quick-stats {
        gap: 6px;
    }

    .quick-stat {
        font-size: 0.7rem;
    }

    .quick-stat-label {
        font-size: 0.6rem;
    }

    .quick-stat-value {
        font-size: 0.75rem;
    }

    .portfolio-percentage {
        font-size: 0.8rem;
        min-width: 45px;
    }

    .portfolio-header-right {
        gap: 4px;
    }
}

.portfolio-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.portfolio-percentage {
    font-size: 1rem;
    font-weight: 600;
    color: #667eea;
    line-height: 1;
}

.card-expand-icon {
    font-size: 0.7rem;
    color: #667eea;
    transition: transform 0.3s;
    user-select: none;
    line-height: 1;
}

.portfolio-card.expanded .card-expand-icon {
    transform: rotate(180deg);
}

.portfolio-ticker-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ticker-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.ticker-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.portfolio-ticker-link {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
    line-height: 1.2;
}

.portfolio-ticker-link:hover {
    color: #667eea;
    text-decoration: underline;
}

.ticker-exchange {
    font-size: 0.65rem;
    color: #999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.portfolio-ticker {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.portfolio-details {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    overflow: hidden;
}

.portfolio-card.expanded .portfolio-details {
    display: grid;
    padding: 16px;
}

@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-card-header {
        grid-template-columns: auto 1fr auto auto;
        gap: 8px;
        padding: 8px 12px;
        align-items: center;
    }

    .portfolio-ticker-section {
        min-width: 60px;
    }

    .portfolio-quick-stats {
        display: flex;
        flex-direction: row;
        gap: 12px;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .quick-stat {
        display: flex;
        flex-direction: column;
        gap: 2px;
        align-items: flex-end;
    }

    .quick-stat-label {
        font-size: 0.6rem;
        white-space: nowrap;
    }

    .quick-stat-value {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Hide less important stats on mobile */
    .quick-stat:nth-child(n+3) {
        display: none;
    }

    .portfolio-header-right {
        gap: 6px;
        display: flex;
        flex-direction: row;
        align-items: center;
    }

    .portfolio-percentage {
        font-size: 0.85rem;
        min-width: 45px;
    }

    .expand-toggle {
        margin-left: 0;
    }

    .portfolio-details {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .portfolio-detail-item {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .portfolio-card-header {
        grid-template-columns: auto 1fr auto;
        gap: 6px;
        padding: 6px 10px;
    }

    .ticker-controls {
        gap: 2px;
    }

    .portfolio-ticker-link {
        font-size: 0.9rem;
    }

    .ticker-exchange {
        font-size: 0.6rem;
    }

    .portfolio-quick-stats {
        gap: 8px;
    }

    .quick-stat-label {
        font-size: 0.55rem;
    }

    .quick-stat-value {
        font-size: 0.7rem;
    }

    .portfolio-percentage {
        font-size: 0.8rem;
        min-width: 40px;
    }

    .expand-toggle {
        font-size: 0.85rem;
        padding: 2px;
    }
}

.portfolio-detail-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
}

.portfolio-detail-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    font-weight: 600;
}

.portfolio-detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
}


/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px 0;
    border-top: 1px solid #e9ecef;
}

.pagination-info {
    color: #666;
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.page-info {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        gap: 10px;
    }
}


/* Portfolio Footer */
.portfolio-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-label:hover {
    color: #333;
}

/* Capital Gains Calculator */
.capital-gains-section {
    margin-top: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 2px solid #dee2e6;
}

/* Foreign bulk action toolbar */
.foreign-bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
    background: #f0f4ff;
    border-radius: 6px;
    border: 1px solid #c5d0f5;
}

.foreign-bulk-count {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
    margin-right: 4px;
}

.calculator-panel h3 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 1.15rem;
}

.calculator-description {
    color: #666;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.calc-securities-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.calc-security-item {
    background: white;
    border: 2px solid #667eea;
    border-radius: 4px;
    padding: 6px;
}

.calc-security-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.calc-security-name {
    font-weight: 700;
    font-size: 1rem;
    color: #333;
}

.calc-remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.calc-remove-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.calc-security-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #666;
}

.calc-info-item {
    display: flex;
    flex-direction: column;
}

.calc-info-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}

.calc-info-value {
    font-weight: 600;
    color: #333;
}

.calc-input-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.calc-input-section label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #667eea;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.calc-shares-input {
    padding: 6px 8px;
    border: 2px solid #667eea;
    border-radius: 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #333;
    background: #f8f9fa;
    transition: all 0.2s;
}

.calc-shares-input:focus {
    outline: none;
    border-color: #5568d3;
    background: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.calc-shares-input::placeholder {
    color: #adb5bd;
    font-weight: 500;
}

.calc-result-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e9ecef;
}

.calc-result-item {
    display: flex;
    flex-direction: column;
}

.calc-result-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}

.calc-result-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.calc-summary {
    background: white;
    padding: 8px;
    border-radius: 4px;
    border: 2px solid #667eea;
}

.calc-summary h4 {
    margin: 0 0 6px 0;
    color: #333;
    font-size: 1.05rem;
}

.calc-summary-breakdown {
    margin-bottom: 8px;
}

.calc-breakdown-table {
    background: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
}

.calc-breakdown-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.2fr 1.2fr 1.2fr;
    gap: 4px;
    padding: 6px 8px;
    background: #667eea;
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.calc-breakdown-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.2fr 1.2fr 1.2fr;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
}

.calc-breakdown-row:last-child {
    border-bottom: none;
}

.calc-breakdown-row:hover {
    background: white;
}

.calc-breakdown-ticker {
    font-weight: 700;
    color: #333;
    font-size: 0.95rem;
}

.calc-breakdown-shares {
    color: #666;
    font-size: 0.85rem;
}

.calc-breakdown-value {
    color: #333;
    font-weight: 600;
    font-size: 0.85rem;
}

.calc-breakdown-gain {
    font-weight: 700;
    font-size: 0.9rem;
}

.calc-summary-grid {
    display: grid;
    gap: 4px;
}

.calc-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.calc-summary-highlight {
    padding: 6px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-top: 4px;
}

.calc-summary-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.calc-summary-highlight .calc-summary-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #333;
}

.calc-summary-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #333;
}

.calc-summary-highlight .calc-summary-value {
    font-size: 1.25rem;
}

.calc-summary-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #dee2e6, transparent);
    margin: 4px 0;
}

.calc-summary-calculation {
    padding: 6px;
    background: #f8f9fa;
    border-radius: 4px;
    margin: 4px 0;
}

.calc-formula {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.calc-formula-item {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
    padding: 4px 8px;
    background: white;
    border-radius: 4px;
    border: 2px solid #dee2e6;
    min-width: 70px;
    text-align: center;
}

.calc-formula-operator {
    font-size: 1.15rem;
    font-weight: 700;
    color: #667eea;
}

.calc-formula-result {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 6px 12px;
    background: white;
    border-radius: 4px;
    border: 3px solid #667eea;
    min-width: 90px;
    text-align: center;
}

@media (max-width: 768px) {

    .calc-security-info,
    .calc-result-preview {
        grid-template-columns: 1fr;
    }

    .calc-formula {
        flex-direction: column;
        gap: 8px;
    }

    .calc-formula-operator {
        transform: rotate(0deg);
    }

    .calc-breakdown-header,
    .calc-breakdown-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .calc-breakdown-header {
        display: none;
    }

    .calc-breakdown-row {
        padding: 15px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .calc-breakdown-ticker {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }

    .calc-breakdown-shares::before {
        content: "Shares: ";
        font-weight: 600;
        color: #666;
    }

    .calc-breakdown-value:nth-child(3)::before {
        content: "Proceeds: ";
        font-weight: 600;
        color: #666;
    }

    .calc-breakdown-value:nth-child(4)::before {
        content: "ACB: ";
        font-weight: 600;
        color: #666;
    }

    .calc-breakdown-gain::before {
        content: "Gain/Loss: ";
        font-weight: 600;
        color: #666;
    }
}

.portfolio-card.selected-for-calc {
    border: 3px solid #28a745;
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.3);
}


/* Create Portfolio Modal Styles */
.modal-body form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[type="text"]::placeholder,
.form-group input[type="password"]::placeholder,
.form-group input[type="email"]::placeholder {
    color: #999;
}

/* Fix browser autofill styling */
.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px white inset !important;
    -webkit-text-fill-color: #333 !important;
    border: 2px solid #e0e0e0 !important;
    transition: background-color 5000s ease-in-out 0s;
}

.form-group select {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.modal-actions button {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.modal-actions .btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.modal-actions .btn-secondary:hover {
    background: #dee2e6;
}

.modal-actions .btn-primary {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.modal-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.modal-actions .btn-primary:active {
    transform: translateY(0);
}

.error-message {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8d7da;
    border-radius: 6px;
    border-left: 3px solid #dc3545;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}


/* Mobile improvements */
@media (max-width: 768px) {

    /* Portfolio tabs mobile */
    .portfolio-tabs-container {
        padding: 0 10px;
        min-height: 50px;
    }

    .portfolio-tab {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-height: 40px;
    }

    .portfolio-add-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    /* Section headers */
    .section-header {
        padding: 15px 0;
    }

    .section-header h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    /* View options inline - 2x2 grid layout */
    .view-options-inline {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        width: 100%;
    }

    /* Position each filter in the grid */
    .view-options-inline .filter-dropdown:nth-of-type(1) {
        /* Stocks - top left */
        grid-column: 1;
        grid-row: 1;
    }

    .view-options-inline .filter-dropdown:nth-of-type(2) {
        /* Type - top right */
        grid-column: 2;
        grid-row: 1;
    }

    .view-options-inline .option-group-inline:nth-of-type(3) {
        /* Per Page - bottom left */
        grid-column: 1;
        grid-row: 2;
    }

    /* Option groups styling */
    .option-group-inline {
        display: flex;
        flex-direction: column;
        gap: 6px;
        min-width: 0 !important;
    }

    .option-group-inline label {
        font-size: 0.85rem;
        font-weight: 600;
        color: #495057;
        margin: 0;
    }

    .option-group-inline select {
        width: 100%;
        padding: 10px;
        font-size: 0.9rem;
        border: 1px solid #ced4da;
        border-radius: 6px;
        background: white;
    }

    /* Filter dropdowns */
    .filter-dropdown {
        display: flex;
        flex-direction: column;
        gap: 6px;
        min-width: 0 !important;
    }

    .filter-dropdown>label {
        font-size: 0.85rem;
        font-weight: 600;
        color: #495057;
        margin: 0;
    }

    .filter-dropdown-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 10px;
        font-size: 0.9rem;
        border: 1px solid #ced4da;
        border-radius: 6px;
        background: white;
    }

    .filter-dropdown-menu {
        width: 100%;
        left: 0;
        right: 0;
        max-height: 250px;
        overflow-y: auto;
    }

    /* Portfolio section header */
    .portfolio-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .portfolio-section-header h2 {
        font-size: 1.2rem;
    }

    /* User info in header */
    .user-info {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .header-controls {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .portfolio-selector-header,
    .currency-selector-header {
        padding: 5px 10px;
        gap: 6px;
    }
}

.currency-selector-header label {
    font-size: 0.8rem;
}

.currency-selector-header select {
    padding: 5px 8px;
    font-size: 0.8rem;
    min-width: 70px;
}

#settings-btn,
#logout-btn {
    min-width: 80px;
    font-size: 0.85rem;
    padding: 6px 12px;
}

/* Table actions */
.table-actions {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.table-actions button {
    flex: 0 0 auto;
    min-width: auto;
    padding: 10px 16px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.action-spacer {
    display: none;
}

/* Pagination */
.pagination-container {
    gap: 15px;
}

.pagination-info {
    font-size: 0.85rem;
    text-align: center;
}

.pagination-controls {
    gap: 10px;
}

.pagination-controls button {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.page-info {
    font-size: 0.85rem;
}

/* Extra small mobile */
@media (max-width: 480px) {
    .portfolio-tab {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

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

    .section-header h2 {
        font-size: 1.1rem;
    }

    .portfolio-section-header h2 {
        font-size: 1rem;
    }

    /* Stack filters vertically on very small screens */
    .view-options-inline {
        grid-template-columns: 1fr;
    }

    .view-options-inline .filter-dropdown:nth-of-type(1),
    .view-options-inline .filter-dropdown:nth-of-type(2),
    .view-options-inline .option-group-inline:nth-of-type(3) {
        grid-column: 1;
        grid-row: auto;
    }

    /* Table actions - keep compact, don't stretch */
    .table-actions button {
        flex: 0 0 auto;
        width: auto;
        white-space: nowrap;
    }
}

/* Tax Reporting Section */
.tax-reporting {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
}

.tax-reporting>h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.5rem;
}

.tax-cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.tax-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Remove custom scrollbar styles - no longer needed */

/* Remove scroll shadow indicators - no longer needed */

.tax-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.tax-card-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.year-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.year-selector label {
    font-weight: 500;
    color: #495057;
    font-size: 0.85rem;
    margin: 0;
}

.year-selector select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
}

.gains-chart-container,
.foreign-chart-container,
.dividend-chart-container,
.portfolio-value-chart-container {
    background: white;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

/* Loading overlay on chart canvas area */
.chart-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.chart-empty-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.chart-empty-message {
    margin: 0;
    color: #aaa;
    font-size: 0.9rem;
    text-align: center;
}

.chart-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #555;
    font-size: 0.9rem;
}

.chart-loading-inner p {
    margin: 0;
    font-weight: 500;
}

.gains-chart-container canvas,
.foreign-chart-container canvas,
.dividend-chart-container canvas,
.portfolio-value-chart-container canvas {
    max-height: 300px;
    width: 100% !important;
    height: auto !important;
}

.gains-losses-content,
.foreign-assets-content,
.dividend-income-content,
.portfolio-value-summary {
    margin-top: 10px;
}

.portfolio-value-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    background: white;
    padding: 15px;
    border-radius: 6px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 500;
}

.stat-value {
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

.stat-value.positive {
    color: #28a745;
}

.stat-value.negative {
    color: #dc3545;
}

@media (max-width: 768px) {
    .portfolio-value-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 1024px) {
    .tax-cards-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .tax-reporting {
        padding: 20px;
        overflow-x: hidden;
    }

    .tax-cards-container {
        gap: 15px;
        overflow-x: hidden;
    }

    .tax-card {
        padding: 15px;
        overflow-x: hidden;
    }

    .gains-chart-container,
    .foreign-chart-container {
        padding: 10px;
        min-height: 200px;
        overflow-x: hidden;
    }

    .gains-chart-container canvas,
    .foreign-chart-container canvas {
        max-height: 200px;
        max-width: 100%;
    }
}

/* Gains/Losses Styles */

.gains-losses-table,
.foreign-assets-table {
    width: 100%;
    margin-top: 15px;
}

.gains-losses-table table,
.foreign-assets-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gains-losses-table thead,
.foreign-assets-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.gains-losses-table th,
.foreign-assets-table th {
    padding: 10px 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gains-losses-table td,
.foreign-assets-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    color: #495057;
    font-size: 0.85rem;
}

.gains-losses-table tbody tr:last-child td,
.foreign-assets-table tbody tr:last-child td {
    border-bottom: none;
}

.gains-losses-table tbody tr:hover,
.foreign-assets-table tbody tr:hover {
    background: #f8f9fa;
    transition: background 0.2s ease;
}

/* Align numbers to the right */
.gains-losses-table td:last-child,
.foreign-assets-table td:nth-child(2),
.foreign-assets-table td:nth-child(3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.gains-summary,
.foreign-summary {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px 20px;
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gains-summary-item,
.summary-item {
    text-align: center;
    padding: 10px;
    border-right: 1px solid #e0e0e0;
}

.gains-summary-item:last-child,
.summary-item:last-child {
    border-right: none;
}

.gains-summary-item span:first-child,
.summary-item span:first-child {
    display: block;
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gains-summary-item strong,
.summary-item strong {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
}

.summary-item.gains strong {
    color: #10b981;
}

.summary-item.losses strong {
    color: #ef4444;
}

.summary-item.net strong {
    color: #3b82f6;
}

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

.gains-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.gains-table thead {
    background: #f8f9fa;
}

.gains-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 500;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.85rem;
}

.gains-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
}

.gains-table tbody tr:hover {
    background: #f8f9fa;
}

.gains-table tbody tr.total-row {
    background: #e7f3ff;
    font-weight: 500;
}

.gains-table tbody tr.total-row:hover {
    background: #d4e9ff;
}

.gains-value {
    font-weight: 500;
}

.gains-value.positive {
    color: #28a745;
}

.gains-value.negative {
    color: #dc3545;
}

@media (max-width: 768px) {
    .tax-reporting {
        padding: 20px;
    }

    .tax-card {
        padding: 15px;
    }

    .gains-chart-container,
    .foreign-chart-container {
        padding: 10px;
        min-height: 200px;
    }

    .gains-chart-container canvas,
    .foreign-chart-container canvas {
        max-height: 200px;
    }

    .gains-summary,
    .foreign-summary {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 12px 15px;
    }

    .gains-summary-item,
    .summary-item {
        padding: 10px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .gains-summary-item:last-child,
    .summary-item:last-child {
        border-bottom: none;
    }

    .gains-summary-item strong,
    .summary-item strong {
        font-size: 1.1rem;
    }

    .gains-losses-table table,
    .foreign-assets-table table {
        font-size: 0.8rem;
    }

    .gains-losses-table th,
    .gains-losses-table td,
    .foreign-assets-table th,
    .foreign-assets-table td {
        padding: 8px 10px;
    }
}

/* Options Integration Styles */
.option-transaction {
    background-color: #fff8e1 !important;
    /* Light amber background for option rows */
}

.option-details-row {
    background-color: #fff3cd !important;
    /* Slightly darker amber for details row */
    border-top: none !important;
}

.option-details-row td {
    padding: 8px 16px !important;
    border-top: none !important;
}

.option-details-expanded {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

.option-details-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.85rem;
}

.option-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-badge.long {
    background: #4caf50;
    color: white;
}

.option-badge.short {
    background: #f44336;
    color: white;
}

.option-info {
    padding: 3px 8px;
    background: #e3f2fd;
    border-radius: 4px;
    color: #1976d2;
    font-size: 0.75rem;
    font-weight: 500;
}

.option-status {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.option-status.status-Open {
    background: #4caf50;
    color: white;
}

.option-status.status-Sold {
    background: #2196f3;
    color: white;
}

.option-status.status-Exercised {
    background: #ff9800;
    color: white;
}

.option-status.status-Expired {
    background: #9e9e9e;
    color: white;
}

.btn-close-option {
    background: #2196f3;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 5px;
    transition: background 0.2s;
}

.btn-close-option:hover {
    background: #1976d2;
}

/* Close Option Dialog Styles */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 15px 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.alert-info {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    color: #1565c0;
}

.alert-warning {
    background: #fff3e0;
    border: 1px solid #ff9800;
    color: #e65100;
}

.alert-success {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    color: #2e7d32;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #ddd;
}

/* Responsive adjustments for options */
@media (max-width: 768px) {
    .option-details-inline {
        flex-direction: column;
        gap: 4px;
    }

    .option-badge,
    .option-info,
    .option-status {
        display: inline-block;
        margin-right: 4px;
    }
}


/* Option Fields in New Transaction Rows */
.option-fields-row {
    background: #f0f4ff;
}

.option-fields-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    margin: 5px;
}

.option-field {
    display: flex;
    flex-direction: column;
}

.option-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.option-field input {
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.option-field input:focus {
    outline: none;
    border-color: #667eea;
}

.option-field small {
    font-size: 0.75rem;
    color: #666;
    margin-top: 3px;
}

.option-field-note {
    grid-column: 1 / -1;
    padding: 10px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #1565c0;
}

.option-field-note strong {
    font-weight: 600;
}

@media (max-width: 768px) {
    .option-fields-container {
        grid-template-columns: 1fr;
    }
}





/* Footer Styles */
.app-footer {
    margin-top: 60px;
    padding: 20px;
}

.app-footer.hidden {
    display: none;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    backdrop-filter: blur(6px);
}

.footer-mascot {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    flex-shrink: 0;
}

.footer-text {
    font-size: 0.8rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.75);
}

.footer-text a {
    color: white;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer-text a:hover {
    opacity: 0.85;
}

.footer-disclaimer {
    margin-top: 4px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .app-footer {
        margin-top: 40px;
    }
}



/* Portfolio Month Breakdown Modal */
#portfolio-month-breakdown-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

#portfolio-month-breakdown-modal.show,
#portfolio-month-breakdown-modal[style*="display: block"] {
    display: flex !important;
}

.portfolio-breakdown-summary {
    margin-bottom: 20px;
}

.breakdown-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-label {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.summary-value {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

.summary-value.positive {
    color: #28a745;
}

.summary-value.negative {
    color: #dc3545;
}

.portfolio-breakdown-holdings h4 {
    margin-top: 20px;
    margin-bottom: 15px;
    color: #333;
}

.holdings-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
}

.holdings-breakdown-table thead {
    background: #667eea;
    color: white;
}

.holdings-breakdown-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
}

.holdings-breakdown-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e0e0e0;
}

.holdings-breakdown-table tbody tr:hover {
    background: #f8f9fa;
}

.holdings-breakdown-table td.positive {
    color: #28a745;
    font-weight: 600;
}

.holdings-breakdown-table td.negative {
    color: #dc3545;
    font-weight: 600;
}

.holdings-breakdown-table small {
    font-size: 0.85em;
    opacity: 0.8;
}

/* Make modal wider for breakdown */
#portfolio-month-breakdown-modal .modal-content {
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
}


/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading {
    color: #666;
    font-size: 14px;
    text-align: center;
}

.empty-state,
.error-state {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.error-state {
    color: #e74c3c;
}

/* Background Task Progress Indicators */
.background-task-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 20px;
}

.progress-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-info {
    flex: 1;
    max-width: 400px;
}

.progress-message {
    margin: 0 0 10px 0;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-percent {
    margin: 0;
    color: #6b7280;
    font-size: 12px;
    text-align: right;
}

/* Loading container for charts */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    min-height: 200px;
}

.loading-container .spinner {
    margin-bottom: 20px;
}

.loading-container .loading {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

/* Capital Gains Transactions Modal */
#gains-transactions-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

#gains-transactions-modal.active,
#gains-transactions-modal[style*="display: block"] {
    display: flex !important;
}

#gains-transactions-modal .modal-content {
    max-width: 1000px;
    width: 90%;
    max-height: 90vh;
    margin: 0;
}

.gains-transactions-summary {
    margin-bottom: 20px;
}

.gains-transactions-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.gains-transactions-summary-grid .summary-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.gains-transactions-summary-grid .summary-label {
    font-size: 0.9em;
    color: #666;
}

.gains-transactions-summary-grid .summary-value {
    font-size: 1.2em;
    font-weight: 600;
}

.gains-transactions-summary-grid .summary-value.positive {
    color: #28a745;
}

.gains-transactions-summary-grid .summary-value.negative {
    color: #dc3545;
}

.gains-transactions-content {
    max-height: 500px;
    overflow-y: auto;
}

.ticker-transactions-section {
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.ticker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    margin: 0;
    font-size: 1.1em;
    border-bottom: 2px solid #e0e0e0;
}

.ticker-header span {
    font-size: 1em;
    font-weight: 600;
}

.ticker-header span.positive {
    color: #28a745;
}

.ticker-header span.negative {
    color: #dc3545;
}

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

.transactions-table thead {
    background: #f8f9fa;
}

.transactions-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
}

.transactions-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.transactions-table tbody tr:hover {
    background: #f8f9fa;
}

.transaction-type {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    background: #e3f2fd;
    color: #1976d2;
    text-transform: uppercase;
}

.loading-state,
.error-state,
.empty-state {
    text-align: center;
    padding: 40px;
    color: #666;
}

.error-state {
    color: #dc3545;
}


/* Tax Year Navigation */
.chart-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    margin-bottom: 10px;
}

.chart-navigation .nav-button {
    padding: 0;
    background: none;
    color: #555;
    border: none;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.chart-navigation .nav-button:hover:not(:disabled) {
    color: #333;
    opacity: 0.8;
}

.chart-navigation .nav-button:disabled {
    color: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.chart-navigation .year-range-display {
    font-size: 12px;
    font-weight: 500;
    color: #666;
}


/* Utility classes to replace inline styles */
.hidden {
    display: none !important;
}

.uppercase-input {
    text-transform: uppercase;
}

.section-spacing-top {
    margin-top: 30px;
}

.checkbox-column {
    width: 40px;
}

/* Settings Danger Zone */
.settings-danger-zone {
    margin-top: 40px;
    padding: 20px;
    border: 2px solid #ef4444;
    border-radius: 8px;
    background-color: #fef2f2;
}

.settings-danger-zone h4 {
    color: #dc2626;
    margin-bottom: 12px;
    font-size: 16px;
}

.settings-danger-zone p {
    color: #991b1b;
    margin-bottom: 12px;
    font-size: 14px;
}

.settings-danger-zone ul {
    color: #991b1b;
    margin-left: 20px;
    margin-bottom: 16px;
    font-size: 14px;
}

.settings-danger-zone ul li {
    margin-bottom: 6px;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-danger:active {
    background-color: #991b1b;
}

/* Split toggle styles */
.split-toggle-container,
.split-toggle-import {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-top: 6px;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.split-toggle-import {
    margin: 10px 0;
    width: 100%;
}

.split-toggle-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
}

.split-radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.split-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #495057;
    font-size: 0.85rem;
    line-height: 1.4;
}

.split-radio-label input[type="radio"] {
    cursor: pointer;
    accent-color: #667eea;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.split-toggle-row td {
    padding: 2px 8px 6px !important;
}

.form-field-full {
    grid-column: 1 / -1;
}

.split-toggle-field {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.split-toggle-field>label:first-child {
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
    margin-bottom: 2px;
}


/* ============================================
   VALIDATION STYLES
   ============================================ */

.validation-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-top: 30px;
    box-shadow: none;
    border: 1px solid #e0e0e0;
}

.validation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.validation-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.btn-close-validation {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
}

.btn-close-validation:hover {
    color: #333;
}

.btn-validate {
    background: #ffb74d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-validate:hover {
    background: #ffa726;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 183, 77, 0.3);
}

.validation-results {
    max-height: 600px;
    overflow-y: auto;
}

.validation-success {
    text-align: center;
    padding: 40px 20px;
    color: #28a745;
}

.validation-success .validation-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.validation-success h4 {
    font-size: 1.3rem;
    margin: 10px 0;
    color: #28a745;
    font-weight: 600;
}

.validation-success p {
    color: #666;
    font-size: 1rem;
}

.validation-group {
    margin-bottom: 30px;
}

.validation-group-title {
    font-size: 1rem;
    margin: 0 0 15px 0;
    padding: 0;
    font-weight: 600;
}

.validation-group-title.error {
    color: #c62828;
}

.validation-group-title.warning {
    color: #e65100;
}

.validation-issue {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.validation-issue:last-child {
    border-bottom: none;
}

.issue-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.issue-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.issue-message {
    font-size: 0.9rem;
    color: #333;
    flex: 1;
    min-width: 0;
}

.issue-details {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.issue-ticker {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
}

.issue-date {
    color: #666;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.issue-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-issue-action {
    background: white;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    color: #667eea;
    font-weight: 500;
    white-space: nowrap;
}

.btn-issue-action:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.highlight-transaction {
    animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {

    0%,
    100% {
        background-color: transparent;
    }

    50% {
        background-color: #fff3cd;
    }
}

@media (max-width: 768px) {
    .validation-section {
        padding: 15px;
        margin-top: 20px;
    }

    .validation-header h3 {
        font-size: 1.1rem;
    }

    .validation-issue {
        padding: 10px;
    }

    .issue-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .issue-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .issue-actions {
        width: 100%;
    }

    .btn-issue-action {
        flex: 1;
    }
}


/* ============================================
   MOBILE — FINAL (≤ 600px)
   ============================================ */

/* Fix white bars: html background matches body gradient */
html {
    background: #764ba2;
}

@media (max-width: 600px) {
    /* ── Typography & Spacing ── */
    body {
        font-size: 16px !important;
        background-attachment: initial !important; 
    }

    /* True 100% width container */
    .container {
        padding: 0 !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .modal-content {
        width: 95% !important;
        margin: 20px auto !important;
        padding: 20px !important;
    }

    /* ── Header Optimization ── */
    header {
        margin-bottom: 20px !important;
        padding: 12px 0 !important;
    }

    header .logo-header,
    .logo-header {
        flex-direction: column !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
    }

    header .bull-logo,
    .bull-logo {
        width: 65px !important;
        height: auto !important;
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)) !important;
    }

    header .logo-text,
    .logo-text {
        align-items: center !important;
        text-align: center !important;
    }

    header .logo-text h1,
    .logo-text h1 {
        font-size: 1.8rem !important;
        margin: 0 !important;
    }

    header .logo-text p,
    .logo-text p {
        font-size: 0.85rem !important;
        color: rgba(255, 255, 255, 0.7) !important;
        margin-top: 4px !important;
    }

    .header-controls {
        flex-direction: column !important;
        width: 100% !important;
        gap: 12px !important;
    }
    
    .portfolio-selector-header,
    .currency-selector-header {
        width: 100% !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
    }

    /* ── Mobile Layout Waste Reduction ── */
    .card, section.portfolio, section.tax-reporting {
        border-radius: 12px !important;
        margin: 0 0 16px 0 !important;
        padding: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-left: none !important;
        border-right: none !important;
        border-top: 1px solid rgba(0,0,0,0.05) !important;
        border-bottom: 1px solid rgba(0,0,0,0.05) !important;
        box-shadow: none !important;
    }

    /* Flatten tax cards nested inside the reporting section */
    .tax-card {
        border-radius: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        width: 100% !important;
    }
    .tax-cards-container {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 0 !important;
    }

    /* ── Portfolio at a Glance ── */
    .portfolio-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* --- The Ultra Dense Grid Layout --- */
    .portfolio-card-header,
    .portfolio-card.expanded .portfolio-card-header {
        display: grid !important;
        grid-template-areas: 
            "ticker right"
            "stats stats" !important;
        grid-template-columns: 1fr auto !important;
        grid-template-rows: auto auto !important;
        gap: 6px !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    .portfolio-card {
        padding: 10px 12px !important;
        border-radius: 10px !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
        margin: 0 !important; /* overrides card margin */
    }

    .portfolio-ticker-section {
        grid-area: ticker !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .ticker-controls {
        display: flex !important;
        align-items: center !important;
        position: static !important;
        margin: 0 !important;
        gap: 6px !important;
    }

    .ticker-checkbox {
        position: static !important;
        margin: 0 !important;
        width: 16px !important;
        height: 16px !important;
    }

    .foreign-toggle {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 22px !important;
        height: 22px !important;
        font-size: 16px !important;
        line-height: 1 !important;
        position: static !important;
        margin: 0 !important;
    }

    .ticker-info {
        display: flex !important;
        align-items: baseline !important;
        gap: 4px !important;
    }

    .portfolio-ticker-link {
        font-size: 1.15rem !important;
        line-height: 1.2 !important;
    }
    .ticker-exchange {
        font-size: 0.75rem !important;
        opacity: 0.7 !important;
    }

    /* Percentage on right */
    .portfolio-header-right {
        grid-area: right !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 6px !important;
        width: 100% !important;
    }
    .portfolio-percentage {
        font-size: 1.05rem !important;
        line-height: 1 !important;
    }
    .card-expand-icon {
        font-size: 0.8rem !important;
    }

    /* Quick Stats Inline Below */
    .portfolio-quick-stats {
        grid-area: stats !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 4px 12px !important;
        justify-content: flex-start !important;
        width: 100% !important;
    }

    .quick-stat {
        display: flex !important;
        flex-direction: row !important;
        align-items: baseline !important;
        gap: 4px !important;
    }
    .quick-stat-label::after {
        content: ": " !important;
    }
    .quick-stat-label {
        font-size: 0.75rem !important;
        margin-bottom: 0 !important;
    }
    .quick-stat-value {
        font-size: 0.8rem !important;
        font-weight: 600 !important;
    }

    /* Global Summary Stats block */
    .portfolio-card-stats {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    .stat-label {
        font-size: 0.75rem !important;
        margin-bottom: 4px !important;
    }
    .stat-value {
        font-size: 0.95rem !important;
        font-weight: 600 !important;
    }

    /* ── UI Components & Forms ── */
    .tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding-bottom: 5px !important;
        margin-bottom: 16px !important;
        justify-content: flex-start !important;
    }
    
    .tab-btn {
        flex-shrink: 0 !important;
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
    }

    .view-options-inline {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .option-group-inline {
        width: 100% !important;
        justify-content: space-between !important;
    }

    /* ── Transaction Add Form ── */
    .add-transaction-form .form-content {
        padding: 15px !important;
        gap: 15px !important;
        grid-template-columns: 1fr !important;
    }
    .add-transaction-form .form-row {
        grid-template-columns: 1fr !important;
    }
    .add-transaction-form .form-field input,
    .add-transaction-form .form-field select {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important; /* CRITICAL: Prevents iOS date inputs from blowing out the grid */
        box-sizing: border-box !important;
        -webkit-appearance: none; /* Prevents native styling expansion */
        appearance: none;
    }
    .add-transaction-form .form-actions {
        flex-direction: column !important;
    }
    .add-transaction-form .btn-primary,
    .add-transaction-form .btn-secondary {
        width: 100% !important;
    }

    /* ── Table Actions Fix ── */
    .table-actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
    }
    .table-actions .dropdown-container,
    .table-actions .btn-validate,
    .table-actions .btn-import-export,
    .table-actions .action-spacer {
        display: none !important;
    }
    .table-actions .btn-secondary,
    .table-actions .btn-delete-all,
    .table-actions .btn-add,
    .table-actions .btn-delete-multi,
    .table-actions .btn-cancel-all,
    .table-actions .btn-save-all {
        padding: 6px 12px !important;
        font-size: 0.85rem !important;
        border-radius: 16px !important;
        flex: 1 1 auto !important;
        min-width: max-content !important;
        text-align: center !important;
        line-height: 1.4 !important;
    }

    /* Adjust the floating bottom checkbox */
    .portfolio-footer {
        padding: 12px 0 0 0 !important;
        margin-top: 15px !important;
        border-top: 1px solid #eee !important;
        display: flex !important;
        justify-content: flex-start !important;
    }
    .checkbox-label {
        color: #444 !important;
        font-size: 0.9rem !important;
        visibility: visible !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        opacity: 1 !important;
    }
    input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        cursor: pointer !important;
    }
}