:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #f1f3f4;
    --text-primary: #1a1a2e;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --border: #e8eaed;
    --shadow: rgba(0, 0, 0, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --card-hover: #fafafa;
    --gradient-start: #4f46e5;
    --gradient-end: #7c3aed;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --card-hover: #273549;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-piggy {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
    margin-left: 52px;
}

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

.theme-toggle:hover {
    background: var(--bg-card);
    transform: scale(1.05);
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

/* Add ETF Button */
.btn-add-etf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 12px;
}

.btn-add-etf:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.search-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-container input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-search {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-search:hover {
    background: var(--accent-hover);
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.search-result-info h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
}

.search-result-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-result-actions {
    display: flex;
    gap: 8px;
}

.btn-add-result {
    padding: 8px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-result:hover {
    background: #059669;
}

.btn-link {
    padding: 8px 16px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-link:hover {
    background: var(--bg-card);
}

.search-error {
    color: var(--warning);
    text-align: center;
    padding: 20px;
}

/* Portfolio Summary */
.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px var(--shadow);
}

.summary-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.summary-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.summary-value.highlight {
    color: var(--success);
}

/* Portfolio Privacy Section */
.portfolio-privacy {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 40px;
}

.privacy-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.privacy-text h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.privacy-text p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Action Card for Report Button */
.action-card {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-report {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-report:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.report-icon {
    font-size: 1.5rem;
}

/* Income Report Section */
.income-report {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-sm);
}

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

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

.btn-close-report {
    background: var(--bg-input);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.report-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.report-stat {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.report-stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.report-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.report-chart-container {
    max-width: 400px;
    margin: 0 auto 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

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

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

.report-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.report-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

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

.report-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* ETF Card Links */
.etf-links {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.etf-link {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s ease;
}

.etf-link:hover {
    background: var(--accent);
    color: white;
}

/* Filter Section */
.filter-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 12px;
}

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

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

.filter-tab.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: 0 2px 4px var(--shadow);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    padding: 12px 16px;
    border-radius: 12px;
    width: 200px;
}

.search-box svg {
    color: var(--text-muted);
}

.search-box input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    width: 100%;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.sort-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: 12px;
}

.sort-box svg {
    color: var(--text-muted);
}

.sort-box select {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

/* ETF Grid */
.etf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 50px;
}

.etf-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.etf-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px var(--shadow);
    border-color: var(--accent);
}

.etf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.etf-symbol {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.etf-category {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.etf-category.Harvest {
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent);
}

.etf-category.harvest-hhis {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.etf-category.Purpose {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.etf-currency {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 6px;
}

.etf-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.etf-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.etf-stat {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 10px;
}

.etf-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.etf-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.etf-stat-value.yield {
    color: var(--success);
}

.quantity-input-group {
    margin-top: 16px;
}

.quantity-input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.quantity-input-wrapper {
    display: flex;
    gap: 10px;
}

.quantity-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.quantity-input:focus {
    border-color: var(--accent);
}

.income-result {
    margin-top: 12px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 10px;
    text-align: center;
}

.income-result-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.income-result-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

/* Loading */
.loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Tools Section */
.tools-section {
    margin-bottom: 50px;
}

.tools-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.tool-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--shadow);
}

.tool-icon {
    font-size: 1.5rem;
}

.tool-name {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    padding: 40px 0;
    margin-top: 20px;
}

.disclaimer {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.disclaimer h3 {
    font-size: 1rem;
    color: var(--warning);
    margin-bottom: 10px;
}

.disclaimer p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.footer-links {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .filter-section {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

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

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

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

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