/* ============================================================
   Alokasi Dana — weekly budget ledger
   Palette: cool paper, deep teal for money in, plum for money out.
   ============================================================ */

:root {
  --ink:        #16202b;
  --ink-soft:   #4d5c6b;
  --ink-faint:  #7d8b99;
  --paper:      #eceff3;
  --surface:    #ffffff;
  --rule:       #d6dce4;
  --rule-soft:  #e6eaef;

  --in:         #0f5d63;   /* money in  */
  --in-wash:    #eaf4f3;
  --in-edge:    #cadfdd;
  --out:        #7a3d5c;   /* money out */
  --out-wash:   #f7eef2;
  --out-edge:   #e6d0da;

  --good:       #146b46;
  --warn:       #8a5a00;
  --bad:        #a5231d;
  --focus:      #0f5d63;

  --radius: 4px;
  --shadow-sm: 0 1px 2px rgba(22, 32, 43, .07);
  --shadow-md: 0 6px 24px rgba(22, 32, 43, .13);

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--ink-faint);
  letter-spacing: .02em;
  font-family: var(--cond);
  font-size: 12px;
}

/* ---------------------------------------------------------- sign in ----- */

.signin {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.signin-art {
  background: var(--ink);
  color: #fff;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.signin-art h1 {
  font-family: var(--cond);
  font-size: clamp(34px, 4.4vw, 54px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -.015em;
  margin: 0 0 12px;
}
.signin-art p { color: #9fb0bd; max-width: 34ch; margin: 0; }
.signin-mark {
  font-family: var(--cond);
  letter-spacing: .04em;
  font-size: 12.5px;
  font-weight: 600;
  color: #7f929f;
}
.signin-bars { display: flex; align-items: flex-end; gap: 5px; height: 132px; }
.signin-bars i {
  flex: 1;
  background: #2e4250;
  border-radius: 1px;
  animation: rise .9s cubic-bezier(.2, .8, .3, 1) backwards;
}
.signin-bars i.lit { background: var(--in); }
.signin-bars i.hot { background: #b8607f; }
@keyframes rise { from { height: 4px !important; opacity: 0; } }

.signin-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.signin-form form { width: min(360px, 100%); }
.signin-form h2 {
  font-family: var(--cond);
  font-size: 24px;
  margin: 0 0 4px;
}
.signin-form .sub { color: var(--ink-soft); margin: 0 0 28px; }

/* ------------------------------------------------------------ forms ----- */

label.field { display: block; margin-bottom: 16px; }
label.field > span {
  display: block;
  font-family: var(--cond);
  letter-spacing: .01em;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(15, 93, 99, .16);
}
textarea { resize: vertical; min-height: 72px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #24323f; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--in); border-color: var(--in); }
.btn.primary:hover { background: #14757c; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { background: #f2f5f8; border-color: var(--ink-faint); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }

.error-note {
  background: #fdecea;
  border: 1px solid #f3c3bf;
  color: var(--bad);
  padding: 9px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

/* ------------------------------------------------------------ shell ----- */

.shell { display: grid; grid-template-rows: auto auto 1fr; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  height: 54px;
  background: var(--ink);
  color: #fff;
}
.topbar .wordmark {
  font-family: var(--cond);
  font-weight: 600;
  letter-spacing: .02em;
  font-size: 13px;
}
.topbar .spacer { flex: 1; }
.topbar select {
  background: #24323f;
  border-color: #3a4a58;
  color: #fff;
  width: auto;
  min-width: 160px;
  padding: 6px 10px;
}
.topbar select:focus { box-shadow: 0 0 0 3px rgba(255, 255, 255, .16); border-color: #6d8496; }
.whoami { text-align: right; line-height: 1.2; }
.whoami b { display: block; font-weight: 600; font-size: 13px; }
.whoami span { font-size: 11.5px; color: #9fb0bd; }
.linkish {
  background: none;
  border: 0;
  color: #9fb0bd;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  font-size: 12px;
}
.linkish:hover { color: #fff; }

/* ----------------------------------------------- the week rail (signature) */

.rail-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 12px 20px 10px;
}
.rail {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 34px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.tick {
  flex: 1 0 9px;
  min-width: 9px;
  height: 14px;
  border: 0;
  padding: 0;
  border-radius: 1px;
  background: #e4e9ee;
  cursor: pointer;
  position: relative;
  transition: height .14s, background .14s;
}
.tick:hover { height: 26px; background: #cdd6de; }
.tick:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tick.draft     { background: #c3ccd5; }
.tick.submitted { background: #d9a12c; }
.tick.approved  { background: var(--in); }
.tick.rejected  { background: var(--bad); }
.tick.past      { opacity: .55; }
.tick.now::after {
  content: "";
  position: absolute;
  inset: auto 0 -6px;
  height: 2px;
  background: var(--ink);
}
.tick.sel { height: 30px; box-shadow: inset 0 0 0 2px var(--ink); }

.rail-legend {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-faint);
}
.rail-legend .key { display: inline-flex; align-items: center; gap: 5px; }
.rail-legend .swatch { width: 9px; height: 9px; border-radius: 1px; display: inline-block; }
.rail-title {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  margin-right: auto;
}

/* ------------------------------------------------------------- body ----- */

.body { display: grid; grid-template-columns: 190px 1fr; align-items: start; }

.sidenav { padding: 18px 12px; position: sticky; top: 0; }
.sidenav .group {
  font-family: var(--cond);
  letter-spacing: .04em;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-faint);
  margin: 18px 0 6px 10px;
}
.sidenav .group:first-child { margin-top: 0; }
.sidenav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink-soft);
}
.sidenav button:hover { background: #e3e8ee; color: var(--ink); }
.sidenav button.on { background: var(--ink); color: #fff; font-weight: 600; }
.sidenav .count {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--warn);
  color: #fff;
  border-radius: 20px;
  padding: 1px 7px;
}
.sidenav button.on .count { background: #fff; color: var(--ink); }

.main { padding: 18px 20px 64px; min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h2 {
  font-family: var(--cond);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.01em;
}
.page-head .sub { color: var(--ink-soft); font-size: 13px; margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--cond);
  letter-spacing: .02em;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid;
}
.pill.draft     { color: var(--ink-soft); border-color: var(--rule); background: #f2f5f8; }
.pill.submitted { color: var(--warn); border-color: #e6cd97; background: #fdf6e6; }
.pill.approved  { color: var(--in); border-color: var(--in-edge); background: var(--in-wash); }
.pill.rejected  { color: var(--bad); border-color: #f3c3bf; background: #fdecea; }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card > header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card > header h3 {
  font-family: var(--cond);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0;
}
.card > header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card .pad { padding: 16px; }

.notice {
  padding: 11px 14px;
  border-left: 3px solid;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 16px;
  font-size: 13.5px;
}
.notice.warn { background: #fdf6e6; border-color: #d9a12c; }
.notice.bad  { background: #fdecea; border-color: var(--bad); }
.notice.info { background: var(--in-wash); border-color: var(--in); }
.notice b { display: block; margin-bottom: 2px; }

/* ------------------------------------------------------------- grid ----- */

.grid-scroll { overflow-x: auto; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--rule-soft);
  padding: 6px 9px;
  text-align: right;
  white-space: nowrap;
}
table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  font-family: var(--cond);
  letter-spacing: .02em;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  padding-top: 9px;
  padding-bottom: 7px;
}
table.grid thead tr.flow th {
  text-align: center;
  letter-spacing: .04em;
  font-size: 12px;
  padding-bottom: 3px;
  border-bottom: 0;
}
/* Quantity and unit price: the two halves of a sourced account's forecast. */
th.num.src, td.num.src {
  background: #fbfaf6;
  border-left: 1px solid var(--rule-soft);
}
th.num.src:last-of-type, td.num.src + td:not(.src) { border-left: 0; }
td.derived {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-style: italic;
}
.src-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: #fbfaf6;
  font-family: var(--cond);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-faint);
  vertical-align: middle;
}

th.flow-in, td.col-in   { background: var(--in-wash); }
th.flow-out, td.col-out { background: var(--out-wash); }
th.flow-in  { color: var(--in); border-left: 1px solid var(--in-edge); border-right: 1px solid var(--in-edge); }
th.flow-out { color: var(--out); border-left: 1px solid var(--out-edge); border-right: 1px solid var(--out-edge); }
td.edge-l { border-left: 1px solid var(--rule-soft); }

th.desc, td.desc { text-align: left; white-space: normal; min-width: 240px; }
td.desc { font-weight: 500; }
td.cat {
  text-align: left;
  font-family: var(--cond);
  font-size: 11.5px;
  letter-spacing: .02em;
  color: var(--ink-faint);
}

tr.cat-head td {
  background: #f2f5f8;
  font-family: var(--cond);
  letter-spacing: .04em;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: left;
  padding-top: 9px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule);
}
table.grid tbody tr:hover td:not(.col-in):not(.col-out) { background: #f7f9fb; }

td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

input.cell {
  width: 100%;
  min-width: 96px;
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 6px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  border-radius: 2px;
}
input.cell:hover:not(:disabled) { border-color: var(--rule); background: rgba(255, 255, 255, .75); }
input.cell:focus {
  border-color: var(--focus);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(15, 93, 99, .16);
  outline: none;
}
input.cell:disabled { color: var(--ink-soft); cursor: default; }
input.cell.zero { color: var(--ink-faint); }
input.cell.saved { animation: flash .7s ease-out; }
@keyframes flash { from { background: #d6ecd8; } to { background: transparent; } }

td.var { position: relative; font-family: var(--mono); font-size: 12px; width: 78px; }
td.var .bar {
  position: absolute;
  right: 0;
  bottom: 1px;
  height: 2px;
  opacity: .55;
  border-radius: 1px;
}
td.var.up   { color: var(--good); }
td.var.down { color: var(--bad); }
td.var.up .bar   { background: var(--good); }
td.var.down .bar { background: var(--bad); }
td.var.flat { color: var(--ink-faint); }

tr.totals td {
  border-top: 2px solid var(--ink);
  border-bottom: 0;
  font-weight: 600;
  background: #fbfcfd;
  padding-top: 9px;
  padding-bottom: 9px;
}
tr.totals td.col-in  { background: var(--in-wash); }
tr.totals td.col-out { background: var(--out-wash); }
tr.net td {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  border-bottom: 0;
}
tr.net td.num { font-size: 13.5px; }

.savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -4px 16px rgba(22, 32, 43, .06);
}
.savebar .status { font-size: 12.5px; color: var(--ink-faint); margin-right: auto; }
.savebar .status.dirty { color: var(--warn); }
.savebar .status.ok { color: var(--good); }
/* Which columns this account is allowed to type into. */
.savebar .role-note {
  font-family: var(--cond);
  letter-spacing: .02em;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
}

/* Jump straight to a week instead of stepping along the rail. */
.week-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
  padding-left: 14px;
}
.week-nav .btn.small { padding: 3px 8px; line-height: 1; }
select.week-jump {
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  max-width: 230px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

/* Reorder arrows in the master line-item list. */
.btn.small.nudge {
  min-width: 26px;
  padding: 3px 6px;
  margin-left: 4px;
  font-size: 12px;
  line-height: 1;
}
.btn.small.nudge:disabled { opacity: .3; cursor: default; }

/* ---------------------------------------------- all-division recap ------ */

table.recap { font-size: 12px; }
table.recap th, table.recap td { white-space: nowrap; }
table.recap th.wk {
  text-align: center;
  background: var(--rule-soft);
  border-left: 2px solid var(--rule);
}
/* First column of each week block, so the blocks read as blocks. */
table.recap th.wk-start, table.recap td.wk-start { border-left: 2px solid var(--rule); }
table.recap tr.total td {
  font-weight: 700;
  border-top: 2px solid var(--ink-soft);
  background: #fafbfc;
  position: sticky;
  bottom: 0;
}
td.nowrap { white-space: nowrap; }

/* Purchase requests: the allocations sitting under each request line. */
.alloc-list {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--rule);
}
.alloc {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 2px 0;
}
.muted.small { font-size: 12px; margin-top: 3px; }
td.unmapped { color: var(--warn); font-style: italic; }

/* Type-to-search in place of a very long dropdown. */
.picker { position: relative; }
.picker-chosen {
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-faint);
}
.picker-list {
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.picker-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule-soft);
  background: transparent;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
}
.picker-option:last-child { border-bottom: 0; }
.picker-option b { display: block; font-weight: 600; }
.picker-option .muted { font-size: 11.5px; color: var(--ink-faint); }
.picker-option:hover, .picker-option.active { background: #eef3f8; }
.picker-empty { padding: 9px 10px; font-size: 12px; color: var(--ink-faint); }
.returned-note { color: var(--bad); }
.linkish.small { font-size: 11.5px; }

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  margin-right: 12px;
}
.inline-check input { margin: 0; }

/* ------------------------------------------------------------ tables ---- */

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th {
  text-align: left;
  font-family: var(--cond);
  letter-spacing: .02em;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}
table.list td { padding: 9px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: #f7f9fb; }
table.list td.num, table.list th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list .muted { color: var(--ink-faint); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 1px; background: var(--rule-soft); }
.stat {
  background: var(--surface);
  padding: 14px 16px;
}
.stat .k {
  font-family: var(--cond);
  letter-spacing: .02em;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.stat .v { font-family: var(--mono); font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .d { font-size: 11.5px; margin-top: 2px; color: var(--ink-faint); }
.stat.in .v  { color: var(--in); }
.stat.out .v { color: var(--out); }

.empty { padding: 40px 16px; text-align: center; color: var(--ink-faint); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 15px; }

/* ------------------------------------------------------------ modal ----- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(22, 32, 43, .42);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: min(480px, 100%);
  max-height: 88vh;
  overflow: auto;
}
.modal header { padding: 16px 20px 0; }
.modal header h3 { font-family: var(--cond); font-size: 18px; margin: 0; }
.modal .pad { padding: 16px 20px 20px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 60;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

/* ------------------------------------------------------------ chart ----- */

.chart { width: 100%; height: 190px; display: block; }
.chart .grid-line { stroke: var(--rule-soft); stroke-width: 1; }
.chart .axis { fill: var(--ink-faint); font-family: var(--mono); font-size: 9px; }
.chart .now-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 900px) {
  .signin { grid-template-columns: 1fr; }
  .signin-art { padding: 32px 24px; }
  .signin-bars { height: 70px; }
  .body { grid-template-columns: 1fr; }
  .sidenav {
    position: static;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--rule);
    background: var(--surface);
  }
  .sidenav .group { display: none; }
  .sidenav button { width: auto; white-space: nowrap; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .main { padding: 14px 12px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
