@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
    --blue-900: #082952;
    --blue-800: #0a4aa1;
    --blue-700: #0f62c2;
    --blue-600: #1279e6;
    --blue-500: #118eea;
    --blue-450: #1d7ef0;
    /* DANA Premium Blue - Bright & Striking */
    --blue-400: #3ca9ff;
    --blue-300: #6bc0ff;
    --blue-200: #9cd5ff;
    --blue-100: #cce7ff;
    --blue-50: #eef7ff;

    --green-500: #10b981;
    /* Vibrant Emerald */
    --green-100: #d1fae5;
    --red-500: #ff3b30;
    /* Vibrant iOS Red */
    --red-100: #ffe5e5;
    --amber-500: #ff9f0a;
    /* Vibrant Amber */
    --purple-500: #a855f7;
    /* Vibrant Purple */
    --pink-500: #ec4899;
    --cyan-500: #06b6d4;
    --orange-500: #f97316;

    --bg-body: #d2e4f9;
    /* Blue background */
    --bg-white: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-white: #ffffff;
    --border: #cbd5e1;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(17, 142, 234, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(108, 176, 244, 0.16), transparent 24%),
        linear-gradient(135deg, #f7fbff 0%, #eaf5ff 45%, #dfeeff 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- App Shell --- */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
    background: linear-gradient(180deg, rgba(128, 242, 230, 0.9) 0%, rgba(126, 239, 205, 0.92) 100%);
    padding-bottom: 90px;
}

/* --- Hero Header (Blue Gradient) --- */
.hero-header {
    background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-500) 50%, var(--blue-400) 100%);
    color: var(--text-white);
    padding: 2rem 1.5rem 2.5rem;
    border-radius: 0 0 28px 28px;
    position: relative;
    overflow: hidden;
    animation: fadeInDown 0.5s ease;
}

.hero-header::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -40px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.hero-header::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
}

.hero-greeting {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.85;
    margin-bottom: 0.25rem;
}

.hero-tagline {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.saldo-section {
    text-align: center;
    position: relative;
    z-index: 1;
}

.saldo-label {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.saldo-amount-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.saldo-amount {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.saldo-toggle-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.saldo-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.saldo-summary {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.summary-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.summary-icon.income {
    background: rgba(34, 197, 94, 0.3);
}

.summary-icon.expense {
    background: rgba(239, 68, 68, 0.3);
}

.summary-info span {
    display: block;
}

.summary-info .label {
    font-size: 0.65rem;
    opacity: 0.7;
}

.summary-info .value {
    font-weight: 600;
    font-size: 0.8rem;
}

/* --- Page Header (Inner pages) --- */
.page-header {
    background: linear-gradient(135deg, var(--blue-800), var(--blue-500));
    color: var(--text-white);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0 0 20px 20px;
    position: relative;
    animation: fadeInDown 0.4s ease;
}

.page-header .back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.page-header .back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.page-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
}

/* --- Menu Grid --- */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 1.5rem 0.75rem;
    color: var(--text-primary);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 0 1.5rem;
    margin-bottom: 1.5rem;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #f4faff 100%);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(18, 121, 230, 0.08);
    text-decoration: none;
    color: var(--text-primary);
}

.menu-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--blue-200);
}

.menu-item:active {
    transform: scale(0.97);
}

.menu-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.menu-icon.mi-pemasukan {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.menu-icon.mi-pengeluaran {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.menu-icon.mi-catatan {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.menu-icon.mi-target {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.menu-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-secondary);
}

/* --- Cards --- */
.card {
    background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
    border: 1px solid rgba(18, 121, 230, 0.08);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 0 1.5rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    animation: fadeInUp 0.4s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--blue-500);
}

/* --- Chart Container --- */
.chart-container {
    position: relative;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2rem 0;
}

.chart-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.4;
}

/* --- Forms --- */
.form-container {
    padding: 1.5rem;
    margin: 0 1rem 1rem;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(18, 121, 230, 0.12);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(15, 83, 164, 0.08);
    animation: fadeInUp 0.5s ease;
}

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

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

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

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input.input-nominal {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: var(--blue-50);
    border-color: var(--blue-200);
}

.form-input.input-nominal:focus {
    background: white;
}

.input-prefix-label {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-textarea {
    resize: vertical;
    min-height: 280px;
    line-height: 1.8;
}

body[data-page="pemasukan"] .form-textarea,
body[data-page="pengeluaran"] .form-textarea {
    min-height: 96px;
    font-size: 0.9rem;
    line-height: 1.6;
}

body[data-page="catatan"] .form-textarea {
    min-height: 300px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* --- Buttons --- */
.btn {
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
    color: white;
    box-shadow: 0 4px 14px rgba(26, 115, 232, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 115, 232, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--blue-500);
    border: 1.5px solid var(--blue-500);
}

.btn-outline:hover {
    background: var(--blue-50);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    width: auto;
    border-radius: 8px;
}

/* --- Target Cards --- */
.target-list {
    padding: 0 1.5rem 1rem;
}

.target-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    animation: fadeInUp 0.4s ease;
}

.target-card:hover {
    box-shadow: var(--shadow-md);
}

.target-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.target-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.target-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}

.target-badge.in-progress {
    background: var(--blue-50);
    color: var(--blue-600);
}

.target-badge.completed {
    background: var(--green-100);
    color: var(--green-500);
}

.target-amounts {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.target-amounts .collected {
    font-weight: 600;
    color: var(--blue-500);
}

.progress-bar-track {
    width: 100%;
    height: 10px;
    background: var(--blue-50);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-500), var(--blue-400));
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.progress-bar-fill.completed {
    background: linear-gradient(90deg, var(--green-500), #4ade80);
}

.target-actions {
    display: flex;
    gap: 0.5rem;
}

/* --- Riwayat / Transaction List --- */
.riwayat-list {
    padding: 0.5rem 1.5rem 1rem;
}

.riwayat-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid #f1f5f9;
    animation: fadeIn 0.3s ease;
    transition: var(--transition);
}

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

.riwayat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.riwayat-icon.income {
    background: var(--green-100);
    color: var(--green-500);
}

.riwayat-icon.expense {
    background: var(--red-100);
    color: var(--red-500);
}

.riwayat-details {
    flex: 1;
    min-width: 0;
}

.riwayat-desc {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.riwayat-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.riwayat-amount {
    font-weight: 700;
    font-size: 0.9rem;
    text-align: right;
    flex-shrink: 0;
}

.riwayat-amount.income {
    color: var(--green-500);
}

.riwayat-amount.expense {
    color: var(--red-500);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    animation: fadeIn 0.5s ease;
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.35;
    display: block;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 0.85rem;
}

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(18, 121, 230, 0.08);
    display: flex;
    z-index: 999;
    box-shadow: 0 -4px 16px rgba(8, 41, 82, 0.05);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.65rem 0;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: none;
    background: none;
}

.nav-item i {
    font-size: 1.15rem;
}

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

.nav-item:hover {
    color: var(--blue-500);
}

/* --- Copyright Footer --- */
.page-footer {
    margin-top: 1.25rem;
    padding: 0 1.5rem 6.5rem;
}

.copyright {
    text-align: center;
    font-size: 0.74rem;
    color: var(--text-secondary);
    padding: 0.8rem 1rem;
    opacity: 0.95;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(18, 121, 230, 0.12);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    max-width: 380px;
    width: calc(100% - 3rem);
    background: var(--bg-white);
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    background: var(--green-100);
    color: var(--green-500);
}

.toast.error .toast-icon {
    background: var(--red-100);
    color: var(--red-500);
}

#toast-message,
.toast-message {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* --- Modal Overlay --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 20px 20px 0 0;
    padding: 1.5rem 1.5rem 2rem;
    width: 100%;
    max-width: 480px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    margin: 0 auto 1rem;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.modal-message {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1.3rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-cancel {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-primary);
    border: none;
}

.btn-cancel:hover {
    background: rgba(148, 163, 184, 0.24);
}

.btn-cancel:active {
    transform: scale(0.98);
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* --- Utilities --- */
.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.text-center {
    text-align: center;
}

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

.text-sm {
    font-size: 0.8rem;
}

/* --- Responsive (already mobile first, but add tablet breakpoint) --- */
@media (min-width: 481px) {
    body {
        background: linear-gradient(135deg, #0f172a 0%, #0d47a1 100%);
    }

    .app-shell {
        margin-top: 1rem;
        border-radius: var(--radius) var(--radius) 0 0;
        background: var(--bg-body);
        box-shadow: var(--shadow-lg);
        overflow: hidden;
    }

    .hero-header {
        border-radius: var(--radius) var(--radius) 28px 28px;
    }
}