/* Warm ledger — personal, not SaaS */
:root{
  --paper:#faf8f3;
  --surface:#ffffff;
  --ink:#1c1917;
  --muted:#6b655a;
  --muted-2:#7d7668;
  --hairline:#e7e0d3;
  --hairline-strong:#d9cfbd;
  --ledger:#1a3c34;
  --ledger-hover:#16332c;
  --accent:#b45309;
  --success:#166534;
  --danger:#b91c1c;
  --radius:10px;
  --radius-sm:6px;
  --mono:'IBM Plex Mono','ui-monospace','Cascadia Code',monospace;
  --sans:'Space Grotesk','Instrument Sans',system-ui,-apple-system,'Segoe UI',sans-serif;
}
*{margin:0;padding:0;box-sizing:border-box}
html{scrollbar-gutter:stable}
body{
  font-family:var(--sans);
  background:var(--paper);
  color:var(--ink);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  font-size:15px;
}
a{color:var(--ledger)}
:focus-visible{outline:2px solid var(--ledger); outline-offset:2px}
::selection{background:rgba(26,60,52,.15)}

/* Shell */
#app{
  max-width:1200px;
  margin:0 auto;
  padding:0 20px 40px;
}
.ledger-header{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  gap:16px;
  margin:0 -20px;
  padding:14px 20px 12px;
  background:rgba(250,248,243,.92);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--hairline);
}
.ledger-header__brand{
  font-weight:700; letter-spacing:-.02em; font-size:15px;
  display:flex; align-items:center; gap:10px;
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.ledger-header__brand small{
  font-weight:400; color:var(--muted); font-size:12px; letter-spacing:.08em; text-transform:uppercase;
}
.ledger-header__period{
  display:flex; align-items:center; gap:8px;
  font-family:var(--mono); font-size:13px;
  min-width:0;
}
.ledger-header__period button.btn-pill{
  width:auto; height:auto; padding:6px 12px; border-radius:999px;
  background:var(--surface); border:1px solid var(--hairline);
  color:var(--ink); font-size:12px; line-height:1.2;
  max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.ledger-header__period button.btn-pill:hover{background:var(--paper)}
/* Month stepper + generic icon buttons stay circular */
.month-nav button.btn-icon{
  width:40px; height:40px; padding:0; border-radius:999px;
  font-size:18px; line-height:1; flex:none;
}
/* Small inline actions (confirms, contoh, kembali): min 32px target */
.btn-sm{ padding:6px 12px; font-size:12.5px; min-height:32px; }
.period-pill{
  background:var(--surface); border:1px solid var(--hairline);
  padding:6px 10px; border-radius:999px;
  font-family:var(--mono); font-size:13px; white-space:nowrap;
}
.page-head__nav{ display:flex; gap:8px; margin-bottom:8px; flex-wrap:wrap; }

/* Import preview dialog */
.dialog-overlay{
  position:fixed; inset:0; z-index:60;
  background:rgba(28,25,23,.45);
  display:flex; align-items:center; justify-content:center;
  padding:16px;
}
.dialog{
  background:var(--surface); color:var(--ink);
  border:1px solid var(--hairline-strong); border-radius:var(--radius);
  max-width:640px; width:100%; max-height:85vh; overflow:auto;
  padding:18px 20px;
  box-shadow:0 16px 48px rgba(0,0,0,.22);
}
.dialog h2{ font-size:18px; letter-spacing:-.01em; }
.dialog__actions{ display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; margin-top:4px; }

/* Layout with sidebar (desktop) */
.app-shell{
  display:grid;
  grid-template-columns:200px 1fr;
  gap:28px;
  margin-top:18px;
}
.sidebar{
  position:sticky; top:62px; align-self:start;
}
.sidebar__section{
  margin-bottom:18px;
}
.sidebar__label{
  font-size:10px; letter-spacing:.14em; text-transform:uppercase;
  color:var(--muted-2); font-weight:700; margin-bottom:8px;
}
.sidebar a{
  display:flex; align-items:center; gap:8px;
  padding:7px 10px 7px 10px;
  border-left:2px solid transparent;
  text-decoration:none; color:var(--muted); font-size:14px; font-weight:500;
  border-radius:0 6px 6px 0;
}
.sidebar a:hover{color:var(--ink); background:rgba(231,224,211,.45)}
.sidebar a.active{
  color:var(--ink); font-weight:700;
  border-left-color:var(--ledger);
  background:var(--surface);
  border-top:1px solid var(--hairline);
  border-right:1px solid var(--hairline);
  border-bottom:1px solid var(--hairline);
}
.sidebar a svg{width:16px;height:16px; stroke-width:1.75}

main{ min-width:0 }
.page-head{ margin-bottom:16px }
.page-head h1{
  font-size:22px; letter-spacing:-.02em; font-weight:700; line-height:1.2;
}
.page-head p{ color:var(--muted); font-size:13px; margin-top:4px }

/* Cards / summary */
.card{
  background:var(--surface);
  border:1px solid var(--hairline);
  border-radius:var(--radius);
  padding:16px 18px;
  box-shadow:none;
  margin-bottom:14px;
}
.card--hero{ border-color:var(--hairline-strong) }
.summary-cards{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:12px;
  margin-bottom:16px;
}
.amount{
  font-family:var(--mono);
  font-size:20px; font-weight:600; letter-spacing:-.02em;
  color:var(--ink);
  font-variant-numeric:tabular-nums;
}
.amount--muted{ color:var(--muted) }
.positive{ color:var(--success) }
.negative{ color:var(--danger) }

/* Ledger tables */
.ledger-table-wrap{ overflow-x:auto; border:1px solid var(--hairline); border-radius:var(--radius); background:var(--surface) }
table{ width:100%; border-collapse:separate; border-spacing:0; margin:0 }
/* Sticky header row (engages when the wrap scrolls) + sticky first column
   so row labels survive horizontal scroll on narrow screens. */
.ledger-table-wrap thead th{ position:sticky; top:0; z-index:3; }
.ledger-table-wrap th:first-child, .ledger-table-wrap td:first-child{
  position:sticky; left:0; z-index:2;
  box-shadow:1px 0 0 var(--hairline);
}
.ledger-table-wrap thead th:first-child{ z-index:4; }
.ledger-table-wrap td:first-child{ background:var(--surface); }
tbody tr:hover td:first-child{ background:#fdfbf7; }
.subtotal td:first-child, .grand td:first-child{ background:var(--paper); }
tr.dirty td:first-child{ background:#fffbeb; }
th,td{
  padding:10px 12px;
  text-align:left;
  border-bottom:1px solid var(--hairline);
  font-size:13.5px;
}
th{
  background:var(--paper);
  font-size:11px; letter-spacing:.06em; text-transform:uppercase;
  font-weight:700; color:var(--muted);
  white-space:nowrap;
}
td{ background:var(--surface) }
tbody tr:hover td{ background:#fdfbf7 }
.num{ font-family:var(--mono); text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap }
.subtotal td{
  font-weight:700; background:var(--paper);
  border-top:1px solid var(--hairline-strong);
}
.grand td{
  font-weight:800; background:var(--paper);
  border-top:2px solid var(--ink);
  border-bottom:2px solid var(--ink);
}
tr.dirty td{ background:#fffbeb; }
.dot{ width:8px;height:8px;border-radius:999px;display:inline-block;background:var(--accent);margin-right:6px;vertical-align:middle; box-shadow:0 0 0 2px rgba(180,83,9,.18) }

/* Inputs */
input, select{
  font:inherit;
}
input[type="text"], input[type="number"], input:not([type]), select{
  padding:8px 10px;
  border:1px solid var(--hairline-strong);
  border-radius:var(--radius-sm);
  background:var(--surface);
  color:var(--ink);
  width:100%;
  max-width:100%;
}
input:focus, select:focus{ outline:none; border-color:var(--ledger); box-shadow:0 0 0 3px rgba(26,60,52,.12) }
input.num{ text-align:right; font-family:var(--mono) }
input[type="checkbox"]{ width:auto; accent-color:var(--ledger) }
select{ cursor:pointer }

/* Per-value cell editing — tinted field at rest, unmistakable when dirty/empty */
.cell-input{
  background:#f6f1e6;
  border:1.5px solid var(--hairline-strong);
  border-radius:var(--radius-sm);
  min-height:36px;
  cursor:text;
}
.cell-input::placeholder{ color:var(--muted-2); opacity:1 }
tbody tr:hover .cell-input{ border-color:rgba(26,60,52,.45); background:#fbf7ee }
.cell-input:focus{
  background:var(--surface);
  border-color:var(--ledger);
  box-shadow:0 0 0 3px rgba(26,60,52,.14);
}
.cell-input.is-empty{
  border-style:dashed;
  border-color:var(--muted-2);
  background:transparent;
}
tbody tr:hover .cell-input.is-empty{ border-color:var(--ledger); background:#fbf7ee }
.cell-input.is-empty::placeholder{ color:var(--muted); font-size:12px }
.cell-input.is-dirty{
  background:#fef3c7;
  border-color:var(--accent);
  border-left-width:4px;
  border-style:solid;
}

/* Buttons */
button{
  font:inherit;
  padding:9px 14px;
  background:var(--ledger);
  color:#fff;
  border:1px solid var(--ledger);
  border-radius:999px;
  cursor:pointer; font-size:13.5px; font-weight:600;
  letter-spacing:-.01em;
  line-height:1;
}
button:hover{ background:var(--ledger-hover) }
button:disabled{ background:#d6d0be; border-color:#d6d0be; color:#fff; cursor:not-allowed }
.btn-ghost{ background:var(--surface); color:var(--ink); border-color:var(--hairline-strong) }
.btn-ghost:hover{ background:var(--paper) }
.btn-danger{ background:var(--danger); border-color:var(--danger) }

/* Month nav */
.month-nav{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  margin-bottom:14px;
}
.month-nav__group{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; min-width:0; }
.month-nav__status{ margin-left:auto; }
.month-nav label{ font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); font-weight:700 }
.month-nav select{ width:auto; min-width:140px }

/* Sticky footer totals */
.sticky-totals{
  position:sticky; bottom:0; z-index:10;
  margin:16px -20px 0; padding:12px 20px;
  background:rgba(255,255,255,.96); backdrop-filter:blur(8px);
  border-top:2px solid var(--ink);
  display:flex; flex-wrap:wrap; gap:16px; align-items:center; justify-content:space-between;
  font-family:var(--mono); font-size:13px;
}
.sticky-totals strong{ font-size:14px }
.progress{
  height:4px; background:var(--hairline); border-radius:999px; overflow:hidden; flex:1 1 160px; max-width:320px;
}
.progress i{ display:block; height:100%; background:var(--ledger); border-radius:999px; transition:width .3s }
.progress i.over{ background:var(--danger) }

/* Toast */
.toast{
  position:fixed; right:16px; bottom:16px; z-index:50;
  background:var(--ink); color:#fff;
  padding:10px 14px; border-radius:999px;
  font-size:13px; font-weight:600;
  max-width:min(440px, calc(100vw - 32px));
  box-shadow:0 8px 24px rgba(0,0,0,.18);
}
@media (max-width: 860px){
  /* keep clear of the sticky save bar */
  .toast{ bottom:84px; }
}
.toast--success{ background:var(--ledger) }
.toast--error{ background:var(--danger) }

/* Skeletons */
.skeleton{
  height:14px; border-radius:6px; background:linear-gradient(90deg,#ece6d9 25%,#f3eee2 37%,#ece6d9 63%);
  background-size:400% 100%; animation:shimmer 1.2s ease infinite;
}
@keyframes shimmer{ 0%{background-position:100% 0} 100%{background-position:0 0} }

/* Utilities */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}
.muted{ color:var(--muted) }
.smallcaps{ font-size:11px; letter-spacing:.1em; text-transform:uppercase; font-weight:700; color:var(--muted) }
.loading{ text-align:center; padding:28px; color:var(--muted) }

/* Responsive: collapse sidebar under 800px */
@media (max-width: 860px){
  .app-shell{ grid-template-columns:1fr }
  .ledger-header{ gap:10px; }
  .ledger-header__brand small{ display:none; }
  .ledger-header__period button.btn-pill{ max-width:44vw; }
  .sidebar{ position:static; display:flex; gap:8px; overflow-x:auto; padding-bottom:4px }
  .sidebar__section{ margin:0; display:flex; gap:8px; align-items:center }
  .sidebar__label{ display:none }
  .sidebar a{ border:1px solid var(--hairline); border-radius:999px; white-space:nowrap }
  .sidebar a.active{ border-left-color:var(--hairline) }
}
