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

:root {
    --primary: #4f46e5;
    --primary-light: #eef2ff;
    --primary-dark: #4338ca;
    --green: #059669;
    --green-bg: #ecfdf5;
    --green-text: #047857;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --red-text: #b91c1c;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border: #e2e8f0;
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-wrap {
    max-width: 520px;
    margin: 0 auto;
    padding-bottom: 72px;
    min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; }

.container {
    padding: 20px 16px 32px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 20px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.3px;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-top: -1px;
}

.badge-balance {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
}

.hero {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 20px;
    padding: 28px 24px;
    color: #fff;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(79, 70, 229, .25);
}

.hero-label {
    font-size: 12px;
    font-weight: 500;
    opacity: .75;
    text-transform: uppercase;
    letter-spacing: .8px;
}

.hero-amount {
    font-size: 34px;
    font-weight: 800;
    margin: 4px 0 20px;
    letter-spacing: -0.5px;
}

.hero-row {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255,255,255,.12);
    border-radius: 14px;
    padding: 14px 16px;
}

.hero-stat {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-divider {
    width: 1px;
    height: 32px;
    background: rgba(255,255,255,.2);
    margin: 0 8px;
}

.hero-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.stat-in { background: rgba(5, 150, 105, .35); color: #a7f3d0; }
.stat-out { background: rgba(220, 38, 38, .35); color: #fca5a5; }

.hero-stat-label {
    font-size: 11px;
    opacity: .7;
    font-weight: 500;
}

.hero-stat-value {
    font-size: 14px;
    font-weight: 700;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.form-toggle {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all .25s;
}

.toggle-btn.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.input-group {
    margin-bottom: 16px;
}

.input-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.input-wrap {
    position: relative;
}

.input-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-tertiary);
}

.input-group input {
    width: 100%;
    padding: 14px 14px 14px 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    background: var(--bg);
    color: var(--text);
}

.input-group input:focus {
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 4px rgba(79,70,229,.1);
}

.input-group input::placeholder {
    color: var(--text-tertiary);
}

.input-group:last-of-type input {
    padding-left: 14px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    color: #fff;
    background: var(--primary);
    cursor: pointer;
    transition: background .2s, transform .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }

.page-header {
    text-align: center;
    padding: 20px 0 12px;
}

.page-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    z-index: 100;
    max-width: 520px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 16px;
    color: var(--text-tertiary);
    transition: color .2s;
    font-family: 'Poppins', sans-serif;
}

.nav-item.active { color: var(--primary); }

.nav-icon {
    width: 24px;
    height: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.count-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 20px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px 32px;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: .6;
}

.empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-desc {
    font-size: 13px;
    color: var(--text-tertiary);
}

.tx-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    transition: opacity .2s;
}

.tx-item:last-child { border-bottom: none; }

.tx-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.tx-badge-in {
    background: var(--green-bg);
    color: var(--green-text);
}

.tx-badge-out {
    background: var(--red-bg);
    color: var(--red-text);
}

.tx-body {
    flex: 1;
    min-width: 0;
}

.tx-desc {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-date {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-top: 1px;
}

.tx-amount-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tx-amount {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: -0.3px;
}

.tx-in { color: var(--green-text); }
.tx-out { color: var(--red-text); }

.tx-del {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: var(--red-bg);
    color: var(--red-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, opacity .2s;
    opacity: 0;
}

.tx-item:hover .tx-del { opacity: 1; }
.tx-del:hover { background: #fee2e2; }

@media (max-width: 480px) {
    .container { padding: 16px 14px 24px; }
    .hero { padding: 24px 18px; }
    .hero-amount { font-size: 28px; }
    .hero-row { flex-direction: column; gap: 8px; }
    .hero-divider { display: none; }
    .tx-del { opacity: 1; }
    .nav-item { padding: 6px 10px; }
}
