:root {
  --navy: #0b1f4b;
  --navy-2: #13295e;
  --navy-3: #1d3a7a;
  --orange: #ff7a1a;
  --orange-2: #ff9a4d;
  --orange-soft: #fff1e6;
  --white: #ffffff;
  --bg: #f4f6fb;
  --text: #0f1a33;
  --muted: #6b7690;
  --line: #e4e8f1;
  --green: #12a150;
  --red: #e5484d;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(11, 31, 75, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
h1, h2, h3 { margin: 0; }

/* ---------- Buttons & form ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
  cursor: pointer; transition: transform .1s, box-shadow .2s, background .2s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 6px 16px rgba(255, 122, 26, .35); }
.btn-primary:hover { background: #ff6a00; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; opacity: .85; }
.btn-ghost:hover { opacity: 1; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 14px; color: var(--navy); }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 11px 14px; font: inherit;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
  outline: none; transition: border .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(255, 122, 26, .15); }
.form-error { color: var(--red); min-height: 18px; margin: 0 0 8px; font-size: 13px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: flex-end;
  padding: 24px 8vw; position: relative;
  background: url('/login-bg.jpg') center 20% / cover no-repeat;
}
.login-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(11, 31, 75, 0) 0%, rgba(11, 31, 75, .2) 45%, rgba(11, 31, 75, .7) 100%);
}
.login-card {
  position: relative; width: 100%; max-width: 400px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, .08) 100%);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, .28); border-top: 4px solid var(--orange);
  border-radius: 24px; padding: 36px 32px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
  color: #fff;
}
.login-card h1 { color: #fff; font-size: 28px; line-height: 1.15; margin: 14px 0 6px; text-shadow: 0 2px 10px rgba(0,0,0,.25); }
.login-card h1 span { color: var(--orange-2); font-size: 18px; font-weight: 600; }
.login-card .muted { margin-bottom: 20px; color: rgba(255, 255, 255, .8); }
.login-card label { color: #fff; }
.login-card input {
  background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff;
}
.login-card input::placeholder { color: rgba(255, 255, 255, .6); }
.login-card input:focus { background: rgba(255, 255, 255, .2); border-color: var(--orange); }
.login-card input:-webkit-autofill { -webkit-text-fill-color: #fff; transition: background-color 9999s; }
.login-card .form-error { color: #ffb4b4; }
.login-card .brand-mark { background: var(--orange); color: #fff; box-shadow: 0 8px 20px rgba(255, 122, 26, .4); }
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px; background: var(--navy); color: var(--orange);
  display: grid; place-items: center; font-weight: 700; font-size: 20px; letter-spacing: 1px;
}
.brand-mark.small { width: 42px; height: 42px; font-size: 16px; background: var(--orange); color: #fff; }
.tabs { display: flex; background: rgba(255, 255, 255, .12); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tab {
  flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font: inherit;
  font-weight: 600; color: rgba(255, 255, 255, .75); cursor: pointer;
}
.tab.active { background: var(--navy); color: #fff; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--navy); color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand strong { display: block; font-size: 17px; }
.sidebar-brand small { color: var(--orange-2); font-size: 11px; }
.menu { flex: 1; overflow-y: auto; padding: 18px 0; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; margin-bottom: 4px;
  color: rgba(255,255,255,.78); text-decoration: none; border-radius: 10px; font: inherit; font-weight: 500;
  background: transparent; border: 0; cursor: pointer; text-align: left; transition: background .2s, color .2s;
}
.menu-item:hover { background: var(--navy-2); color: #fff; }
.menu-item.active { background: var(--orange); color: #fff; box-shadow: 0 6px 16px rgba(255,122,26,.35); }
.menu-item .ico { width: 22px; text-align: center; }
.caret { margin-left: auto; transition: transform .2s; }
.menu-group:not(.open) .caret { transform: rotate(-90deg); }
.submenu { overflow: hidden; max-height: 0; transition: max-height .3s ease; padding-left: 14px; }
.submenu.open { max-height: 400px; }
.submenu .menu-item { font-size: 13px; padding: 9px 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 0 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--orange); display: grid; place-items: center;
  font-weight: 700; text-transform: uppercase;
}
.sidebar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }

.main { flex: 1; min-width: 0; padding: 24px 32px 40px; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar h2 { color: var(--navy); font-size: 24px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.month-picker { width: auto; margin: 0; padding: 9px 12px; }
.hamburger { display: none; border: 0; background: var(--navy); color: #fff; width: 40px; height: 40px; border-radius: 10px; font-size: 18px; cursor: pointer; }
.backdrop { display: none; }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.two-col { grid-template-columns: 1.1fr 1fr; margin-bottom: 18px; }
.card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { font-size: 15px; color: var(--navy); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 .sub { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }

.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 6px; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi .kpi-ico { position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; }
.kpi.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%); }
.kpi.hero .label, .kpi.hero .hint { color: rgba(255,255,255,.7); }
.kpi.hero .value { color: #fff; }
.kpi.hero .kpi-ico { background: rgba(255,255,255,.12); }
.kpi.accent { background: linear-gradient(135deg, var(--orange) 0%, #ffa45c 100%); }
.kpi.accent .label, .kpi.accent .hint { color: rgba(255,255,255,.85); }
.kpi.accent .value { color: #fff; }
.kpi.accent .kpi-ico { background: rgba(255,255,255,.2); }
.ico-soft { background: var(--orange-soft); }
.pos { color: var(--green) !important; }
.neg { color: var(--red) !important; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 190px; height: 190px; flex-shrink: 0; }
.legend { flex: 1; min-width: 180px; list-style: none; padding: 0; margin: 0; }
.legend li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.legend li:last-child { border: 0; }
.legend .amt { margin-left: auto; font-weight: 600; color: var(--navy); }
.legend .pct { width: 42px; text-align: right; color: var(--muted); font-size: 12px; }

/* Bars */
.bars { width: 100%; height: 220px; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Budget progress */
.progress-item { margin-bottom: 16px; }
.progress-item:last-child { margin-bottom: 0; }
.progress-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.progress-head .right { margin-left: auto; color: var(--muted); font-size: 12px; }
.progress { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; transition: width .6s ease; }
.over { color: var(--red); font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; border-bottom: 2px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #fafbfe; }
td.amt { font-weight: 600; text-align: right; white-space: nowrap; }
th.amt { text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--bg); white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.icon-btn { border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; margin-left: 4px; }
.icon-btn:hover { background: var(--orange-soft); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Category hero */
.cat-hero {
  border-radius: var(--radius); padding: 22px 24px; color: #fff; margin-bottom: 18px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%); position: relative; overflow: hidden;
}
.cat-hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: var(--orange); opacity: .18; }
.cat-hero .big { font-size: 28px; font-weight: 700; }
.cat-hero .muted { color: rgba(255,255,255,.7); }
.cat-hero .stat { min-width: 150px; }
.cat-hero .emoji { font-size: 36px; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.12); }

/* Budget form */
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.budget-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; }
.budget-card .head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.budget-card small { color: var(--muted); display: block; margin-bottom: 8px; }
.budget-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.tip { background: var(--orange-soft); border-left: 4px solid var(--orange); padding: 12px 14px; border-radius: 10px; margin-bottom: 18px; font-size: 13px; color: var(--navy); }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(11, 31, 75, .55); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(3px); }
.modal-card { background: #fff; border-radius: 20px; padding: 26px; width: 100%; max-width: 440px; border-top: 5px solid var(--orange); }
.modal-card h3 { color: var(--navy); margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal .btn-ghost { color: var(--navy); }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; border-left: 4px solid var(--orange); box-shadow: var(--shadow); z-index: 60; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
  .hamburger { display: block; }
  .main { padding: 16px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .month-picker { flex: 1; }
  .login-view { justify-content: center; align-items: flex-end; padding: 45vh 16px 16px; background-position: 40% top; background-size: cover; background-color: var(--navy); }
  .login-card { padding: 26px 22px; }
  .login-card h1 { font-size: 24px; }
  .login-overlay { background: linear-gradient(180deg, rgba(11,31,75,0) 0%, rgba(11,31,75,0) 30%, rgba(11,31,75,1) 64%); }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
}

/* ---------- Install (PWA) ---------- */
.btn-install {
  margin-top: 12px; background: rgba(255, 255, 255, .12); color: #fff;
  border: 1px dashed rgba(255, 255, 255, .45);
}
.btn-install:hover { background: rgba(255, 255, 255, .2); }
.sidebar .btn-install { margin: 0 0 10px; }
.ios-steps { padding-left: 20px; margin: 0 0 18px; line-height: 1.7; color: var(--text); }
/* Saat dibuka sebagai aplikasi terinstall, beri ruang untuk status bar iPhone */
@media (display-mode: standalone) {
  .main { padding-top: max(24px, env(safe-area-inset-top)); }
  .sidebar { padding-top: max(22px, env(safe-area-inset-top)); }
}
