/* ============================================================
   CATATAN KEUANGAN — Design System (Light Theme)
   Brand: #6C47FF  |  Font: Inter
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap");

/* ── Tokens ── */
:root {
    /* Brand */
    --fk-brand:          #6C47FF;
    --fk-brand-light:    #EDE9FF;
    --fk-brand-mid:      #8B68FF;
    --fk-brand-hover:    #5835EB;

    /* Background & Surface */
    --fk-bg:             #F5F5FA;
    --fk-bg-inner:       #EEEEF6;
    --fk-surface:        #FFFFFF;
    --fk-surface-2:      #F9F9FC;

    /* Text */
    --fk-ink:            #131316;
    --fk-ink-2:          #3D3D50;
    --fk-muted:          #7C7C99;
    --fk-muted-light:    #AEAEC8;

    /* Border */
    --fk-line:           #E2E2EE;
    --fk-line-2:         #D0D0E4;

    /* Semantic */
    --fk-success:        #16A34A;
    --fk-success-bg:     #F0FDF4;
    --fk-danger:         #DC2626;
    --fk-danger-bg:      #FEF2F2;
    --fk-warning:        #D97706;
    --fk-warning-bg:     #FFFBEB;
    --fk-info:           #2563EB;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    /* Radius */
    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   14px;
    --r-xl:   20px;
    --r-full: 9999px;

    /* Shadow */
    --sh-xs:  0 1px 2px rgba(19,19,22,.06);
    --sh-sm:  0 2px 8px rgba(19,19,22,.08);
    --sh-md:  0 4px 20px rgba(19,19,22,.08);
    --sh-brand: 0 4px 16px rgba(108,71,255,.18);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--fk-ink);
    background: var(--fk-bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ── Utility ── */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.text-positive { color: var(--fk-success) !important; }
.text-negative  { color: var(--fk-danger)  !important; }
.text-warning   { color: var(--fk-warning)  !important; }
.text-muted     { color: var(--fk-muted); }
.text-brand     { color: var(--fk-brand); }
.text-xs  { font-size: 11px; }
.text-sm  { font-size: 13px; }
.fw-700   { font-weight: 700; }
.fw-600   { font-weight: 600; }

/* ─────────────────────────────────────────────
   PAGE SHELL
───────────────────────────────────────────── */
.finance-page { background: var(--fk-bg); min-height: 100vh; }

.finance-wrapper { min-height: 100vh; }

.finance-main {
    width: min(1200px, 100% - 40px);
    margin: 0 auto;
    padding: var(--sp-5) 0 80px;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

/* ─────────────────────────────────────────────
   TOPBAR
───────────────────────────────────────────── */
.finance-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) 0;
}

.finance-home-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    height: 38px;
    padding: 0 var(--sp-4);
    background: var(--fk-surface);
    border: 1px solid var(--fk-line);
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    color: var(--fk-ink);
    box-shadow: var(--sh-xs);
    transition: border-color .18s, box-shadow .18s, color .18s;
}
.finance-home-link:hover {
    border-color: var(--fk-brand);
    color: var(--fk-brand);
    box-shadow: var(--sh-brand);
}
.finance-home-link i { font-size: 12px; }

.finance-brand-mark {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--fk-muted);
}
.finance-brand-mark i { color: var(--fk-brand); }

/* ─────────────────────────────────────────────
   PAGE HERO (compact)
───────────────────────────────────────────── */
.page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-6);
    background: linear-gradient(135deg, var(--fk-surface) 0%, var(--fk-brand-light) 100%);
    border: 1px solid var(--fk-line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-sm);
    position: relative;
    overflow: hidden;
}
.page-hero::after {
    content: "";
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(108,71,255,.12) 0%, transparent 70%);
    pointer-events: none;
}

.page-hero-left { display: flex; flex-direction: column; gap: var(--sp-1); }

.page-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--fk-brand);
}

.page-hero-title {
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 800;
    line-height: 1.15;
    color: var(--fk-ink);
    max-width: 540px;
}

.page-hero-desc {
    font-size: 13px;
    color: var(--fk-muted);
    max-width: 420px;
    margin-top: var(--sp-1);
}

.page-hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    flex-shrink: 0;
    align-items: center;
}

/* ─────────────────────────────────────────────
   STAT STRIP  (3 columns)
───────────────────────────────────────────── */
.stat-strip {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr;
    gap: var(--sp-4);
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-5);
    background: var(--fk-surface);
    border: 1px solid var(--fk-line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xs);
    transition: box-shadow .18s;
}
.stat-card:hover { box-shadow: var(--sh-sm); }

.stat-card--primary {
    background: linear-gradient(135deg, var(--fk-ink) 0%, #2d1b6e 100%);
    border-color: transparent;
    color: #fff;
}
.stat-card--primary .stat-label,
.stat-card--primary .stat-meta  { color: rgba(255,255,255,.6); }
.stat-card--primary .stat-value { color: #fff; }

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--fk-muted);
}

.stat-value {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    line-height: 1.1;
    color: var(--fk-ink);
    overflow-wrap: anywhere;
}

.stat-meta {
    font-size: 11px;
    font-weight: 500;
    color: var(--fk-muted);
}

/* ─────────────────────────────────────────────
   PILL / BADGE
───────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}
.pill--default {
    background: var(--fk-bg-inner);
    color: var(--fk-muted);
    border: 1px solid var(--fk-line);
}
.pill--brand {
    background: var(--fk-brand-light);
    color: var(--fk-brand);
    border: 1px solid rgba(108,71,255,.2);
}
.pill--success {
    background: var(--fk-success-bg);
    color: var(--fk-success);
    border: 1px solid rgba(22,163,74,.15);
}
.pill--danger {
    background: var(--fk-danger-bg);
    color: var(--fk-danger);
    border: 1px solid rgba(220,38,38,.15);
}
.pill--warning {
    background: var(--fk-warning-bg);
    color: var(--fk-warning);
    border: 1px solid rgba(217,119,6,.15);
}

/* ─────────────────────────────────────────────
   DASHBOARD GRID
───────────────────────────────────────────── */
.db-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    grid-template-rows: auto;
    gap: var(--sp-4);
    align-items: start;
}

/* Left column stacks vertically */
.db-col-main {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    min-width: 0;
}

/* Right column stacks vertically */
.db-col-side {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    min-width: 0;
}

/* ─────────────────────────────────────────────
   CARD — base
───────────────────────────────────────────── */
.card {
    background: var(--fk-surface);
    border: 1px solid var(--fk-line);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--sh-xs);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    transition: box-shadow .18s;
}
.card:hover { box-shadow: var(--sh-sm); }

.card--accent {
    background: linear-gradient(135deg, var(--fk-ink) 0%, #1f0256 100%);
    border-color: rgba(108,71,255,.3);
    box-shadow: 0 8px 32px rgba(108,71,255,.18);
    color: #fff;
}
.card--accent .card-subtitle { color: rgba(255,255,255,.55); }
.card--accent .card-title    { color: #fff; }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
}

.card-kicker {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.card-subtitle {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--fk-muted);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--fk-ink);
    line-height: 1.3;
}

/* ─────────────────────────────────────────────
   SMART INPUT CARD
───────────────────────────────────────────── */
.smart-input-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.smart-textarea {
    width: 100%;
    min-height: 90px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    color: #fff;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    transition: border-color .18s, box-shadow .18s;
}
.smart-textarea:focus {
    border-color: rgba(255,255,255,.4);
    box-shadow: 0 0 0 3px rgba(108,71,255,.25);
    outline: none;
}
.smart-textarea::placeholder { color: rgba(255,255,255,.35); }

.smart-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}

.db-prompt-chip,
.db-prompt-loading {
    padding: 4px 10px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--r-full);
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,.75);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.db-prompt-chip:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
}

.smart-actions {
    display: flex;
    gap: var(--sp-2);
}

/* ─────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    height: 38px;
    padding: 0 var(--sp-4);
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    transition: all .18s;
    white-space: nowrap;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--fk-brand);
    color: #fff;
    box-shadow: var(--sh-brand);
}
.btn-primary:hover {
    background: var(--fk-brand-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(108,71,255,.28);
}

.btn-secondary {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.2);
    color: rgba(255,255,255,.9);
}
.btn-secondary:hover {
    background: rgba(255,255,255,.2);
    border-color: rgba(255,255,255,.35);
}

.btn-ghost {
    background: transparent;
    border-color: var(--fk-line);
    color: var(--fk-ink-2);
}
.btn-ghost:hover {
    border-color: var(--fk-brand);
    color: var(--fk-brand);
}

.icon-btn {
    width: 30px; height: 30px;
    border-radius: var(--r-sm);
    background: transparent;
    border: 1px solid var(--fk-line-2);
    color: var(--fk-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: all .15s;
    flex-shrink: 0;
}
.icon-btn:hover {
    border-color: var(--fk-brand);
    color: var(--fk-brand);
    background: var(--fk-brand-light);
}

.ghost-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--fk-brand);
    transition: color .15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.ghost-link:hover { color: var(--fk-brand-hover); text-decoration: underline; }

/* ─────────────────────────────────────────────
   CHART
───────────────────────────────────────────── */
.chart-actions { display: flex; gap: var(--sp-1); align-items: center; }

.chart-wrapper {
    height: 130px;
    background: var(--fk-bg);
    border: 1px solid var(--fk-line);
    border-radius: var(--r-md);
    overflow: hidden;
}
.chart-svg { width: 100%; height: 100%; }
.db-chart-grid {
    stroke: var(--fk-line);
    stroke-width: 1;
    stroke-dasharray: 3 4;
    fill: none;
}
.chart-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--fk-muted);
}

/* ─────────────────────────────────────────────
   LEDGER + CATEGORY  (split inside main col)
───────────────────────────────────────────── */
.two-col-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    align-items: start;
}

/* ─────────────────────────────────────────────
   LIST — transactions / categories
───────────────────────────────────────────── */
.list-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.list-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--fk-surface-2);
    border: 1px solid var(--fk-line);
    transition: background .15s;
}
.list-row:hover { background: var(--fk-brand-light); border-color: rgba(108,71,255,.2); }

.list-icon {
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    background: var(--fk-brand-light);
    color: var(--fk-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.list-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--fk-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-sub {
    font-size: 11px;
    color: var(--fk-muted);
}

.list-amount {
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    flex-shrink: 0;
}

.cat-bar-wrap { display: flex; flex-direction: column; gap: 2px; }
.cat-bar-track {
    height: 3px;
    border-radius: var(--r-full);
    background: var(--fk-line);
    overflow: hidden;
}
.cat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fk-brand), var(--fk-brand-mid));
    border-radius: var(--r-full);
}

/* ─────────────────────────────────────────────
   AI INSIGHT
───────────────────────────────────────────── */
.ai-signal-item {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    background: var(--fk-surface-2);
    border-left: 3px solid var(--fk-brand);
    transition: background .15s;
}
.ai-signal-item:hover { background: var(--fk-brand-light); }
.ai-signal-item i { color: var(--fk-brand); margin-top: 1px; flex-shrink: 0; }
.ai-signal-body h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.ai-signal-body p  { font-size: 11px; color: var(--fk-muted); margin: 0; }

.ai-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--fk-line);
}
.ai-legend-item {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: 11px;
    color: var(--fk-muted);
    font-weight: 500;
}

/* ─────────────────────────────────────────────
   BUDGET CARD (sidebar)
───────────────────────────────────────────── */
.budget-percent-label {
    font-size: 22px;
    font-weight: 800;
    color: var(--fk-ink);
    line-height: 1;
}

.budget-track {
    height: 8px;
    background: var(--fk-bg-inner);
    border-radius: var(--r-full);
    overflow: hidden;
}
.budget-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fk-brand), var(--fk-brand-mid));
    border-radius: var(--r-full);
    transition: width .4s ease;
}
.budget-fill--warn { background: linear-gradient(90deg, var(--fk-warning), #FBBF24); }
.budget-fill--over { background: linear-gradient(90deg, var(--fk-danger),  #F87171); }

.budget-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--fk-muted);
}

/* ─────────────────────────────────────────────
   SHORTCUT GRID (sidebar)
───────────────────────────────────────────── */
.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-2);
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: var(--sp-3) var(--sp-2);
    background: var(--fk-surface-2);
    border: 1px solid var(--fk-line);
    border-radius: var(--r-md);
    color: var(--fk-ink-2);
    transition: all .18s;
    text-align: center;
}
.shortcut-item:hover {
    background: var(--fk-brand);
    border-color: var(--fk-brand);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--sh-brand);
}
.shortcut-icon { font-size: 15px; }
.shortcut-label { font-size: 10px; font-weight: 600; }

/* ─────────────────────────────────────────────
   REMINDER / DUE CARD
───────────────────────────────────────────── */
.due-meta {
    font-size: 12px;
    color: var(--fk-muted);
    margin: 0;
}

/* ─────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────── */
.db-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-5);
    border: 1px dashed var(--fk-line-2);
    border-radius: var(--r-md);
    background: var(--fk-surface-2);
    color: var(--fk-muted-light);
    font-size: 12px;
    text-align: center;
    min-height: 80px;
}

/* ─────────────────────────────────────────────
   TOAST
───────────────────────────────────────────── */
.db-toast {
    position: fixed;
    bottom: var(--sp-6);
    right: var(--sp-6);
    background: var(--fk-ink);
    color: #fff;
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    z-index: 200;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .25s, transform .25s;
}
.db-toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ─────────────────────────────────────────────
   LEGACY CLASS ALIASES  (JS-rendered rows)
   So dynamic JS-injected classes still render.
───────────────────────────────────────────── */
.db-tx-row,
.db-cat-row,
.fai-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--r-md);
    background: var(--fk-surface-2);
    border: 1px solid var(--fk-line);
    transition: background .15s;
}
.db-tx-row:hover,
.db-cat-row:hover { background: var(--fk-brand-light); border-color: rgba(108,71,255,.2); }

.db-tx-icon,
.db-cat-icon,
.fai-item-icon {
    width: 34px; height: 34px;
    border-radius: var(--r-sm);
    background: var(--fk-brand-light);
    color: var(--fk-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.db-tx-info,
.db-cat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.db-tx-info strong,
.db-cat-info strong { font-size: 13px; font-weight: 600; color: var(--fk-ink); }
.db-tx-info em,
.db-cat-info em     { font-size: 11px; color: var(--fk-muted); font-style: normal; }

.db-tx-amount { font-size: 13px; font-weight: 700; text-align: right; flex-shrink: 0; }

.db-cat-progress {
    height: 3px;
    border-radius: var(--r-full);
    background: var(--fk-line);
    overflow: hidden;
    margin-top: 4px;
}
.db-cat-progress span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--fk-brand), var(--fk-brand-mid));
}

.fai-item { align-items: flex-start; }
.fai-item-icon { margin-top: 2px; }
.fai-item span:first-of-type + * { flex: 1; }

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */

/* Tablet: sidebar falls below main */
@media (max-width: 1023px) {
    .db-grid {
        grid-template-columns: 1fr;
    }
    .db-col-side {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--sp-4);
    }
    .stat-strip {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Mobile */
@media (max-width: 639px) {
    .finance-main { width: min(100%, 100% - 24px); padding-top: var(--sp-4); }
    .page-hero { flex-direction: column; align-items: flex-start; gap: var(--sp-4); }
    .page-hero-badges { width: 100%; }
    .stat-strip { grid-template-columns: 1fr; }
    .two-col-split { grid-template-columns: 1fr; }
    .db-col-side { grid-template-columns: 1fr; }
    .shortcut-grid { grid-template-columns: repeat(3, 1fr); }
    .smart-actions { flex-wrap: wrap; }
    .smart-actions .btn { flex: 1; }
}
