/* Daybook — mobile-first dark UI */
:root {
  --bg: #0b0b0f;
  --card: #1c1c22;
  --card2: #26262e;
  --text: #f2f2f5;
  --muted: #8e8e98;
  --line: #33333c;
  --green: #2ecc71;
  --red: #ff5c47;
  --blue: #1f8fff;
  --radius: 16px;
  --nav-h: 74px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 16px;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; flex: 1; text-align: center; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--card); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 26px; border: none; cursor: pointer;
}
.iconbtn.spacer { background: transparent; }
.iconbtn.danger { color: var(--red); }
.right-slot { display: inline-flex; gap: 8px; }

.content { padding: 6px 16px 24px; max-width: 560px; margin: 0 auto; }

/* Cards / stat grid */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
}
.stat .label { color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}
.badge.get { background: rgba(46,204,113,.18); color: var(--green); }
.badge.pay { background: rgba(255,92,71,.18); color: var(--red); }

h2.section { font-size: 20px; margin: 22px 0 12px; }

/* Transaction list */
.txnlist { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.txnlist .daterow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  color: var(--text); font-weight: 600; font-size: 15px;
}
.txnlist .daterow .dbal { color: var(--muted); font-weight: 600; }
.txn {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.txn:last-child { border-bottom: none; }
.txn .t { flex: 1; min-width: 0; }
.txn .t .desc { font-size: 16.5px; font-weight: 600; word-wrap: break-word; }
.txn .t .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.txn .amt { font-weight: 700; font-size: 16.5px; white-space: nowrap; }
.amt.in { color: var(--green); }
.amt.out { color: var(--red); }
.empty { color: var(--muted); text-align: center; padding: 34px 16px; }

/* Report tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 15.5px;
  display: flex; flex-direction: column; gap: 12px;
}
.tile .ticon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--card2);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}

/* Bottom nav */
.bottomnav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  background: #17171c; border: 1px solid var(--line);
  display: flex; gap: 4px; padding: 6px;
  border-radius: 999px; z-index: 30;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.bottomnav .tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); text-decoration: none;
  font-size: 12px; padding: 8px 18px; border-radius: 999px;
}
.bottomnav .tab svg { width: 22px; height: 22px; }
.bottomnav .tab.active { color: var(--blue); background: #22222b; }

/* FAB action buttons */
.fabrow {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 14px; z-index: 25;
  pointer-events: none;
}
.fabrow .fab {
  pointer-events: auto;
  border: none; border-radius: 999px; padding: 14px 26px;
  font-size: 16.5px; font-weight: 700; color: #fff; text-decoration: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.fab.expense { background: #e8442a; }
.fab.income { background: #17b26a; }

/* Forms */
label.f { display: block; color: var(--muted); font-size: 14px; margin: 16px 0 6px; }
input.f, select.f, textarea.f {
  width: 100%; background: transparent; border: 1px solid var(--line);
  color: var(--text); border-radius: 12px; padding: 13px 14px; font-size: 16px;
  appearance: none;
}
input.f:focus, select.f:focus, textarea.f:focus { outline: none; border-color: var(--blue); }
select.f { background: var(--bg); }
.btn {
  display: block; width: 100%; border: none; cursor: pointer;
  background: #fff; color: #000; font-size: 17px; font-weight: 700;
  padding: 15px; border-radius: 999px; margin-top: 22px; text-align: center; text-decoration: none;
}
.btn.secondary { background: var(--card2); color: var(--text); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.error { background: rgba(255,92,71,.12); color: var(--red); padding: 12px 14px; border-radius: 12px; margin: 12px 0; font-size: 14.5px; }
.success { background: rgba(46,204,113,.12); color: var(--green); padding: 12px 14px; border-radius: 12px; margin: 12px 0; font-size: 14.5px; }

/* Add-entry screen */
.addwrap { max-width: 560px; margin: 0 auto; }
.seg {
  display: flex; justify-content: center; gap: 8px; padding: 10px 0;
}
.seg a {
  padding: 9px 22px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 700; font-size: 16px;
}
.seg a.on.income { background: #1d2733; color: #fff; }
.seg a.on.expense { background: #2d2230; color: #fff; }
.bigamount {
  text-align: center; font-size: 44px; font-weight: 700; margin: 18px 0 6px;
}
.bigamount.in { color: var(--text); } .bigamount .cur.in { color: var(--green); }
.bigamount .cur.out { color: var(--red); }
.bigamount input {
  background: transparent; border: none; color: inherit; font: inherit;
  width: 60%; text-align: left; outline: none;
}
.centerfield { display: flex; justify-content: center; margin: 8px 0; }
.centerfield input {
  background: transparent; border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); text-align: center; padding: 11px 16px; font-size: 15.5px; width: 82%;
  outline: none;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
.chip {
  background: #1d2530; color: #cfd6e2; border: none; cursor: pointer;
  border-radius: 999px; padding: 9px 16px; font-size: 14.5px;
}
.chip.on { background: var(--blue); color: #fff; }
.choose-cat { text-align: center; margin: 10px 0; }
.choose-cat a { color: var(--blue); text-decoration: none; font-weight: 600; font-size: 15.5px; }
.metarow { display: flex; gap: 10px; margin: 16px 0; }
.metarow > * { flex: 1; }

/* Filter sheet + chips */
.filterrow { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.filterrow::-webkit-scrollbar { display: none; }
.fchip {
  flex: 0 0 auto; background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 8px 16px; font-size: 14px; text-decoration: none;
}
.fchip.on { background: var(--blue); color: #fff; }

/* Contact rows (credit book) */
.crow {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.crow:last-child { border-bottom: none; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--card2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: var(--blue); flex: 0 0 auto;
}
.crow .n { flex: 1; min-width: 0; }
.crow .n .nm { font-weight: 600; font-size: 16.5px; }
.crow .n .ph { color: var(--muted); font-size: 13px; margin-top: 2px; }
.crow .bal { text-align: right; }
.crow .bal .b { font-weight: 700; }
.crow .bal .lbl { font-size: 12px; color: var(--muted); }

/* Login */
.login-wrap { max-width: 400px; margin: 12vh auto 0; padding: 0 22px; text-align: center; }
.login-wrap .logo {
  width: 76px; height: 76px; border-radius: 22px; background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; margin: 0 auto 18px;
}
.login-wrap h1 { font-size: 24px; margin: 0 0 4px; }
.login-wrap p { color: var(--muted); margin: 0 0 22px; }
.login-wrap form { text-align: left; }

/* Settings list */
.setlist { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.setlist a, .setlist .srow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line); font-size: 16px;
}
.setlist a:last-child, .setlist .srow:last-child { border-bottom: none; }
.setlist .chev { color: var(--muted); }

/* Summary bar on cashbook (period totals) */
.sumbar {
  display: flex; gap: 10px; margin-bottom: 12px;
}
.sumbar .s { flex: 1; background: var(--card); border-radius: 12px; padding: 10px 12px; }
.sumbar .s .k { color: var(--muted); font-size: 12.5px; }
.sumbar .s .v { font-weight: 700; font-size: 15.5px; margin-top: 3px; }

@media (min-width: 700px) {
  body { font-size: 16px; }
  .content { max-width: 640px; }
}
