:root {
    --bg-color: #0f172a; /* Slate 900 */
    --glass-bg: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --glass-border: rgba(255, 255, 255, 0.08); /* Subtle white border */
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --accent-primary: #06b6d4; /* Cyan 500 */
    --accent-secondary: #22d3ee; /* Cyan 400 */
    --success: #10b981; /* Emerald 500 */
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #ef4444; /* Red 500 */
    --danger-bg: rgba(239, 68, 68, 0.15);
    --hover-bg: rgba(248, 250, 252, 0.05); /* Hover state */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(6, 182, 212, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-content p {
    color: var(--text-secondary);
    font-size: 1rem;
    letter-spacing: 0.5px;
}

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

button, .nav-tab, .tf-btn, .benchmark-item, .cal-nav-btn, .cal-today-btn, .chart-btn-icon, .ratio-input {
    touch-action: manipulation;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    /* Dynamic background with gradients */
    background-image: 
        radial-gradient(circle at 15% 30%, rgba(6, 182, 212, 0.15), transparent 35%),
        radial-gradient(circle at 85% 70%, rgba(16, 185, 129, 0.12), transparent 35%),
        radial-gradient(circle at 50% 100%, rgba(15, 23, 42, 1), transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.dashboard-wrapper {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.2), 0 0 3px rgba(255,255,255,0.02) inset;
}

/* Header */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.logo i {
    font-size: 1.75rem;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.6));
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 2rem;
    transition: var(--transition-smooth);
}

.user-profile:hover {
    background: var(--hover-bg);
}

.avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-badge {
    font-size: 0.75rem;
    color: var(--accent-secondary);
}

/* Grid Layout */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.metrics-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 1200px) {
    .metrics-container {
        grid-template-columns: 1fr 1fr;
    }
}

/* Metric Cards */
.metric-card {
    padding: 1.75rem;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), transparent);
    opacity: 0;
    transition: var(--transition-smooth);
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.15);
}

.metric-card:hover::before {
    opacity: 1;
}

.metric-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.metric-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.metric-change {
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

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

.metric-value.margin-safe { color: #22c55e; }
.metric-value.margin-warn { color: #eab308; }
.metric-value.margin-danger { color: #ef4444; }

/* Invested Composition Bar */
.invested-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.invested-bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}

.invested-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--success));
    transition: width 0.6s ease;
}

.invested-bar-label {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-secondary);
    min-width: 90px;
    text-align: right;
}

/* Current DD Badge */
.current-dd-line {
    display: none;
    margin-top: 0.4rem;
}

.current-dd-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(239,68,68,0.15);
    color: #f87171;
}

/* Chart Section */
.chart-section {
    padding: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.chart-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    background: rgba(0,0,0,0.3);
    padding: 0.35rem;
    border-radius: 0.75rem;
    align-items: center;
}

.chart-actions .mode-toggle {
    background: transparent;
    margin-right: 0;
    padding: 0;
}

.chart-actions .divider {
    width: 1px;
    height: 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 0.15rem;
    flex-shrink: 0;
}

.chart-actions .mode-btn,
.chart-actions .chart-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 0.85rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.chart-actions .mode-btn:hover,
.chart-actions .chart-action-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.chart-actions .mode-btn.active {
    background: var(--glass-border);
    color: var(--text-primary);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.chart-controls {
    display: flex;
    gap: 0.25rem;
    background: rgba(0,0,0,0.3);
    padding: 0.35rem;
    border-radius: 0.75rem;
}

.chart-controls button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.chart-controls button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.chart-controls button.active {
    background: var(--glass-border);
    color: var(--text-primary);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.mode-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px;
    border-radius: 0.5rem;
    margin-right: 0.5rem;
}

.mode-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.mode-btn.active {
    background: var(--accent-primary);
    color: white;
}

.chart-action-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.2);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chart-action-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--glass-border);
    margin: 0 1rem;
    align-self: center;
}

.chart-container {
    height: 380px;
    width: 100%;
}

.drawdown-container {
    height: 160px;
    width: 100%;
    margin-top: -10px;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

/* Alignment Utilities */
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Responsive Visibility */
.desktop-only { display: block; }
.mobile-only { display: none; }

.live-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.live-dot--online { background: var(--success); }
.live-dot--offline { background: var(--danger); }
.live-dot--closed { background: #6b7280; }

.chart-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 0.3rem;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.chart-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

/* Transactions */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1rem;
    border-radius: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: var(--transition-smooth);
}

.transaction-item:hover {
    background: var(--hover-bg);
    transform: translateX(4px);
}

.tx-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.tx-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.tx-icon.buy,
.tx-icon.deposit {
    background: var(--success-bg);
    color: var(--success);
}

.tx-icon.sell,
.tx-icon.withdraw {
    background: var(--danger-bg);
    color: var(--danger);
}

.tx-icon.loan {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
}

.tx-icon.repay {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
}

.tx-icon.transfer,
.tx-icon.interest,
.tx-icon.default {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

.tx-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tx-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tx-right {
    text-align: right;
}

.tx-amount {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.15rem;
}

.tx-price {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===================== */
/* Live Indicator Badge  */
/* ===================== */
#live-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1.5rem;
    padding: 0.4rem 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 2rem;
}

#live-badge .live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-live 1.5s ease-in-out infinite;
}

.live-text {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 1.5px;
}

.live-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

/* LIVE tag on crypto asset names */
.live-tag {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--success);
    background: var(--success-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    letter-spacing: 1px;
    vertical-align: middle;
    margin-left: 0.4rem;
    animation: pulse-live 2s ease-in-out infinite;
}

/* Flash animation for value updates */
@keyframes value-flash {
    0% { background: rgba(6, 182, 212, 0.2); }
    100% { background: transparent; }
}

.asset-item[data-updated="true"] {
    animation: value-flash 0.6s ease-out;
}

/* Transaction Form Styles */
.transaction-form-section {
    padding: 2rem;
}

.tx-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}


.tx-form select, .tx-form input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.tx-form select:focus, .tx-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

/* Date input specific styles */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}
input[type="date"] {
    position: relative;
    color-scheme: dark;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-top: 0.5rem;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
    filter: brightness(1.1);
}

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

/* Adjustments for Transactions Section inside container */
.interactions-container .transactions-section {
    max-height: none; /* Let it grow or scroll naturally */
    flex: 1;
}

/* Transaction Actions (Edit/Delete) */
.transaction-item {
    position: relative;
    overflow: hidden; /* handle slide or fade if needed, but not strictly required */
}

.tx-actions {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    background: var(--surface-primary); /* mask underlying text */
    padding-left: 1rem;
    border-radius: 20px 0 0 20px;
    box-shadow: -10px 0 15px var(--surface-primary);
}

.transaction-item:hover .tx-actions {
    opacity: 1;
    pointer-events: auto;
}

.tx-action-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 0.5rem;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.tx-action-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.tx-action-btn.edit:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.tx-action-btn.delete:hover {
    color: var(--danger);
    border-color: var(--danger);
}
/* Navigation Tabs */
.main-tabs {
    display: flex;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.35rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
}

.nav-tab {
    background: transparent;
    border: none;
    padding: 0.5rem 1.25rem;
    color: var(--text-secondary);
    border-radius: 0.35rem;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-smooth);
    font-size: 0.9rem;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: rgba(6, 182, 212, 0.25);
    color: var(--accent-secondary);
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.1);
}

/* Tab Views */
.tab-view {
    /* Initially hide the transactions tab, done in HTML inline style */
}

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-view {
    animation: fade-in-up 0.4s ease-out;
}

/* Calendar View Layout */
.transactions-view {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.calendar-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

@media (max-width: 1024px) {
    .calendar-layout {
        flex-direction: column;
    }
}

.calendar-section {
    flex: 2;
    min-width: 0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.interactions-container {
    /* override any previous dashboard flex settings */
    flex: 1;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Calendar Components */
.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.cal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.cal-nav-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.cal-nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: scale(1.05);
}

.cal-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    flex: 1;
}

.cal-day {
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    touch-action: manipulation;
    overflow: hidden;
    min-height: 0;
}

.cal-day:hover {
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.4);
}

.cal-day.selected {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}

.cal-day.empty {
    opacity: 0;
    pointer-events: none;
}

.cal-day-num {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.cal-day.today {
    outline: 2px solid var(--accent-secondary);
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px rgba(192, 132, 252, 0.2), 0 0 12px rgba(192, 132, 252, 0.15);
    position: relative;
}

.cal-day.today.selected {
    outline: 2px solid var(--accent-primary);
    box-shadow: inset 0 0 0 1px rgba(192, 132, 252, 0.3), 0 0 15px rgba(6, 182, 212, 0.2);
}

.cal-day.today .cal-day-num {
    color: var(--accent-secondary);
    font-weight: 700;
}

.cal-day-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.today-badge {
    display: none;
}

@keyframes today-pulse {
    0% { opacity: 0.8; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.02); box-shadow: 0 0 15px rgba(192, 132, 252, 0.6); }
    100% { opacity: 0.8; transform: scale(0.95); }
}

.cal-day-content {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-content: flex-end;
    height: 100%;
}

.cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.cal-dot.buy { background: var(--success); box-shadow: 0 0 5px var(--success);}
.cal-dot.deposit { background: var(--success); box-shadow: 0 0 5px var(--success); }
.cal-dot.sell { background: var(--danger); box-shadow: 0 0 5px var(--danger); }
.cal-dot.withdraw { background: var(--danger); box-shadow: 0 0 5px var(--danger); }

/* Full Calendar Adjustments */
.full-width {
    max-width: 100%;
}
.cal-nav-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.cal-today-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.3rem 1rem;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.cal-today-btn:hover { background: rgba(255,255,255,0.1); }
.cal-days-header .sun { color: #f87171; }
.cal-days-header .sat { color: #60a5fa; }
.cal-days-header {
    background: rgba(0,0,0,0.3);
    padding: 0.5rem 0;
    margin-bottom: 0;
    border: 1px solid var(--glass-border);
    border-bottom: none;
}

.full-cal-grid {
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    gap: 0;
    border-left: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border);
}
.full-cal-grid .cal-day {
    aspect-ratio: auto;
    background: #1a1a1a;
    border: none;
    border-right: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    padding: 0.25rem;
}
.full-cal-grid .cal-day:hover { background: #222; }
.full-cal-grid .cal-day.empty { background: #111; opacity: 1; }
.cal-day-num { text-align: right; margin-bottom: 0.25rem; margin-right: 0.25rem; font-size: 0.9rem; color: #aaa; }
.cal-day:nth-child(7n+1) .cal-day-num { color: #f87171; }
.cal-day:nth-child(7n) .cal-day-num { color: #60a5fa; }

/* Transaction Pills */
.tx-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.15rem 0.3rem;
    border-radius: 0.15rem;
    font-size: 0.75rem;
    cursor: pointer;
    margin-bottom: 2px;
    font-weight: 500;
    color: white;
    touch-action: manipulation;
    overflow: hidden;
    white-space: nowrap;
    min-height: 0;
}
.tx-pill.buy { background: #4caf50; }
.tx-pill.buy:hover { background: #45a049; }
.tx-pill.sell { background: #f44336; }
.tx-pill.sell:hover { background: #da3e32; }
.pill-left { opacity: 0.9; overflow: hidden; text-overflow: ellipsis; max-width: 3em; }
.pill-right { display: none; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    touch-action: pan-y;
}
.modal-content {
    background: #1e1e1e;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    padding: 1.5rem 2rem;
    animation: fade-in-up 0.2s ease-out;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 { font-size: 1.25rem; font-weight: 500; }
.btn-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.25rem;
    cursor: pointer;
}
.btn-close:hover { color: #fff; }

/* Type Toggles */
.type-toggles {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.type-toggles input[type="radio"] { display: none; }
.type-toggles label {
    flex: 1;
    text-align: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #333;
    cursor: pointer;
    font-weight: 500;
    color: #888;
    transition: all 0.2s;
}
.type-toggles input[value="buy"]:checked + label {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}
.type-toggles input[value="sell"]:checked + label {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

/* Modal Fields */
.modal-field { margin-bottom: 1rem; }
.modal-field label { display: block; font-size: 0.85rem; color: #888; margin-bottom: 0.4rem; }
.modal-field input, .modal-field select, .modal-field textarea {
    width: 100%;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    padding: 0.6rem;
    border-radius: 0.35rem;
    font-family: inherit;
}
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus {
    border-color: #555;
    outline: none;
}
.input-with-icon { position: relative; }
.input-with-icon i { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); color: #666; pointer-events: none; }
.modal-field-row { display: flex; gap: 1rem; }
.modal-total-display { font-size: 0.9rem; color: #aaa; margin-bottom: 1.5rem; }

.asset-input-wrap { display: flex; gap: 0.5rem; align-items: center; }
.asset-input-wrap input { flex: 1; }
.asset-add-btn {
    background: #339AF0;
    color: white;
    border: none;
    border-radius: 0.35rem;
    padding: 0 0.75rem;
    height: 100%;
    min-height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}
.asset-add-btn:hover { background: #228be6; }
.asset-add-btn.added { background: #40c057; }
.asset-help-text {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: #909296;
}

/* Allocation table manual price input */
.alloc-price-input {
    width: 70px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: var(--text-primary);
    padding: 0.3rem 0.35rem;
    border-radius: 0.35rem;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
}
.alloc-price-input:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer-right { display: flex; gap: 0.5rem; }
.btn-outline-danger {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 0.5rem 1rem;
    border-radius: 0.35rem;
    cursor: pointer;
}
.btn-outline-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-secondary { background: transparent; color: #fff; border: none; cursor: pointer; padding: 0.5rem 1rem; }
.btn-secondary:hover { color: #ccc; }

/* Refinement */
.modal-content {
    background: #25262B; /* Darker grey */
    border-color: #373A40;
    font-family: 'Inter', sans-serif;
}
.type-toggles label {
    background: #2C2E33;
    border-color: transparent;
    color: #909296;
}
.type-toggles input[value="buy"]:checked + label {
    border-color: #339AF0; /* Light blue border */
    color: #339AF0;
    background: rgba(51, 154, 240, 0.1);
}
.type-toggles input[value="sell"]:checked + label {
    border-color: #FA5252; /* Red */
    color: #FA5252;
    background: rgba(250, 82, 82, 0.1);
}
.modal-field input, .modal-field select, .modal-field textarea {
    background: #373A40;
    border: none;
    color: #C1C2C5;
    font-size: 0.9rem;
}
.modal-field label {
    color: #909296;
}
.btn-primary { background: #339AF0; color: white; }
.btn-outline-danger { border-color: #FA5252; color: #FA5252; }

/* Calendar refine to match image */
.cal-days-header {
    background: #2C2E33;
    border-top: 1px solid #373A40;
    border-bottom: 2px solid #373A40;
}
.cal-days-header .sun { background: #3B2A2A; color: #FA5252; }
.cal-days-header .sat { background: #2A333B; color: #339AF0; }

.full-cal-grid .cal-day {
    background: #1A1B1E;
    border-right: 1px solid #373A40;
    border-bottom: 1px solid #373A40;
}
.tx-pill {
    background: #40C057; /* Bright Green */
    border-radius: 2px;
    padding: 2px 4px;
    font-size: 11px;
}
.tx-pill.sell {
    background: #FA5252;
}

/* Fix Calendar Height and Display */
#tab-transactions {
    height: calc(100vh - 80px); /* Fill most of viewport */
    overflow-y: auto;
}
.full-cal-grid {
    min-height: 600px;
}
.cal-day {
    min-height: 0;
}

/* Modal button style to match "Add" blue */
#btnSaveTx {
    background: #007bff !important;
    border-radius: 4px !important;
    padding: 8px 24px !important;
    font-weight: 600;
}
.btn-secondary {
    color: #fff !important;
    padding: 8px 16px !important;
}

/* Import All Button (Binance + Kiwoom) */
.btn-import-upbit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #f0b90b, #f3ca2b);
    color: #1f2937;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(240, 185, 11, 0.3);
    margin-right: 1rem;
}

.btn-import-upbit:hover {
    background: linear-gradient(135deg, #f5c836, #f7d14a);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(240, 185, 11, 0.5);
}

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

.btn-import-upbit.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-import-upbit.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    z-index: 9999;
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.7s forwards;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.toast.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

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

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

/* Chart Modal Styling */
.modal-large {
    max-width: 1000px;
    width: 90%;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.timeframe-selector {
    display: flex;
    background: rgba(0,0,0,0.3);
    padding: 0.2rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
}

.tf-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.35rem;
    transition: all 0.2s;
}

.tf-btn.active {
    background: var(--accent-primary);
    color: #fff;
}

.modal-header-title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.chart-pnl-badge {
    font-size: 0.9rem;
    display: flex;
    gap: 0.5rem;
}

.chart-controls-row {
    margin: 1rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.chart-toggle-group {
    display: flex;
    gap: 1.5rem;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.switch-label input {
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.lightweight-chart-container {
    flex: 1;
    width: 100%;
    min-height: 400px;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.chart-btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.chart-btn-icon:hover {
    color: var(--accent-primary);
    transform: scale(1.1);
}

.alloc-chart-btn {
    font-size: 0.95rem;
    padding: 0.15rem 0.3rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    border-radius: 0.35rem;
    line-height: 1;
}
.alloc-chart-btn:hover {
    color: var(--accent-primary);
    transform: scale(1.15);
}

/* Benchmark Styles */
.benchmark-container {
    position: relative;
    display: flex;
    align-items: center;
}

.benchmark-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.benchmark-btn:hover, .benchmark-btn.active {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.benchmark-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.5rem;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.benchmark-item {
    padding: 0.6rem 0.8rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.benchmark-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.benchmark-item.active {
    background: rgba(6, 182, 212, 0.2);
    color: var(--accent-primary);
}

.benchmark-dynamic-separator {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0.25rem 0;
    padding-top: 0.25rem;
}
.benchmark-dynamic-separator::before {
    content: 'Tracked assets';
    display: block;
    padding: 0.35rem 0.8rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Allocation Section */
.allocation-section {
    margin-top: 1.5rem;
    padding: 2rem;
}

.allocation-section .section-header {
    margin-bottom: 1.5rem;
}

.allocation-layout {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 2rem;
    align-items: center;
}

.donut-wrapper {
    position: relative;
    height: 440px;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.allocation-table {
    width: 100%;
    border-collapse: collapse;
}

.allocation-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
}

.allocation-table td {
    padding: 0.85rem 0.75rem;
    font-size: 0.95rem;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    white-space: nowrap;
}

.allocation-table .alloc-primary {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.allocation-table .alloc-secondary {
    color: var(--text-secondary);
    font-size: 0.78em;
    white-space: nowrap;
}

.allocation-table .alloc-pnl-value {
    font-weight: 600;
}

.allocation-table .alloc-pnl-rate {
    font-size: 0.78em;
}

.allocation-table .alloc-detail-btn,
.allocation-table .alloc-asset-detail-btn {
    display: inline;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.allocation-table .alloc-detail-btn:active,
.allocation-table .alloc-asset-detail-btn:active {
    color: var(--accent-secondary);
}

.allocation-detail-content {
    max-width: 360px;
    padding: 1.25rem;
    background: rgba(30, 41, 59, 0.98);
}

.allocation-detail-content .modal-header {
    margin-bottom: 1rem;
}

.allocation-detail-subtitle {
    margin-top: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.allocation-detail-grid {
    display: grid;
    gap: 0.5rem;
}

.allocation-detail-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    align-items: baseline;
    padding: 0.7rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 0.65rem;
    background: rgba(15, 23, 42, 0.34);
    font-variant-numeric: tabular-nums;
}

.allocation-detail-row.is-highlight {
    border-color: rgba(6, 182, 212, 0.48);
    background: rgba(6, 182, 212, 0.09);
}

.allocation-detail-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.allocation-detail-primary {
    min-width: 0;
    color: var(--text-primary);
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
}

.allocation-detail-secondary {
    grid-column: 2;
    color: var(--text-secondary);
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.72rem;
    white-space: nowrap;
}

.allocation-detail-row.pnl-positive .allocation-detail-primary,
.allocation-detail-row.pnl-positive .allocation-detail-secondary {
    color: #4ade80;
}

.allocation-detail-row.pnl-negative .allocation-detail-primary,
.allocation-detail-row.pnl-negative .allocation-detail-secondary {
    color: #f87171;
}

.allocation-table tr:hover {
    background: rgba(255,255,255,0.03);
}

.allocation-table tr.active-slice {
    background: rgba(6, 182, 212, 0.15);
    color: #00fbff;
}

.analysis-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.5rem; margin-top: 1.5rem; }
.invest-target-section { padding: 1.5rem; height: 100%; }
.allocation-section { padding: 1.5rem; }

.target-section-header {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.target-inline-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.target-control {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
}

.target-control-label {
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.target-number-stepper {
    display: inline-flex;
    align-items: stretch;
    height: 30px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 5px;
}

.target-stepper-buttons {
    display: grid;
    grid-template-rows: 1fr 1fr;
    width: 18px;
    border-left: 1px solid rgba(6, 182, 212, 0.22);
}

.target-stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    min-height: 0;
    padding: 0;
    border: 0;
    background: rgba(6, 182, 212, 0.08);
    color: #94a3b8;
    font-size: 0.58rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.target-stepper-btn:first-child {
    border-bottom: 1px solid rgba(6, 182, 212, 0.16);
}

.target-stepper-btn:active {
    background: rgba(6, 182, 212, 0.24);
    color: #00fbff;
}

.target-fx-value {
    color: #cbd5e1;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.76rem;
}
.budget-input {
    background: transparent;
    border: 0;
    color: #00fbff;
    padding: 0.2rem 0.35rem;
    width: 72px;
    text-align: right;
    font-size: 0.78rem;
    font-weight: 700;
    outline: none;
    font-family: 'Roboto Mono', monospace;
}
.margin-multiplier-input {
    background: transparent;
    border: none;
    color: #00fbff;
    padding: 0.1rem 0.1rem;
    width: 30px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    outline: none;
    font-family: 'Roboto Mono', monospace;
}
.target-input-suffix {
    align-self: center;
    color: #00fbff;
    font-size: 0.72rem;
    font-weight: 700;
}
.ratio-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 42px;
    text-align: right;
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
    font-family: 'Roboto Mono', monospace;
}
.gap-badge { padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.gap-badge.positive { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.gap-badge.negative { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.target-table-container { overflow-x: auto; width: 100%; margin: 0; padding: 0; -webkit-overflow-scrolling: touch; }
.target-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.target-table th { font-size: 0.75rem; color: #64748b; padding: 0.5rem 0.5rem 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.target-table td { padding: 0.65rem 0.5rem; font-size: 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
.target-table th:first-child,
.target-table td:first-child {
    width: 22%;
    min-width: 82px;
    max-width: 112px;
}
.target-asset-name {
    max-width: 100%;
    overflow: hidden;
    color: #e2e8f0;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.target-buy-order,
.target-buy-etf {
    color: #00fbff;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}
.target-buy-etf { color: #f8fafc; }
.target-buy-principal,
.target-buy-kind {
    color: #94a3b8;
    font-size: 0.68rem;
    line-height: 1.3;
    white-space: nowrap;
}
.target-buy-kind { color: #64748b; }
.target-buy-error {
    color: #f87171;
    font-size: 0.72rem;
    font-weight: 600;
}
.target-total-row { border-top: 2px solid rgba(255,255,255,0.1); font-weight: 700; color: #fff; }
.target-total-row td { padding-top: 0.8rem; }
.target-total-badge { padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; font-weight: 700; }
.target-total-badge.error { background: rgba(239,68,68,0.2); color: #f87171; }
.target-total-badge.ok { background: rgba(34,197,94,0.2); color: #4ade80; }
.target-bottom-summary { font-family: 'Roboto Mono', monospace; font-size: 0.75rem; color: #94a3b8; text-align: right; }

.allocation-layout { display: flex; flex-direction: column; gap: 1rem; align-items: stretch; }
.donut-wrapper { height: 350px; width: 100%; max-width: 350px; margin: -15px auto 0; position: relative; display: flex; justify-content: center; align-items: center; }
.allocation-table-container { overflow-x: auto; width: 100%; margin: 0; padding: 0; }
.allocation-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.allocation-table td { font-size: 0.9rem; padding: 0.7rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.allocation-table th { font-size: 0.75rem; padding: 0.5rem 0.5rem 0.8rem; }
.allocation-table .text-right { padding-left: 12px; }
.allocation-table th:first-child,
.allocation-table td:first-child {
    width: 22%;
    min-width: 78px;
    max-width: 112px;
    color: #e2e8f0;
}

.allocation-table td:first-child > div {
    min-width: 0;
}

.allocation-table td:first-child span:last-child {
    min-width: 0;
    max-width: 100%;
    color: #e2e8f0;
}

input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.section-header { min-height: 40px; display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.allocation-layout, .target-table-container { margin-top: 0; padding-top: 0; }
.allocation-table thead th, .target-table thead th { line-height: 1; padding-top: 0; padding-bottom: 1rem; vertical-align: middle; }



/* ======================================================== */
/* Bottom Tab Bar (Mobile Navigation)                       */
/* ======================================================== */

.bottom-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-tab i {
    font-size: 1.25rem;
}

.bottom-tab.active {
    color: var(--accent-primary);
}

.bottom-tab.active i {
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.5));
}

/* ======================================================== */
/* Chart Controls Toggle (Mobile)                           */
/* ======================================================== */

.chart-controls-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
}

.chart-controls-wrapper {
    overflow: visible;
}

/* ======================================================== */
/* Responsive Design (Mobile Optimization)                  */
/* ======================================================== */

@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: block; }
    .bottom-tab-bar { display: none; }

    body {
        padding-bottom: 0;
    }

    .dashboard-wrapper,
    .dashboard-container {
        padding: 0.75rem;
    }

    .top-nav {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .logo {
        flex: 1 1 auto;
        min-width: 0;
    }

    .main-tabs.desktop-tabs {
        flex: 1 1 100%;
        order: 3;
    }

    .main-tabs .nav-tab {
        flex: 1;
        text-align: center;
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .logo i {
        font-size: 1.4rem;
    }

    #live-badge {
        margin-left: 0.75rem;
        padding: 0.25rem 0.6rem;
    }

    .live-text {
        font-size: 0.6rem;
    }

    .live-time {
        font-size: 0.65rem;
    }

    .metrics-container {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-card h3 {
        font-size: 0.7rem;
        margin-bottom: 0.4rem;
    }

    .metric-value {
        font-size: 1.4rem;
        letter-spacing: -0.5px;
    }

    .metric-change {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }

    .metric-subtitle {
        font-size: 0.75rem;
    }

    .chart-section {
        padding: 1rem;
    }

    .section-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 1rem;
    }

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

    .chart-controls-toggle {
        display: flex;
    }

    .chart-controls-wrapper {
        display: none;
        margin-bottom: 1rem;
    }

    .chart-controls-wrapper.open {
        display: block;
    }

    .chart-actions {
        flex-wrap: nowrap;
        gap: 3px;
        padding: 5px;
    }

    .chart-actions .mode-btn,
    .chart-actions .chart-action-btn {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

    .chart-controls {
        flex-wrap: wrap;
        gap: 4px;
        padding: 6px;
    }

    .chart-controls button,
    .chart-actions .mode-btn,
    .chart-actions .chart-action-btn {
        padding: 6px 10px;
        font-size: 0.7rem;
        flex: 1 1 auto;
        min-width: 40px;
    }

    .chart-controls .divider {
        display: none;
    }

    .mode-toggle {
        margin-right: 0;
    }

    .chart-container {
        height: 240px;
    }

    .drawdown-container {
        height: 180px;
        margin-top: 10px;
    }

    .analysis-grid {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    .allocation-section,
    .invest-target-section {
        padding: 1rem;
    }

    .allocation-layout {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .donut-wrapper {
        width: 100%;
        max-width: 320px;
        height: 300px;
    }

    .target-inline-controls {
        gap: 0.6rem;
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
    }

    .budget-input {
        width: 72px;
        font-size: 0.78rem;
    }

    .target-fx-control {
        display: none;
    }

    .allocation-table-container,
    .target-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .allocation-table,
    .target-table {
        min-width: 440px;
        width: 100%;
    }

    .allocation-table {
        table-layout: fixed;
    }

    .allocation-table th,
    .allocation-table td {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .allocation-table td,
    .allocation-table th {
        font-size: 0.78rem;
        padding: 0.5rem 0.35rem;
    }

    .target-table td,
    .target-table th {
        font-size: 0.8rem;
        padding: 0.5rem 0.35rem;
    }

    .alloc-sticky-col {
        position: sticky;
        left: 0;
        background: rgba(30, 41, 59, 0.9);
        background-clip: padding-box;
        z-index: 2;
        box-shadow: 1px 0 0 rgba(148, 163, 184, 0.16);
    }

    .target-sticky-col {
        position: sticky;
        left: 0;
        overflow: hidden;
        background: rgba(30, 41, 59, 0.96);
        background-clip: padding-box;
        box-shadow: 1px 0 0 rgba(148, 163, 184, 0.16);
        z-index: 2;
    }

    .target-table thead .target-sticky-col,
    .target-table tfoot .target-sticky-col {
        z-index: 3;
    }

    .transactions-view {
        padding: 0.75rem;
    }

    .calendar-section {
        padding: 1rem;
    }

    .cal-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

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

    .cal-nav-buttons {
        flex-wrap: wrap;
    }

    .full-cal-grid {
        grid-auto-rows: minmax(80px, auto);
    }

    .cal-day {
        min-height: 70px;
        padding: 2px;
    }

    .cal-day-num {
        font-size: 0.75rem;
    }

    .tx-pill {
        font-size: 0.65rem;
        padding: 1px 3px;
    }

    .pill-left {
        max-width: 2em;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 1rem 1rem 0 0;
        padding: 1.25rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0));
        max-height: 85vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    .modal-field-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-large {
        max-width: 100%;
        width: 100%;
        height: 90vh;
        border-radius: 1rem 1rem 0 0;
    }

    .modal-large .modal-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .modal-large .modal-header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .modal-large .btn-close {
        flex-shrink: 0;
    }

    .chart-controls-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .chart-toggle-group {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .btn-primary {
        width: 100%;
    }

    .benchmark-dropdown {
        right: auto;
        left: 0;
        width: 100%;
    }

}

@media (max-width: 400px) {
    .metric-value {
        font-size: 1.2rem;
    }

    .logo h1 {
        font-size: 1.1rem;
    }



    .cal-day {
        min-height: 60px;
    }

    .tx-pill .pill-right {
        display: none;
    }
}

/* ========================================================
   WebAuthn & Biometric Authentication Styles
   ======================================================== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.25rem;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1.25rem;
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(6, 182, 212, 0.15);
    animation: authCardPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-icon-wrapper {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.2));
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.25);
}

.auth-icon-wrapper.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.25);
}

.auth-fingerprint-icon {
    font-size: 2.2rem;
    color: var(--accent-secondary);
    animation: pulseFingerprint 2.5s infinite ease-in-out;
}

@keyframes pulseFingerprint {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.08); opacity: 1; color: #38bdf8; }
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.btn-biometric-login {
    width: 100%;
    padding: 0.9rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #06b6d4, #2563eb);
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.35);
}

.btn-biometric-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
    background: linear-gradient(135deg, #0891b2, #1d4ed8);
}

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

.auth-password-details {
    margin-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.85rem;
    text-align: center;
}

.auth-password-summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    user-select: none;
}

.auth-password-summary::-webkit-details-marker {
    display: none;
}

.auth-password-summary:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.auth-password-details[open] .auth-password-summary {
    color: var(--accent-secondary);
    margin-bottom: 0.25rem;
}

.auth-password-details[open] .auth-password-form {
    animation: fadeInSlideDown 0.25s ease-out;
}

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

.auth-password-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-password-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.auth-password-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.auth-status-msg {
    margin-top: 1rem;
    font-size: 0.82rem;
    min-height: 1.2rem;
    transition: all 0.2s ease;
}

.auth-status-msg.error {
    color: #f87171;
}

.auth-status-msg.success {
    color: #34d399;
}

.auth-status-msg.loading {
    color: var(--accent-secondary);
}

.header-auth-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.header-auth-btn:hover {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.4);
    color: var(--accent-secondary);
}
