:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #e2e6eb;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --chart-series: #2f6fed;
  --ok: #1f9d55;
  --ok-bg: #e3f5ea;
  --warn: #b97400;
  --warn-bg: #fdf1d8;
  --over: #d23f3f;
  --over-bg: #fbe4e4;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

/* Tema gelap: berlaku kalau user memilih "Gelap", atau "Otomatis" dan sistemnya gelap. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #232830;
    --text: #e8ebef;
    --muted: #96a1ae;
    --border: #2c323b;
    --accent: #6b9bff;
    --accent-contrast: #0d1117;
    --chart-series: #3987e5;
    --ok: #4cc77f;
    --ok-bg: #173324;
    --warn: #f0b545;
    --warn-bg: #3a2c10;
    --over: #ff6b6b;
    --over-bg: #3d1a1a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #111418;
  --surface: #1a1e24;
  --surface-2: #232830;
  --text: #e8ebef;
  --muted: #96a1ae;
  --border: #2c323b;
  --accent: #6b9bff;
  --accent-contrast: #0d1117;
  --chart-series: #3987e5;
  --ok: #4cc77f;
  --ok-bg: #173324;
  --warn: #f0b545;
  --warn-bg: #3a2c10;
  --over: #ff6b6b;
  --over-bg: #3d1a1a;
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: 96px;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}
h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}
h3 {
  font-size: 0.95rem;
  margin: 20px 0 8px;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.neg {
  color: var(--over);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
}
/* Logo, header, tombol tema, dan footer sengaja sama persis dengan homepage (home/style.css). */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.brand img {
  border-radius: 7px;
}
.tabs {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.tabs button {
  border: 0;
  background: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}
.tabs button:hover {
  background: var(--surface-2);
}
.tabs button[aria-current='page'] {
  color: var(--text);
  background: var(--surface-2);
  font-weight: 600;
}
body.is-setup .tabs,
body.is-setup .fab {
  display: none;
}

/* ---------- Cards & layout ---------- */

main {
  padding-top: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 {
  margin: 0;
}
.eyebrow {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.empty {
  color: var(--muted);
  text-align: center;
  padding: 16px 0;
  margin: 0;
}
.hint {
  text-align: center;
}
.row-end {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Period nav ---------- */

.period-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.period-label strong {
  font-size: 1.05rem;
}

/* ---------- Summary ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.summary .card {
  margin-bottom: 0;
}
.stat strong {
  display: block;
  font-size: 1.35rem;
  margin: 2px 0 6px;
  font-variant-numeric: tabular-nums;
}
.alerts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 0;
}
.summary + .cat-list,
.alerts + .cat-list {
  margin-top: 16px;
}

/* ---------- Progress & badges ---------- */

.bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  flex: 1;
  min-width: 60px;
}
.fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.3s;
}
.fill.status-ok {
  background: var(--ok);
}
.fill.status-warn {
  background: var(--warn);
}
.fill.status-over {
  background: var(--over);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.status-ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.status-warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge.status-over {
  background: var(--over-bg);
  color: var(--over);
}
.tag {
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
}

/* ---------- Category list (master–detail) ---------- */

.cat-list {
  padding: 8px;
}
.cat-head,
.cat-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) repeat(3, minmax(105px, 1fr)) minmax(220px, 1.8fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}
.cat-head {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cat + .cat {
  border-top: 1px solid var(--border);
}
.cat-row {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}
.cat-row:hover {
  background: var(--surface-2);
}
.cat-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chev {
  display: inline-block;
  color: var(--muted);
  transition: transform 0.15s;
}
.cat.is-open .chev {
  transform: rotate(90deg);
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cat-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pct {
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}
.cat-detail {
  margin: 0 12px 12px 32px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

/* ---------- Transaction table ---------- */

.tx-table {
  width: 100%;
  border-collapse: collapse;
}
.tx-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px;
}
.tx-table td {
  padding: 8px;
  border-top: 1px solid var(--border);
}
.tx-table .num {
  white-space: nowrap;
}
.tx-table .note {
  width: 100%;
}
.tx-table .actions {
  white-space: nowrap;
  text-align: right;
}

/* ---------- Buttons ---------- */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-2);
}
.btn-danger {
  background: none;
  color: var(--over);
  border-color: var(--over);
}
.btn-link {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.icon-btn.small {
  width: 30px;
  height: 30px;
  border: 0;
  background: none;
  color: var(--muted);
}
.icon-btn.small:hover {
  background: var(--surface);
  color: var(--text);
}
.icon-btn.danger:hover {
  color: var(--over);
}

.fab {
  position: fixed;
  right: max(16px, calc((100vw - 1080px) / 2 + 16px));
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}
.fab:hover {
  filter: brightness(1.08);
}

/* ---------- Forms ---------- */

input,
select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}
.field > span:first-child {
  font-weight: 600;
  font-size: 0.9rem;
}
#cutoff-day {
  width: 100px;
}

.input-affix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.input-affix:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.input-affix span {
  padding: 0 10px;
  color: var(--muted);
}
.input-affix input {
  border: 0;
  outline: none;
  flex: 1;
  width: 100%;
}
.input-affix.big input {
  font-size: 1.5rem;
  font-weight: 600;
  padding: 6px 10px 6px 0;
}

.cat-editor {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.editor-head,
.editor-row {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) 110px minmax(130px, 1.4fr) 100px 40px;
  gap: 8px;
  align-items: center;
}
.editor-head {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.editor-row .input-affix input[type='number'] {
  text-align: right;
}

.archived {
  margin: 0;
  padding-left: 18px;
}

/* ---------- Dialog ---------- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(460px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok);
}
.toast-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn);
  font-weight: 600;
}
.toast-over,
.toast-error {
  background: var(--over-bg);
  color: var(--over);
  border: 1px solid var(--over);
  font-weight: 600;
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  .summary {
    grid-template-columns: 1fr 1fr;
  }
  .summary .stat:nth-child(2) {
    grid-column: 1 / -1;
    order: -1;
  }
  .stat strong {
    font-size: 1.15rem;
  }
  .cat-head {
    display: none;
  }
  .cat-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 12px;
  }
  .cat-name,
  .cat-progress {
    grid-column: 1 / -1;
  }
  .cat-row .num {
    text-align: left;
    font-size: 0.9rem;
  }
  .cat-row .num::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--muted);
  }
  .cat-detail {
    margin-left: 12px;
    padding: 4px 8px;
  }
  .editor-head {
    display: none;
  }
  /* HP: nama + tombol hapus, lalu tipe + budget, lalu warning % (khusus Harian). */
  .editor-row {
    grid-template-columns: 1fr 1fr 40px;
    grid-template-areas:
      'name name del'
      'kind budget budget'
      'pct pct .';
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .editor-row .name-cell {
    grid-area: name;
  }
  .editor-row .kind-cell {
    grid-area: kind;
  }
  .editor-row .budget-cell {
    grid-area: budget;
  }
  .editor-row .pct-cell {
    grid-area: pct;
  }
  .editor-row .del-cell {
    grid-area: del;
  }
  .editor-row[data-kind='bill'] {
    grid-template-areas:
      'name name del'
      'kind budget budget';
  }
  .editor-row[data-kind='bill'] .pct-cell {
    display: none;
  }
  .tx-table th:first-child,
  .tx-table td:first-child {
    white-space: nowrap;
  }
  .card {
    padding: 16px;
  }
}

/* ---------- Theme ---------- */

.theme-toggle {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: none;
  color: var(--muted);
}
.theme-toggle:hover {
  color: var(--text);
}
.tabs + .theme-toggle {
  margin-left: 0;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 8px;
}
.segmented label {
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: block;
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
}
.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

@media (max-width: 720px) {
  .tabs {
    order: 3;
    width: 100%;
    margin-left: 0;
    padding-bottom: 8px;
  }
  .tabs + .theme-toggle {
    margin-left: auto;
  }
}

/* ---------- Footer ---------- */

.app-footer {
  border-top: 1px solid var(--border);
  margin-top: 24px;
  padding: 24px 0;
  font-size: 0.9rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toast:has(.toast-action) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.toast-action {
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
}

/* ---------- Setup contoh & validasi ---------- */

.setup-note {
  background: var(--warn-bg);
  color: var(--text);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 0.9rem;
}
.setup h2 .tag {
  vertical-align: middle;
  font-weight: 600;
}
.name-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.name-cell small {
  font-size: 0.75rem;
  padding-left: 2px;
}
.input-affix input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
input[aria-invalid='true'],
.input-affix:has(input[aria-invalid='true']) {
  border-color: var(--over);
  box-shadow: 0 0 0 1px var(--over);
}
.input-affix input[aria-invalid='true'] {
  box-shadow: none;
}

.import-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 16px 0 8px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Charts ---------- */

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.chart-card h2 {
  margin-bottom: 4px;
}
.chart-box {
  position: relative;
  margin-top: 12px;
}
.chart {
  display: block;
  overflow: visible;
}
.chart text {
  font-size: 12px;
  fill: var(--muted);
}
.chart .bar-label {
  font-size: 13px;
  fill: var(--text);
}
.chart .bar-value {
  font-variant-numeric: tabular-nums;
  fill: var(--muted);
}
.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}
.chart .axis {
  stroke: var(--muted);
  stroke-opacity: 0.5;
  stroke-width: 1;
}
.chart .tick {
  font-variant-numeric: tabular-nums;
}
.chart .bar {
  fill: var(--chart-series);
  transition: opacity 0.15s;
}
.chart .budget-tick {
  stroke: var(--text);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.7;
}
.chart .bar-row.is-muted .bar {
  fill: var(--muted);
  opacity: 0.35;
}
.chart .bar-row.is-muted .bar-label {
  fill: var(--muted);
}
.chart .hit {
  fill: transparent;
}
.chart .bar-row {
  outline: none;
  cursor: default;
}
.chart .bar-row:hover .hit,
.chart .bar-row:focus-visible .hit {
  fill: var(--surface-2);
}
.chart .line {
  fill: none;
  stroke: var(--chart-series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .area {
  fill: var(--chart-series);
  opacity: 0.1;
}
.chart .peak,
.chart .cursor {
  fill: var(--chart-series);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .peak-label {
  fill: var(--text);
  font-weight: 600;
}
.chart .crosshair {
  stroke: var(--muted);
  stroke-width: 1;
}
svg.chart:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--muted);
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.key-bar {
  width: 14px;
  height: 10px;
  border-radius: 0 3px 3px 0;
  background: var(--chart-series);
}
.key-tick {
  width: 2px;
  height: 14px;
  border-radius: 1px;
  background: var(--text);
  opacity: 0.7;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
  font-size: 0.8rem;
  line-height: 1.5;
}
.chart-tooltip-title {
  color: var(--muted);
  margin-bottom: 2px;
}
.chart-tooltip strong {
  color: var(--text);
}
.chart-tooltip span {
  color: var(--muted);
}

.chart-table {
  margin-top: 12px;
  font-size: 0.9rem;
}
.chart-table summary {
  cursor: pointer;
  color: var(--accent);
}

/* Tabel transaksi di layar kecil: kategori pindah ke bawah deskripsi supaya tabel tidak melebar. */
.cat-inline {
  display: none;
}
@media (max-width: 600px) {
  .tx-table .col-cat {
    display: none;
  }
  .cat-inline {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
  }
  .tx-table td,
  .tx-table th {
    padding: 8px 4px;
  }
  .tx-table .icon-btn.small {
    width: 28px;
  }
}

/* ---------- Sisa, laju belanja, backup ---------- */

.pos {
  color: var(--ok);
}
.per-day {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}
.bar-wrap {
  position: relative;
  display: block;
  flex: 1;
  min-width: 60px;
}
.bar-wrap .bar {
  width: 100%;
}
/* Garis tipis = posisi hari ini dalam periode. */
.pace-tick {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--text);
  opacity: 0.45;
}
.stat .bar-wrap {
  margin: 4px 0 6px;
}
.badge.pace-fast {
  background: transparent;
  color: var(--warn);
  box-shadow: inset 0 0 0 1px var(--warn);
}

.backup-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  border-left: 3px solid var(--warn);
  font-size: 0.9rem;
}
.backup-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* ---------- Perbandingan periode ---------- */

.chart .bar-prev {
  fill: var(--muted);
  opacity: 0.45;
}
.chart .bar-row.is-muted .bar-prev {
  opacity: 0.2;
}
.chart .delta {
  font-weight: 600;
}
.chart .delta-up {
  fill: var(--over);
}
.chart .delta-down {
  fill: var(--ok);
}
.key-prev {
  width: 14px;
  height: 7px;
  border-radius: 0 3px 3px 0;
  background: var(--muted);
  opacity: 0.45;
}

/* ---------- Pencarian & input cepat ---------- */

.search-input {
  flex: 1 1 220px;
  max-width: 320px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 14px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip:hover {
  background: var(--surface-2);
}

/* ---------- Tipe kategori: Harian / Tagihan ---------- */

.kind-help {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 12px;
}
.kind-help strong {
  color: var(--text);
}
/* Warning % tidak berlaku untuk Tagihan; disembunyikan tapi tetap menjaga kolom tetap rata. */
.editor-row[data-kind='bill'] .pct-cell {
  visibility: hidden;
}
.badge.status-paid {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.status-unpaid {
  background: var(--surface-2);
  color: var(--muted);
}
.fill.status-paid {
  background: var(--ok);
}
.stat .muted.small {
  display: block;
}

/* ---------- Editor kategori: semua kolom sejajar ---------- */
/* Rata atas (bukan tengah), supaya keterangan di bawah nama tidak menurunkan kolom lain,
   dan semua kontrol setinggi 40px. */
.editor-head,
.editor-row {
  align-items: start;
}
.editor-row > input,
.editor-row > select,
.editor-row .name-cell input,
.editor-row .input-affix,
.editor-row .del-cell {
  height: 40px;
}
.editor-row .input-affix input {
  height: 100%;
  padding-block: 0;
}
.editor-row .del-cell {
  width: 40px;
}
.editor-row select {
  padding-block: 0;
}

@media (max-width: 720px) {
  /* Judul kolom disembunyikan di HP, jadi kolom warning diberi label sendiri. */
  .editor-row .pct-cell::before {
    content: 'Warning jika >';
    padding-left: 10px;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
  }
}

/* ---------- Item tagihan ---------- */

.item-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  justify-items: start;
  margin: 2px 0 6px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}
.editor-row[data-kind='daily'] .item-editor {
  display: none;
}
.item-list {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 560px;
}
.item-list:empty {
  display: none;
}
.item-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) minmax(120px, 1fr) 32px;
  gap: 6px;
  align-items: center;
}
.item-row > input,
.item-row .input-affix {
  height: 36px;
}
.item-row .input-affix input {
  height: 100%;
  padding-block: 0;
}
.item-editor .btn-link {
  padding: 2px 0;
  font-size: 0.85rem;
}
.item-editor > .muted.small {
  font-size: 0.75rem;
}
/* Budget otomatis dari jumlah item: tampil seperti field terkunci. */
.editor-row.has-items .budget-cell {
  background: var(--surface-2);
}
.editor-row.has-items .budget-cell input {
  cursor: default;
}

/* Checklist di baris kategori dashboard */
.cat-name > span {
  display: grid;
  gap: 2px;
}
.item-status {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}
.item-status .is-paid {
  color: var(--ok);
}
.badge.status-partial {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.fill.status-partial {
  background: var(--ok);
  opacity: 0.6;
}
.bill-items {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0;
  display: grid;
  gap: 4px;
}
.bill-items li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.9rem;
}
.bill-items li.is-paid > span:first-child {
  color: var(--ok);
}
.bill-items .muted {
  font-size: 0.8rem;
}
.item-tag {
  margin: 0 4px 0 0;
}

@media (max-width: 720px) {
  .editor-row[data-kind='bill'] {
    grid-template-areas:
      'name name del'
      'kind budget budget'
      'items items items';
  }
  .editor-row .item-editor {
    grid-area: items;
  }
  .item-row {
    grid-template-columns: 1fr 1fr 32px;
  }
}

/* Kategori dengan checklist item: tanda › tetap sejajar dengan nama, bukan dengan checklist. */
.cat-name .chev {
  align-self: flex-start;
}
.editor-row.has-items .budget-cell input {
  background: transparent;
}
