/* Catatan Harian — satu berkas CSS, tanpa framework. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e8ec;
  --text: #16232b;
  --muted: #64757f;
  --accent: #0f766e;
  --accent-soft: #e5f4f1;
  --danger: #b4232a;
  --danger-soft: #fdeceb;
  --ok: #196a4e;
  --ok-soft: #e6f5ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 40, .05), 0 6px 20px rgba(16, 32, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1418;
    --surface: #161e23;
    --surface-2: #1b252b;
    --border: #27343b;
    --text: #e8eef1;
    --muted: #94a5ae;
    --accent: #2dd4bf;
    --accent-soft: #14312e;
    --danger: #f98a8a;
    --danger-soft: #38191b;
    --ok: #6ee7b7;
    --ok-soft: #12302a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.02rem; letter-spacing: .01em; }

.muted, small { color: var(--muted); }
small { font-size: .82em; }

/* -------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 680; }
.brand:hover { text-decoration: none; }

.brand-mark {
  display: block;
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.brand-mark.big { width: 64px; height: 64px; }

.topnav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }

.topnav a {
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 560;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topnav a.on { background: var(--accent-soft); color: var(--accent); }
.topnav a.ghost { color: var(--muted); }

/* --------------------------------------------------------------- layout */

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wrap-bare { min-height: 82vh; justify-content: center; max-width: 420px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  padding: 0 16px 28px;
}

/* ---------------------------------------------------------------- flash */

.flash {
  padding: 10px 13px;
  border-radius: 11px;
  font-size: .9rem;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-err { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* ---------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-main { grid-column: 1 / -1; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-main .stat-value { font-size: 2rem; color: var(--accent); }
.stat-value.over { color: var(--danger); }
.stat-sub { font-size: .8rem; color: var(--muted); }

.bar {
  display: block;
  height: 6px;
  margin-top: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar i.over { background: var(--danger); }

/* ----------------------------------------------------------------- form */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-amount input {
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.field-amount small { display: block; margin-top: 5px; min-height: 1.1em; color: var(--accent); font-weight: 600; }

.entry-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.entry-form .field-amount, .entry-form .field-note, .entry-form .actions { grid-column: 1 / -1; }

.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 17px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s, background .12s;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #05231f; } }
.btn-ghost { background: transparent; }
.btn.disabled { opacity: .35; pointer-events: none; }

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; }

/* ------------------------------------------------------------ month nav */

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.month-nav h2 { margin: 0; }
.month-nav .btn { padding: 6px 13px; font-size: 1.1rem; line-height: 1; flex: none; }
.month-title { text-align: center; min-width: 0; }
.month-title small { display: block; color: var(--muted); font-size: .78rem; margin-top: 1px; }

/* --------------------------------------------------------- ringkasan angka */

.ringkas { list-style: none; margin: 0 0 14px; padding: 0; }
.ringkas li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.ringkas li:last-child { border-bottom: 0; }
.ringkas span { color: var(--muted); font-size: .88rem; }
.ringkas strong { font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ringkas strong.over { color: var(--danger); }

/* -------------------------------------------------- pengeluaran per hari */

.harian { list-style: none; margin: 0; padding: 0; }
.harian li + li { margin-top: 11px; }
.hr-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hr-tgl { font-weight: 580; font-size: .92rem; }
.hr-tgl small { color: var(--muted); font-weight: 400; margin-left: 5px; }
.hr-nilai { font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ----------------------------------------------------------- daftar hari */

.days, .items, .breakdown { list-style: none; margin: 0; padding: 0; }

.day + .day { margin-top: 14px; }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0 6px;
  border-bottom: 1px solid var(--border);
}
.day-date { font-size: .84rem; font-weight: 650; color: var(--muted); }
.day-total { font-size: .88rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "cat amount act" "note amount act";
  align-items: center;
  gap: 0 10px;
  padding: 9px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.item:last-child { border-bottom: 0; }

.item-cat { grid-area: cat; font-weight: 580; }
.item-note { grid-area: note; font-size: .82rem; color: var(--muted); }
.item-note:empty { display: none; }
.item-amount { grid-area: amount; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-actions { grid-area: act; display: flex; gap: 2px; align-items: center; }

.inline { display: inline; margin: 0; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .95rem;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.empty { color: var(--muted); font-size: .9rem; margin: 6px 0 2px; }
.lead { margin: 0 0 12px; }

/* ------------------------------------------------------------- breakdown */

.breakdown li + li { margin-top: 13px; }
.breakdown.compact li + li { margin-top: 9px; }
.bd-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bd-name { font-weight: 580; }
.bd-name small { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; margin-top: 1px; }
.bd-val { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bd-meta { display: block; margin-top: 3px; }

.chart-note { font-size: .8rem; color: var(--muted); margin: 12px 0 0; }

/* ------------------------------------------------------------------ auth */

.auth { display: flex; flex-direction: column; gap: 18px; }
.auth-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-brand h1 { margin: 0; }
.auth-brand p { margin: 0; color: var(--muted); font-size: .9rem; max-width: 30ch; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .entry-form { grid-template-columns: 1fr; }
  .stat-main .stat-value { font-size: 1.75rem; }
  .topnav a { padding: 6px 10px; font-size: .86rem; }
}
