/* ===== CacheFlow — Modern SaaS theme ===== */
:root {
    --cf-bg: #f8fafc;
    --cf-card: #ffffff;
    --cf-border: #e2e8f0;
    --cf-border-soft: #eef2f7;
    --cf-text: #0f172a;
    --cf-muted: #64748b;
    --cf-blue: #3b82f6;
    --cf-indigo: #6366f1;
    --cf-indigo-600: #4f46e5;
    --cf-grad: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --cf-income: #10b981;
    --cf-expense: #f43f5e;
    --cf-warn: #f59e0b;
    --cf-radius: 14px;
    --cf-radius-sm: 12px;
    --cf-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 8px -2px rgba(15, 23, 42, .04), 0 10px 25px -5px rgba(0, 0, 0, .06);
    --cf-shadow-hover: 0 2px 4px rgba(15, 23, 42, .05), 0 8px 16px -4px rgba(15, 23, 42, .06), 0 20px 40px -8px rgba(99, 102, 241, .14);
    --cf-shadow-accent: 0 4px 10px -2px rgba(99, 102, 241, .35), 0 12px 28px -6px rgba(59, 130, 246, .35);

    --bs-body-font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', system-ui, sans-serif;
    --bs-body-bg: var(--cf-bg);
    --bs-body-color: var(--cf-text);
    --bs-primary: #6366f1;
    --bs-primary-rgb: 99, 102, 241;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: #4338ca;
    --bs-border-color: var(--cf-border);
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 12px;
    --bs-border-radius-sm: 8px;
}

body {
    font-family: var(--bs-body-font-family);
    background: var(--cf-bg);
    color: var(--cf-text);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -.005em;
}
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.02em; color: var(--cf-text); }
.text-muted { color: var(--cf-muted) !important; }
.fw-medium { font-weight: 500; }
.tnum { font-variant-numeric: tabular-nums; }

/* ----- Navbar ----- */
.app-navbar {
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--cf-border);
    padding: .55rem 0;
}
.app-navbar .navbar-brand { color: var(--cf-text); font-weight: 800; letter-spacing: -.03em; display: flex; align-items: center; gap: .55rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--cf-grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--cf-shadow-accent); font-size: 1.05rem; }
.app-navbar .nav-link { color: var(--cf-muted); font-weight: 500; font-size: .92rem; border-radius: 10px; padding: .45rem .8rem !important; transition: all .15s; }
.app-navbar .nav-link:hover { color: var(--cf-text); background: #f1f5f9; }
.app-navbar .nav-link.active { color: var(--cf-indigo-600); background: #eef2ff; }
.app-navbar .navbar-toggler { color: var(--cf-text); font-size: 1.5rem; padding: .25rem .5rem; box-shadow: none; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--cf-grad); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }

.dropdown-menu { border: 1px solid var(--cf-border); border-radius: var(--cf-radius-sm); box-shadow: var(--cf-shadow-hover); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; font-size: .92rem; }
.dropdown-item:active { background: var(--cf-indigo); }

.offcanvas { border-left: 0 !important; }
.offcanvas-header.cf-offcanvas-head { background: var(--cf-grad); color: #fff; }
.offcanvas .list-group-item { border: 0; margin: .15rem .5rem; border-radius: 10px; font-weight: 500; }
.offcanvas .list-group-item.active { background: #eef2ff; color: var(--cf-indigo-600); }

/* ----- Buttons ----- */
.btn { border-radius: 10px; font-weight: 600; font-size: .92rem; padding: .5rem 1rem; transition: transform .12s, box-shadow .15s, background .15s; }
.btn-lg { border-radius: 12px; padding: .7rem 1.25rem; font-size: 1rem; }
.btn-sm { border-radius: 8px; padding: .3rem .6rem; font-size: .82rem; }
.btn-primary { --bs-btn-bg: #6366f1; --bs-btn-border-color: transparent; --bs-btn-hover-bg: #4f46e5; --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: #4338ca; background-image: var(--cf-grad); box-shadow: var(--cf-shadow-accent); border: 0; }
.btn-primary:hover { transform: translateY(-1px); background-image: linear-gradient(135deg, #2563eb, #4f46e5); }
.btn-outline-primary { --bs-btn-color: #4f46e5; --bs-btn-border-color: #c7d2fe; --bs-btn-hover-bg: #eef2ff; --bs-btn-hover-color: #4338ca; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-active-bg: #6366f1; --bs-btn-active-border-color: #6366f1; background: #fff; }
.btn-success { --bs-btn-bg: #10b981; --bs-btn-border-color: #10b981; --bs-btn-hover-bg: #059669; --bs-btn-hover-border-color: #059669; box-shadow: 0 6px 16px -6px rgba(16, 185, 129, .55); }
.btn-danger { --bs-btn-bg: #f43f5e; --bs-btn-border-color: #f43f5e; --bs-btn-hover-bg: #e11d48; --bs-btn-hover-border-color: #e11d48; box-shadow: 0 6px 16px -6px rgba(244, 63, 94, .55); }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--cf-border); --bs-btn-hover-bg: #f8fafc; --bs-btn-hover-border-color: #cbd5e1; --bs-btn-color: #334155; }
.btn-warning { --bs-btn-bg: #f59e0b; --bs-btn-border-color: #f59e0b; --bs-btn-color: #fff; --bs-btn-hover-bg: #d97706; --bs-btn-hover-color: #fff; }

/* ----- Forms ----- */
.form-control, .form-select { border-radius: 10px; border-color: var(--cf-border); padding: .55rem .85rem; font-size: .95rem; background-color: #fff; }
.form-control-lg, .input-group-lg > .form-control { border-radius: 12px; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }
.input-group-text { background: #f8fafc; border-color: var(--cf-border); color: var(--cf-muted); border-radius: 10px; }
.form-label { font-weight: 600; font-size: .85rem; color: #334155; margin-bottom: .35rem; }
.form-text { color: var(--cf-muted); font-size: .8rem; }
.form-check-input:checked { background-color: var(--cf-indigo); border-color: var(--cf-indigo); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); border-color: #a5b4fc; }

/* ----- Cards / bento ----- */
.card {
    border: 1px solid rgba(226, 232, 240, .7);
    border-radius: var(--cf-radius);
    background: var(--cf-card);
    box-shadow: var(--cf-shadow);
    transition: box-shadow .2s, transform .2s;
}
a.card:hover, .card.hoverable:hover { box-shadow: var(--cf-shadow-hover); transform: translateY(-2px); }
.card-header { background: transparent; border-bottom: 1px solid var(--cf-border-soft); font-weight: 700; padding: 1rem 1.25rem; font-size: .95rem; letter-spacing: -.01em; border-radius: var(--cf-radius) var(--cf-radius) 0 0 !important; }
.card-body { padding: 1.15rem 1.25rem; }
.card-title-sm { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--cf-muted); }

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.bento > * { min-width: 0; }
.b-span-3 { grid-column: span 3; } .b-span-4 { grid-column: span 4; } .b-span-5 { grid-column: span 5; }
.b-span-6 { grid-column: span 6; } .b-span-7 { grid-column: span 7; } .b-span-8 { grid-column: span 8; } .b-span-12 { grid-column: span 12; }
.b-row-2 { grid-row: span 2; }
@media (max-width: 1199.98px) {
    .b-span-3 { grid-column: span 6; } .b-span-4, .b-span-5, .b-span-7, .b-span-8 { grid-column: span 12; } .b-span-6 { grid-column: span 6; }
    .b-row-2 { grid-row: auto; }
    .bento .b-md-6 { grid-column: span 6; }
}
@media (max-width: 767.98px) {
    .bento { gap: .75rem; }
    .b-span-6 { grid-column: span 12; }
    .bento .b-md-6 .card-body { padding: .9rem; }
    .bento .b-md-6 .row-line { font-size: .82rem; }
    .b-span-3 { grid-column: span 6; }
}

.hero-card { background: var(--cf-grad); color: #fff; border: 0; box-shadow: var(--cf-shadow-accent); position: relative; overflow: hidden; }
.hero-card::before, .hero-card::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero-card::before { width: 220px; height: 220px; right: -60px; top: -80px; }
.hero-card::after { width: 160px; height: 160px; right: 40px; bottom: -90px; background: rgba(255, 255, 255, .07); }
.hero-card .card-body { position: relative; z-index: 1; }
.hero-card .hero-label { font-size: .82rem; opacity: .85; font-weight: 500; }
.hero-card .hero-value { font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.hero-card .hero-wallet { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid rgba(255, 255, 255, .15); font-size: .9rem; }
.hero-card .hero-wallet:last-child { border-bottom: 0; }
.hero-card .btn-glass { background: rgba(255, 255, 255, .18); color: #fff; border: 1px solid rgba(255, 255, 255, .25); backdrop-filter: blur(6px); }
.hero-card .btn-glass:hover { background: rgba(255, 255, 255, .28); color: #fff; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; font-weight: 800; letter-spacing: -.03em; display: flex; align-items: center; }
.page-head h1 > i { width: 38px; height: 38px; border-radius: 11px; background: #eef2ff; color: var(--cf-indigo-600); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-right: .65rem !important; }
.page-sub { color: var(--cf-muted); font-size: .9rem; }

.text-income { color: var(--cf-income) !important; }
.text-expense { color: var(--cf-expense) !important; }
.text-warning { color: var(--cf-warn) !important; }
.bg-income-soft { background: #ecfdf5; color: #059669; }
.bg-expense-soft { background: #fff1f2; color: #e11d48; }

.stat-card .card-body { padding: 1rem 1.15rem; }
.stat-card .stat-label { font-size: .8rem; color: var(--cf-muted); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.stat-card .stat-value { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.icon-tile { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; }
.icon-tile.indigo { background: #eef2ff; color: #4f46e5; }
.icon-tile.blue { background: #eff6ff; color: #2563eb; }
.icon-tile.violet { background: #f5f3ff; color: #7c3aed; }
.icon-tile.slate { background: #f1f5f9; color: #475569; }

.period-card .period-title { font-weight: 700; font-size: 1rem; }
.period-card .row-line { display: flex; justify-content: space-between; font-size: .9rem; padding: .2rem 0; font-variant-numeric: tabular-nums; }
.period-card .net { border-top: 1px dashed var(--cf-border); margin-top: .5rem; padding-top: .55rem; font-weight: 700; }
.mini-bar { height: 6px; border-radius: 99px; background: #fff1f2; overflow: hidden; margin-top: .6rem; }
.mini-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #10b981, #34d399); border-radius: 99px; }

.wallet-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem; flex-shrink: 0; box-shadow: 0 4px 10px -3px rgba(15, 23, 42, .25); }

.txn-item { display: flex; align-items: center; gap: .85rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--cf-border-soft); transition: background .12s; }
.txn-item:hover { background: #fafbff; }
.txn-item:last-child { border-bottom: 0; border-radius: 0 0 var(--cf-radius) var(--cf-radius); }
.txn-item .txn-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.05rem; }
.txn-item .txn-main { flex: 1; min-width: 0; }
.txn-item .txn-title { font-weight: 600; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-item .txn-meta { font-size: .78rem; color: var(--cf-muted); }
.txn-item .txn-amount { font-weight: 700; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 240px; }
@media (max-width: 576px) { .chart-box { height: 240px; } }

.type-toggle { background: #f1f5f9; padding: 4px; border-radius: 12px; }
.type-toggle .btn { flex: 1; padding: .6rem; font-weight: 600; border: 0; border-radius: 9px !important; color: var(--cf-muted); background: transparent; box-shadow: none; }
.type-toggle .btn-check:checked + .btn-outline-success { background: #fff; color: var(--cf-income); box-shadow: var(--cf-shadow); }
.type-toggle .btn-check:checked + .btn-outline-danger { background: #fff; color: var(--cf-expense); box-shadow: var(--cf-shadow); }

.attach-thumb { width: 92px; height: 92px; border-radius: 12px; object-fit: cover; border: 1px solid var(--cf-border); background: #f8fafc; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--cf-expense); }
.attach-wrap { position: relative; display: inline-block; text-align: center; width: 96px; }
.attach-wrap small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .7rem; color: var(--cf-muted); }

/* ----- Tables ----- */
.table { --bs-table-hover-bg: #fafbff; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem 1rem; border-color: var(--cf-border-soft); }
.table thead th { font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--cf-muted); background: #f8fafc; white-space: nowrap; border-bottom: 1px solid var(--cf-border); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { background: #f8fafc; border-top: 1px solid var(--cf-border); }
.card > .table-responsive:last-child .table tr:last-child td:first-child { border-bottom-left-radius: var(--cf-radius); }

/* ----- Nav pills (segmented) ----- */
.nav-pills.cf-seg { background: #fff; border: 1px solid var(--cf-border); padding: 4px; border-radius: 12px; display: inline-flex; box-shadow: var(--cf-shadow); max-width: 100%; }
.nav-pills .nav-link { color: var(--cf-muted); font-weight: 600; font-size: .88rem; border-radius: 9px; padding: .45rem .9rem; }
.nav-pills .nav-link:hover { color: var(--cf-text); }
.nav-pills .nav-link.active { background: var(--cf-grad); color: #fff; box-shadow: var(--cf-shadow-accent); }

.pagination { --bs-pagination-border-radius: 10px; --bs-pagination-active-bg: #6366f1; --bs-pagination-active-border-color: #6366f1; --bs-pagination-color: #475569; gap: .25rem; }
.pagination .page-link { border-radius: 10px !important; border-color: var(--cf-border); }

.alert { border-radius: var(--cf-radius-sm); border: 0; box-shadow: var(--cf-shadow); }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fff1f2; color: #9f1239; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info { background: #eff6ff; color: #1e40af; }

.badge { font-weight: 600; border-radius: 6px; padding: .3em .55em; }
.badge-special { background: #fef3c7; color: #92400e; }

.filter-card .form-label { font-size: .75rem; color: var(--cf-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ----- Login ----- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, .18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(99, 102, 241, .2), transparent 60%), var(--cf-bg); }
.login-page .card { box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 20px 50px -12px rgba(15, 23, 42, .15); }

/* ----- Mobile bottom navigation ----- */
.bottom-nav { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1030; background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: flex; justify-content: space-around; align-items: center; border: 1px solid var(--cf-border); border-radius: 18px; box-shadow: 0 10px 30px -8px rgba(15, 23, 42, .18); padding: .4rem 0; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; color: #94a3b8; text-decoration: none; font-size: .68rem; font-weight: 600; }
.bottom-nav a i { font-size: 1.25rem; line-height: 1.25; }
.bottom-nav a.active { color: var(--cf-indigo-600); }
.bottom-nav a.add-btn { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 16px; background: var(--cf-grad); color: #fff; justify-content: center; margin-top: -26px; box-shadow: var(--cf-shadow-accent); }
.bottom-nav a.add-btn i { font-size: 1.5rem; }
@media (max-width: 991.98px) { .app-main { padding-bottom: 100px !important; } }
