:root {
    --bg: #eef0f6;
    --surface: #ffffff;
    --ink: #1a1d2e;
    --muted: #6b7088;
    --line: #e3e5ee;
    --accent: #5b4bd6;
    --accent-hover: #4a3bc2;
    --income: #139c68;
    --expense: #e0505a;
    --shadow: 0 6px 24px rgba(40, 40, 90, 0.08);
}

[data-theme="dark"] {
    --bg: #12111d;
    --surface: #1c1a2e;
    --ink: #ecebf7;
    --muted: #9a98b5;
    --line: #2b2945;
    --accent: #8b7dff;
    --accent-hover: #a094ff;
    --income: #3ddc97;
    --expense: #ff7b84;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    padding: 28px 16px 48px;
    transition: background 0.25s, color 0.25s;
}

.container { max-width: 860px; margin: auto; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

header h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
header p { color: var(--muted); margin-top: 4px; font-size: 14px; }

.hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
    padding: 28px;
    margin-bottom: 20px;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(135deg, #5b4bd6 0%, #3a7bd5 100%);
    box-shadow: var(--shadow);
}

[data-theme="dark"] .hero { background: linear-gradient(135deg, #4a3bc2 0%, #2b5fb0 100%); }

.hero .label { display: block; font-size: 13px; opacity: 0.8; margin-bottom: 6px; }
.hero h2 { font-size: 38px; font-weight: 800; letter-spacing: -1px; overflow-wrap: anywhere; }

.hero-main select {
    margin-top: 16px;
    width: auto;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 12px;
}
.hero-main select option { color: #1a1d2e; }

.hero-side { display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.hero-side strong { font-size: 20px; overflow-wrap: anywhere; }
#income { color: #a8f5d2; }
#expense { color: #ffc2c7; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

.panel {
    background: var(--surface);
    padding: 24px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    transition: background 0.25s;
}
.grid .panel { margin-bottom: 0; }
.panel h2 { font-size: 17px; margin-bottom: 16px; }

form { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    background: var(--bg);
    color: var(--ink);
}

input:focus-visible, select:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[data-theme="dark"] input[type="date"] { color-scheme: dark; }

button {
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
[data-theme="dark"] button { color: #12111d; }
button:hover { background: var(--accent-hover); }

button.ghost {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 9px 14px;
    white-space: nowrap;
}
button.ghost:hover { background: var(--line); }

.chart-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
#donut { width: 150px; height: 150px; flex-shrink: 0; }
#donut circle { transition: stroke-dasharray 0.4s; }
.donut-total { fill: var(--ink); font-size: 11px; font-weight: 800; }
.donut-sub { fill: var(--muted); font-size: 6px; }

#legend { list-style: none; flex: 1; min-width: 140px; font-size: 13px; }
#legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
#legend .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
#legend .pct { margin-left: auto; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }

#transaction-list { list-style: none; }
#transaction-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}
#transaction-list li:last-child { border-bottom: none; }

.badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 15px;
    color: #fff;
}

.transaction-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.transaction-info strong { display: block; font-size: 14px; }
.transaction-info small { color: var(--muted); font-size: 12px; }
.transaction-amount { font-weight: 800; white-space: nowrap; font-size: 14px; }
.transaction-amount.income { color: var(--income); }
.transaction-amount.expense { color: var(--expense); }

.delete-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 6px 10px;
    font-size: 12px;
}
[data-theme="dark"] .delete-btn { color: var(--muted); }
.delete-btn:hover { background: var(--expense); color: #fff; border-color: var(--expense); }

@media (max-width: 640px) {
    .hero { grid-template-columns: 1fr; padding: 22px; }
    .hero h2 { font-size: 32px; }
    .grid { grid-template-columns: 1fr; }
    header h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* Pencarian, export, dan edit */
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.panel-head h2 { margin-bottom: 0; }

.tools { display: flex; gap: 8px; flex: 1; justify-content: flex-end; min-width: 220px; }
.tools input { max-width: 220px; padding: 9px 12px; }

.edit-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--line);
    padding: 6px 10px;
    font-size: 12px;
}
[data-theme="dark"] .edit-btn { color: var(--accent); }
.edit-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .edit-btn:hover { color: #12111d; }

@media (max-width: 640px) {
    .tools { justify-content: stretch; }
    .tools input { max-width: none; flex: 1; }
}