/* Personal Finance App: design tokens + core components.
   Source of truth: PERSONAL_FINANCE_APP_SPEC.md §29, §31, §32. Light mode only (§22.6).
   No inline styles anywhere in templates: CSP is style-src 'self'. */

@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* colors §29.1 */
  --lime: #C4E861;
  --lime-dark: #ADCF53;
  --lime-soft: #EAF7C7;
  --black: #111213;
  --white: #FFFFFF;
  --background: #F3F5F1;
  --surface: #FFFFFF;
  --surface-soft: #F7F9F4;
  --text-primary: #111213;
  --text-secondary: #656965;
  --text-muted: #92968F;
  --border: #DDE2D8;
  --success: #3E7C3D;
  --danger: #D95050;
  --warning: #C98628;

  /* category donut ranking: darkest = largest category, by rank not by category identity */
  --slice-1: #5E7326;
  --slice-2: #8AA43C;
  --slice-3: #ADCF53;
  --slice-4: #C4E861;
  --slice-5: #D8EF8E;
  --slice-6: #EAF7C7;
  --slice-other: #C6CCBF;

  /* spacing §29.3: only these */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  /* radius §29.4 */
  --r-sm: 10px;
  --r-input: 14px;
  --r-btn: 14px;
  --r-card: 20px;
  --r-card-lg: 24px;
  --r-sheet: 28px;
  --r-pill: 999px;

  /* shadow §29.5: floating elements only */
  --shadow-float: 0 6px 24px rgba(17, 18, 19, 0.08);

  /* interaction §29.6 */
  --focus-ring: 2px solid var(--black);
  --focus-offset: 2px;
  --dur: 150ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --z-nav: 10;
  --z-savebar: 9;
  --z-toast: 30;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: calc(64px + var(--safe-bottom));

  --font: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font: 400 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

:where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* icons: Iconoir Regular inlined, currentColor §30 */
.i {
  width: 20px;
  height: 20px;
  flex: none;
  display: block;
}
.i-16 { width: 16px; height: 16px; }
.i-24 { width: 24px; height: 24px; }
.i-28 { width: 28px; height: 28px; }
.i-32 { width: 32px; height: 32px; }

/* layout §29.9: mobile first, centered on wide screens */
.app {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--background);
}
.main {
  flex: 1;
  padding: var(--s5) var(--s5) var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.grow { flex: 1; min-width: 0; }

/* typography §29.2 */
.value-xl { font-size: 32px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.title { font-size: 24px; font-weight: 600; line-height: 1.2; margin: 0; }
.section-title { font-size: 18px; font-weight: 600; line-height: 1.3; margin: 0; }
.body-strong { font-size: 15px; font-weight: 600; }
.small { font-size: 13px; }
.caption { font-size: 12px; }
.muted { color: var(--text-secondary); }
.label-caps { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }

/* cards §29.4-29.5: border, no shadow */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s4);
}
.card-lg { border-radius: var(--r-card-lg); padding: var(--s5); }

.icon-badge {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--lime-soft);
  color: var(--black);
}

/* SummaryCard / MetricCard */
.summary { display: flex; flex-direction: column; gap: var(--s4); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.metric { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.metric-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* buttons §29.4 */
.btn {
  min-height: 52px;
  padding: 0 var(--s5);
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--lime); color: var(--black); }
.btn-primary:hover { background: var(--lime-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--surface-soft); }
.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-block { width: 100%; }
.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}
.btn-icon { width: 44px; min-height: 44px; padding: 0; }

/* fields §32: labels always visible */
.field { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.input {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  background: var(--surface);
  font-size: 15px;
  transition: border-color var(--dur) var(--ease);
}
.input::placeholder { color: var(--text-muted); }
.input:focus-visible { border-color: var(--black); outline-offset: 0; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled { background: var(--surface-soft); color: var(--text-muted); }
textarea.input { padding-block: var(--s3); min-height: 84px; resize: vertical; }
.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  font-size: 13px;
  color: var(--danger);
}
.field-error .i { margin-top: 1px; }

/* MoneyInput: numeric keyboard, big value */
.money {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
}
.money-prefix { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.money-input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.money-input::placeholder { color: var(--text-muted); }
.money-input:focus-visible { outline: none; }
.money-card:focus-within { border-color: var(--black); }

/* SegmentedControl: selected = lime + black edge, not color alone */
.seg {
  display: flex;
  gap: var(--s1);
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
}
.seg-btn {
  flex: 1;
  min-height: 44px;
  padding: 0 var(--s2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.seg-btn[aria-pressed="true"] { background: var(--lime); border-color: var(--black); color: var(--black); }

/* Wrapping variant for a segmented control with too many/long options for one row
   (e.g. the 5-way expense group picker) — plain .seg forces a horizontal overflow instead. */
.seg-wrap { flex-wrap: wrap; }
.seg-wrap .seg-btn { flex: 1 1 30%; }

/* CategoryPicker */
.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.cat {
  min-height: 76px;
  padding: var(--s2) 2px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.cat[aria-pressed="true"] { background: var(--lime-soft); border-color: var(--black); font-weight: 600; }

@media (max-width: 380px) {
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* IconPicker: category icon choice, icon-only (spec §11.3 "re-icon") */
.icon-group { display: flex; flex-direction: column; gap: var(--s1); }
.icon-group-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.icon-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s1); }
.icon-choice {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
}
.choice-input:checked + .icon-choice { background: var(--lime-soft); border-color: var(--black); }
.choice-input:focus-visible + .icon-choice { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

@media (max-width: 380px) {
  .icon-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* AccountPicker / chips */
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s1); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  min-height: 44px;
  padding: 0 var(--s4);
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 15px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--lime-soft); border-color: var(--black); font-weight: 600; }

/* disclosure: "Opsi lain" */
.more > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.more > summary::-webkit-details-marker { display: none; }
.more[open] > summary .i { transform: rotate(180deg); }
.more-body { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s2); }

/* TransactionRow */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--border); }
.tx { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) 0; }
.tx-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.tx-sub { font-size: 12px; color: var(--text-secondary); }
.tx-amount { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amount.income { color: var(--success); }

/* institution group */
.inst-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.inst-total { font-size: 15px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.acct { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) 0; }

/* notices: never color alone, always an icon */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--warning);
  border-radius: var(--r-input);
  background: var(--surface);
  font-size: 13px;
}
.notice .i { color: var(--warning); margin-top: 1px; }
.notice-actions { display: flex; gap: var(--s2); margin-top: var(--s2); }
.btn-sm { min-height: 44px; padding: 0 var(--s4); font-size: 13px; }

/* EmptyState §34 */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s8) var(--s4); text-align: center; }
.empty .icon-badge { width: 56px; height: 56px; border-radius: var(--r-card); }

/* Toast: floating, only element with shadow */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--s4));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  width: calc(100% - 2 * var(--s5));
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-btn);
  background: var(--black);
  color: var(--white);
  font-size: 15px;
  box-shadow: var(--shadow-float);
}
.toast[hidden] { display: none; }

/* save bar sits above the nav */
.savebar {
  position: sticky;
  bottom: var(--nav-h);
  z-index: var(--z-savebar);
  padding: var(--s3) var(--s5);
  background: var(--background);
  border-top: 1px solid var(--border);
}

/* BottomNavigation §6: icons only, 5 items */
.nav {
  position: sticky;
  bottom: 0;
  z-index: var(--z-nav);
  height: var(--nav-h);
  padding: var(--s2) var(--s3) calc(var(--s2) + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  gap: var(--s1);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav-item {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--r-input);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--dur) var(--ease);
}
.nav-item[aria-current="page"] { background: var(--lime-soft); color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.nav-add { background: var(--lime); color: var(--black); border-radius: var(--r-pill); }
.nav-add[aria-current="page"] { background: var(--lime); box-shadow: inset 0 0 0 1.5px var(--black); }

/* auth screen */
.auth { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: var(--s6); padding: var(--s6) var(--s5); }
.brand-mark { width: 56px; height: 56px; display: grid; place-items: center; border-radius: var(--r-card); background: var(--lime); }

/* ---- T1 web extensions (tokens only) ---- */

/* form flow inside .main: same rhythm as sibling sections */
.form-stack { display: flex; flex-direction: column; gap: var(--s6); }

/* Radio-backed choices work without JS: a visually hidden <input type="radio"> followed by
   its <label class="seg-btn|cat|chip">. :checked mirrors aria-pressed="true" styling. */
.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.choice-input:checked + .seg-btn { background: var(--lime); border-color: var(--black); color: var(--black); }
.choice-input:checked + .cat { background: var(--lime-soft); border-color: var(--black); font-weight: 600; }
.choice-input:checked + .chip { background: var(--lime-soft); border-color: var(--black); font-weight: 600; }
.choice-input:focus-visible + .seg-btn,
.choice-input:focus-visible + .cat,
.choice-input:focus-visible + .chip { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

/* ---- T2 web extensions (tokens only) ---- */
:root { --z-sheet: 20; }

/* icon-only SegmentedControl (jenis transaksi): every button needs aria-label + title */
.seg-icons .seg-btn { min-height: 62px; padding: var(--s2) 0; flex-direction: column; gap: 2px; }
.seg-label { font-size: 11px; font-weight: 600; line-height: 1.2; }

.chips-wrap { flex-wrap: wrap; overflow: visible; }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-badge { position: relative; }
.btn-count {
  position: absolute;
  top: calc(-1 * var(--s1));
  right: calc(-1 * var(--s1));
  min-width: 20px;
  height: 20px;
  padding: 0 var(--s1);
  display: grid;
  place-items: center;
  border: 1px solid var(--black);
  border-radius: var(--r-pill);
  background: var(--lime);
  color: var(--black);
  font-size: 12px;
  font-weight: 600;
}

/* search + filter row */
.toolbar { display: flex; gap: var(--s2); }
.search { position: relative; flex: 1; min-width: 0; }
.search .i { position: absolute; left: var(--s4); top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search .input { padding-left: var(--s10); }

/* tappable rows: TransactionRow and account row as <button> */
.row-btn { width: 100%; border: 0; background: none; padding: var(--s2) 0; color: inherit; text-align: left; cursor: pointer; }
.tx-side { display: flex; flex-direction: column; align-items: flex-end; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 0 var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}
.tag-warn { border-color: var(--warning); color: var(--text-primary); }
.tag-warn .i { color: var(--warning); }

/* BottomSheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-sheet) - 1); background: rgba(17, 18, 19, 0.4); }
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: var(--z-sheet);
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-float);
}
.sheet-handle { width: 40px; height: 4px; margin: var(--s2) auto 0; border-radius: var(--r-pill); background: var(--border); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s2) 0 var(--s5); }
.sheet-body { overflow-y: auto; padding: var(--s3) var(--s5) calc(var(--s6) + var(--safe-bottom)); display: flex; flex-direction: column; gap: var(--s5); }

.sheet-actions { position: sticky; bottom: 0; display: flex; gap: var(--s2); padding-top: var(--s3); background: var(--surface); }

/* key/value rows in transaction detail */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); min-height: 44px; padding: var(--s2) 0; }
.kv-row + .kv-row { border-top: 1px solid var(--border); }
.kv-k { flex: none; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.kv-v { min-width: 0; font-size: 15px; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv-v.income { color: var(--success); }

/* split editor */
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: var(--s2); align-items: center; }
.split-row > .btn { grid-column: 2; grid-row: 1 / span 2; }
.split-row + .split-row { padding-top: var(--s3); border-top: 1px solid var(--border); }
.stack-sm > .tag { align-self: flex-start; }
.split-rest { display: flex; align-items: center; gap: var(--s2); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.split-rest.ok { color: var(--success); }
.split-rest.bad { color: var(--danger); }

/* reconciliation difference */
.diff { display: flex; align-items: center; gap: var(--s2); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.diff.pos { color: var(--success); }
.diff.neg { color: var(--danger); }

.toast-btn { flex: none; min-height: 44px; padding: 0 var(--s3); border: 0; background: none; color: var(--lime); font-size: 15px; font-weight: 600; cursor: pointer; }

/* ---- T2 server-rendered additions (tokens only) ---- */

/* visually hidden but focusable-by-script: the implicit-submit default button of a form */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* links styled as seg buttons, chips and rows keep the control look, not the link look */
a.seg-btn,
a.chip,
a.row-btn { color: inherit; text-decoration: none; }
a.seg-btn { color: var(--text-secondary); }
.seg-btn[aria-current="true"] { background: var(--lime); border-color: var(--black); color: var(--black); }
.chip[aria-current="true"] { background: var(--lime-soft); border-color: var(--black); font-weight: 600; }
.seg-btn:disabled { color: var(--text-muted); cursor: not-allowed; }
.seg-btn:disabled[aria-pressed="true"] { color: var(--black); }

.filter-form { display: flex; flex-direction: column; gap: var(--s5); }
.toast form { margin: 0; }
.kv-v .btn-ghost { min-height: 44px; padding: 0 var(--s2); }
.tx > form { margin: 0; }
.acct .grow > .tag { margin-top: var(--s1); }
.main .sheet-actions { position: static; padding-top: 0; background: none; }

/* ---- T3: Beranda metrics, Laporan, Transaksi Berulang (tokens only; charts are server-rendered SVG, no inline styles) ---- */

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.month-nav .title, .month-nav .section-title { text-align: center; flex: 1; }

.metrics-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.metric-value.income { color: var(--success); }
.metric-value.danger { color: var(--danger); }
.hero-rule { border: 0; border-top: 1px solid var(--border); margin: 0; }

html.privacy [data-mask] { position: relative; color: transparent; }
html.privacy [data-mask]::after { content: "••••••"; position: absolute; inset: 0; color: var(--text-primary); }

.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-line { fill: none; stroke: var(--black); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-ref { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-target { fill: none; stroke: var(--warning); stroke-width: 1.5; stroke-dasharray: 2 4; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-area { fill: var(--lime-soft); stroke: none; }
.chart-dot { fill: var(--lime); stroke: var(--black); stroke-width: 2; }
.chart-dot[data-chart-point] { cursor: pointer; }
.chart-dot[data-chart-point]:focus, .chart-dot.selected { outline: none; stroke-width: 3; }
.chart-detail { flex-basis: 100%; color: var(--text-primary); font-size: 14px; font-weight: 600; }
.chart-label { font-family: var(--font); font-size: 11px; fill: var(--text-secondary); }
.chart-bar { fill: var(--lime-dark); }
.chart-bar-now { fill: var(--lime); stroke: var(--black); stroke-width: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 12px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: var(--s2); }
.legend-swatch { width: 16px; height: 0; border-top: 2px solid var(--black); }
.legend-swatch.ref { border-top: 2px dashed var(--text-muted); }
.legend-swatch.target { border-top: 2px dotted var(--warning); }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s1) var(--s3); align-items: baseline; }
.bar-row + .bar-row { margin-top: var(--s3); }
.bar-name { font-size: 15px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.bar-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { grid-column: 1 / -1; display: block; width: 100%; height: 8px; }
.bar-bg { fill: var(--surface-soft); stroke: var(--border); stroke-width: 1; }
.bar-fill { fill: var(--lime-dark); }
.bar-fill.warn { fill: var(--warning); }
.bar-sub { grid-column: 1 / -1; font-size: 12px; color: var(--text-secondary); }

.delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.delta.up { color: var(--danger); }
.delta.down { color: var(--success); }

/* category donut: color is assigned by rank (.slice-1 = largest), not per category */
.slice-1 { fill: var(--slice-1); background: var(--slice-1); }
.slice-2 { fill: var(--slice-2); background: var(--slice-2); }
.slice-3 { fill: var(--slice-3); background: var(--slice-3); }
.slice-4 { fill: var(--slice-4); background: var(--slice-4); }
.slice-5 { fill: var(--slice-5); background: var(--slice-5); }
.slice-6 { fill: var(--slice-6); background: var(--slice-6); }
.slice-other { fill: var(--slice-other); background: var(--slice-other); }

.donut-wrap { display: flex; justify-content: center; padding: var(--s2) 0 var(--s4); }
.donut { width: 190px; height: 190px; overflow: visible; }
.donut [data-donut-slice] { cursor: pointer; transition: opacity var(--dur) var(--ease); }
.donut.has-selected [data-donut-slice]:not(.selected) { opacity: 0.35; }
.donut-center { font-family: var(--font); pointer-events: none; }
.donut-total { font-size: 19px; font-weight: 600; fill: var(--text-primary); font-variant-numeric: tabular-nums; }
.donut-label { font-size: 11px; fill: var(--text-secondary); }
@media (max-width: 400px) { .donut { width: 170px; height: 170px; } }

.cat-row {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 0 var(--s3); align-items: baseline;
  width: 100%; background: none; border: none; padding: var(--s2); margin: 0 calc(var(--s2) * -1);
  border-radius: var(--r-sm); font: inherit; color: inherit; text-align: left; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.cat-row + .cat-row { margin-top: var(--s2); }
.cat-row:hover { background: var(--surface-soft); }
.cat-row.selected { background: var(--lime-soft); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.cat-name { font-size: 15px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.cat-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-sub { grid-column: 2 / -1; font-size: 12px; color: var(--text-secondary); }

.headline { font-size: 18px; font-weight: 600; line-height: 1.3; }
.nodata { display: flex; align-items: center; gap: var(--s2); font-size: 15px; font-weight: 600; color: var(--text-secondary); }

.group-head { font-size: 13px; font-weight: 600; color: var(--text-secondary); padding-top: var(--s2); }
.group-head.warn { color: var(--danger); }
.day-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s1) var(--s3); }
.day-totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s1) var(--s3); font-size: 12px; font-weight: 600; }
.day-total.expense { color: var(--danger); }
.day-total.income { color: var(--success); }
.day-total.invest { color: var(--text-secondary); }
.rx { display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: var(--s2) 0; }
.rx-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: center; }
.tag-ok { border-color: var(--success); color: var(--text-primary); }
.tag-ok .i { color: var(--success); }
.progress-line { display: flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--text-secondary); }
.reflect { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) 0; }
.reflect + .reflect { border-top: 1px solid var(--border); }
.reflect .chip { padding: 0 var(--s3); }
.menu-row { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) 0; width: 100%; text-align: left; }

/* A .menu-row whose row also needs its own interactive controls (e.g. Kategori's move
   buttons) can't be an <a> itself (nested interactive elements are invalid HTML); this class
   makes the icon+label portion behave like the old whole-row link inside a plain .menu-row. */
.menu-row-link { display: flex; align-items: center; gap: var(--s3); flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.menu-row-move { display: flex; gap: 2px; }
.menu-row-move .btn-icon { width: 36px; min-height: 36px; }

/* ---- T4: Data & Cadangan, Impor CSV, PWA strips (tokens only) ---- */

/* update / offline strips (server-rendered hidden, shown by app.js) */
.strip { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); font-size: 14px; }
.strip-update { background: var(--black); color: var(--white); }
.strip-offline { background: var(--surface); color: var(--text-primary); border-bottom: 1px solid var(--border); }
.strip-offline .i { color: var(--warning); }
.strip-btn { min-height: 44px; padding: 0 var(--s3); border: 0; background: none; color: var(--lime); font-size: 14px; font-weight: 600; cursor: pointer; }

.nav-gap { width: 44px; flex: none; }

.step-row { display: flex; gap: 6px; }
.step-row .tag { flex: 1; justify-content: center; }

.err-row { display: flex; gap: var(--s3); align-items: baseline; padding: var(--s2) 0; font-size: 13px; }
.err-row + .err-row { border-top: 1px solid var(--border); }
.err-row b { flex: none; min-width: 56px; }
.err-row span { min-width: 0; overflow-wrap: anywhere; }

.map-grid { display: grid; grid-template-columns: 1fr; gap: var(--s3); }

.csv { overflow-x: auto; }
.csv table { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.csv th, .csv td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.csv th { color: var(--text-secondary); font-weight: 600; }

.confirm-form { display: flex; flex-direction: column; gap: var(--s5); }
.empty .field { align-self: stretch; }
.empty .field > label { text-align: center; }
.input[type="file"] { padding: var(--s3) var(--s4); }
.input[type="file"]::file-selector-button {
  min-height: 36px;
  margin-right: var(--s3);
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
