:root {
    --primary-teal: #0D9488;
    --primary-blue: #3b82f6;
    --secondary-slate: #475569;
    --accent-cyan: #06B6D4;
    --primary-orange: #f97316;
    --primary-pink: #ec4899;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --warning-orange: #f59e0b;

    --bg-primary: #f5f5f7;
    --bg-white: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
}

.header {
    background: var(--bg-white);
    padding: 24px 40px;
    margin-bottom: 0;
    width: 100%;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-teal) 0%, var(--accent-cyan) 50%, var(--primary-blue) 100%);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    color: white;
    box-shadow: var(--shadow-md);
}

.brand-icon-img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    display: block;
    flex-shrink: 0;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 4px;
}

.btn-user-profile {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-user-profile:hover {
    background: var(--bg-white);
    border-color: var(--primary-teal);
    color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.btn-user-profile:active {
    transform: scale(0.95);
}

.btn-user-profile.active {
    background: var(--bg-white);
    border-color: var(--primary-teal);
    color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.btn-user-profile.hidden {
    display: none;
}

.main-content {
    padding: 32px 40px;
    min-height: calc(100vh - 112px);
}

.search-section {
    background: var(--bg-white);
    border-radius: 4px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.search-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

#tickerInput {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 15px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    font-weight: 500;
}

#tickerInput:focus {
    outline: none;
    border-color: var(--primary-teal);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#tickerInput::placeholder {
    color: var(--text-tertiary);
    text-transform: none;
}

#searchBtn {
    padding: 12px 24px;
    background: var(--primary-teal);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

#searchBtn:hover {
    background: #0F766E;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#searchBtn:active {
    transform: translateY(0);
}

#searchBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.loading {
    text-align: center;
    padding: 60px;
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-teal);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

.error {
    background: #fef2f2;
    color: var(--danger-red);
    padding: 16px 20px;
    border-radius: 4px;
    border: 1px solid #fecaca;
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error::before {
    content: '⚠';
    font-size: 1.2rem;
}

.results {
    display: none;
}

.results.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

.stock-info {
    background: var(--bg-white);
    border-radius: 4px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.4s ease;
}

.company-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 28px;
}

.company-name {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.ticker-symbol {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.metric-card {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 4px;
    padding: 13px 20px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-teal);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.metric-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.metric-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.metric-value.positive {
    color: var(--success-green);
}
.metric-value.negative {
    color: var(--danger-red);
}

/* Portfolio Header Container */
.portfolio-header-container {
    background: var(--bg-white);
    border-radius: 4px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Portfolio Header */
.portfolio-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 24px;
    background: var(--bg-white);
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
}

.portfolio-header-left {
    display: flex;
    flex-direction: column;
}

.portfolio-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.portfolio-sub {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 0;
    margin-bottom: 0;
    background: var(--bg-white);
    border-radius: 0;
    padding: 6px;
    box-shadow: none;
    border-top: 1px solid var(--border-color);
}

.tab {
    padding: 10px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    border: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    background: transparent;
    border-radius: 4px;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.tab.active {
    background: var(--primary-teal);
    color: white;
    box-shadow: var(--shadow-sm);
}

.positions-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-add-top {
    padding: 10px 18px;
    background: var(--primary-teal);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-add-top:hover {
    background: #0F766E;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn {
    padding: 12px 24px;
    background: var(--primary-teal);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
    min-width: 140px;
    display: inline-block;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: #0F766E;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

/* Hero Actions */
.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.setup-card {
    max-width: 600px;
    margin: 40px auto;
    background: var(--bg-white);
    border-radius: 4px;
    padding: 24px;
    text-align: left;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.4s ease;
}

@media (max-width: 900px) {
    .portfolio-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .portfolio-header-right {
        width: 100%;
        justify-content: flex-start;
    }
}

/* View Management */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-teal);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Login form styles */
#loginView #loginUsername {
    background: #e8f0fe;
    border: 2px solid var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
    padding: 12px 16px;
    height: 43px;
}

#loginView #loginUsername:focus {
    background: #e8f0fe;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#loginView #loginPassword {
    background: #f5f5f7;
    border: 1px solid var(--border-color);
    height: 43px;
}

#loginView #loginPassword:focus {
    background: #f5f5f7;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* Login form buttons layout */
#loginForm {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#loginForm .form-group {
    margin-bottom: 20px;
}

#loginForm > button {
    margin-top: 0 !important;
}

#loginForm .btn-group {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-top: 12px;
    align-items: center;
}

#loginForm .btn-group .btn {
    padding: 12px 24px;
    height: 41px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Setup form styles */
#setupView .form-input {
    background: #f5f5f7;
    border: 1px solid var(--border-color);
    height: 43px;
}

#setupView .form-input:focus {
    background: #f5f5f7;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#setupView small {
    color: #9ca3af;
    font-size: 0.875rem;
    margin-top: 4px;
    display: block;
}

#portfolioSetupForm {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#portfolioSetupForm .form-group {
    margin-bottom: 20px;
}

#portfolioSetupForm .btn-group {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-top: 12px;
    align-items: center;
}

#portfolioSetupForm .btn-group .btn {
    padding: 12px 24px;
    height: 41px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Create portfolio form styles */
#createPortfolioForm {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#createPortfolioForm .form-group {
    margin-bottom: 20px;
}

#createPortfolioForm .form-input {
    background: #f5f5f7;
    border: 1px solid var(--border-color);
    height: 43px;
}

#createPortfolioForm .form-input:focus {
    background: #f5f5f7;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

#createPortfolioForm .btn-group {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-top: 12px;
    align-items: center;
}

#createPortfolioForm .btn-group .btn {
    padding: 12px 24px;
    height: 41px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}


.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Setup Card Titles */
.setup-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.setup-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Secondary Button */
.btn-secondary {
    background: var(--secondary-slate);
    color: white;
    border: 1px solid var(--secondary-slate);
    margin-top: 12px;
    border-radius: 4px;
}

.btn-secondary:hover {
    background: #334155;
    border-color: #334155;
    transform: translateY(-1px);
}

/* Tertiary Button */
.btn-tertiary {
    background: transparent;
    color: var(--primary-teal);
    border: 2px solid var(--primary-teal);
    margin-top: 12px;
    border-radius: 4px;
}

.btn-tertiary:hover {
    background: #F0FDFA;
    transform: translateY(-1px);
}

/* Success Message */
.success-message {
    background: #d1fae5;
    color: #065f46;
    padding: 16px;
    border-radius: 4px;
    border: 1px solid #a7f3d0;
    margin-bottom: 20px;
    display: none;
    font-weight: 600;
    animation: slideUp 0.4s ease;
}

.success-message.show {
    display: flex;
    align-items: center;
    gap: 8px;
}

.success-message::before {
    content: '✓';
    font-size: 1.2rem;
    font-weight: 700;
}

/* Calculation Box */
.calculation-box {
    background: linear-gradient(135deg, var(--primary-teal) 0%, var(--primary-blue) 100%);
    border-radius: 4px;
    padding: 20px;
    margin: 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.calc-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.calc-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

/* Section Title */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

/* Chart Wrapper */
.chart-wrapper {
    background: var(--bg-white);
    border-radius: 4px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* Empty State */
.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 60px 24px;
    text-align: center;
    background: var(--bg-white);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    margin: 0 auto 24px auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #f0fdfa 0%, #cbfbf1 100%);
    color: var(--primary-teal);
    flex-shrink: 0;
}

.empty-state-icon svg {
    width: 48px;
    height: 48px;
    color: var(--primary-teal);
}

.empty-state-title {
    font-size: 20px;
    font-weight: 700;
    color: #101828;
    margin-bottom: 16px;
    line-height: 28px;
}

.empty-state-message {
    font-size: 14px;
    font-weight: 400;
    color: #6b7280;
    line-height: 22px;
    max-width: 448px;
}

/* Positions Section */
.positions-section {
    background: var(--bg-white);
    border-radius: 4px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* Positions Table */
.positions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    table-layout: auto;
}

.positions-table thead {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.positions-table th {
    padding: 12px 12px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.positions-table .sortable-header {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
    white-space: normal;
}

.positions-table .sortable-header:hover {
    color: var(--text-primary);
}

.positions-table .sort-indicator {
    font-size: 0.65rem;
    min-width: 12px;
    display: inline-block;
    color: var(--primary-teal);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.positions-table .sortable-header.active .sort-indicator {
    opacity: 1;
}

.positions-table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
    vertical-align: middle;
}

.positions-table tbody tr {
    transition: all 0.2s ease;
}

.positions-table tbody tr:hover {
    background: var(--bg-primary);
}

.positions-table tbody tr:last-child td {
    border-bottom: none;
}

/* Ticker column */
.positions-table th:nth-child(1),
.positions-table td:nth-child(1) {
    min-width: 100px;
}

/* Numeric columns - right align */
.positions-table th:nth-child(2),
.positions-table th:nth-child(3),
.positions-table th:nth-child(4),
.positions-table th:nth-child(5),
.positions-table th:nth-child(6),
.positions-table th:nth-child(7),
.positions-table td:nth-child(2),
.positions-table td:nth-child(3),
.positions-table td:nth-child(4),
.positions-table td:nth-child(5),
.positions-table td:nth-child(6),
.positions-table td:nth-child(7) {
    text-align: right;
}

/* Actions column */
.positions-table th:last-child,
.positions-table td:last-child {
    width: 140px;
    text-align: right;
    white-space: nowrap;
}

.ticker-cell {
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.company-name-cell {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.gain-positive {
    color: var(--success-green);
    font-weight: 700;
    background-color: rgba(16, 185, 129, 0.08);
    padding: 6px 10px;
    border-radius: 4px;
}

.gain-negative {
    color: var(--danger-red);
    font-weight: 700;
    background-color: rgba(239, 68, 68, 0.08);
    padding: 6px 10px;
    border-radius: 4px;
}

.actions-cell {
    white-space: nowrap;
}

.btn-action {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: 6px;
}

.btn-action:first-child {
    margin-left: 0;
}

.btn-action:hover {
    background: var(--bg-primary);
    transform: translateY(-1px);
}

.btn-edit:hover {
    background: #eef2ff;
    border-color: var(--primary-blue);
}

.btn-delete:hover {
    background: #fff0f0;
    border-color: var(--danger-red);
    color: var(--danger-red);
}

/* Portfolio Actions Cell */
.actions-portfolio-cell {
    text-align: center;
    padding: 12px 8px;
    position: relative;
}

.portfolio-actions-menu {
    position: relative;
    display: inline-block;
}

.btn-portfolio-actions {
    padding: 6px;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-portfolio-actions:hover {
    color: var(--primary-teal);
    background: rgba(13, 148, 136, 0.1);
    transform: scale(1.1);
}

.btn-portfolio-actions:active {
    transform: scale(0.95);
}

.btn-portfolio-actions.active {
    color: var(--primary-teal);
    background: rgba(13, 148, 136, 0.1);
}

/* Portfolio Context Menu */
.portfolio-context-menu {
    position: absolute;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 160px;
    max-height: 80vh;
    overflow-y: auto;
    top: 100%;
    right: 0;
    margin-top: 4px;
    display: none;
    animation: slideUp 0.15s ease;
}

.portfolio-context-menu.visible {
    display: block;
}

/* Position menu above button when near bottom of viewport */
.portfolio-context-menu.menu-above {
    top: auto;
    bottom: 100%;
    margin-bottom: 4px;
    margin-top: 0;
    animation: slideDown 0.15s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.15s ease;
    text-align: left;
}

.menu-item:first-child {
    border-radius: 4px 4px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 4px 4px;
}

.menu-item:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.menu-item.delete-item:hover {
    background: #fff0f0;
    color: var(--danger-red);
}

.menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* News Controls */
.news-controls {
    display: flex;
    gap: 24px;
    align-items: flex-end;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-white);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.filter-select:hover {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* News Container */
.news-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-white);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.news-article {
    background: var(--bg-white);
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.news-article:last-child {
    border-bottom: none;
}

.news-article:hover {
    background: var(--bg-primary);
}

.news-headline {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.4;
    display: block;
}

.news-article:hover .news-headline {
    color: var(--primary-teal);
}

.news-date-summary {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.news-date {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}

.news-summary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.news-footer {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.news-source {
    font-weight: 600;
    color: var(--text-primary);
}

.news-ticker {
    background: rgba(13, 148, 136, 0.1);
    color: var(--primary-teal);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.news-return {
    font-weight: 600;
}

.news-return.positive {
    color: var(--success-green);
}

.news-return.negative {
    color: var(--danger-red);
}

.news-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.news-empty-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.news-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-teal) 0%, var(--primary-blue) 100%);
    border-radius: 4px;
    padding: 40px 24px;
    margin-bottom: 32px;
    color: white;
    position: relative;
    overflow: hidden;
}

.hero-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.hero-section p {
    font-size: 1rem;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.hero-actions {
    position: relative;
    z-index: 1;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    z-index: 0;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.loading-cell {
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(8px);
}

.loading-card {
    background: var(--bg-white);
    border-radius: 4px;
    padding: 48px;
    text-align: center;
    min-width: 320px;
    box-shadow: var(--shadow-xl);
}

.loading-spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-teal);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.loading-progress {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

/* Skeleton Loaders */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e8e8e8 50%,
        #f0f0f0 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
    border-radius: 4px;
}

.skeleton-metric {
    height: 48px;
    margin-bottom: 8px;
}

.skeleton-metric-value {
    height: 32px;
    margin-top: 8px;
}

.skeleton-chart {
    height: 400px;
    border-radius: 4px;
    margin-bottom: 24px;
}

.skeleton-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 4px;
}

.skeleton-row-cell {
    height: 20px;
    flex: 1;
}

.skeleton-row-cell-small {
    height: 20px;
    width: 60px;
}

.skeleton-row-cell-large {
    height: 20px;
    width: 120px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    z-index: 10;
}

.loading-message {
    text-align: center;
    color: #9ca3af;
    font-size: 0.9rem;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(57, 57, 57, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 4px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    animation: scaleIn 0.2s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin: 0 0 12px;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-warning {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-body .form-input {
    border: 2px solid var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
    height: 43px;
    margin-top: 12px;
}

.modal-body .form-input:focus {
    border-color: var(--primary-teal);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    padding: 10px 24px;
    border-radius: 4px;
    border: none;
    background: #6b7280;
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-cancel:hover {
    background: #4b5563;
}

.btn-delete-confirm {
    padding: 10px 24px;
    border-radius: 4px;
    border: none;
    background: var(--danger-red);
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-delete-confirm:hover {
    background: #dc2626;
}

.btn-delete-confirm:active {
    transform: scale(0.98);
}

.btn-warning-confirm {
    padding: 10px 24px;
    border-radius: 4px;
    border: none;
    background: var(--warning-orange);
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-warning-confirm:hover {
    background: #d97706;
}

.btn-warning-confirm:active {
    transform: scale(0.98);
}

.btn-primary-confirm {
    padding: 12px 24px;
    border-radius: 4px;
    border: none;
    background: var(--primary-teal);
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-primary-confirm:hover {
    background: #0F766E;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

/* ========================================
   PHASE 3: Portfolio Landing Page Styles
   ======================================== */

.portfolios-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.portfolio-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.portfolio-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-teal);
    transform: translateY(-2px);
}

.portfolio-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.portfolio-card-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.badge {
    background: var(--primary-teal);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.portfolio-card-meta {
    margin-bottom: 16px;
}

.portfolio-card-meta small {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.portfolio-card .btn {
    margin-top: auto;
    width: 100%;
}

.btn-select {
    background: var(--primary-teal);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-select:hover {
    background: #0F766E;
}

.btn-secondary {
    background: var(--text-tertiary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--text-secondary);
}

.create-new-portfolio {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.create-new-portfolio .btn-secondary {
    min-width: 200px;
}

.positions-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 450px;
    padding: 60px 24px;
    text-align: center;
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    margin: 0 0 24px 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #F0FDFA 0%, #CBFBF1 100%);
    color: var(--primary-teal);
}

.empty-state-icon svg {
    width: 48px;
    height: 48px;
    color: var(--primary-teal);
}

.empty-state-title {
    font-size: 20px;
    font-weight: 700;
    color: #101828;
    margin: 0 0 16px 0;
    letter-spacing: -0.45px;
    text-align: center;
}

.empty-state-message {
    font-size: 14px;
    font-weight: 400;
    color: #4a5565;
    line-height: 1.625;
    margin: 0;
    max-width: 448px;
    letter-spacing: -0.15px;
    text-align: center;
}

.empty-state-container {
    display: none;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 20px;
    font-size: 1rem;
}

.empty-state .btn {
    background: var(--primary-teal);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
}

/* PHASE 4: Portfolio Switcher Dropdown */
.portfolio-switcher-dropdown {
    position: fixed;
    background: white;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    width: 320px;
    z-index: 1000;
    padding: 0;
    overflow: hidden;
    animation: slideUp 0.15s ease;
}

.portfolio-switcher-dropdown.hidden {
    display: none;
}

.switcher-header {
    padding: 20px;
    background: #f9fafb;
}

.username-section {
    display: flex;
    flex-direction: column;
}

.username-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.username-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1f2937;
}

.switcher-divider {
    height: 1px;
    background: #e5e7eb;
    display: none;
}

.portfolios-section {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px 0;
}

.portfolio-list {
    display: flex;
    flex-direction: column;
}

.portfolio-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.portfolio-item:hover {
    background-color: #f3f4f6;
    border-left-color: var(--primary-teal);
}

.portfolio-item.active {
    background-color: #f3f4f6;
    border-left-color: var(--primary-teal);
}

.portfolio-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.portfolio-name:hover {
    color: var(--primary-teal);
}

.portfolio-return {
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 4px;
}

.portfolio-return.positive {
    color: #10b981;
}

.portfolio-return.negative {
    color: #ef4444;
}

.portfolio-return.neutral {
    color: #6b7280;
}

.btn-create-portfolio {
    width: auto;
    padding: 12px 24px;
    background: var(--primary-teal);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.95rem;
    display: block;
    margin: 0 auto;
}

.btn-create-portfolio:hover {
    background-color: #0F766E;
}

.btn-create-portfolio:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
}

.btn-logout {
    width: 100%;
    padding: 12px 20px;
    background: white;
    color: #ef4444;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.95rem;
}

.btn-logout:hover {
    background-color: #fee2e2;
}

/* Portfolio Overview Styles */
.portfolio-overview {
    padding: 24px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.overview-header {
    margin-bottom: 40px;
}

.overview-title {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 24px;
}

.aggregated-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    padding: 20px;
    border-radius: 4px;
    border-left: 4px solid #0D9488;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.metric-value.positive {
    color: #10b981;
}

.metric-value.negative {
    color: #ef4444;
}

/* Portfolio Table Styles */
.portfolios-table-container {
    overflow-x: auto;
    margin-bottom: 24px;
}

.portfolios-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.portfolios-table thead {
    background-color: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.portfolios-table th {
    padding: 16px;
    text-align: right;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.portfolios-table th:first-child {
    text-align: left;
}

.portfolios-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
}

.portfolios-table tbody tr:hover {
    background-color: #f9fafb;
}

.portfolios-table td {
    padding: 16px;
    color: #374151;
    text-align: right;
}

.portfolios-table td:first-child {
    text-align: left;
}

.portfolio-name-col {
    font-weight: 600;
}

.portfolio-link {
    color: #0D9488;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.portfolio-link:hover {
    color: #0F766E;
    text-decoration: underline;
}

.shares-col,
.value-col,
.invested-col,
.gainloss-col,
.created-date-col {
    text-align: right;
    font-family: 'Monaco', 'Menlo', monospace;
    font-weight: 600;
}

/* Portfolio list table - match font family */
.portfolios-table td {
    font-family: 'Monaco', 'Menlo', monospace;
}

.gainloss-col.positive {
    color: #10b981;
}

.gainloss-col.negative {
    color: #ef4444;
}

.return-col {
    text-align: right;
    font-weight: 600;
}

.return-col .positive {
    color: #10b981;
}

.return-col .negative {
    color: #ef4444;
}

.return-col .neutral {
    color: #6b7280;
}

/* Sortable table header styling */
.portfolios-table .sortable-col {
    user-select: none;
    transition: background-color 0.2s, color 0.2s;
}

.portfolios-table .sortable-col:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.portfolios-table .sort-indicator {
    display: inline-block;
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
    min-width: 12px;
}

.actions-col {
    text-align: center;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background-color: #0D9488;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-small:hover {
    background-color: #0F766E;
}

.overview-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* ========================================
   MOBILE-OPTIMIZED PORTFOLIO CARDS
   ======================================== */

/* Metrics Header - Aggregated Portfolio Stats */
.metrics-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 32px;
}

@media (min-width: 640px) {
    .metrics-header {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .metrics-header {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

/* Enhanced metric cards for headers */
.metrics-header .metric-card {
    background: linear-gradient(150deg, rgb(243, 244, 246) 0%, rgb(229, 231, 235) 100%);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-teal);
    padding: 20px 24px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
    .metrics-header .metric-card {
        padding: 24px;
    }
}

.metrics-header .metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metrics-header .metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0;
}

.metrics-header .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

@media (min-width: 640px) {
    .metrics-header .metric-value {
        font-size: 1.75rem;
    }
}

.metrics-header .metric-value.positive {
    color: var(--success-green);
}

.metrics-header .metric-value.negative {
    color: var(--danger-red);
}

/* Portfolio Cards Grid Container - Responsive */
.portfolios-overview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    margin-top: 24px;
}

@media (min-width: 640px) {
    .portfolios-overview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .portfolios-overview-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

/* Individual Portfolio Card */
.portfolio-overview-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-teal);
    border-radius: 4px;
    padding: 20px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 260px;
}

@media (min-width: 640px) {
    .portfolio-overview-card {
        padding: 24px;
    }
}

.portfolio-overview-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-left-color: var(--primary-teal);
}

/* Portfolio Card Header */
.portfolio-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.portfolio-card-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-teal);
    margin: 0;
    word-break: break-word;
    flex: 1;
}

.portfolio-card-header button {
    flex-shrink: 0;
}

/* Portfolio Metrics Grid - 2 columns on mobile, 3 on desktop */
.portfolio-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
    flex-grow: 1;
}

@media (min-width: 640px) {
    .portfolio-metrics-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* Individual Metric in Card */
.portfolio-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.portfolio-metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.portfolio-metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

@media (min-width: 640px) {
    .portfolio-metric-value {
        font-size: 1.125rem;
    }
}

.portfolio-metric-value.positive {
    color: var(--success-green);
}

.portfolio-metric-value.negative {
    color: var(--danger-red);
}

/* Empty state for no portfolios */
.portfolios-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.portfolios-empty-state-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.portfolios-empty-state-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.portfolios-empty-state-text {
    font-size: 0.9375rem;
    margin-bottom: 24px;
}

/* Refresh Icon Animation */
@keyframes spin-refresh {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

svg.refreshing {
    animation: spin-refresh 1s linear infinite;
}

.refresh-icon.refreshing {
    animation: spin-refresh 1s linear infinite;
}

/* ===== ADD POSITION PANEL STYLES (FROM FIGMA EXACT) ===== */

/* Panel backdrop - transparent, just catches outside clicks */
.panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: transparent;
}

.panel-backdrop.open {
    display: block;
}

/* Right-sliding panel */
.add-position-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 500px;
    max-width: 100vw;
    background: white;
    border-radius: 4px;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.add-position-panel.open {
    transform: translateX(0);
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    height: 73px;
    flex-shrink: 0;
}

.panel-title {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    font-family: Inter, sans-serif;
    line-height: 32px;
}

.panel-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

/* Panel Form Container */
.panel-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

/* Panel Body - Form fields */
.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    border-bottom: 1px solid #ced4da;
}

/* Form row - each field */
.form-row {
    display: flex;
    align-items: center;
    padding: 8px 24px;
    gap: 0;
}

.form-row > * {
    flex: 1 0 0;
}

.form-row .form-label {
    padding-right: 24px;
}

.form-label {
    font-size: 15px;
    font-weight: 400;
    color: #1f2937;
    font-family: Inter, sans-serif;
    line-height: 22.5px;
    white-space: nowrap;
}

.form-input {
    padding: 12px 16px;
    background: #f5f5f7;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 15px;
    color: #1f2937;
    font-family: Arial, sans-serif;
    height: 43px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    line-height: normal;
}

.form-input:focus {
    outline: none;
    border-color: #0d9488;
    background: white;
}

.panel-body .form-input::placeholder {
    color: #757575;
    text-transform: uppercase;
}

.form-value {
    font-size: 15px;
    color: #1f2937;
    font-family: Inter, sans-serif;
    text-align: right;
    padding-right: 16px;
}

/* Direction toggle buttons */
.direction-toggle {
    display: flex;
    gap: 0;
    flex: 1;
}

.direction-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    font-family: Inter, sans-serif;
    margin-right: -1px;
    transition: background 0.15s ease;
    line-height: normal;
}

.direction-btn-sell {
    background: #e5e7eb;
    color: #1f2937;
    border-radius: 4px 0 0 4px;
}

.direction-btn-sell.active {
    background: #EF4444;
    color: white;
}

.direction-btn-buy {
    background: #e5e7eb;
    color: #1f2937;
    border-radius: 0 4px 4px 0;
}

.direction-btn-buy.active {
    background: #2196F3;
    color: white;
}

/* Footer - Total consideration */
.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: #f8f9fa;
    height: 91px;
    flex-shrink: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

.footer-label {
    font-size: 14px;
    font-weight: 600;
    color: #212529;
    font-family: Inter, sans-serif;
    line-height: 22.4px;
}

.footer-value {
    font-size: 20px;
    font-weight: 700;
    color: #000;
    font-family: Inter, sans-serif;
    line-height: 51.2px;
}

/* Button section */
.panel-button-section {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 17px 24px;
    height: 74px;
    flex-shrink: 0;
    border-top: 1px solid #e5e7eb;
}

.btn-panel {
    width: 452px;
    height: 41px;
    padding: 12px 24px;
    background: #0d9488;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    font-family: Arial, sans-serif;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease;
    text-align: center;
    line-height: normal;
}

.btn-panel:hover {
    background: #0a7c6f;
}

.btn-panel:active {
    background: #086652;
}

.btn-panel:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Responsive: narrow screens */
@media (max-width: 600px) {
    .add-position-panel {
        width: 100vw;
    }

    .btn-panel {
        width: 100%;
    }
}

