/* NSofts Pocket styles. Five themes: light (default), pink, blue, green, dark.
   A theme only changes the colour tokens below; nothing else in this file is colour specific.
   No theme chosen = follow the device (light or dark). */
:root {
  --bg: #f3f6f6; --card: #ffffff; --ink: #0f1f1d; --muted: #5a6b68; --line: #e0e8e6;
  --brand: #0f766e; --brand-2: #14b8a6; --brand-ink: #ffffff; --soft: #e3f3f0; --soft-ink: #0b5a54;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --good: #15803d; --good-soft: #dcfce7;
  --side: #ffffff; --field: #f6f9f8;
  --shadow: 0 1px 2px rgba(15, 31, 29, .05), 0 6px 20px rgba(15, 31, 29, .06);
  --shadow-lg: 0 2px 4px rgba(15, 31, 29, .06), 0 14px 38px rgba(15, 31, 29, .10);
  --radius: 16px; --radius-sm: 10px;
}
:root[data-theme="pink"] {
  --bg: #fdf1f6; --card: #ffffff; --ink: #2b1420; --muted: #7b5869; --line: #f3d6e3;
  --brand: #be185d; --brand-2: #ec4899; --brand-ink: #ffffff; --soft: #fce7f1; --soft-ink: #9d174d;
  --good: #15803d; --side: #fff8fb; --field: #fff6fa;
  --shadow: 0 1px 2px rgba(190, 24, 93, .06), 0 6px 20px rgba(190, 24, 93, .08);
  --shadow-lg: 0 2px 4px rgba(190, 24, 93, .08), 0 14px 38px rgba(190, 24, 93, .12);
}
:root[data-theme="blue"] {
  --bg: #eef4fc; --card: #ffffff; --ink: #0e1c33; --muted: #52647f; --line: #d3e0f3;
  --brand: #1d4ed8; --brand-2: #38bdf8; --brand-ink: #ffffff; --soft: #e0ebfe; --soft-ink: #1e40af;
  --side: #f8fbff; --field: #f4f8fe;
  --shadow: 0 1px 2px rgba(29, 78, 216, .06), 0 6px 20px rgba(29, 78, 216, .08);
  --shadow-lg: 0 2px 4px rgba(29, 78, 216, .08), 0 14px 38px rgba(29, 78, 216, .12);
}
:root[data-theme="green"] {
  --bg: #eef8f0; --card: #ffffff; --ink: #0f2217; --muted: #526b5b; --line: #d2e6d7;
  --brand: #15803d; --brand-2: #4ade80; --brand-ink: #ffffff; --soft: #dff3e4; --soft-ink: #166534;
  --good: #166534; --side: #f8fdf9; --field: #f4fbf6;
  --shadow: 0 1px 2px rgba(21, 128, 61, .06), 0 6px 20px rgba(21, 128, 61, .08);
  --shadow-lg: 0 2px 4px rgba(21, 128, 61, .08), 0 14px 38px rgba(21, 128, 61, .12);
}
:root[data-theme="dark"] {
  --bg: #0b1211; --card: #141f1e; --ink: #e8f1ef; --muted: #98aaa6; --line: #243433;
  --brand: #2dd4bf; --brand-2: #5eead4; --brand-ink: #04211e; --soft: #14302d; --soft-ink: #99f6e4;
  --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1515; --good: #4ade80; --good-soft: #0f2e1b;
  --side: #101a19; --field: #0f1918;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 38px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0b1211; --card: #141f1e; --ink: #e8f1ef; --muted: #98aaa6; --line: #243433;
    --brand: #2dd4bf; --brand-2: #5eead4; --brand-ink: #04211e; --soft: #14302d; --soft-ink: #99f6e4;
    --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #f87171; --bad-soft: #3b1515; --good: #4ade80; --good-soft: #0f2e1b;
    --side: #101a19; --field: #0f1918;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 38px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Nirmala UI", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: var(--brand); }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico { display: contents; }
.fld[hidden] { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell: phone first ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.brand img { border-radius: 8px; display: block; }
.brand small { font-weight: 600; font-size: 10px; color: var(--soft-ink); background: var(--soft); border-radius: 999px; padding: 2px 8px; text-transform: uppercase; letter-spacing: .06em; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.top-actions .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.top-actions .btn { padding: 8px 10px; }
main { padding: 6px 16px 112px; outline: none; max-width: 1080px; margin: 0 auto; }
h2 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 14px 0 14px; font-weight: 800; }
h3 { font-size: 12px; margin: 22px 0 8px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0;
  box-shadow: var(--shadow);
}
.card > b:first-child { font-size: 16px; }

/* ---------- forms ---------- */
textarea, input, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--field);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; min-height: 46px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
textarea { resize: vertical; min-height: 110px; font-size: 18px; line-height: 1.45; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); background: var(--card); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row > * { min-width: 0; }
.row.r3 { grid-template-columns: repeat(3, 1fr); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; cursor: pointer;
  border-radius: 12px; padding: 11px 18px; min-height: 44px; border: 1.5px solid transparent;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, var(--brand-2))); color: var(--brand-ink);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 30%, transparent);
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn[hidden] { display: none; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--soft); filter: none; }
.btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: 14px; min-height: 36px; border-radius: 10px; }
.btn.big { padding: 13px 24px; font-size: 17px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip { flex: none; }
.chip {
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; background: var(--soft); color: var(--soft-ink);
  border: 1px solid transparent; border-radius: 999px; padding: 6px 13px; min-height: 32px; transition: background .15s, transform .08s;
}
.chip:hover { background: color-mix(in srgb, var(--soft) 70%, var(--brand) 14%); }
.chip:active { transform: scale(.96); }
.chip.q { background: transparent; border-color: var(--line); color: var(--muted); }
.chips.tight { margin-top: 8px; gap: 6px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.item:first-child { border-top: 0; padding-top: 2px; }
.item:last-child { padding-bottom: 2px; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 650; overflow-wrap: anywhere; }
.item .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.av { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--soft); color: var(--soft-ink); }
.av svg.i { width: 20px; height: 20px; }
.av.income, .av.repayment { background: var(--good-soft); color: var(--good); }
.av.bill, .av.reminder { background: var(--warn-soft); color: var(--warn); }
.av.borrowed { background: var(--bad-soft); color: var(--bad); }
.amt { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt.in, .good { color: var(--good); }
.amt.out { color: var(--ink); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.col-side .item .acts { flex-basis: 100%; justify-content: flex-start; padding-left: 52px; }
.tag { white-space: nowrap; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; background: var(--soft); color: var(--soft-ink); border-radius: 6px; padding: 2px 6px; margin-right: 6px; vertical-align: 1px; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.acts input { width: 120px; padding: 6px 10px; min-height: 36px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; border: 1.5px dashed var(--line); border-radius: var(--radius); margin: 12px 0; }

/* ---------- sync dot, banner, toast ---------- */
.syncdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.syncdot[hidden] { display: none; }
.syncdot.ok { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.syncdot.busy { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.syncdot.err { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.banner { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; font-size: 14px; }
.gbtn { min-height: 44px; margin: 12px 0; }
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 40;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; transition: .2s; max-width: 92vw; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.act { pointer-events: auto; }
#toast .btn { margin-left: 10px; padding: 4px 12px; min-height: 30px; }

/* ---------- stats and bars ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 24px; margin-top: 4px; letter-spacing: -.01em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.stat.hero { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--brand-2))); border-color: transparent; color: var(--brand-ink); }
.stat.hero span { color: inherit; opacity: .85; }
.bar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; }
.cat { margin: 14px 0; }
.cat .line { display: flex; justify-content: space-between; font-size: 14px; gap: 12px; }
.month { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 14px; }
.month b { font-size: 18px; }

/* ---------- capture: composer and the "understood" card ---------- */
.composer { padding: 18px; background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card) 90%, var(--soft))); }
.composer h2 { margin-top: 0; }
.live { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 26px; margin-top: 8px; }
.composer .actions { margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--soft); color: var(--soft-ink); }
.pill.type { background: var(--brand); color: var(--brand-ink); }
.pill.need { background: var(--warn-soft); color: var(--warn); }
.pill.learned::before { content: "\2726"; font-size: 11px; }
.und { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); box-shadow: var(--shadow-lg); animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.und-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.und-head .av { width: 44px; height: 44px; }
.und-head .big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.und-head .what { font-size: 13px; color: var(--muted); }
.quote { font-size: 14px; color: var(--muted); border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin: 8px 0 4px; overflow-wrap: anywhere; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; border: 1.5px solid var(--line); background: var(--field); color: var(--muted); border-radius: 999px; padding: 6px 13px; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.hint { font-size: 12px; margin-top: 4px; min-height: 16px; color: var(--muted); }
.fld.need input, .fld.need select { border-color: var(--warn); background: var(--warn-soft); }
.fld.need .hint { color: var(--warn); font-weight: 700; }
.fld.learned .hint { color: var(--soft-ink); }
.fld.learned .hint::before { content: "\2726 "; }
.fld.text .hint::before { content: "\2713 "; color: var(--good); }
.cols { display: block; }

/* ---------- settings ---------- */
.narrow { max-width: 720px; }
.themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 8px; }
.theme {
  font: inherit; cursor: pointer; background: var(--field); border: 2px solid var(--line); border-radius: 14px; padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink); font-size: 12.5px; font-weight: 600; min-height: 76px;
}
.theme[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .12); position: relative; overflow: hidden; }
.sw::after { content: ""; position: absolute; right: 0; bottom: 0; width: 50%; height: 50%; border-top-left-radius: 100%; background: var(--c2); }
.sw.light { --c2: #0f766e; background: #f3f6f6; }
.sw.pink { --c2: #be185d; background: #fdf1f6; }
.sw.blue { --c2: #1d4ed8; background: #eef4fc; }
.sw.green { --c2: #15803d; background: #eef8f0; }
.sw.dark { --c2: #2dd4bf; background: #0b1211; }

/* ---------- NSofts parent brand: the logo sits on a white tile so its dark wordmark reads in every theme ---------- */
.nsofts { display: block; text-decoration: none; color: var(--muted); }
.nsofts .by { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 6px; }
.nsofts .tile { display: block; background: #ffffff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; box-shadow: var(--shadow); transition: transform .12s; }
.nsofts:hover .tile { transform: translateY(-1px); }
.nsofts img { display: block; width: 100%; height: auto; }
.foot { max-width: 1080px; margin: 0 auto; padding: 0 16px 120px; text-align: center; }
.foot .nsofts { max-width: 220px; margin: 8px auto 0; }
.foot p { margin: 10px 0 0; }
.side-brand { display: none; }

/* ---------- navigation: bottom bar on phones ---------- */
#tabs {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; display: flex; gap: 2px; padding: 6px;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
}
#tabs button {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-size: 11px; font-weight: 600;
  padding: 8px 2px 6px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 16px; transition: background .15s, color .15s;
}
#tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tabs button.on { color: var(--brand); background: var(--soft); }
#tabs button.on svg.i { stroke-width: 2.2; }

/* ---------- tablet and desktop: sidebar ---------- */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .chips.scroll { flex-wrap: wrap; overflow: visible; margin: 12px 0 0; padding: 0; }
}
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px; padding: 22px 14px 18px; background: var(--side); border-right: 1px solid var(--line); }
  .top { display: contents; }
  .brand { order: 0; padding: 0 10px 18px; font-size: 22px; }
  #tabs { order: 1; position: static; flex-direction: column; gap: 4px; padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; border-radius: 0; }
  #tabs button { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 12px 14px; border-radius: 12px; }
  #tabs button.on { background: var(--soft); }
  .side-brand { display: block; order: 3; padding: 14px 4px 0; }
  .foot { display: none; }
  .top-actions { order: 2; margin-top: auto; flex-direction: column; align-items: stretch; gap: 8px; }
  .top-actions .btn { justify-content: flex-start; padding: 11px 14px; }
  .top-actions .btn span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .top-actions .syncdot { align-self: flex-start; margin: 0 0 4px 14px; }
  main { padding: 20px 40px 60px; margin: 0; max-width: none; width: 100%; }
  main > div { max-width: 1040px; margin: 0 auto; }
  h2 { font-size: 30px; margin-top: 8px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .card { padding: 20px; }
  #toast { bottom: 28px; left: calc(50% + 126px); }
  .row.r3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1180px) {
  .cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 24px; align-items: start; }
  .cols > .col-side h3:first-child { margin-top: 12px; }
  .stats.four { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 639px) {
  .item .acts { flex-basis: 100%; justify-content: flex-start; padding-left: 52px; }
}
@media (max-width: 420px) {
  .themes { grid-template-columns: repeat(3, 1fr); }
  .row.keep { grid-template-columns: 1fr 1fr; }
  h2 { font-size: 23px; }
  .stat b { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
