:root {
    /* ─── Light Theme (Default) ─── */
    --bg-app: #f7f7fc;
    --bg-page: #ffffff;
    --bg-surface: #f5f6fa;
    --bg-raised: #eef0f7;
    --bg-glass: rgba(247, 247, 252, 0.85);
    
    --text-primary: #1a1a2e;
    --text-secondary: #3c3c56;
    --text-muted: #5a5a78;
    --text-disabled: #9898b0;
    --text-inverse: #ffffff;

    --border: #dde1ec;
    --border-subtle: rgba(148, 163, 184, 0.15);
    --border-medium: rgba(148, 163, 184, 0.3);
    
    --primary: #5b4ef5;
    --primary-hover: #4a3dd4;
    --primary-active: #3a2db8;
    --primary-subtle: #ebe8fd;
    --primary-glow: rgba(91, 78, 245, 0.2);
    
    --success: #2d9e5f;
    --success-bg: #e8f7ef;
    --warning: #d48a0a;
    --warning-bg: #fdf3dc;
    --error: #c94040;
    --error-bg: #fde8e8;
    --info: #2980d4;
    --info-bg: #e3f0fc;

    --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-glow: 0 0 15px rgba(91, 78, 245, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'IBM Plex Sans', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --glass-blur: blur(16px);
    
    --transition-snappy: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-theme: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    
    /* Aliases for template compatibility */
    --accent: var(--primary);
    --accent-light: var(--primary-hover);
    --surface: var(--bg-surface);
    --surface2: var(--bg-raised);
    --text: var(--text-primary);
    --text2: var(--text-secondary);
}

[data-theme='dark'] {
    /* ─── Dark Theme Overrides (Premium Indigo) ─── */
    --bg-app: #0d0d14;
    --bg-page: #13131a;
    --bg-surface: #1c1c28;
    --bg-raised: #232334;
    --bg-glass: rgba(13, 13, 20, 0.85);

    --text-primary: #f0f0f5;
    --text-secondary: #c4c4d4;
    --text-muted: #a0a0b5;
    --text-disabled: #606075;
    --text-inverse: #020617;

    --border: #2a2a3a;
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-medium: rgba(255, 255, 255, 0.08);

    --primary: #7c6af7;
    --primary-hover: #9d8ff9;
    --primary-active: #5b4ef5;
    --primary-subtle: #2a2a4a;
    --primary-glow: rgba(124, 106, 247, 0.25);

    --success-bg: #1e3a2a;
    --warning-bg: #3a2510;
    --error-bg: #3a1515;
    --info-bg: #102040;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(124, 106, 247, 0.15);

    /* Aliases for template compatibility */
    --accent: var(--primary);
    --accent-light: var(--primary-hover);
    --surface: var(--bg-surface);
    --surface2: var(--bg-raised);
    --text: var(--text-primary);
    --text2: var(--text-secondary);
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: var(--transition-theme);
}

[hidden] {
    display: none !important;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }



/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon svg {
    width: 36px;
    height: 36px;
}

.logo-text h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-group {
    display: flex;
    background: var(--bg-raised);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.btn-theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-snappy);
    width: 40px;
    height: 40px;
}

.btn-theme-toggle:hover {
    background: var(--bg-surface-hover);
    border-color: var(--primary);
    transform: rotate(15deg) scale(1.1);
}

[data-theme='dark'] .sun-icon { display: none !important; }
[data-theme='dark'] .moon-icon { display: block !important; }
[data-theme='light'] .sun-icon { display: block !important; }
[data-theme='light'] .moon-icon { display: none !important; }

.toggle-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

/* Export Button */
.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-export:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

.btn-export:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Main ──────────────────────────────────────────────────────────────── */
.main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* ── Upload Section ────────────────────────────────────────────────────── */
.upload-section {
    animation: fadeInUp 0.6s ease-out;
}

.upload-container {
    max-width: 780px;
    margin: 0 auto;
    text-align: center;
}

.upload-hero {
    margin-bottom: 2.5rem;
}

.upload-icon-wrapper {
    margin-bottom: 1.5rem;
}

.upload-icon {
    width: 80px;
    height: 80px;
    animation: float 3s ease-in-out infinite;
}

.upload-hero h2 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #f1f5f9, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.upload-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 500px;
    margin: 0 auto;
}

/* Upload Cards */
.upload-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.upload-card {
    background: var(--bg-surface);
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.upload-card-trigger {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-content-wrapper {
    pointer-events: none;
    width: 100%;
}

.upload-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.upload-card:hover {
    border-color: var(--primary);
    background: var(--bg-surface-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.upload-card:hover::before {
    opacity: 1;
}

.upload-card.has-file {
    border-style: solid;
    border-color: var(--success-border);
    background: var(--success-bg);
}

.upload-card-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-card-icon svg {
    width: 28px;
    height: 28px;
}

.txn-icon {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.trade-icon {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.upload-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.upload-format {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.btn-browse-visual {
    display: inline-block;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid var(--border-medium);
    color: var(--primary-light);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.upload-card:hover .btn-browse-visual {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
}

.file-name {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-name.active {
    color: var(--success);
}

/* Analyze Button */
.btn-analyze {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
    border: none;
    color: white;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 18px 48px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
    min-width: 260px;
    margin-top: 2rem;
}

.btn-analyze:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.5);
}

.btn-analyze:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

/* Advanced Settings */
.advanced-settings-wrapper {
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.btn-toggle-advanced {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    transition: color var(--transition-fast);
}

.btn-toggle-advanced:hover {
    color: var(--primary-light);
}

.btn-toggle-advanced svg {
    transition: transform var(--transition-normal);
}

.btn-toggle-advanced.active svg {
    transform: rotate(90deg);
}

.advanced-content {
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 0.5rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.mapping-container label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.mapping-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.mapping-info code {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    color: var(--primary);
}

#symbolMapping {
    width: 100%;
    min-height: 80px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 12px;
    border-radius: var(--radius-sm);
    resize: vertical;
    transition: border-color var(--transition-fast);
}

#symbolMapping:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Dashboard Layout ────────────────────────────────────────────────────── */
.dashboard-view {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* ── Summary Cards (Premium Glass) ───────────────────────────────────────── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    animation: slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.summary-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-soft);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    box-shadow: var(--card-shadow);
}

.summary-card:hover {
    transform: translateY(-5px) scale(1.02);
    background: var(--bg-surface-hover);
    border-color: var(--border-medium);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at top left, var(--primary-glow), transparent 70%);
    opacity: 0.5;
    pointer-events: none;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.card-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
}

.card-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    z-index: 1;
    font-family: inherit;
}

.card-stats-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 1;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--error); }

/* ── Typography & Header ─────────────────────────────────────────────────── */
h1, h2, h3 { font-weight: 700; color: var(--text-primary); }
.text-gradient {
    background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Stat Cards (Terminal Aesthetic) ────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.stat-card:hover .stat-icon {
    transform: rotate(10deg) scale(1.1);
}

.stat-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-primary {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-weight: 800;
}

.stat-primary .currency {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.stat-primary .value {
    font-size: 2.25rem;
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-primary .unit {
    font-size: 1rem;
    color: var(--text-muted);
    margin-left: 0.1rem;
}

.stat-secondary {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.stat-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.stat-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-trend {
    font-size: 0.85rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--error); }

.summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    transition: all var(--transition-normal);
    animation: fadeInUp 0.5s ease-out both;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
}

.summary-card.invested::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.summary-card.current::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.summary-card.realized::before { background: linear-gradient(90deg, #10b981, #34d399); }
.summary-card.unrealized::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.summary-card.overall::before { background: linear-gradient(90deg, #8b5cf6, #c084fc); }

.summary-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card .card-stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.unit-segment {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.table-container th {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.summary-card .card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.summary-card .card-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.summary-card .card-sub {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    margin-top: 0.35rem;
}

.value-positive { color: var(--success); }
.value-negative { color: var(--error); }
.value-neutral { color: var(--text-primary); }

/* ── Dashboard Layout ──────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.8fr;
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 420px;
    transition: var(--transition-normal);
}

.dashboard-card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.card-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breakdown-card .table-wrapper {
    margin: 0;
    max-height: none;
    background: transparent;
    border: none;
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 300px;
}

/* ────────────────────────────────────────────────────────────────────────── */

/* ── Tab Navigation ────────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.badge {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    background: var(--error);
    color: white;
    min-width: 18px;
    text-align: center;
}

/* ── Tab Panels ────────────────────────────────────────────────────────── */
.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-panel.active {
    display: block;
}

.panel-header {
    margin-bottom: 1.25rem;
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.panel-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Filter Row */
.filter-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.filter-input, .filter-select {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-input {
    flex: 1;
    max-width: 250px;
}

/* ── Data Tables ───────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table th {
    background: var(--bg-raised);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    padding: 12px 16px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast);
}

.data-table th.sortable:hover {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.data-table th.sortable::after {
    content: "↕";
    margin-left: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.4;
}

.data-table th.sortable.sort-asc::after {
    content: "↑";
    color: var(--primary);
    opacity: 1;
}

.data-table th.sortable.sort-desc::after {
    content: "↓";
    color: var(--primary);
    opacity: 1;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.05);
    white-space: nowrap;
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Numeric cells */
.cell-number {
    font-family: var(--font-mono);
    font-size: 0.83rem;
    text-align: right;
    font-weight: 500;
}

.cell-symbol {
    font-weight: 600;
    color: var(--primary);
}

.cell-date {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cell-event {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.event-buy { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.event-sell { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.event-bonus { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.event-rights { background: rgba(139, 92, 246, 0.1); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.event-ipo { background: rgba(236, 72, 153, 0.1); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.event-merger { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.event-unknown { background: rgba(100, 116, 139, 0.1); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }

.cell-matched {
    font-size: 0.95rem;
}

/* LTP Input in holdings table */
.ltp-input {
    width: 100px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.83rem;
    padding: 5px 8px;
    border-radius: 6px;
    text-align: right;
    transition: border-color var(--transition-fast);
}

.ltp-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Update LTP Button */
.btn-update-ltp {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 1rem;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid var(--border-medium);
    color: var(--primary-light);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-update-ltp:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* ── Warning Section ───────────────────────────────────────────────────── */
.warning-section {
    margin-bottom: 2rem;
}

.warning-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.warning-table td {
    color: var(--text-secondary);
}

.alias-resolver {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.alias-resolver h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.alias-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.alias-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.alias-input {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    width: 120px;
}

.btn-add-alias {
    background: var(--primary);
    color: white;
    border: none;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.btn-add-alias:hover {
    opacity: 0.9;
}

.alias-help {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.recon-summary {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.recon-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-mono);
}

.recon-badge.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.recon-badge.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error-border);
}

/* ── Charts ────────────────────────────────────────────────────────────── */
.charts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    min-height: 300px;
}

.chart-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    min-width: 320px;
    max-width: 500px;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(16px);
}

.toast.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error);
}

.toast.success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success);
}

.toast.warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning);
}

/* ── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Animations ────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Total Rows */
.table-total-row {
    background: rgba(99, 102, 241, 0.1) !important;
    border-top: 2px solid var(--border-accent);
}

.table-total-row td {
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    padding: 14px 16px !important;
}

.cell-total-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-light) !important;
}

tfoot {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--bg-surface);
}

/* ── Ledger Controls ─────────────────────────────────────────────────── */
.ledger-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.ledger-select {
    flex: 1;
    max-width: 360px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 10.5L2.5 5h11L8 10.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.ledger-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.ledger-select option {
    background: var(--bg-raised);
    color: var(--text-primary);
}

/* ── Filter Bar ──────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.filter-input {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Table Container ─────────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    border-radius: var(--radius-md);
}

.table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: transparent;
}

.table-container::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* ── Panel Empty State ───────────────────────────────────────────────── */
.panel-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-style: italic;
    background: rgba(99, 102, 241, 0.03);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-subtle);
}

/* ── Symbol Link Buttons ─────────────────────────────────────────────── */
.symbol-link {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0;
    text-decoration: none;
    transition: color var(--transition-fast), text-shadow var(--transition-fast);
}

.symbol-link:hover {
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary-glow);
}

/* ── Recon Badges ────────────────────────────────────────────────────── */
.recon-summary {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.recon-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.recon-badge.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.recon-badge.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error-border);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Stagger animation for summary cards */
.summary-card:nth-child(1) { animation-delay: 0.05s; }
.summary-card:nth-child(2) { animation-delay: 0.1s; }
.summary-card:nth-child(3) { animation-delay: 0.15s; }
.summary-card:nth-child(4) { animation-delay: 0.2s; }
.summary-card:nth-child(5) { animation-delay: 0.25s; }

/* ── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* ── Event Badges ──────────────────────────────────────────────────────── */
.event-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-ipo { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-ca-bonus { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-ca-rights { background: #6366f120; color: #818cf8; border: 1px solid #818cf840; }
.badge-buy, .badge-on-cr, .badge-ca-merger-(cr) { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-sell, .badge-on-dr, .badge-ca-merger-(dr) { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.badge-ca-rearrangement { background: #64748b20; color: #94a3b8; border: 1px solid #64748b40; }

.symbol-link {
    background: none;
    border: none;
    color: var(--primary-light);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    transition: var(--transition-fast);
}

.symbol-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}



/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .header-inner { padding: 0 1rem; }
    .main { padding: 1rem; }

    .upload-cards {
        grid-template-columns: 1fr;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .tab-nav {
        overflow-x: auto;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-input {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .btn-export span:not(svg) {
        display: none;
    }
}

/* ── SaaS Dashboard Layout ────────────────────────────────────────────── */
.dashboard-layout {
    display: flex;
    min-height: calc(100vh - 80px); /* Adjust for header */
}

/* Sidebar */
.dashboard-sidebar {
    width: 260px;
    background: var(--bg-raised);
    border-right: 1px solid var(--border-subtle);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
}

.sidebar-top {
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
}

.active-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.profile-name-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

.profile-sync-status {
    font-size: 0.7rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.profile-sync-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1.5rem 0.75rem 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.nav-link:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-glow);
    color: var(--primary-light);
    font-weight: 600;
}

.nav-link.active svg {
    color: var(--primary-light);
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}

.secondary-link {
    color: var(--text-muted);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    transition: all var(--transition-fast);
}

.btn-logout-sidebar:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* Dashboard Main */
.dashboard-main {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: var(--bg-app);
}

.tab-panels {
    width: 100%;
    height: 100%;
    position: relative;
}

.tab-panel {
    display: none;
    width: 100%;
    animation: fadeIn var(--transition-normal);
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard-content-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header-saas {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.stats-bar-saas {
    display: flex;
    gap: 2rem;
}

.stats-bar-saas .stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stats-bar-saas .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stats-bar-saas .stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Settings Drawer */
.settings-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    animation: fadeIn 0.3s ease;
}

.settings-drawer {
    width: 480px;
    background: var(--bg-raised);
    height: 100%;
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.4s var(--transition-smooth);
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.drawer-title-group h3 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.drawer-title-group p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
}

.advanced-content-saas {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.mapping-grid-saas {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mapping-grid-saas textarea {
    width: 100%;
    min-height: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    resize: vertical;
}

.drawer-footer {
    padding: 2rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-glass);
}

/* Premium Buttons */
.btn-primary-saas {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary-saas:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.full-width {
    grid-column: 1 / -1;
}

.primary-btn-sm {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    border: 1px solid var(--primary-glow);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-sidebar {
        width: 80px;
        padding: 2rem 0.5rem;
    }
    .profile-status, .nav-group-label, .nav-link span, .sidebar-footer span {
        display: none;
    }
    .nav-link {
        justify-content: center;
    }
}

/* ── Profile System ────────────────────────────────────────────────────── */
.launchpad-section {
    padding: 4rem 1.5rem;
    animation: fadeUp 0.8s var(--transition-smooth) forwards;
}

.launchpad-container {
    max-width: 1000px;
    margin: 0 auto;
}

.launchpad-header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.launchpad-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    background: linear-gradient(to bottom, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.launchpad-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.profile-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
}

.profile-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, var(--primary-glow), transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.profile-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    background: var(--bg-surface-hover);
}

.profile-card:hover::before {
    opacity: 1;
}

.profile-info h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-transform: capitalize;
}

.profile-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 1rem;
}

.meta-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.meta-value {
    color: var(--text-primary);
    font-weight: 600;
}

.profile-card-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.launch-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.profile-card:hover .launch-btn {
    transform: scale(1.15) rotate(-45deg);
    background: var(--primary-light);
}

/* Add Card */
.add-card {
    border: 2px dashed var(--border-medium);
    background: rgba(99, 102, 241, 0.05);
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    min-height: 220px;
    transition: all var(--transition-normal);
}

.add-card:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-8px);
}

.add-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.add-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px dashed var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-light);
    transition: all var(--transition-normal);
}

.add-card:hover .add-icon {
    background: var(--primary);
    color: white;
    border-style: solid;
    transform: scale(1.1);
}

/* Header Profiles (Small pills) */
.header-profiles {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border-subtle);
    overflow-x: auto;
    max-width: 500px;
    scrollbar-width: none; /* Hide scrollbar Firefox */
}

.header-profiles::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.profile-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.profile-pill:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.profile-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-light);
    box-shadow: 0 0 15px var(--primary-glow);
}

.profile-pill.add-btn {
    background: transparent;
    border-style: dashed;
    color: var(--primary-light);
    font-weight: 600;
    padding: 6px 12px;
}

.profile-pill.add-btn:hover {
    background: var(--primary-glow);
    border-style: solid;
}

.btn-delete-profile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-left: 4px;
    opacity: 0.4;
    transition: all var(--transition-fast);
    background: rgba(255, 255, 255, 0.15);
    font-size: 10px;
    font-weight: 800;
}

.btn-delete-profile:hover {
    opacity: 1;
    background: var(--error);
    color: white;
}

/* ── Modal System ──────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

.modal-overlay[hidden],
.vault-wrapper[hidden],
.settings-drawer-overlay[hidden] {
    display: none !important;
}

.modal {
    background: var(--bg-raised);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg), 0 0 50px rgba(99, 102, 241, 0.15);
    transform: translateY(0);
    animation: modalAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalAppear {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

/* ── Responsive Overrides ────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .two-col, .three-col {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    html { font-size: 14px; }
    
    .header-inner { padding: 0 1rem; }
    .main { padding: 1rem; }
    
    .logo-text { font-size: 1.1rem; }
    .logo-sub { display: none; }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .upload-cards {
        grid-template-columns: 1fr !important;
    }
    
    .summary-cards {
        grid-template-columns: 1fr !important;
    }

    .btn-analyze {
        width: 100%;
        padding: 14px 24px;
        font-size: 1rem;
    }

    /* Tabs scrollable on mobile */
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        gap: 2px;
        scrollbar-width: none; /* Hide scrollbar for Firefox */
    }
    .tabs::-webkit-scrollbar { display: none; } /* Hide scrollbar for Chrome/Safari */
    
    .tab {
        padding: 10px 16px;
        flex-shrink: 0;
    }


    /* Adjust cards and paddings */
    .stat-card, .chart-card, .summary-card {
        padding: 1.25rem !important;
    }
    
    .stat-primary .value {
        font-size: 1.75rem;
    }

    /* Table containers always scrollable */
    .overflow-x-auto {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
        width: calc(100% + 1rem);
    }

    .responsive-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .responsive-header > div {
        width: 100% !important;
    }
    .responsive-header input {
        width: 100% !important;
    }
}

@media (min-width: 640px) {
    .responsive-header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    .responsive-header > div {
        width: auto !important;
    }
}

@media (max-width: 480px) {
    .header-actions .hidden.md\:flex {
        display: none !important;
    }
    
    .header-actions {
        gap: 0.75rem;
    }
}

/* ── BETA Ribbon ────────────────────────────────────────────────────────── */
.beta-ribbon-wrapper {
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    overflow: hidden;
    pointer-events: none;
    z-index: 10;
}
.beta-ribbon {
    position: absolute;
    top: 15px;
    right: -25px;
    width: 120px;
    padding: 4px 0;
    background: linear-gradient(135deg, var(--accent), #00a884);
    color: #fff;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transform: rotate(45deg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}
