:root {
    --navy: #0d1642;
    --navy-2: #131c4f;
    --coral: #ea5040;
    --coral-dark: #d6402f;
    --blue: #2f7fe0;
    --teal: #26c6a2;
    --purple: #7c4dff;
    --ink: #1f2333;
    --muted: #8991a8;
    --line: #eef0f6;
    --card: #ffffff;
    --bg: #f2f4fa;
    --radius-lg: 26px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --shadow: 0 12px 30px -12px rgba(13, 22, 66, 0.25);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--navy);
    color: var(--ink);
    min-height: 100vh;
}

h1, h2, h3, h4, .heading {
    font-family: 'Poppins', 'Inter', sans-serif;
    margin: 0;
}

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

button { font-family: inherit; cursor: pointer; }

/* ---------- Auth screen ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 15%, #1a2568 0%, var(--navy) 55%);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 36px 30px;
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--coral);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 18px;
}

.auth-card h1 {
    font-size: 22px;
    color: var(--navy);
    margin-bottom: 6px;
}

.auth-card p.sub {
    color: var(--muted);
    font-size: 13.5px;
    margin-bottom: 26px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    font-size: 14.5px;
    background: #fafbfe;
    color: var(--ink);
    outline: none;
    transition: border-color .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--coral);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 14.5px;
    font-weight: 600;
    width: 100%;
}

.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { background: var(--coral-dark); }
.btn-outline { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-block { width: 100%; }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; }

.auth-hint {
    margin-top: 20px;
    background: #fbeeec;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 12.5px;
    color: #9a4636;
    line-height: 1.5;
}

/* ---------- App shell (phone-style container) ---------- */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    padding-bottom: 86px;
}

.app-header {
    background: var(--coral);
    color: #fff;
    padding: 20px 20px 46px;
    border-radius: 0 0 28px 28px;
    position: relative;
}

.app-header .top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.app-header .greeting {
    font-size: 12.5px;
    opacity: .85;
}

.app-header h1 {
    font-size: 19px;
    font-weight: 600;
}

.app-header .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.saldo-box {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.saldo-box .item .label {
    font-size: 11.5px;
    opacity: .8;
    margin-bottom: 4px;
}

.saldo-box .item .value {
    font-size: 16px;
    font-weight: 700;
}

.saldo-box .item.total .value { font-size: 20px; }

.content {
    padding: 0 18px;
    margin-top: -30px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title small {
    font-weight: 500;
    font-size: 12px;
    color: var(--muted);
}

/* ---------- Donut chart + legend ---------- */
.donut-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    position: relative;
}

.donut-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center .amt { font-size: 15px; font-weight: 700; color: var(--navy); }
.donut-center .lbl { font-size: 10.5px; color: var(--muted); }

.legend-list { display: flex; flex-direction: column; gap: 10px; }

.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.legend-dot {
    width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}

.legend-pct {
    background: #eef0f6;
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    min-width: 40px;
    text-align: center;
}

.legend-name { flex: 1; color: var(--ink); }
.legend-amt { color: var(--muted); font-size: 12.5px; }

.empty-note {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 20px 0;
}

/* ---------- Transaction list ---------- */
.trx-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

.trx-row:last-child { border-bottom: none; }

.trx-icon {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.trx-info { flex: 1; min-width: 0; }
.trx-info .cat { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.trx-info .ket { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.trx-amt { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.trx-amt.masuk { color: var(--blue); }
.trx-amt.keluar { color: var(--coral); }

.trx-actions { display: flex; gap: 6px; }
.icon-btn {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: none;
    background: #f1f3f9;
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.icon-btn.danger { color: var(--coral); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgba(13,22,66,.08);
    z-index: 50;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    color: var(--muted);
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

.nav-item .ic { font-size: 18px; }
.nav-item.active { color: var(--coral); }

/* ---------- FAB ---------- */
.fab {
    position: fixed;
    bottom: 84px;
    left: 50%;
    transform: translateX(calc(-50% + 190px));
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--coral);
    color: #fff;
    font-size: 26px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 20px -6px rgba(234,80,64,.6);
    border: none;
    z-index: 60;
}

/* ---------- Page top bar (inner pages) ---------- */
.page-topbar {
    background: var(--coral);
    color: #fff;
    padding: 18px 18px 16px;
    border-radius: 0 0 22px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.page-topbar .back {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}

.page-topbar h1 { font-size: 17px; font-weight: 600; }

/* ---------- Tabs (Harian/Mingguan/Bulanan/Tahunan) ---------- */
.tabs {
    display: flex;
    background: rgba(255,255,255,.16);
    border-radius: 12px;
    padding: 4px;
    margin-top: 12px;
}

.tabs a {
    flex: 1;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    opacity: .75;
    padding: 8px 4px;
    border-radius: 9px;
}

.tabs a.active {
    background: #fff;
    color: var(--coral);
    opacity: 1;
}

.period-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 14px 0 10px;
    padding: 0 2px;
}

.period-nav .cur {
    font-weight: 600;
    font-size: 14px;
    color: var(--navy);
}

.period-nav a {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: #fff;
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    color: var(--navy);
}

.summary-strip {
    display: flex;
    background: var(--card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.summary-strip .col {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    border-right: 1px solid var(--line);
}
.summary-strip .col:last-child { border-right: none; }
.summary-strip .col .lbl { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.summary-strip .col .val { font-size: 13.5px; font-weight: 700; }
.summary-strip .col .val.masuk { color: var(--blue); }
.summary-strip .col .val.keluar { color: var(--coral); }
.summary-strip .col .val.saldo { color: var(--navy); }

.day-group { margin-bottom: 14px; }

.day-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 6px;
}

.day-badge {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: #eef0f6;
    color: var(--navy);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    line-height: 1.1;
    flex-shrink: 0;
}
.day-badge .num { font-size: 15px; font-weight: 700; }
.day-badge .mon { font-size: 8.5px; text-transform: uppercase; color: var(--muted); }

.day-head .dname { flex: 1; font-size: 13px; font-weight: 600; color: var(--ink); }
.day-head .dsum { text-align: right; font-size: 12px; }
.day-head .dsum span { display: block; }

.table-simple { width: 100%; border-collapse: collapse; }
.table-simple th, .table-simple td {
    text-align: left;
    padding: 10px 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}
.table-simple th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; }
.table-simple td.num { text-align: right; font-weight: 600; }

/* ---------- Category chip list (manage kategori) ---------- */
.chip-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.chip-dot { width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.chip-row .cname { flex: 1; font-size: 13.5px; font-weight: 600; }
.chip-row .ctype { font-size: 11px; padding: 3px 8px; border-radius: 8px; font-weight: 700; }
.ctype.masuk { background: #e7f1fd; color: var(--blue); }
.ctype.keluar { background: #fbeae8; color: var(--coral); }

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}
.alert-success { background: #e6f7f1; color: #1c8a63; }
.alert-error { background: #fbeae8; color: #b3392a; }

/* ---------- Misc ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.section-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 22px 0 10px;
}
.section-label:first-child { margin-top: 0; }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}
.toggle-row .t-label { font-size: 13.5px; font-weight: 600; }
.toggle-row .t-desc { font-size: 11.5px; color: var(--muted); }

.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #d9dce6; border-radius: 24px; transition: .2s;
}
.slider:before {
    content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
input:checked + .slider { background: var(--coral); }
input:checked + .slider:before { transform: translateX(18px); }

.badge-role {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 8px;
    background: rgba(255,255,255,.2);
    margin-top: 4px;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #c9cee0; border-radius: 4px; }

@media (max-width: 400px) {
    .fab { transform: translateX(calc(-50% + 42vw)); }
}
