/* =====================================================================
   Buku Kas — Design tokens
   Palet: kertas hangat + tinta navy, aksen hijau ledger & rust amber.
   Tipografi: Fraunces (display) + IBM Plex Sans (isi) + IBM Plex Mono (angka)
   ===================================================================== */

:root {
  --ink:        #16233F;
  --ink-soft:   #2C3B5E;
  --paper:      #F7F5EF;
  --paper-raised: #FFFFFF;
  --line:       #DAD4C3;
  --line-soft:  #E9E5D8;
  --green:      #2F6F4E;
  --green-soft: #E4EEE7;
  --rust:       #B5502C;
  --rust-soft:  #F5E6DE;
  --gold:       #C9A227;
  --slate:      #6B6459;
  --slate-dim:  #948C7C;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 3px;
  --shadow-card: 0 1px 0 rgba(22,35,63,0.05), 0 8px 20px -14px rgba(22,35,63,0.35);
}

* { box-sizing: border-box; }

/* Atribut hidden HARUS selalu menang atas display apa pun yang diset class lain
   (mis. .modal / .field pakai display:flex) — tanpa ini, elemen tetap tampil
   walau JS sudah menutupnya lewat `el.hidden = true`. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------------------------------------------------------------
   Masthead
   --------------------------------------------------------------------- */
.masthead {
  padding: 32px 0 0;
}

.masthead__top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
}

.masthead__title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.masthead__mark {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}

.masthead__title h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.masthead__title p {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--slate);
}

.masthead__actions { display: flex; gap: 10px; }

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--ink);
  color: var(--paper);
}
.btn--primary:hover { background: var(--ink-soft); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn--ghost:hover { background: var(--paper-raised); border-color: var(--slate-dim); }

.btn--add {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--slate);
  padding: 8px;
  text-align: center;
}
.btn--add:hover { border-color: var(--gold); color: var(--ink); background: var(--paper); }

.btn--icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--slate-dim);
  padding: 4px 6px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1;
}
.btn--icon:hover { color: var(--rust); background: var(--rust-soft); }

/* ---------------------------------------------------------------------
   Month tabs — bergaya folder tab pada buku fisik
   --------------------------------------------------------------------- */
.month-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-top: 6px;
  scrollbar-width: thin;
}

.month-tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--slate);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  top: 1px;
}

.month-tab:hover { color: var(--ink); }

.month-tab.is-active {
  background: var(--paper-raised);
  color: var(--ink);
  border-color: var(--line);
  border-bottom: 1px solid var(--paper-raised);
  font-weight: 600;
}

.month-tab__del {
  opacity: 0;
  border: none;
  background: none;
  color: var(--slate-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}
.month-tab:hover .month-tab__del { opacity: 1; }
.month-tab__del:hover { color: var(--rust); }

/* ---------------------------------------------------------------------
   Ledger main area
   --------------------------------------------------------------------- */
.ledger {
  border-top: 1px solid var(--line);
  background: var(--paper-raised);
  padding: 28px;
  border-radius: 0 6px 6px 6px;
  box-shadow: var(--shadow-card);
}

/* Statement strip */
.statement {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
}

.statement__figure {
  padding: 16px 18px;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--paper);
}
.statement__figure:last-child { border-right: none; }

.statement__label {
  font-size: 11.5px;
  color: var(--slate);
  text-transform: none;
}

.statement__value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.statement__figure--income .statement__value { color: var(--green); }
.statement__figure--paid .statement__value { color: var(--green); }
.statement__figure--due .statement__value { color: var(--rust); }
.statement__figure--balance { background: var(--ink); }
.statement__figure--balance .statement__label { color: #B9C2D6; }
.statement__figure--balance .statement__value { color: var(--paper); }
.statement__value.is-negative { color: var(--rust); }

/* Layout: main content + sidebar */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.layout__main { display: flex; flex-direction: column; gap: 24px; }
.layout__side { display: flex; flex-direction: column; gap: 24px; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Cards */
.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  background: var(--paper-raised);
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.card__head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.search {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  background: var(--paper);
  min-width: 180px;
}
.search:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Tables */
.table-wrap { overflow-x: auto; }

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.ledger-table thead th {
  text-align: left;
  font-weight: 500;
  color: var(--slate);
  font-size: 11.5px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.ledger-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.ledger-table tbody tr:hover { background: #FCFBF7; }

.col-num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.col-action { width: 34px; text-align: center; }
.col-status { width: 108px; }

.ledger-table__total td {
  border-bottom: none;
  border-top: 2px solid var(--ink);
  font-weight: 600;
  padding-top: 9px;
}

.cell-input {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 3px;
  padding: 4px 6px;
  width: 100%;
  font-family: inherit;
}
.cell-input:hover { border-color: var(--line); }
.cell-input:focus { border-color: var(--gold); background: var(--paper); outline: none; }

input.cell-input.col-num-input { text-align: right; font-family: var(--font-mono); }

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.status-pill--lunas { background: var(--green-soft); color: var(--green); }
.status-pill--belum { background: var(--rust-soft); color: var(--rust); }

.row-negative { color: var(--rust); }

/* Chart cards */
.chart-box { position: relative; min-height: 220px; }
.empty-note { font-size: 12.5px; color: var(--slate-dim); text-align: center; padding: 40px 0; }

/* Empty state (no month yet) */
.empty-state {
  text-align: center;
  color: var(--slate);
  padding: 60px 20px;
  font-size: 15px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  margin-top: 12px;
}

.page-foot {
  text-align: center;
  color: var(--slate-dim);
  font-size: 12px;
  padding-top: 28px;
}

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(22,35,63,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal:not([hidden]) {
  display: flex;
}

.modal__panel {
  background: var(--paper-raised);
  border-radius: 6px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 60px -20px rgba(22,35,63,0.5);
}

.modal__panel h3 {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0 0 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--slate);
}

.field select, .field input[type="number"], .field input[type="text"] {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--paper);
  color: var(--ink);
}
.field select:focus, .field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field--checkbox input { width: 15px; height: 15px; }

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 20px;
  border-radius: 6px;
  font-size: 13.5px;
  z-index: 60;
  box-shadow: 0 12px 28px -10px rgba(0,0,0,0.4);
}
.toast--error { background: var(--rust); }
.toast--success { background: var(--green); }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .statement { grid-template-columns: repeat(3, 1fr); }
  .statement__figure:nth-child(3) { border-right: none; }
}

@media (max-width: 640px) {
  .page { padding: 0 14px 48px; }
  .masthead { padding-top: 20px; }
  .ledger { padding: 16px; }
  .statement { grid-template-columns: repeat(2, 1fr); }
  .statement__figure:nth-child(2n) { border-right: none; }
  .pair { grid-template-columns: 1fr; }
  .masthead__title h1 { font-size: 24px; }
  .card__head { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
