/* ============================================
   GLOBAL FLUID TYPOGRAPHY MODULE
   ============================================ */
:root {
    /* Dynamic scale: gracefully scales between constraints based on viewport width (vw) */
    --text-xs: clamp(0.7rem, 0.68rem + 0.1vw, 0.75rem);
    --text-sm: clamp(0.8rem, 0.78rem + 0.1vw, 0.875rem);
    --text-base: clamp(0.875rem, 0.85rem + 0.12vw, 0.95rem);
    --text-lg: clamp(1rem, 0.95rem + 0.15vw, 1.1rem);
    --text-xl: clamp(1.15rem, 1.1rem + 0.2vw, 1.3rem);
    --text-2xl: clamp(1.4rem, 1.3rem + 0.3vw, 1.65rem);
    --text-3xl: clamp(1.75rem, 1.6rem + 0.5vw, 2.1rem);
}

/* ============================================
   LANDING / HOMEPAGE STYLES
   ============================================ */

#landing-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-hero {
    text-align: center;
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
}

.landing-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.landing-bull-logo {
    width: 100px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

.landing-title {
    color: #667eea;
    font-family: 'Inter', sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
}

.landing-tagline {
    color: #1e293b;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 24px 0;
}

.landing-description {
    color: #64748b;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto 32px auto;
}

.landing-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.landing-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.landing-feature .feature-icon {
    font-size: 1.2rem;
}

.landing-feature .feature-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
}

.landing-cta {
    padding-top: 8px;
}

.cta-text {
    color: #94a3b8;
    font-size: 0.95rem;
    margin: 0;
}

@media (max-width: 600px) {
    .landing-hero {
        padding: 32px 20px;
    }

    .landing-title {
        font-size: 2rem;
    }

    .landing-features {
        gap: 8px;
    }

    .landing-feature {
        padding: 8px 12px;
    }

    .landing-feature .feature-text {
        font-size: 0.8rem;
    }
}

/* ============================================
   AUTH STYLES
   ============================================ */

.form-footer {
    margin-top: 12px;
    text-align: center;
}

.text-link {
    color: #667eea;
    text-decoration: none;
    font-size: inherit;
    transition: color 0.2s;
}

.text-link:hover {
    color: #5568d3;
    text-decoration: underline;
}

.form-note {
    margin-top: 16px;
    font-size: var(--text-xs);
    color: #666;
    text-align: center;
    line-height: 1.4;
}

.error-message {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    font-size: var(--text-sm);
    text-align: center;
}

.error-message:not(:empty) {
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.error-message[style*="color: #1a7f37"],
.error-message[style*="color:#1a7f37"] {
    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: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f0f2f5;
    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: 1350px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    width: 100%;
}

@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: #4f63c8;
    font-size: var(--text-sm);
    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: var(--text-xs);
    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: var(--text-lg);
    font-weight: 500;
    margin: 0;
    color: white;
}

header {
    text-align: center;
    color: #1e293b;
    margin-bottom: 40px;
    position: relative;
}

.app-top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    flex-wrap: wrap;
    gap: 20px;
}

.app-top-header .logo-header {
    margin-bottom: 0;
}

.header-right-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
}

.app-top-header .user-info,
.app-top-header .header-controls {
    margin-top: 0;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .app-top-header {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 15px !important;
    }

    .app-top-header .logo-header,
    header.app-top-header .logo-header {
        width: 100% !important;
        justify-content: center !important;
        align-items: center !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .app-top-header .logo-text,
    header .logo-text {
        align-items: center !important;
        text-align: center !important;
    }

    .header-right-panel {
        align-items: center !important;
        width: 100% !important;
    }

    .app-top-header .user-info,
    .app-top-header .header-controls {
        justify-content: center !important;
        width: 100% !important;
    }

    .header-controls {
        justify-content: center !important;
        width: 100% !important;
    }

    .portfolio-selector-header,
    .currency-selector-header {
        justify-content: center !important;
    }
}

header .logo-header {
    flex-direction: row;
    gap: 14px;
    margin-bottom: 20px;
}

header .bull-logo {
    width: 100px;
}

header .logo-text {
    align-items: flex-start;
    text-align: left;
}

header .logo-text h1 {
    color: #667eea;
    font-family: 'Inter', sans-serif;
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
}

header .logo-text p {
    color: #4b5563;
    font-size: var(--text-sm);
    margin: 2px 0 0 0;
    font-weight: 500;
}

header h1 {
    font-size: var(--text-3xl);
    margin-bottom: 10px;
}

header p {
    font-size: var(--text-lg);
    opacity: 0.9;
}

main {
    display: grid;
    gap: 30px;
    overflow-x: hidden;
    width: 100%;
    min-width: 0;
    /* CRITICAL: Prevents flex children from blowing out */
}

/* 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: var(--text-base);
    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;
    min-width: 0;
}

.main-tab-content.active {
    display: block;
}

section {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 0 8px 8px 8px;
    padding: 30px;
    box-shadow: none;
    margin-bottom: 20px;
    overflow-x: hidden;
    width: 100%;
    min-width: 0;
    /* CRITICAL: Prevents CSS grid children from blowing out layout bounds */
}


@media (max-width: 768px) {
    .main-tabs {
        padding: 0 10px;
        gap: 3px;
    }

    .main-tab-btn {
        padding: 10px 16px;
        font-size: var(--text-sm);
    }

    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: var(--text-xs);
    }

    section {
        padding: 10px;
        border-width: 1px;
    }
}

/* 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: var(--text-xl);
}

.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: var(--text-base);
    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: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.stock-card {
    position: absolute;
    background: white;
    border-radius: 10px;
    padding: 15px;
    border: 3px solid;
    box-shadow: none;
    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: none;
    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: var(--text-xl);
    font-weight: bold;
    color: #333;
}

.stock-percentage {
    font-size: var(--text-base);
    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: var(--text-xs);
    color: #666;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: var(--text-base);
    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: var(--text-sm);
}

.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: #c9302c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--text-sm);
}

.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: #8b9bb4;
    padding: 3.5rem 2rem;
    margin: 1.5rem auto;
    background-color: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 16px;
    font-size: var(--text-base);
    font-weight: 500;
    line-height: 1.5;
    width: 90%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: none;
}

/* Compact line-item style for paragraph empty states (e.g. tax breakdown hints) */
p.empty-state {
    display: block;
    width: auto;
    margin: 8px 0;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: var(--text-sm);
    font-weight: 450;
    font-style: normal;
    color: #64748b;
    text-align: center;
    box-shadow: none;
}

.empty-state:hover {
    background-color: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.08);
}

div.empty-state::before {
    content: "📊";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 50%;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.03);
    font-size: var(--text-2xl);
    margin-bottom: 20px;
}

/* No icon for compact paragraph empty states */
p.empty-state::before {
    content: none;
}

p.empty-state.error {
    border-color: #fecaca;
    background-color: #fef2f2;
    color: #ef4444;
}

p.empty-state.error::before {
    content: "⚠️";
    opacity: 1;
}

td.empty-state {
    background-color: transparent !important;
    border: none !important;
    width: auto !important;
    display: table-cell !important;
    padding: 4rem 1rem !important;
    box-shadow: none !important;
}

td.empty-state:hover {
    background-color: transparent !important;
    border-color: transparent !important;
}

td.empty-state::before {
    content: "📂";
    display: block;
    font-size: var(--text-3xl);
    margin: 0 auto 12px auto;
    opacity: 0.5;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.04));
}

@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: var(--text-base);
    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: var(--text-lg);
}

.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: var(--text-sm);
}

.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: var(--text-lg);
    padding: 15px 30px;
}

#import-status {
    font-size: var(--text-sm);
    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: var(--text-sm);
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.option-group-inline select {
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: var(--text-sm);
    background: white;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.2s;
}

.option-group-inline select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: none;
}

/* Filter Dropdown */
.filter-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.filter-dropdown label {
    font-size: var(--text-sm);
    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: var(--text-sm);
    transition: all 0.2s;
}

.filter-dropdown-toggle:hover {
    border-color: #667eea;
}

.filter-dropdown-toggle.active {
    border-color: #667eea;
    box-shadow: none;
}

.dropdown-arrow {
    font-size: var(--text-xs);
    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: none;
    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: var(--text-sm);
    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;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf4 50%, #f0f2f5 100%);
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.auth-wrapper {
    display: flex;
    align-items: stretch;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    max-width: 1100px;
    width: 100%;
}

.auth-wrapper .auth-box {
    box-shadow: none;
    border-radius: 0;
    flex: 0 0 380px;
    width: 380px;
    background: white;
    padding: 36px 36px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-height: 92vh;
}

.auth-features {
    flex: 1;
    padding: 28px 28px;
    color: #1e293b;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 16px;
}

.features-intro {
    display: none;
}

.features-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.features-list li {
    display: block;
    padding: 10px 14px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.features-list li .feature-label {
    display: block;
    font-weight: 600;
    color: #1e293b;
    font-size: var(--text-sm);
    margin-bottom: 2px;
}

.features-list li .feature-desc {
    display: block;
    color: #64748b;
    font-size: var(--text-sm);
    line-height: 1.4;
}

.features-list li .feature-text {
    display: block;
}

/* Last item spans full width if odd count */
.features-list li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.features-list li:hover {
    border-color: #cbd5e1;
}

/* Screenshot preview */
.auth-preview {
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid #dde2ea;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
    /* Maintain the image's natural aspect ratio (2560x1324) */
    aspect-ratio: 2560 / 1324;
    width: 100%;
}

.auth-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, #f8fafc);
    pointer-events: none;
}

.preview-screenshot {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: top left;
}

/* Features bottom strip */
.auth-features-bottom {
    flex-shrink: 0;
}

@media (max-width: 960px) {
    .auth-wrapper {
        flex-direction: column;
        max-width: 460px;
        background: transparent;
        box-shadow: none;
        border: none;
        max-height: 100%;
    }

    .auth-wrapper .auth-box {
        border-radius: 16px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
        max-width: 100%;
        flex: unset;
        width: 100%;
        background: white;
    }

    .auth-features {
        display: none;
    }
}

@media (max-width: 600px) {
    .auth-container {
        padding: 0;
        background: white;
        align-items: flex-start;
        overflow-y: auto;
    }

    .auth-wrapper .auth-box {
        border-radius: 0;
        padding: 30px 20px;
        box-shadow: none;
        max-width: 100%;
        background: transparent;
    }
}

/* Logo Header */
.logo-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.mobile-auth-desc {
    display: none;
}

@media (max-width: 960px) {
    .mobile-auth-desc {
        display: block;
        text-align: center;
        color: #64748b;
        font-size: var(--text-sm);
        margin: -12px 0 20px 0;
        line-height: 1.4;
        padding: 0 10px;
    }
}

.bull-logo {
    width: 140px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    text-align: center;
}

.logo-text h1 {
    color: #667eea;
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 1.85rem;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.logo-text p {
    color: #64748b;
    margin: 4px 0 0 0;
    font-size: var(--text-sm);
    line-height: 1.3;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.auth-box .tagline {
    text-align: left;
}

/* Social auth */
.auth-social {
    margin-bottom: 0;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    color: #333;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.btn-google:active {
    transform: scale(0.99);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: #94a3b8;
    font-size: var(--text-xs);
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.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: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid #e9ecef;
}

.auth-tab {
    background: none;
    border: none;
    padding: 10px 24px;
    font-size: var(--text-base);
    font-weight: 500;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -2px;
}

.auth-tab:hover {
    color: #667eea;
}

.auth-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form .form-group input {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: var(--text-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
    background: #f8fafc;
}

.auth-form .form-group input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
    background: white;
}

.auth-form .btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    font-size: var(--text-base);
    font-weight: 600;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 4px;
}

.auth-form .btn-primary:hover {
    background: #5a6fd6;
}

.auth-form .btn-primary:active {
    transform: scale(0.99);
}

.form-footer {
    text-align: center;
    margin-top: 14px;
}

.form-footer .text-link {
    color: #667eea;
    font-size: var(--text-sm);
    text-decoration: none;
}

.form-footer .text-link:hover {
    text-decoration: underline;
}

.form-note {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    margin-top: 14px;
    line-height: 1.4;
}

/* ============================================
   MFA / 2FA SCREENS
   ============================================ */

.mfa-screen-wrapper {
    max-width: 480px;
}

.mfa-screen-wrapper .auth-box {
    flex: 1;
    max-width: 100%;
}

/* MFA screens: horizontal logo layout with larger bull */
.mfa-screen-wrapper .logo-header {
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.mfa-screen-wrapper .bull-logo {
    width: 110px;
    margin-top: -12px;
    align-self: flex-start;
    margin-bottom: -8px;
}

.mfa-screen-wrapper .logo-text {
    align-items: flex-start;
    text-align: left;
}

.mfa-screen-wrapper .logo-text h1 {
    font-size: 2rem;
}

.mfa-screen-wrapper .logo-text p {
    font-size: var(--text-base);
}

.mfa-hero {
    text-align: center;
    margin-bottom: 24px;
}

.mfa-hero-icon {
    font-size: 2.5em;
    line-height: 1;
}

.mfa-hero h2 {
    margin: 10px 0 8px;
    font-size: var(--text-xl);
    color: #1e293b;
}

.mfa-hero p {
    color: #475569;
    font-size: var(--text-sm);
    line-height: 1.5;
    margin: 0;
}

.mfa-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mfa-actions-row {
    flex-direction: row;
}

.mfa-actions-row .btn-primary {
    flex: 1;
}

.mfa-loading {
    color: #64748b;
    text-align: center;
    padding: 8px 0;
}

/* QR enroll flow */
.mfa-enroll-flow p {
    margin-bottom: 12px;
    color: #475569;
    line-height: 1.5;
}

.mfa-qr-container {
    text-align: center;
    margin-bottom: 16px;
}

.mfa-qr-container img {
    width: 180px;
    height: 180px;
    border-radius: 8px;
}

.mfa-secret-toggle {
    margin-bottom: 16px;
}

.mfa-secret-toggle summary {
    cursor: pointer;
    color: #667eea;
    font-size: var(--text-sm);
    user-select: none;
}

.mfa-secret-toggle code {
    display: block;
    margin-top: 8px;
    padding: 10px;
    background: #f1f5f9;
    border-radius: 6px;
    word-break: break-all;
    font-size: var(--text-sm);
    color: #334155;
}

/* Code input shared style for MFA screens */
.mfa-code-input {
    text-align: center;
    font-size: var(--text-xl);
    letter-spacing: 0.3em;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.mfa-enroll-flow .mfa-code-input {
    font-size: var(--text-lg);
    letter-spacing: 0.2em;
}

.mfa-enroll-flow .form-group label {
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .mfa-screen-wrapper {
        max-width: 100%;
    }

    .mfa-qr-container img {
        width: 160px;
        height: 160px;
    }

    .mfa-hero-icon {
        font-size: 2em;
    }

    .mfa-hero h2 {
        font-size: var(--text-lg);
    }
}

/* MFA status cards (Settings page) */
.mfa-status-card {
    padding: 14px;
    border-radius: 8px;
    border: 1px solid;
}

.mfa-status-enabled {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.mfa-status-disabled {
    background: #fefce8;
    border-color: #fde68a;
}

.mfa-status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.mfa-status-label {
    font-weight: 600;
}

.mfa-status-enabled .mfa-status-label {
    color: #166534;
}

.mfa-status-disabled .mfa-status-label {
    color: #854d0e;
}

.mfa-status-desc {
    color: #64748b;
    font-size: var(--text-sm);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.mfa-btn-danger {
    color: #dc2626;
    border-color: #fecaca;
}

.mfa-btn-danger:hover {
    background: #fef2f2;
    border-color: #f87171;
}

/* ============================================
   REUSABLE UTILITY CLASSES
   ============================================ */

/* Gain/loss value coloring */
.value-positive {
    color: #1a7f37 !important;
}

.value-negative {
    color: #c9302c !important;
}

.value-neutral {
    color: #666 !important;
}

.value-accent {
    color: #8b5cf6 !important;
}

/* Bold variant for table cells / summaries */
.value-bold {
    font-weight: 600;
}

/* Form hint text below inputs */
.form-hint {
    color: #6c757d;
    font-size: var(--text-xs);
    margin-top: 4px;
    display: block;
    line-height: 1.4;
}

/* Readonly/disabled-looking input */
.input-readonly {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Split-adjusted annotation */
.split-adjusted-note {
    color: #888;
    font-size: 0.85em;
}

/* Inline checkbox label in empty states */
.empty-state-toggle {
    margin-top: 10px;
    display: block;
}

/* Options guide list */
.option-guide-list {
    margin: 5px 0 0 20px;
    font-size: var(--text-xs);
}

/* Initially hidden elements (toggled by JS) */
.initially-hidden {
    display: none;
}

/* Invisible spacer (takes up space but not visible) */
.visibility-hidden {
    visibility: hidden;
}

/* Modal dialog variants */
.modal-content-sm {
    max-width: 450px;
}

/* Modal body text */
.modal-text {
    margin: 0;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
}

.modal-text-spaced {
    margin: 0 0 12px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
}

/* Full-width form input */
.input-full {
    width: 100%;
    box-sizing: border-box;
}

/* Closed status text */
.status-closed {
    color: #999;
}

/* Compact progress bar for chart overlays */
.progress-bar-compact {
    width: 160px;
}

/* 2FA settings section in modals */
.settings-2fa-section h4 {
    margin: 0 0 12px 0;
}

.mfa-later-hint {
    text-align: center;
    margin-top: 16px;
}

.error-message {
    color: #c9302c;
    font-size: var(--text-sm);
    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: #1e293b;
    font-weight: 600;
}

.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: white;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    box-shadow: none;
}

.portfolio-selector-header label {
    color: #1e293b;
    font-size: var(--text-sm);
    font-weight: 600;
    margin: 0;
}

.portfolio-selector-header select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: var(--text-sm);
    background: #f8fafc;
    color: #333;
    cursor: pointer;
    min-width: 120px;
    font-weight: 600;
}

.portfolio-selector-header select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: none;
}

.portfolio-add-btn-header {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #475569;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--text-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.portfolio-add-btn-header:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: scale(1.05);
}

.portfolio-delete-btn-header {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #475569;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--text-sm);
    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.1);
    color: #c9302c;
    border-color: #c9302c;
    transform: scale(1.05);
}

.currency-selector-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    box-shadow: none;
}

.currency-selector-header label {
    color: #1e293b;
    font-size: var(--text-sm);
    font-weight: 600;
    margin: 0;
}

.currency-selector-header select {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: var(--text-sm);
    background: #f8fafc;
    color: #333;
    cursor: pointer;
    min-width: 80px;
    font-weight: 600;
}

.currency-selector-header select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: none;
}

#logout-btn,
#settings-btn {
    padding: 8px 16px;
    font-size: var(--text-sm);
    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%;
}

/* Dummy rows shown when no transactions exist */
.dummy-row {
    filter: blur(3px);
    user-select: none;
    pointer-events: none;
    opacity: 0.5;
}

/* Empty state overlay over dummy rows */
.empty-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: 8px;
}

.empty-overlay-content {
    text-align: center;
    padding: 32px 40px;
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    max-width: 360px;
}

.empty-overlay-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 12px;
}

.empty-overlay-content h3 {
    color: #1e293b;
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-overlay-content p {
    color: #64748b;
    font-size: var(--text-sm);
    margin-bottom: 20px;
    line-height: 1.5;
}

.empty-overlay-content .btn-primary {
    width: auto;
    padding: 10px 24px;
    font-size: var(--text-sm);
}

/* Base Table Styles */
.transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    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: var(--text-sm);
    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: var(--text-xs);
    margin-left: 4px;
}

.transactions-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

/* Mid-Size Display Scaling (Laptops/Tablets) */
@media (max-width: 1450px) {

    .transactions-table th,
    .transactions-table td {
        padding: 10px 8px;
        /* Slightly compact but larger than before */
    }

    .transactions-table tfoot input,
    .transactions-table tfoot select {
        padding: 8px 6px;
    }
}

.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: var(--text-xs);
    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: var(--text-xs);
    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: var(--text-sm);
    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: var(--text-sm);
}

.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: var(--text-sm);
    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;
}

/* Fix mobile Safari date input collapse when empty */
.transactions-table tfoot input[type="date"],
input[type="date"] {
    min-height: 42px;
    position: relative;
}

/* Custom placeholder for date inputs */
input[type="date"]::before {
    content: attr(placeholder);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    /* Muted slate color */
    pointer-events: none;
    font-size: var(--text-sm);
    display: block;
    z-index: 1;
}

/* Hide the browser's default date text when it's just showing the placeholder */
input[type="date"]:not(:focus):not(:valid)::-webkit-datetime-edit {
    color: transparent;
}

input[type="date"]:focus::before,
input[type="date"]:valid::before,
input[type="date"]:not([value=""])::before {
    display: none;
}

/* Ensure the text is visible when something is entered */
input[type="date"]:valid::-webkit-datetime-edit,
input[type="date"]:focus::-webkit-datetime-edit {
    color: inherit;
}

/* Action buttons in new row */
.transactions-table tfoot .action-cell {
    padding: 10px 12px;
}

.transactions-table tfoot button {
    padding: 4px 8px;
    font-size: var(--text-sm);
    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: #1a7f37;
    font-weight: 600;
}

.transactions-table .type-sell {
    color: #c9302c;
    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: none;
}

.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: var(--text-base);
    color: #333;
}

.btn-toggle-form {
    background: none;
    border: none;
    font-size: var(--text-xl);
    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: var(--text-sm);
    color: #495057;
}

.add-transaction-form .form-field input:not([type="radio"]):not([type="checkbox"]),
.add-transaction-form .form-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: var(--text-base);
    transition: all 0.2s;
}

.add-transaction-form .form-field input:not([type="radio"]):not([type="checkbox"]):focus,
.add-transaction-form .form-field select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: none;
}

.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: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-transaction-form .btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: none;
}

.add-transaction-form .btn-secondary {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: var(--text-base);
    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: var(--text-xl);
    color: white;
}

.transaction-info-card .info-title {
    flex: 1;
}

.transaction-info-card .info-title h4 {
    margin: 0;
    font-size: var(--text-lg);
    color: #333;
}

.transaction-info-card .info-title p {
    margin: 4px 0 0 0;
    font-size: var(--text-sm);
    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: var(--text-sm);
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transaction-info-card .info-section p {
    margin: 0;
    font-size: var(--text-base);
    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: var(--text-sm);
    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 (base rules)
   ============================================ */

@media (max-width: 1200px) {
    .transactions-table thead {
        display: none;
    }

    .transactions-table tbody,
    .transactions-table tfoot {
        display: block;
    }

    .transactions-table tr {
        margin-bottom: 4px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background: white;
        cursor: pointer;
        transition: all 0.2s;
        overflow: hidden;
    }

    .transactions-table tr:active {
        transform: scale(0.99);
    }

    .transactions-table .edit-indicator {
        display: none;
    }
}

.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: var(--text-sm);
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.sample-link:hover {
    background: #f0f3ff;
    text-decoration: underline;
}

.import-status {
    font-size: var(--text-sm);
    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: var(--text-base);
    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: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-save-all {
    background: #1a7f37;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save-all:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-cancel-all {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel-all:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-delete-multi {
    background: #c9302c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-multi:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-delete-all {
    background: #fb7185;
    /* Soft Coral/Salmon */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-all:hover {
    background: #f43f5e;
    /* slightly deeper rose */
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-import {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-import:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.btn-export {
    background: #1a7f37;
    color: white;
    border: 1px solid #1a7f37;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    background: #218838;
    border-color: #1e7e34;
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-import-export {
    background: #64748b;
    color: white;
    border: 1px solid #64748b;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-import-export:hover {
    background: #475569;
    border-color: #475569;
    transform: translateY(-1px);
    box-shadow: none;
}

.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: none;
    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: var(--text-sm);
    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: var(--text-lg);
    padding: 4px 8px;
    color: #6c757d;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: #c9302c;
}

.btn-save {
    background: #1a7f37;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: var(--text-sm);
    cursor: pointer;
}

.btn-save:hover {
    background: #218838;
}

.btn-cancel {
    background: #c9302c;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: var(--text-sm);
    cursor: pointer;
}

.btn-cancel:hover {
    background: #c82333;
}

.fetching-price {
    color: #667eea;
    font-style: italic;
    font-size: var(--text-sm);
}

@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: var(--text-xs);
        margin-bottom: 4px;
    }

    .option-group-inline select,
    .filter-dropdown-toggle {
        padding: 8px 10px;
        font-size: var(--text-sm);
        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: auto;
        -webkit-overflow-scrolling: touch;
    }

    .transactions-table {
        display: table;
        min-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: var(--text-xs);
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .option-badge {
        padding: 3px 8px;
        font-size: var(--text-xs);
    }

    .option-info {
        font-size: var(--text-xs);
        padding: 3px 8px;
    }

    .option-status {
        font-size: var(--text-xs);
        padding: 3px 8px;
    }

    /* Table actions */
    .table-actions {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .table-actions button {
        font-size: var(--text-sm);
        padding: 10px 15px;
        flex: 0 1 auto;
    }

    /* Pagination */
    .pagination-container {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }

    .pagination-info {
        font-size: var(--text-sm);
        text-align: center;
    }

    .pagination-controls {
        gap: 10px;
    }

    .pagination-controls button {
        padding: 8px 16px;
        font-size: var(--text-sm);
    }
}

/* 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;
}

@media (max-width: 600px) {
    .modal.active {
        align-items: flex-end;
    }
}

@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: none;
    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: var(--text-xl);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-2xl);
    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: var(--text-base);
    font-weight: 700;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

.import-section h5 {
    color: #343a40;
    margin: 10px 0 6px 0;
    font-size: var(--text-sm);
    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: var(--text-xs);
}

.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: var(--text-xs);
    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: var(--text-sm);
    font-weight: 700;
}

.column-item.optional strong {
    color: #868e96;
}

.column-item span {
    display: block;
    color: #868e96;
    font-size: var(--text-xs);
    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: var(--text-xs);
    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: var(--text-xs);
    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: var(--text-xs);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
}

.csv-example .example-note {
    margin-top: 8px;
    font-size: var(--text-xs);
    color: #868e96;
    font-style: italic;
}

.import-instructions h4 {
    color: #343a40;
    margin-bottom: 10px;
    font-size: var(--text-base);
}

.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: var(--text-sm);
}

.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: var(--text-sm);
    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: var(--text-base);
}

.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: var(--text-xs);
}

.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: var(--text-base);
}

.csv-preview {
    background: #1e2433;
    color: #cdd9e5;
    padding: 10px 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: var(--text-xs);
    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: var(--text-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.btn-download:hover {
    background: #343a40;
    transform: translateY(-1px);
    box-shadow: none;
}

.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: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-upload:hover {
    background: #2b8a3e;
    transform: translateY(-1px);
    box-shadow: none;
}

#import-modal-status {
    font-size: var(--text-sm);
    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: var(--text-base);
    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: var(--text-sm);
}

.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: var(--text-sm);
}

.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: var(--text-xs);
    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: var(--text-xs);
    font-weight: 600;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.new-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
    background: #d4edda;
    color: #155724;
    border: 1px solid #1a7f37;
}

.duplicate-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .duplicate-table {
        font-size: var(--text-xs);
    }

    .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: var(--text-base);
    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: var(--text-sm);
    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: #c9302c;
    font-size: var(--text-lg);
    line-height: 1;
    transition: all 0.2s ease;
    margin-left: 4px;
}

.portfolio-tab-delete:hover {
    background: #c9302c;
    color: white;
    transform: scale(1.1);
}

.portfolio-add-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #667eea;
    color: white;
    border: none;
    font-size: var(--text-xl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    align-self: flex-end;
    box-shadow: none;
    margin-bottom: 8px;
    margin-right: 0;
}

.portfolio-add-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: none;
}

.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: #4f63c8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle-cards:hover {
    background: #3d4fa6;
    transform: translateY(-1px);
    box-shadow: none;
}

.portfolio-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portfolio-card {
    background: white;
    border-radius: 6px;
    padding: 0;
    box-shadow: none;
    transition: all 0.2s ease;
    cursor: pointer;
    overflow: hidden;
}

.portfolio-card:hover {
    box-shadow: none;
}

.portfolio-card.active {
    border: 2px solid #667eea;
    box-shadow: none;
}

.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: var(--text-base);
    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: var(--text-base);
    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: var(--text-xs);
    color: #717171;
    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: var(--text-base);
    font-weight: 700;
    color: #4f63c8;
    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: var(--text-xs);
    color: #717171;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    line-height: 1;
}

.quick-stat-value {
    font-size: var(--text-base);
    font-weight: 600;
    color: #333;
    line-height: 1;
    margin-top: 2px;
}

.card-expand-icon {
    font-size: var(--text-xs);
    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: #1a7f37;
    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: var(--text-xs);
    }

    .quick-stat-label {
        font-size: var(--text-xs);
    }

    .quick-stat-value {
        font-size: var(--text-sm);
    }
}

@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: var(--text-sm);
    }

    .portfolio-ticker-link {
        font-size: var(--text-base);
    }

    .ticker-exchange {
        font-size: var(--text-xs);
    }

    .portfolio-quick-stats {
        display: flex;
        gap: 8px;
        overflow: visible;
    }

    .quick-stat {
        font-size: var(--text-xs);
    }

    .quick-stat-label {
        font-size: var(--text-xs);
    }

    .quick-stat-value {
        font-size: var(--text-xs);
    }

    /* 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: var(--text-sm);
        min-width: 50px;
    }

    .card-expand-icon {
        font-size: var(--text-xs);
    }

    .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: var(--text-xs);
        padding: 1px;
    }

    .portfolio-ticker-link {
        font-size: var(--text-sm);
    }

    .portfolio-quick-stats {
        gap: 6px;
    }

    .quick-stat {
        font-size: var(--text-xs);
    }

    .quick-stat-label {
        font-size: var(--text-xs);
    }

    .quick-stat-value {
        font-size: var(--text-xs);
    }

    .portfolio-percentage {
        font-size: var(--text-xs);
        min-width: 45px;
    }

    .portfolio-header-right {
        gap: 4px;
    }
}

.portfolio-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.portfolio-percentage {
    font-size: var(--text-base);
    font-weight: 600;
    color: #4f63c8;
    line-height: 1;
}

.card-expand-icon {
    font-size: var(--text-xs);
    color: #4f63c8;
    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: var(--text-lg);
    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;
}

.portfolio-ticker {
    font-size: var(--text-xl);
    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: var(--text-xs);
        white-space: nowrap;
    }

    .quick-stat-value {
        font-size: var(--text-xs);
        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: var(--text-sm);
        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: var(--text-sm);
    }

    .ticker-exchange {
        font-size: var(--text-xs);
    }

    .portfolio-quick-stats {
        gap: 8px;
    }

    .quick-stat-label {
        font-size: var(--text-xs);
    }

    .quick-stat-value {
        font-size: var(--text-xs);
    }

    .portfolio-percentage {
        font-size: var(--text-xs);
        min-width: 40px;
    }

    .expand-toggle {
        font-size: var(--text-sm);
        padding: 2px;
    }
}

.portfolio-detail-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
}

.portfolio-detail-label {
    font-size: var(--text-xs);
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    font-weight: 600;
}

.portfolio-detail-value {
    font-size: var(--text-base);
    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: var(--text-sm);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.page-info {
    color: #666;
    font-size: var(--text-sm);
    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: var(--text-base);
    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: var(--text-sm);
    color: #495057;
    font-weight: 500;
    margin-right: 4px;
}

.calculator-panel h3 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: var(--text-lg);
}

.calculator-description {
    color: #666;
    margin-bottom: 8px;
    font-size: var(--text-sm);
}

.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: var(--text-base);
    color: #333;
}

.calc-remove-btn {
    background: #c9302c;
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: var(--text-sm);
    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: var(--text-sm);
    color: #666;
}

.calc-info-item {
    display: flex;
    flex-direction: column;
}

.calc-info-label {
    font-size: var(--text-xs);
    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: var(--text-sm);
    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: var(--text-base);
    font-weight: 700;
    color: #333;
    background: #f8f9fa;
    transition: all 0.2s;
}

.calc-shares-input:focus {
    outline: none;
    border-color: #5568d3;
    background: white;
    box-shadow: none;
}

.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: var(--text-xs);
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}

.calc-result-value {
    font-size: var(--text-base);
    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: var(--text-base);
}

.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: var(--text-xs);
    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: var(--text-base);
}

.calc-breakdown-shares {
    color: #666;
    font-size: var(--text-sm);
}

.calc-breakdown-value {
    color: #333;
    font-weight: 600;
    font-size: var(--text-sm);
}

.calc-breakdown-gain {
    font-weight: 700;
    font-size: var(--text-sm);
}

.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: var(--text-sm);
    color: #666;
    font-weight: 500;
}

.calc-summary-highlight .calc-summary-label {
    font-size: var(--text-base);
    font-weight: 700;
    color: #333;
}

.calc-summary-value {
    font-size: var(--text-base);
    font-weight: 700;
    color: #333;
}

.calc-summary-highlight .calc-summary-value {
    font-size: var(--text-lg);
}

.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: var(--text-base);
    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: var(--text-lg);
    font-weight: 700;
    color: #667eea;
}

.calc-formula-result {
    font-size: var(--text-lg);
    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: var(--text-lg);
        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 #1a7f37;
    box-shadow: none;
}


/* 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: var(--text-base);
}

.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: var(--text-base);
    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: none;
}

.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: var(--text-base);
    transition: all 0.2s ease;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.modal-actions button {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: var(--text-base);
    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: none;
}

.modal-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.modal-actions .btn-primary:active {
    transform: translateY(0);
}

.error-message {
    color: #c9302c;
    font-size: var(--text-sm);
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8d7da;
    border-radius: 6px;
    border-left: 3px solid #c9302c;
    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: var(--text-sm);
        min-height: 40px;
    }

    .portfolio-add-btn {
        width: 40px;
        height: 40px;
        font-size: var(--text-lg);
    }

    /* Section headers */
    .section-header {
        padding: 15px 0;
    }

    .section-header h2 {
        font-size: var(--text-xl);
        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: var(--text-sm);
        font-weight: 600;
        color: #495057;
        margin: 0;
    }

    .option-group-inline select {
        width: 100%;
        padding: 10px;
        font-size: var(--text-sm);
        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: var(--text-sm);
        font-weight: 600;
        color: #495057;
        margin: 0;
    }

    .filter-dropdown-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 10px;
        font-size: var(--text-sm);
        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: var(--text-lg);
    }

    /* 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: var(--text-xs);
}

.currency-selector-header select {
    padding: 5px 8px;
    font-size: var(--text-xs);
    min-width: 70px;
}

#settings-btn,
#logout-btn {
    min-width: 80px;
    font-size: var(--text-sm);
    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: var(--text-sm);
    white-space: nowrap;
}

.action-spacer {
    display: none;
}

/* Pagination */
.pagination-container {
    gap: 15px;
}

.pagination-info {
    font-size: var(--text-sm);
    text-align: center;
}

.pagination-controls {
    gap: 10px;
}

.pagination-controls button {
    padding: 8px 12px;
    font-size: var(--text-sm);
}

.page-info {
    font-size: var(--text-sm);
}

/* Extra small mobile */
@media (max-width: 480px) {
    .portfolio-tab {
        padding: 8px 12px;
        font-size: var(--text-sm);
    }

    .portfolio-quick-stats {
        grid-template-columns: 1fr;
    }

    .section-header h2 {
        font-size: var(--text-lg);
    }

    .portfolio-section-header h2 {
        font-size: var(--text-base);
    }

    /* 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: none;
    margin-top: 30px;
}

.tax-reporting>h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: var(--text-xl);
}

.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: var(--text-lg);
    font-weight: 600;
}

.year-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.year-selector label {
    font-weight: 500;
    color: #495057;
    font-size: var(--text-sm);
    margin: 0;
}

.year-selector select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: var(--text-sm);
    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: var(--text-sm);
    text-align: center;
}

.chart-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #555;
    font-size: var(--text-sm);
}

.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: var(--text-sm);
    color: #6c757d;
    font-weight: 500;
}

.stat-value {
    font-size: var(--text-lg);
    color: #333;
    font-weight: 600;
}

.stat-value.positive {
    color: #1a7f37;
}

.stat-value.negative {
    color: #c9302c;
}

@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: var(--text-sm);
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none;
}

.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: var(--text-xs);
    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: var(--text-sm);
}

.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: none;
}

.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: var(--text-xs);
    color: #666;
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gains-summary-item strong,
.summary-item strong {
    font-size: var(--text-xl);
    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: var(--text-sm);
}

.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: var(--text-sm);
}

.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: #1a7f37;
}

.gains-value.negative {
    color: #c9302c;
}

@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: var(--text-lg);
    }

    .gains-losses-table table,
    .foreign-assets-table table {
        font-size: var(--text-xs);
    }

    .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: var(--text-sm);
}

.option-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: var(--text-xs);
    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: var(--text-xs);
    font-weight: 500;
}

.option-status {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: var(--text-xs);
    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: var(--text-sm);
    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: var(--text-sm);
    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: var(--text-sm);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: var(--text-sm);
    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: var(--text-sm);
}

.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: var(--text-sm);
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.option-field input {
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: var(--text-sm);
}

.option-field input:focus {
    outline: none;
    border-color: #667eea;
}

.option-field small {
    font-size: var(--text-xs);
    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: var(--text-sm);
    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: 40px;
    padding: 24px 0;
    background: #f0f2f5;
    border-top: 1px solid #e2e8f0;
}

.app-footer.hidden {
    display: none;
}

.footer-content {
    max-width: 1350px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-text {
    font-size: var(--text-base);
    line-height: 1.5;
    color: #475569;
}

.footer-text a {
    color: #1e293b;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer-text a:hover {
    color: #667eea;
}

.footer-disclaimer {
    margin-top: 6px;
    font-size: var(--text-sm);
    color: #94a3b8;
}

.footer-links {
    margin-top: 8px;
    font-size: var(--text-sm);
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-sep {
    margin: 0 8px;
    color: #cbd5e1;
}

@media (max-width: 600px) {
    .app-footer {
        margin-top: 24px;
        padding: 20px 16px;
    }

    .footer-content {
        padding: 0;
    }

    .footer-text {
        font-size: var(--text-xs);
    }

    .footer-disclaimer {
        font-size: 11px;
    }
}

/* Auth page inline footer */
.auth-footer-inline {
    width: 100%;
    max-width: 1100px;
    margin-top: 24px;
    padding: 16px 20px 8px;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .auth-footer-inline {
        padding: 12px 16px 8px;
    }

    .auth-footer-inline .footer-text {
        text-align: center;
    }
}



/* 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: var(--text-sm);
    color: #666;
    font-weight: 500;
}

.summary-value {
    font-size: var(--text-lg);
    font-weight: 600;
    color: #333;
}

.summary-value.positive {
    color: #1a7f37;
}

.summary-value.negative {
    color: #c9302c;
}

.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: var(--text-sm);
}

.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: #1a7f37;
    font-weight: 600;
}

.holdings-breakdown-table td.negative {
    color: #c9302c;
    font-weight: 600;
}

.holdings-breakdown-table small {
    font-size: var(--text-sm);
    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: var(--text-sm);
    text-align: center;
}

.empty-state,
.error-state {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: var(--text-sm);
}

.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: var(--text-sm);
    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: var(--text-xs);
    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: var(--text-sm);
    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: var(--text-sm);
    color: #666;
}

.gains-transactions-summary-grid .summary-value {
    font-size: var(--text-lg);
    font-weight: 600;
}

.gains-transactions-summary-grid .summary-value.positive {
    color: #1a7f37;
}

.gains-transactions-summary-grid .summary-value.negative {
    color: #c9302c;
}

.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: var(--text-lg);
    border-bottom: 2px solid #e0e0e0;
}

.ticker-header span {
    font-size: var(--text-base);
    font-weight: 600;
}

.ticker-header span.positive {
    color: #1a7f37;
}

.ticker-header span.negative {
    color: #c9302c;
}

.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: var(--text-sm);
    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: #c9302c;
}


/* 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: var(--text-xs);
    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: var(--text-xs);
    font-weight: 500;
    color: #666;
}


/* ── Chart Placeholder Overlay ── */
.chart-placeholder-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    pointer-events: none;
}

.chart-placeholder-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px;
    padding: 18px 28px;
    max-width: 360px;
    text-align: center;
}

.chart-placeholder-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.chart-placeholder-text {
    font-size: var(--text-sm);
    color: #64748b;
    font-weight: 500;
    line-height: 1.5;
}

/* 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-modal .modal-content {
    max-width: 680px;
}

.settings-2fa-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.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: var(--text-base);
}

.settings-danger-zone p {
    color: #991b1b;
    margin-bottom: 12px;
    font-size: var(--text-sm);
}

.settings-danger-zone ul {
    color: #991b1b;
    margin-left: 20px;
    margin-bottom: 16px;
    font-size: var(--text-sm);
}

.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: var(--text-sm);
    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: var(--text-sm);
    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: var(--text-sm);
    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: var(--text-sm);
    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: var(--text-xl);
}

.btn-close-validation {
    background: none;
    border: none;
    font-size: var(--text-xl);
    color: #999;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
}

.btn-close-validation:hover {
    color: #333;
}

.btn-validate {
    background: #d97706;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 500;
    transition: all 0.2s;
}

.btn-validate:hover {
    background: #b45309;
    transform: translateY(-1px);
    box-shadow: none;
}

.validation-results {
    max-height: 600px;
    overflow-y: auto;
}

.validation-success {
    text-align: center;
    padding: 40px 20px;
    color: #1a7f37;
}

.validation-success .validation-icon {
    font-size: var(--text-3xl);
    margin-bottom: 10px;
}

.validation-success h4 {
    font-size: var(--text-xl);
    margin: 10px 0;
    color: #1a7f37;
    font-weight: 600;
}

.validation-success p {
    color: #666;
    font-size: var(--text-base);
}

.validation-group {
    margin-bottom: 30px;
}

.validation-group-title {
    font-size: var(--text-base);
    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: var(--text-sm);
    color: #333;
    flex: 1;
    min-width: 0;
}

.issue-details {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    font-size: var(--text-sm);
}

.issue-ticker {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: var(--text-xs);
    white-space: nowrap;
}

.issue-date {
    color: #666;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: var(--text-xs);
    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: var(--text-xs);
    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: var(--text-lg);
    }

    .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: #667eea;
}

@media (max-width: 600px) {

    /* ── Typography & Spacing ── */
    body {
        font-size: var(--text-base) !important;
        background-attachment: initial !important;
    }

    /* True 100% width container */
    .container {
        padding: 0 !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        animation: slideUpMobile 0.3s ease !important;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    /* ── Header Optimization ── */
    header {
        margin-bottom: 20px !important;
        padding: 12px 0 !important;
    }

    .app-top-header {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
    }

    .header-right-panel {
        align-items: center !important;
        width: 100% !important;
        gap: 12px !important;
    }

    .app-top-header .user-info,
    .app-top-header .header-controls {
        justify-content: center !important;
        width: 100% !important;
    }

    header .logo-header,
    .logo-header {
        flex-direction: column !important;
        align-items: center !important;
        gap: 6px !important;
        margin-bottom: 12px !important;
    }

    header .bull-logo,
    .bull-logo {
        width: 100px !important;
        height: auto !important;
    }

    header .logo-text,
    .logo-text {
        align-items: center !important;
        text-align: center !important;
    }

    header .logo-text h1,
    .logo-text h1 {
        font-size: 1.4rem !important;
        margin: 0 !important;
    }

    header .logo-text p,
    .logo-text p {
        font-size: var(--text-xs) !important;
        margin-top: 2px !important;
    }

    header .logo-text p {
        color: #64748b !important;
    }

    .header-controls {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 8px !important;
        justify-content: center !important;
    }

    .portfolio-selector-header {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .portfolio-selector-header select {
        min-width: 0 !important;
        width: 100% !important;
    }

    .portfolio-selector-header,
    .currency-selector-header {
        flex: 1 !important;
        width: auto !important;
        min-width: 0 !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
        padding: 4px 6px !important;
        gap: 4px !important;
    }

    .portfolio-selector-header {
        flex: 2 !important;
    }

    .portfolio-selector-header select,
    .currency-selector-header select {
        min-width: 0 !important;
        width: 100% !important;
        flex: 1 !important;
    }

    .portfolio-selector-header label,
    .currency-selector-header label {
        display: none !important;
    }

    .portfolio-add-btn-header,
    .portfolio-delete-btn-header {
        width: 24px !important;
        height: 24px !important;
        padding: 0 !important;
        font-size: var(--text-sm) !important;
        flex-shrink: 0 !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;
    }

    .portfolio-value-chart-container {
        height: 250px !important;
        min-height: 250px !important;
        padding: 0 !important;
    }

    .portfolio-value-card .chart-navigation {
        display: none !important;
    }

    .portfolio-value-card .tax-card-header {
        margin-bottom: 25px !important;
        gap: 15px !important;
    }

    .portfolio-value-summary {
        margin-top: 0 !important;
    }

    .gains-chart-container,
    .foreign-chart-container,
    .dividend-chart-container {
        padding: 5px !important;
        min-height: 220px !important;
        margin-bottom: 5px !important;
    }

    /* Flatten tax cards nested inside the reporting section */
    .tax-card {
        border-radius: 0 !important;
        padding: 0 0 25px 0 !important;
        border: none !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
        background: transparent !important;
        box-shadow: none !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    .tax-card:last-child {
        border-bottom: none !important;
        margin-bottom: 0 !important;
        padding-bottom: 0 !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: 0 !important;
        margin-left: -12px !important;
        margin-right: -12px !important;
        width: calc(100% + 24px) !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: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    .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: var(--text-base) !important;
        line-height: 1 !important;
        position: static !important;
        margin: 0 !important;
    }

    .ticker-info {
        display: flex !important;
        flex-direction: row !important;
        align-items: baseline !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }

    .portfolio-ticker-link {
        font-size: var(--text-base) !important;
        line-height: 1.2 !important;
    }

    .ticker-exchange {
        font-size: var(--text-xs) !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: var(--text-base) !important;
        line-height: 1 !important;
    }

    .card-expand-icon {
        font-size: var(--text-xs) !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;
    }

    .portfolio-quick-stats .quick-stat:nth-child(2),
    .portfolio-quick-stats .quick-stat:nth-child(4) {
        display: none !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: var(--text-xs) !important;
        margin-bottom: 0 !important;
    }

    .quick-stat-value {
        font-size: var(--text-xs) !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: var(--text-xs) !important;
        margin-bottom: 4px !important;
    }

    .stat-value {
        font-size: var(--text-base) !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: var(--text-sm) !important;
    }

    .main-tab-btn {
        box-shadow: none !important;
        outline: none !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        border-width: 1px !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;
    }

    /* ── Form Inputs Flattening ── */
    .add-transaction-form .form-content,
    .modal-body form {
        padding: 16px !important;
        gap: 16px !important;
        grid-template-columns: 1fr !important;
    }

    .modal-body {
        padding: 16px !important;
    }

    /* Settings modal mobile tweaks */
    #settings-modal .modal-actions {
        flex-direction: column-reverse !important;
    }

    #settings-modal .modal-actions button {
        width: 100% !important;
    }

    #settings-modal .settings-danger-zone {
        margin-top: 24px !important;
        padding: 16px !important;
    }

    /* ── Mobile Holdings Breakdown Table (Modal) ── */
    .holdings-breakdown-table,
    .holdings-breakdown-table tbody {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    .holdings-breakdown-table thead {
        display: none !important;
        /* Hide column headers */
    }

    .holdings-breakdown-table tr {
        display: block !important;
        margin-bottom: 16px !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px !important;
        padding: 8px 16px !important;
        background: #fff !important;
        box-shadow: none !important;
    }

    .holdings-breakdown-table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 0 !important;
        border: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
        text-align: right !important;
        font-size: var(--text-base) !important;
        font-family: 'Inter', sans-serif !important;
    }

    .holdings-breakdown-table td:last-child {
        border-bottom: none !important;
    }

    .holdings-breakdown-table td::before {
        font-weight: 600 !important;
        color: #555 !important;
        text-transform: uppercase !important;
        font-size: var(--text-xs) !important;
        letter-spacing: 0.5px !important;
    }

    .holdings-breakdown-table td:nth-child(1)::before {
        content: "Ticker";
    }

    .holdings-breakdown-table td:nth-child(2)::before {
        content: "Shares";
    }

    .holdings-breakdown-table td:nth-child(3)::before {
        content: "ACB/Share";
    }

    .holdings-breakdown-table td:nth-child(4)::before {
        content: "Price/Share";
    }

    .holdings-breakdown-table td:nth-child(5)::before {
        content: "Total ACB";
    }

    .holdings-breakdown-table td:nth-child(6)::before {
        content: "Market Value";
    }

    .holdings-breakdown-table td:nth-child(7)::before {
        content: "Gain/Loss";
    }

    /* ── Transaction Add Form ── */
    .add-transaction-form .form-row {
        grid-template-columns: 1fr !important;
    }

    .add-transaction-form .form-field input:not([type="radio"]):not([type="checkbox"]),
    .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-add,
    .table-actions .btn-delete-multi,
    .table-actions .btn-cancel-all,
    .table-actions .btn-save-all {
        padding: 6px 12px !important;
        font-size: var(--text-sm) !important;
        border-radius: 6px !important;
        flex: 1 1 auto !important;
        min-width: max-content !important;
        text-align: center !important;
        line-height: 1.4 !important;
    }

    .table-actions .btn-delete-all {
        padding: 10px 18px !important;
        /* Extra padding as requested */
        font-size: var(--text-sm) !important;
        border-radius: 6px !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: var(--text-sm) !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;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        -webkit-appearance: checkbox !important;
        appearance: auto !important;
    }

    /* ── Filter Dropdown (bottom sheet) ── */
    .filter-dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 60vh !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
        z-index: 2000 !important;
    }

    .filter-dropdown-menu .filter-option {
        padding: 12px 16px !important;
        font-size: var(--text-base) !important;
        border-bottom: 1px solid #f1f3f5 !important;
    }

    .filter-dropdown-menu .filter-option label {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        font-size: var(--text-base) !important;
    }

    .filter-dropdown-menu .filter-option input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
        flex-shrink: 0 !important;
    }

    .filter-dropdown-menu .filter-select-all {
        padding: 14px 16px !important;
        font-weight: 600 !important;
        border-bottom: 2px solid #e2e8f0 !important;
    }
}


/* ============================================
   TRANSACTIONS — COMPACT MOBILE (≤ 1200px)
   ============================================ */
@media (max-width: 1200px) {

    /* ── Filters: side by side ── */
    .view-options-inline {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        align-items: center !important;
        margin-bottom: 6px !important;
    }

    .view-options-inline .option-group-inline {
        flex: 1 !important;
        min-width: 0 !important;
        width: auto !important;
    }

    .view-options-inline .option-group-inline:last-child {
        flex: 0 0 auto !important;
    }

    .view-options-inline .option-group-inline:last-child select {
        width: auto !important;
        min-width: 70px !important;
    }

    .view-options-inline .option-group-inline label {
        display: none !important;
    }

    .view-options-inline .filter-dropdown-toggle,
    .view-options-inline select {
        width: 100% !important;
        font-size: var(--text-sm) !important;
        padding: 6px 8px !important;
    }

    /* ── Single-line transaction rows ──
       ☐ TICKER  TYPE  $PRICE  DATE
    ── */
    .transactions-table tr {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 10px 10px !important;
        margin-bottom: 4px !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        gap: 8px !important;
    }

    .transactions-table td {
        display: none !important;
        border: none !important;
        padding: 0 !important;
        white-space: nowrap !important;
    }

    /* Checkbox */
    .transactions-table td:nth-child(1) {
        display: flex !important;
        flex: 0 0 auto !important;
        background: transparent !important;
    }

    .transactions-table td:nth-child(1)::before {
        display: none !important;
    }

    /* Ticker — bold, left-aligned */
    .transactions-table td:nth-child(3) {
        display: block !important;
        flex: 0 0 auto !important;
        font-size: var(--text-base) !important;
        font-weight: 700 !important;
    }

    .transactions-table td:nth-child(3)::before {
        display: none !important;
    }

    /* Type — small colored badge */
    .transactions-table td:nth-child(4) {
        display: block !important;
        flex: 0 0 auto !important;
        font-size: var(--text-xs) !important;
        font-weight: 600 !important;
    }

    .transactions-table td:nth-child(4)::before {
        display: none !important;
    }

    /* Price — pushed right with flex spacer */
    .transactions-table td:nth-child(6) {
        display: block !important;
        flex: 1 1 auto !important;
        font-size: var(--text-xs) !important;
        text-align: right !important;
    }

    .transactions-table td:nth-child(6)::before {
        display: none !important;
    }

    /* Date — right end */
    .transactions-table td:nth-child(2) {
        display: block !important;
        flex: 0 0 auto !important;
        font-size: var(--text-xs) !important;
        color: #94a3b8 !important;
    }

    .transactions-table td:nth-child(2)::before {
        display: none !important;
    }

    /* Shares — hidden in collapsed */
    .transactions-table td:nth-child(5) {
        display: none !important;
    }

    /* ── Expanded: full detail view ── */
    .transactions-table tr.expanded {
        flex-direction: column !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    .transactions-table tr.expanded td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 12px !important;
        border-bottom: 1px solid #f1f3f5 !important;
        font-size: var(--text-sm) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        flex: unset !important;
        white-space: normal !important;
        text-align: right !important;
    }

    .transactions-table tr.expanded td::before {
        content: attr(data-label) !important;
        display: block !important;
        font-weight: 600 !important;
        color: #6c757d !important;
        text-transform: uppercase !important;
        font-size: var(--text-xs) !important;
        letter-spacing: 0.5px !important;
        flex-shrink: 0 !important;
        margin-right: 12px !important;
        text-align: left !important;
    }

    .transactions-table tr.expanded td:nth-child(1) {
        background: #f8f9fa !important;
    }

    .transactions-table tr.expanded td:nth-child(1)::before {
        content: "Select" !important;
    }

    .transactions-table tr.expanded td:nth-child(5),
    .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(11),
    .transactions-table tr.expanded td:nth-child(12) {
        display: flex !important;
    }

    /* ── Spacing fixes ── */
    .add-transaction-form {
        margin-bottom: 12px !important;
    }

    .add-transaction-form .form-header {
        padding: 10px 14px !important;
    }

    .transactions .section-header {
        margin-bottom: 8px !important;
    }

    .transactions .section-header:first-child {
        margin-bottom: 6px !important;
    }

    .transactions .section-header.section-spacing-top {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin-top: 12px !important;
    }

    .transactions-table-container {
        margin-top: 6px !important;
    }

    .section-spacing-top {
        margin-top: 12px !important;
    }

    .table-actions {
        gap: 6px !important;
        margin-top: 8px !important;
        flex-wrap: wrap !important;
    }

    .table-actions button {
        font-size: var(--text-xs) !important;
        padding: 6px 10px !important;
    }

    .pagination-container {
        gap: 4px !important;
        margin-top: 8px !important;
    }

    .transactions h2 {
        font-size: var(--text-lg) !important;
        margin-bottom: 8px !important;
    }

    .portfolio-section-header {
        margin-bottom: 8px !important;
    }
}