/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #22263a;
    --border: #2e3250;
    --accent: #6c63ff;
    --accent-glow: rgba(108, 99, 255, 0.25);
    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.12);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.12);
    --text: #e2e8f0;
    --text-muted: #8892a4;
    --radius: 14px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 22px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #6c63ff, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.currency-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.currency-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

#currency-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    max-width: 210px;
}

#currency-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#currency-select option {
    background: var(--surface-2);
}

.header-date {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Main Layout ──────────────────────────────────────────── */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Summary Cards ────────────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.card-balance::before {
    background: linear-gradient(90deg, #6c63ff, #a78bfa);
}

.card-income::before {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.card-expense::before {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 10px;
}

.card-balance .card-value {
    color: var(--text);
}

.card-income .card-value {
    color: var(--green);
}

.card-expense .card-value {
    color: var(--red);
}

.card-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-muted);
}

/* ── Charts ───────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.chart-wrapper {
    position: relative;
    height: 220px;
}

/* ── Bottom Grid ──────────────────────────────────────────── */
.bottom-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 16px;
    align-items: start;
}

/* ── Form Card ────────────────────────────────────────────── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-group input,
.form-group select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select option {
    background: var(--surface-2);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

/* Type Toggle */
.type-row {
    grid-template-columns: 1fr;
}

.type-toggle-group {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.type-btn {
    flex: 1;
    padding: 9px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}

.type-btn.active[data-type="income"] {
    background: var(--green-soft);
    color: var(--green);
}

.type-btn.active[data-type="expense"] {
    background: var(--red-soft);
    color: var(--red);
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 12px;
    margin-top: 6px;
    background: linear-gradient(135deg, #6c63ff, #a78bfa);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    letter-spacing: 0.02em;
}

.submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

/* ── History Card ─────────────────────────────────────────── */
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-height: 520px;
    display: flex;
    flex-direction: column;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.history-header .section-title {
    margin-bottom: 0;
}

.search-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 8px 12px;
    outline: none;
    width: 180px;
    transition: border-color var(--transition);
}

.search-input:focus {
    border-color: var(--accent);
}

/* Transaction List */
.transaction-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.transaction-list::-webkit-scrollbar {
    width: 4px;
}

.transaction-list::-webkit-scrollbar-track {
    background: transparent;
}

.transaction-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.transaction-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    transition: background var(--transition);
    position: relative;
    overflow: hidden;
}

.transaction-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
}

.transaction-list li.plus::before {
    background: var(--green);
}

.transaction-list li.minus::before {
    background: var(--red);
}

.transaction-list li:hover {
    background: #262a3e;
}

.tx-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 8px;
    flex-shrink: 0;
}

.tx-info {
    flex: 1;
    min-width: 0;
}

.tx-desc {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.tx-amount {
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

.tx-amount.plus {
    color: var(--green);
}

.tx-amount.minus {
    color: var(--red);
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.delete-btn:hover {
    color: var(--red);
    background: var(--red-soft);
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 40px 0;
    display: none;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .history-card {
        max-height: 400px;
    }

    .header-inner {
        flex-wrap: wrap;
        gap: 12px;
    }

    .header-right {
        flex-wrap: wrap;
        gap: 10px;
    }

    #currency-select {
        max-width: 160px;
    }
}

@media (max-width: 500px) {
    .app-main {
        padding: 16px 14px 40px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .card-value {
        font-size: 22px;
    }
}