:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --bg: #ffffff;
    --surface: #f9fafb;
    --surface-alt: #f3f4f6;
    --border: #e5e7eb;
    --border-dark: #d1d5db;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --radius: 0.375rem;
    --radius-lg: 0.5rem;
    --transition: all 0.2s ease-in-out;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #1e3a8a;
    --success: #10b981;
    --success-light: #064e3b;
    --danger: #ef4444;
    --danger-light: #7f1d1d;
    --warning: #f59e0b;
    --warning-light: #78350f;
    --bg: #1f2937;
    --surface: #111827;
    --surface-alt: #374151;
    --border: #374151;
    --border-dark: #4b5563;
    --text: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.4);
}

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

html {
    scroll-behavior: smooth;
}

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

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
    z-index: 1000;
    transition: var(--transition);
}

.skip-link:focus {
    top: 0;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.icon {
    flex-shrink: 0;
}

.theme-toggle {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.theme-toggle:hover,
.theme-toggle:focus {
    background: var(--border);
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Navigation */
.nav {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 73px;
    z-index: 90;
}

.nav-list {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    transition: var(--transition);
    border-radius: var(--radius);
    font-family: inherit;
}

.nav-btn:hover,
.nav-btn:focus {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.nav-btn.active {
    background: var(--primary-dark);
    font-weight: 600;
}

/* Main Content */
.main {
    flex: 1;
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Notification */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    background: var(--success);
    color: white;
    box-shadow: 0 4px 6px var(--shadow);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.notification.error {
    background: var(--danger);
}

.notification.warning {
    background: var(--warning);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.footer a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
}

.btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    transition: var(--transition);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Stats */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
}

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

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.stat-change {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    min-width: 600px;
}

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

.table th {
    background: var(--surface-alt);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table th:hover {
    background: var(--border);
}

.table th:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

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

.table tbody tr:hover {
    background: var(--surface-alt);
}

.sort-indicator {
    margin-left: 0.5rem;
    opacity: 0.6;
}

/* Highlight */
.highlight {
    background: yellow;
    color: black;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
    font-weight: 600;
}

[data-theme="dark"] .highlight {
    background: #fbbf24;
    color: #1f2937;
}

/* Charts */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 200px;
    padding: 1rem 0;
    margin: 1rem 0;
}

.chart-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
}

.chart-bar-fill {
    width: 100%;
    background: var(--primary);
    border-radius: var(--radius) var(--radius) 0 0;
    transition: height 0.3s ease;
    min-height: 2px;
    position: relative;
}

.chart-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.chart-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

/* Search */
.search-bar {
    margin-bottom: 1.5rem;
}

.search-input-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-input {
    padding-left: 2.5rem;
}

.search-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.search-hint code {
    background: var(--surface-alt);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8em;
    color: var(--primary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Mobile Cards */
.mobile-cards {
    display: none;
}

.transaction-card {
    padding: 1rem;
    margin-bottom: 1rem;
}

.transaction-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.transaction-description {
    font-weight: 600;
    flex: 1;
}

.transaction-amount {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.transaction-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
    max-width: 800px;
    margin: 0 auto;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lead {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Features */
.features {
    margin: 4rem 0;
}

.features h3 {
    font-size: 1.875rem;
    margin-bottom: 2rem;
    text-align: center;
}

.feature-card {
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--shadow);
}

.feature-card h4 {
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 1.125rem;
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* About Section */
.about {
    margin: 4rem 0;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary);
}

.about h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.contact {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.contact a {
    color: var(--primary);
    text-decoration: none;
    margin: 0 0.5rem;
    font-weight: 500;
}

.contact a:hover {
    text-decoration: underline;
}

/* Settings Actions */
.settings-actions {
    display: grid;
    gap: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .nav {
        top: 121px;
    }

    .nav-list {
        justify-content: center;
    }

    .nav-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .main {
        padding: 1.5rem 0;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .lead {
        font-size: 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }

    .mobile-cards {
        display: block;
    }

    .chart {
        height: 150px;
        gap: 0.25rem;
    }

    .chart-label {
        font-size: 0.7rem;
    }

    .table-wrapper {
        border: none;
        background: transparent;
    }

    .settings-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 2rem 0;
    }

    .hero h2 {
        font-size: 1.75rem;
    }

    .features h3 {
        font-size: 1.5rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .action-buttons {
        justify-content: stretch;
    }

    .action-buttons .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Print Styles */
@media print {
    .nav,
    .theme-toggle,
    .notification,
    .action-buttons {
        display: none !important;
    }

    .header,
    .footer {
        background: white !important;
        color: black !important;
        border-color: #ccc !important;
    }

    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .table {
        border: 1px solid #ccc !important;
    }

    .table th {
        background: #f0f0f0 !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --shadow: rgba(0, 0, 0, 0.5);
    }

    .btn {
        border: 2px solid;
    }

    .form-input,
    .form-select {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .notification {
        animation: none;
    }

    .page.active {
        animation: none;
    }
}