/* Crypto Portfolio - Theme Variables */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #21262d;
    --bg-input: #161b22;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-primary: #f7931a;
    --accent-secondary: #627eea;
    --accent-hover: #e8851a;
    --success: #3fb950;
    --error: #f85149;
    --warning: #d29922;
    --danger: #f85149;
    --hover: rgba(255,255,255,0.05);
    
    /* Aliases for consistency */
    --border: var(--border-color);
    --surface: var(--bg-card);
    --primary: var(--accent-primary);
    --accent: var(--accent-primary);
    --text: var(--text-primary);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #f6f8fa;
    --border-color: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
    --accent-primary: #d97706;
    --accent-secondary: #4f46e5;
    --accent-hover: #b45309;
    --success: #1a7f37;
    --error: #cf222e;
    --warning: #9a6700;
    --danger: #cf222e;
    --hover: rgba(0,0,0,0.04);
}

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

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

a {
    color: var(--accent-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

header nav {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

header nav a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: color 0.2s;
}

header nav a:hover,
header nav a.active {
    color: var(--accent-primary);
    text-decoration: none;
}

/* Main */
main {
    padding: 30px 0;
    min-height: calc(100vh - 150px);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h2, .card h3 {
    margin-bottom: 15px;
    font-weight: 600;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    text-align: center;
    padding: 25px;
}

.summary-card.total {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-tertiary));
    border-color: var(--accent-primary);
}

[data-theme="light"] .summary-card.total {
    background: linear-gradient(135deg, #fff8f0, #fff0e0);
    border-color: var(--accent-primary);
}

.card-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-value.positive { color: var(--success); }
.card-value.negative { color: var(--error); }

.card-sub {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.data-table td.right,
.data-table th.right {
    text-align: right;
}

.data-table tr:hover {
    background: rgba(255,255,255,0.02);
}

.data-table .positive { color: var(--success); }
.data-table .negative { color: var(--error); }

.data-table code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg-card);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #000;
}

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

.btn-danger {
    border-color: var(--error);
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: #fff;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.85rem;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Actions column */
.actions {
    display: flex;
    gap: 5px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(63, 185, 80, 0.2);
    color: var(--success);
}

.badge-error {
    background: rgba(248, 81, 73, 0.2);
    color: var(--error);
}

.badge-muted {
    background: rgba(110, 118, 129, 0.2);
    color: var(--text-muted);
}

.admin-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--accent-primary);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    margin: 10% auto;
}

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

.modal-header h2 {
    margin: 0;
}

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

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

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

.modal-content form {
    padding: 20px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.page-header h2 {
    margin: 0;
}

/* Settings */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-row:last-child {
    border-bottom: none;
}

/* Messages */
.db-error {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    color: var(--error);
}

.error-message {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: var(--error);
}

.success-message {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: var(--success);
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 300;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-color: var(--success);
    background: rgba(63, 185, 80, 0.15);
}

.toast.error {
    border-color: var(--error);
    background: rgba(248, 81, 73, 0.15);
}

/* ==================== */
/* Login Page Styles    */
/* ==================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    max-width: 400px;
    margin: 5rem auto;
}

.login-box,
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box .btn-primary,
.btn-login {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: var(--accent-primary);
    border: none;
    border-radius: 8px;
    color: #000;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-login:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== */
/* Admin Page Styles    */
/* ==================== */
.user-row, .account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.user-row:hover, .account-row:hover {
    background: var(--hover);
}

.user-info, .account-info {
    flex: 1;
}

.user-actions, .account-actions {
    display: flex;
    gap: 0.5rem;
}

/* ==================== */
/* History Page Styles  */
/* ==================== */
.history-grid {
    display: grid;
    gap: 1rem;
}

.snapshot-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

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

.snapshot-date {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.snapshot-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.asset-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
}

.asset-name {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.asset-amount {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.asset-value {
    font-size: 0.95rem;
    color: var(--success);
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* ==================== */
/* Reports Page Styles  */
/* ==================== */
.report-buttons {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
}

.report-buttons button {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 4px;
    transition: all 0.2s;
}

.report-buttons button:hover {
    background: var(--hover);
    border-color: var(--accent-primary);
}

.report-preview {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.text-report {
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.5;
}

.formatted-report {
    font-size: 0.95rem;
}

.formatted-report h2 {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    color: var(--accent-primary);
}

.formatted-report table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.formatted-report th,
.formatted-report td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.formatted-report th {
    background: var(--hover);
    font-weight: 600;
}

.formatted-report .total-row {
    font-weight: 600;
    background: var(--hover);
}

.copy-notice {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--success);
    color: white;
    border-radius: 4px;
    display: none;
}

.copy-notice.show {
    display: block;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    header nav {
        width: 100%;
        justify-content: flex-start;
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .card-value {
        font-size: 1.5rem;
    }
    
    .data-table {
        display: block;
        overflow-x: auto;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .report-buttons {
        flex-direction: column;
    }
    
    .breakdown-grid {
        grid-template-columns: 1fr;
    }
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.theme-toggle:hover {
    opacity: 1;
}
