:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1e2a47;
    --bg-card-hover: #253557;
    --text-primary: #e8e8e8;
    --text-secondary: #8b8fa3;
    --accent: #4facfe;
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --success: #66bb6a;
    --warning: #ffa726;
    --danger: #ef5350;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --glass-bg: rgba(30, 42, 71, 0.7);
    --glass-border: rgba(79, 172, 254, 0.15);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 40px;
}

/* Filters */
.filters {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.filter-group input,
.filter-group select {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--accent);
}

.btn-apply {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    height: 42px;
}

.btn-apply:hover {
    opacity: 0.9;
}

.btn-apply:active {
    transform: scale(0.97);
}

/* Summary */
.summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.summary-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.summary-label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.summary-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Chart */
.chart-section {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.chart-section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.chart-container canvas {
    max-width: 250px;
    max-height: 250px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 20px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-amount {
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 4px;
}

/* Transactions */
.transactions-section {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.transactions-section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 0;
    font-size: 14px;
}

.tx-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    border: 1px solid transparent;
}

.tx-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--glass-border);
}

.tx-card:active {
    transform: scale(0.99);
}

.tx-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.tx-desc {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.tx-amount {
    font-weight: 700;
    font-size: 15px;
    color: var(--accent);
    white-space: nowrap;
    margin-left: 12px;
}

.tx-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    align-items: center;
}

.tx-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-category {
    background: rgba(79, 172, 254, 0.15);
    color: var(--accent);
}

.badge-important {
    background: rgba(255, 167, 38, 0.15);
    color: var(--warning);
}

.badge-not-important {
    background: rgba(139, 143, 163, 0.15);
    color: var(--text-secondary);
}

.badge-user {
    background: rgba(102, 187, 106, 0.15);
    color: var(--success);
}

/* Items expandable */
.tx-items {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
    display: none;
}

.tx-items.open {
    display: block;
}

.tx-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.tx-item-name {
    color: var(--text-primary);
}

.tx-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tx-item-amount {
    color: var(--text-secondary);
    font-weight: 500;
}

.tx-item-importance {
    font-size: 14px;
}

.tx-expand-hint {
    font-size: 11px;
    color: var(--accent);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tx-expand-hint::before {
    content: "▸";
    transition: transform 0.2s;
}

.tx-card.expanded .tx-expand-hint::before {
    content: "▾";
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px 0;
    color: var(--text-secondary);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 380px) {
    .summary {
        grid-template-columns: 1fr;
    }
    .summary-value {
        font-size: 18px;
    }
    .filter-row {
        flex-direction: column;
    }
}
