/* ============================================================
   Duit Kita — Personal Expense Application
   Mobile-first design system. Warm paper + deep green + amber.
   ============================================================ */

:root {
  --ink: #1d2a24;
  --ink-soft: #4a564f;
  --muted: #837f74;
  --paper: #f3efe7;
  --card: #fffdf9;
  --line: #e5ddcc;
  --line-soft: #ece5d6;
  --deep: #122921;
  --deep-2: #1b3a2f;
  --cream: #f3efe7;
  --accent: #157a63;
  --accent-soft: #e2efe9;
  --amber: #c98a2e;
  --amber-soft: #f7ecd9;
  --neg: #b23a31;
  --neg-soft: #f7e4e1;
  --blue-soft: #e3ebf3;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(29,42,36,.06), 0 6px 18px -8px rgba(29,42,36,.14);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 50% -220px, #e9e2d2 0%, var(--paper) 60%) no-repeat,
    var(--paper);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
svg { width: 20px; height: 20px; flex: none; }
img { max-width: 100%; }
button { font-family: var(--font); }

.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.neg, .neg { color: var(--neg); }
.pos { color: var(--accent); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.maincol { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  background: var(--deep);
  color: var(--cream);
  box-shadow: 0 2px 10px rgba(18,41,33,.25);
}
.topbar-title { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.topbar-user {
  font-size: 12px; font-weight: 600; color: var(--deep);
  background: var(--amber); border-radius: 999px; padding: 3px 10px;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px calc(96px + var(--safe-b));
}

/* ---------- Flash messages ---------- */
.flashes { max-width: 640px; margin: 10px auto 0; padding: 0 14px; width: 100%; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-s); font-size: 14px;
  margin-bottom: 8px; border: 1px solid transparent;
}
.flash-success { background: var(--accent-soft); color: #0d5c4a; border-color: #c4ded4; }
.flash-error { background: var(--neg-soft); color: #86271f; border-color: #ecc9c4; }
.flash-info { background: var(--blue-soft); color: #2d4a66; border-color: #cddae8; }

/* ---------- Bottom navigation ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: space-around;
  background: var(--deep);
  padding: 6px 6px calc(8px + var(--safe-b));
  box-shadow: 0 -4px 20px rgba(18,41,33,.28);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #9fb4a9; font-size: 10.5px; font-weight: 600;
  background: none; border: 0; padding: 6px 10px; border-radius: 10px; cursor: pointer;
  min-width: 58px;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.on { color: var(--amber); }
.bn-fab {
  width: 54px; height: 54px; border-radius: 18px; border: 0; cursor: pointer;
  background: linear-gradient(160deg, #e0a33e, var(--amber));
  color: var(--deep); display: flex; align-items: center; justify-content: center;
  margin: 0 4px; transform: translateY(-14px);
  box-shadow: 0 8px 18px -4px rgba(201,138,46,.55);
}
.bn-fab svg { width: 26px; height: 26px; }

/* ---------- Sheets (bottom sheets / modals) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(18,29,24,.45); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + var(--safe-b));
  transform: translateY(105%); transition: transform .22s ease;
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(18,29,24,.3);
}
.sheet.show { transform: translateY(0); }
.sheet-grab { width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 10px; }
.sheet-title { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.sheet .sheet-close {
  position: absolute; top: 14px; right: 14px; border: 0; background: var(--paper);
  border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; color: var(--ink-soft); cursor: pointer;
}
.sheet .sheet-close svg { width: 16px; height: 16px; }

.record-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.record-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--ink);
  padding: 10px 4px 12px; border-radius: var(--radius); background: var(--paper);
}
.ro-ic {
  width: 46px; height: 46px; border-radius: 14px; display: flex;
  align-items: center; justify-content: center; color: #fff;
}
.ro-ic svg { width: 22px; height: 22px; }
.ro-exp { background: var(--accent); }
.ro-trf { background: #3d6b8e; }
.ro-rev { background: var(--amber); color: var(--deep); }
.ro-com { background: #7a4d8a; }

.menu-list { display: flex; flex-direction: column; }
.menu-list a {
  display: flex; align-items: center; gap: 12px; padding: 13px 6px;
  color: var(--ink); font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--line-soft);
}
.menu-list a:last-child { border-bottom: 0; }
.menu-list a.danger { color: var(--neg); }
.menu-list svg { color: var(--ink-soft); }
.menu-list a.danger svg { color: var(--neg); }

/* ---------- Section headings ---------- */
.sec-h {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 20px 2px 8px;
}
.sec-h:first-child { margin-top: 2px; }
.sec-h h2 {
  margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted);
}
.sec-h .sec-link { font-size: 13px; font-weight: 600; }

/* ---------- Cards & list groups ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }
.card-pad { padding: 14px; }

.rowlist { display: flex; flex-direction: column; }
.rowlist > .row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
}
.rowlist > .row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; font-size: 14.5px; }
.row .r-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row .r-amt { font-weight: 700; font-size: 15px; }

.logo-chip {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); border: 1px solid var(--line-soft); overflow: hidden;
}
.logo-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-chip.emoji { font-size: 19px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; font-weight: 650; font-size: 15px;
  border-radius: 12px; padding: 12px 18px; color: #fff; background: var(--accent);
  transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-amber { background: var(--amber); color: var(--deep); }
.btn-dark { background: var(--deep); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-danger { background: var(--neg); }
.btn-sm { padding: 8px 13px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn svg { width: 18px; height: 18px; }

.iconbtn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn.danger { color: var(--neg); }

/* ---------- Forms ---------- */
label.f-label {
  display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  margin: 0 0 5px 2px; letter-spacing: .3px;
}
.input, select.input, textarea.input {
  width: 100%; padding: 11px 12px; font-size: 15px; font-family: var(--font);
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: #fff; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(21,122,99,.12); }
.input.err { border-color: var(--neg); }
.f-group { margin-bottom: 14px; }
.f-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.f-err { font-size: 12.5px; color: var(--neg); margin-top: 4px; font-weight: 600; }
.f-row { display: flex; gap: 10px; }
.f-row > * { flex: 1; min-width: 0; }

.amount-input-wrap { position: relative; }
.amount-input-wrap .rm-prefix {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-weight: 700; color: var(--muted); font-size: 16px;
}
.amount-input-wrap input {
  padding-left: 46px; font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Date/time quick bar */
.dt-bar { display: flex; gap: 8px; align-items: stretch; }
.dt-bar .iconbtn { height: auto; }
.dt-bar input { text-align: center; font-weight: 600; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink-soft);
  padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 650;
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--deep); border-color: var(--deep); color: var(--cream); }
.chip .c-ic { font-size: 15px; }

/* Account tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: var(--card); padding: 10px; cursor: pointer; font-size: 13.5px;
  font-weight: 650; color: var(--ink); font-family: var(--font);
}
.tile.on { border-color: var(--accent); background: var(--accent-soft); }
.tile .logo-chip { width: 32px; height: 32px; border-radius: 9px; }

/* ---------- Steps ---------- */
.steps {
  display: flex; gap: 4px; margin: 2px 0 14px;
}
.steps .st {
  flex: 1; height: 4px; border-radius: 4px; background: var(--line);
}
.steps .st.done { background: var(--accent); }
.steps .st.now { background: var(--amber); }
.step-panel { display: none; }
.step-panel.show { display: block; animation: fadein .15s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }
.step-title { margin: 0 0 12px; font-size: 16.5px; font-weight: 700; }

/* Sticky form footer (summary + actions) */
.formfoot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 14px calc(12px + var(--safe-b));
  box-shadow: 0 -6px 24px rgba(18,29,24,.12);
}
.formfoot-in { max-width: 640px; margin: 0 auto; }
.ff-sum {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; gap: 10px;
}
.ff-sum b { font-size: 16px; color: var(--ink); }
.ff-sum .ok { color: var(--accent); font-weight: 700; }
.ff-sum .bad { color: var(--neg); font-weight: 700; }
.ff-actions { display: flex; gap: 10px; }
.ff-actions .btn { flex: 1; }
body.has-formfoot .content { padding-bottom: calc(150px + var(--safe-b)); }
body.has-formfoot .bottomnav { display: none; }

/* ---------- Expense items ---------- */
.item-card { position: relative; }
.item-card .item-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
}
.item-card .item-body { padding: 0 14px 14px; }
.item-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--deep);
  color: var(--cream); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.item-remove { margin-left: auto; }
.cat-pick {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1.5px dashed var(--line); background: var(--paper);
  padding: 10px 12px; border-radius: var(--radius-s); cursor: pointer;
  font-size: 14.5px; font-weight: 650; color: var(--ink-soft); font-family: var(--font);
}
.cat-pick.picked { border-style: solid; background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.cat-pick .cp-ic { font-size: 18px; }
.fuel-box {
  margin-top: 10px; border: 1.5px solid var(--amber); border-radius: var(--radius-s);
  background: var(--amber-soft); padding: 12px;
}
.fuel-box .fb-title { font-size: 12.5px; font-weight: 800; color: #8a5d17; letter-spacing: .5px; margin-bottom: 10px; }
.fuel-litres { font-size: 13px; font-weight: 700; color: #8a5d17; margin-top: 6px; }

.alloc-bar {
  display: flex; justify-content: space-between; font-size: 12.5px;
  color: var(--muted); font-weight: 600; margin: 8px 2px 0;
}

/* ---------- Picker sheet (categories/places/accounts) ---------- */
.pick-search { position: sticky; top: 0; background: var(--card); padding: 2px 0 10px; z-index: 2; }
.pick-list { display: flex; flex-direction: column; }
.pick-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft); cursor: pointer; background: none;
  border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left;
  font-size: 15px; font-family: var(--font); color: var(--ink); font-weight: 600;
}
.pick-item .pi-ic { font-size: 19px; width: 28px; text-align: center; }
.pick-item .pi-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.pick-item .pi-right { margin-left: auto; color: var(--muted); }
.pick-group {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); padding: 12px 4px 4px;
}
.pick-add {
  display: flex; align-items: center; gap: 8px; padding: 12px 4px; width: 100%;
  color: var(--accent); font-weight: 700; background: none; border: 0;
  font-size: 14.5px; cursor: pointer; font-family: var(--font);
}

/* ---------- Dashboard ---------- */
.hero {
  background: linear-gradient(150deg, var(--deep) 0%, var(--deep-2) 100%);
  border-radius: 16px; color: var(--cream); padding: 18px 16px;
  box-shadow: var(--shadow); margin-bottom: 14px; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px;
  border-radius: 50%; background: rgba(201,138,46,.14);
}
.hero .hero-label { font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: #9fb4a9; font-weight: 700; }
.hero .hero-amt { font-size: 30px; font-weight: 750; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.hero .hero-sub { font-size: 12.5px; color: #b9c9c0; }

.balgrid { display: flex; flex-direction: column; gap: 10px; }

.topcat { cursor: pointer; }
.topcat .tc-bar-wrap { height: 5px; border-radius: 4px; background: var(--paper); margin-top: 6px; overflow: hidden; }
.topcat .tc-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), #35a389); }
.topcat.tc-open { background: #fbf8f0; }
.tc-rank {
  width: 22px; font-size: 12px; font-weight: 800; color: var(--muted); text-align: center; flex: none;
}
.drill { border-top: 1px dashed var(--line); background: #fbf9f3; padding: 4px 14px 10px 46px; }
.drill .d-row {
  display: flex; justify-content: space-between; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 13.5px; cursor: pointer;
}
.drill .d-row:last-child { border-bottom: 0; }
.drill .d-sub { color: var(--muted); font-size: 12px; }
.drill .d-amt { font-weight: 700; white-space: nowrap; }
.drill .d-lines { padding-left: 12px; border-left: 2px solid var(--line); margin: 2px 0 6px; }

/* ---------- Ledger ---------- */
.led-day {
  font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); margin: 16px 4px 6px;
}
.txn-card { margin-bottom: 10px; overflow: hidden; }
.txn-head { display: flex; align-items: center; gap: 10px; padding: 11px 13px 9px; }
.txn-type {
  font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  border-radius: 6px; padding: 3px 7px; flex: none;
}
.tt-expense { background: var(--accent-soft); color: #0d5c4a; }
.tt-transfer { background: var(--blue-soft); color: #2d4a66; }
.tt-revenue { background: var(--amber-soft); color: #8a5d17; }
.tt-commitment { background: #efe3f3; color: #6b3d7a; }
.tt-opening { background: #eee9df; color: #6d6759; }
.txn-when { font-size: 12px; color: var(--muted); }
.txn-total { margin-left: auto; font-weight: 750; font-size: 15.5px; }
.txn-lines { padding: 0 13px 6px; }
.txn-pair {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  font-size: 13.5px;
}
.txn-pair .tp-side {
  font-size: 10px; font-weight: 800; width: 24px; flex: none; text-align: center;
  border-radius: 5px; padding: 2px 0;
}
.tp-dr { background: var(--accent-soft); color: #0d5c4a; }
.tp-cr { background: var(--neg-soft); color: #86271f; }
.txn-pair .tp-name { flex: 1; min-width: 0; }
.txn-pair .tp-name .tp-det { color: var(--muted); font-size: 12px; }
.txn-pair .tp-amt { font-weight: 650; white-space: nowrap; font-size: 13px; }
.txn-group-rail { border-left: 2px solid var(--line); margin-left: 11px; padding-left: 10px; }
.txn-foot {
  display: flex; align-items: center; gap: 8px; padding: 8px 13px 11px;
  border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted);
}
.txn-foot .tf-place { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-foot .iconbtn { width: 30px; height: 30px; }

/* Filter bar */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar .input-wrap { position: relative; flex: 1; }
.searchbar .input-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted);
}
.searchbar input { padding-left: 36px; }
.filter-chips { margin-bottom: 12px; }
.filter-chips .chip { font-size: 12.5px; padding: 6px 11px; }
.fbadge {
  background: var(--amber); color: var(--deep); font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 1px 7px; margin-left: 4px;
}

/* ---------- Fuel ---------- */
.fuel-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.fstat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px; text-align: center; }
.fstat .fs-v { font-weight: 750; font-size: 15px; font-variant-numeric: tabular-nums; }
.fstat .fs-l { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.kml-badge {
  font-weight: 800; font-size: 14px; border-radius: 9px; padding: 5px 9px;
  background: var(--accent-soft); color: #0d5c4a; white-space: nowrap;
}
.kml-badge.na { background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 700; }
.kml-badge.warn { background: var(--neg-soft); color: #86271f; }
.fuel-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.fuel-meta b { font-variant-numeric: tabular-nums; }

/* ---------- Management tables ---------- */
.mng-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mng-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); font-weight: 650; box-shadow: var(--shadow);
}
.mng-tile svg { color: var(--accent); width: 22px; height: 22px; }
.mng-tile .mt-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.badge {
  font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 7px;
  background: var(--paper); color: var(--ink-soft);
}
.badge.off { background: var(--neg-soft); color: #86271f; }
.badge.sysb { background: var(--blue-soft); color: #2d4a66; }
.row .actions { display: flex; gap: 6px; }

/* ---------- Login ---------- */
body.login-page { background: var(--deep); }
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card);
  border-radius: 20px; padding: 28px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { margin: 0 auto 10px; }
.login-brand h1 { font-size: 20px; margin: 0; color: var(--ink); }
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.brand-mark {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: linear-gradient(150deg, #e0a33e, var(--amber));
  color: var(--deep); font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.5px;
}

/* ---------- Confirm dialog ---------- */
.confirm-body { font-size: 14px; color: var(--ink-soft); }
.confirm-body .cb-box {
  background: var(--paper); border-radius: var(--radius-s); padding: 12px; margin: 10px 0 16px;
  font-size: 13.5px;
}
.confirm-body .cb-box div { padding: 2px 0; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* ---------- Empty states ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 34px 20px; font-size: 14px;
}
.empty .e-ic { font-size: 34px; margin-bottom: 8px; }

/* ---------- Utility ---------- */
.mt0{margin-top:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt20{margin-top:20px}
.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}
.tac{text-align:center}.small{font-size:12.5px;color:var(--muted)}
.hide { display: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ============================================================
   Single mobile layout on every screen size.
   On wide screens the app renders as a centred phone-width column.
   ============================================================ */
.sidebar { display: none !important; }

/* ============================================================
   v2 refinements — typography, texture, compact ledger, media
   ============================================================ */

:root {
  --font-display: Cambria, "Palatino Linotype", Georgia, "Times New Roman", serif;
  --cr-ink: #a3432f;
  --dr-ink: #0e6b5c;
}

/* ---------- Typography with character ---------- */
body { font-size: 14.5px; letter-spacing: .1px; }
.topbar-title, .step-title, .sheet-title, .login-brand h1, .brand-name,
.hero-amt, .r-amt, .fs-v, .ls-v, .txn-pair .tp-amt, .ff-sum b, .drill .d-amt {
  font-family: var(--font-display);
}
.hero-amt { font-size: 34px; letter-spacing: .3px; }
.r-amt { font-size: 16px; }
.f-label, .sec-h h2, .led-day, .fs-l, .pick-group, .hero-label {
  letter-spacing: 1.1px;
}
.topbar-title { letter-spacing: .4px; }

/* ---------- Textured paper background ---------- */
body {
  background:
    repeating-linear-gradient(0deg, rgba(29,42,36,.014) 0 1px, transparent 1px 28px),
    radial-gradient(1100px 480px at 18% -180px, #ece4d0 0%, rgba(236,228,208,0) 62%),
    radial-gradient(900px 420px at 108% -140px, rgba(21,122,99,.10) 0%, rgba(21,122,99,0) 60%),
    var(--paper);
}
body.login-page {
  background:
    radial-gradient(900px 480px at 80% -10%, rgba(201,138,46,.16) 0%, transparent 55%),
    radial-gradient(700px 500px at 0% 110%, rgba(21,122,99,.22) 0%, transparent 60%),
    var(--deep);
}

/* ---------- Header & nav polish ---------- */
.topbar { border-bottom: 3px solid var(--amber); }
.bottomnav {
  left: 10px; right: 10px; bottom: 10px;
  border-radius: 20px;
  padding: 6px 6px calc(8px + var(--safe-b) * .4);
  box-shadow: 0 10px 30px rgba(18,41,33,.35), inset 0 1px 0 rgba(255,255,255,.06);
}
.content { padding-bottom: calc(104px + var(--safe-b)); }

/* ---------- Section headers with rule ---------- */
.sec-h { gap: 12px; }
.sec-h h2 { display: flex; align-items: center; gap: 10px; flex: 1; }
.sec-h h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sec-h .badge { letter-spacing: 0; }

/* ---------- Cards: warmer, less uniform ---------- */
.card { border-color: #e2d9c6; box-shadow: 0 1px 2px rgba(29,42,36,.05), 0 10px 24px -14px rgba(120,100,60,.25); }
.hero { border: 1px solid #0d1f19; }
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.022) 0 2px, transparent 2px 9px);
  pointer-events: none;
}

/* ---------- Ledger: compact + typed accent + DR/CR colours ---------- */
.txn-card { margin-bottom: 8px; border-left: 4px solid var(--line); }
.txn-card.lt-expense { border-left-color: var(--accent); }
.txn-card.lt-transfer { border-left-color: #3d6b8e; }
.txn-card.lt-revenue { border-left-color: var(--amber); }
.txn-card.lt-commitment { border-left-color: #7a4d8a; }
.txn-card.lt-opening { border-left-color: #9a927e; }
.txn-head {
  padding: 7px 8px 4px 12px; gap: 8px;
  border-bottom: 1px dashed var(--line-soft);
}
.txn-head .tf-place {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--muted);
}
.txn-head .txn-when { flex: none; }
.txn-head .iconbtn { width: 28px; height: 28px; border-radius: 8px; }
.txn-head .iconbtn svg { width: 15px; height: 15px; }
.txn-lines { padding: 2px 12px 8px; }
.txn-pair { padding: 4px 0; }
.txn-pair .tp-amt { font-size: 14px; }
.txn-pair .tp-amt.dr { color: var(--dr-ink); }
.txn-pair .tp-amt.cr { color: var(--cr-ink); }
.txn-foot { padding: 6px 12px 8px; }
.led-day {
  display: flex; align-items: center; gap: 10px; margin: 14px 4px 6px;
}
.led-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.led-summary {
  display: flex; gap: 18px; align-items: baseline;
  background: var(--card); border: 1px solid #e2d9c6; border-left: 4px solid var(--amber);
  border-radius: var(--radius-s); padding: 9px 14px; margin: 0 0 12px;
}
.led-summary .ls-item { display: flex; align-items: baseline; gap: 6px; }
.led-summary .ls-v { font-weight: 750; font-size: 17px; font-variant-numeric: tabular-nums; }
.led-summary .ls-l { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }

/* ---------- Mini icons in ledger lines & pickers ---------- */
.mini-ic {
  width: 20px; height: 20px; border-radius: 6px; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper); border: 1px solid var(--line-soft);
  font-size: 12px; line-height: 1;
}
.mini-ic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pi-img { width: 24px; height: 24px; border-radius: 7px; object-fit: cover; display: inline-block; vertical-align: middle; }
.cat-pick .cp-ic img.pi-img { width: 22px; height: 22px; }

/* ---------- Media manager ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media-item {
  background: var(--card); border: 1px solid #e2d9c6; border-radius: var(--radius-s);
  padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
.media-thumb {
  width: 56px; height: 56px; border-radius: 12px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center;
}
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-name { font-size: 11.5px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-use { font-size: 10.5px; color: var(--muted); }

/* ---------- Buttons & inputs polish ---------- */
.btn { box-shadow: inset 0 -2px 0 rgba(0,0,0,.14); }
.btn-ghost { box-shadow: none; }
.input, select.input { background: #fffdf8; }
.amount-input-wrap input { font-family: var(--font-display); }

/* ============================================================
   Phone-width app column on every screen size
   ============================================================ */
:root { --appw: 520px; }
.maincol { max-width: var(--appw); width: 100%; margin: 0 auto; }
.flashes { max-width: var(--appw); }
.bottomnav {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(100vw - 20px, calc(var(--appw) - 20px));
}
.formfoot {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(100vw, var(--appw));
  border-radius: 14px 14px 0 0;
}
.sheet { max-width: var(--appw); margin: 0 auto; }
.pwa-banner { }
@media (min-width: 560px) {
  .maincol {
    box-shadow: 0 0 0 1px #ddd3bd, 0 30px 80px -30px rgba(29,42,36,.45);
    min-height: 100vh;
  }
  .login-card { max-width: 360px; }
}

/* ---------- Media picker (visual logo chooser) ---------- */
.media-pick { width: 100%; }
.media-pick .mp-preview { display: inline-flex; align-items: center; justify-content: center; width: 26px; }
.mp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px;
  padding-bottom: 6px;
}
.mp-item {
  border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius-s);
  padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-family: var(--font);
}
.mp-item:hover { border-color: var(--accent); }
.mp-item .media-thumb { width: 44px; height: 44px; border-radius: 10px; }
.mp-item .media-name { font-size: 10px; font-weight: 600; color: var(--ink-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- PWA install banner ---------- */
.pwa-banner {
  position: fixed; z-index: 55;
  left: 50%; transform: translateX(-50%);
  bottom: calc(84px + var(--safe-b));
  width: min(100vw - 24px, calc(var(--appw) - 24px));
  background: var(--deep); color: var(--cream);
  border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 14px 40px rgba(18,41,33,.45);
}
.pwa-banner .pb-ic { font-size: 22px; }
.pwa-banner .pb-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pwa-banner .pb-txt b { font-size: 13.5px; }
.pwa-banner .pb-txt span { font-size: 11.5px; color: #b9c9c0; }
.pwa-banner .pb-close {
  background: none; border: 0; color: #9fb4a9; font-size: 15px; cursor: pointer;
  padding: 6px; flex: none;
}
