:root {
  /* palette from the Pushpadarshan logo: maroon #663333 + white */
  --bg: #f8f4f3; --card: #ffffff; --text: #2a1716; --muted: #7a6462; --line: #ecdfdd;
  --brand: #663333; --brand-2: #f5e9e7; --on-brand: #ffffff; --hero: #663333;
  --ok: #1a7f4b; --ok-bg: #e5f4ec; --warn: #a15c00; --warn-bg: #fdf0dc;
  --bad: #c0281c; --bad-bg: #fde9e7; --wa: #1fa855; --shadow: 0 1px 2px rgba(60,20,20,.06), 0 4px 14px rgba(60,20,20,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #140d0d; --card: #201616; --text: #f1e7e5; --muted: #b39e9b; --line: #352624;
    --brand: #e3aaa2; --brand-2: #3a2321; --on-brand: #2a1212; --hero: #5a2c2c;
    --ok: #4ccb8a; --ok-bg: #143224; --warn: #f0b45b; --warn-bg: #33270f;
    --bad: #ff8a80; --bad-bg: #3a1a17; --wa: #3ccf75; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }

/* layout */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 24px; margin: 0; flex: 1; letter-spacing: -.3px; }
.top .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
main { padding: 4px 16px calc(env(safe-area-inset-bottom) + 92px); max-width: 640px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; background: none; border: 0; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--brand); font-weight: 600; }

/* cards & lists */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; margin: 0 0 14px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.hero { background: var(--hero); color: #fff; }
.toplogo { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.hero .lbl { opacity: .85; font-size: 14px; }
.hero .big { font-size: 34px; font-weight: 700; letter-spacing: -.5px; margin: 2px 0 6px; }
.hero .row3 { display: flex; gap: 12px; font-size: 13px; opacity: .92; flex-wrap: wrap; }
.list { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); margin: 0 0 14px; overflow: hidden; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.list .item:first-child { border-top: 0; }
.list button.item:active { background: var(--brand-2); }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 600; text-align: right; white-space: nowrap; }
.item .amt small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 42px; border-radius: 12px; background: var(--brand-2); color: var(--brand); font-weight: 700; font-size: 15px; flex: none; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.part { background: var(--warn-bg); color: var(--warn); } .chip.due { background: var(--bad-bg); color: var(--bad); }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 4px 8px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.section-title button { text-transform: none; letter-spacing: 0; }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; font-size: 14px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.hero .bar { background: rgba(255,255,255,.25); } .hero .bar i { background: #fff; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; }
.kv span:first-child { color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--brand); color: var(--on-brand); }
.btn.sec { background: var(--brand-2); color: var(--brand); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { padding: 7px 11px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:active { opacity: .8; }
.btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 4px; font-size: 15px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.quick { display: flex; gap: 10px; margin: 0 0 14px; } .quick .btn { flex: 1; padding: 14px; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand-2); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn.wa { background: var(--ok-bg); color: var(--wa); }

/* month switcher */
.mswitch { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; margin: 0 0 14px; }
.mswitch b { font-size: 17px; }

/* sheet */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 20; animation: fade .18s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg); border-radius: 20px 20px 0 0; max-height: 92vh; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px); animation: up .22s ease-out; max-width: 640px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 8px; }
.sheet .shead { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.sheet .shead h3 { margin: 0; font-size: 19px; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* forms */
label.f { display: block; margin: 0 0 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; font-weight: 500; }
.in, select.in, textarea.in { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; -webkit-appearance: none; appearance: none; }
select.in { 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 1l5 5 5-5' fill='none' stroke='%239a8482' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.in:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.in.big { font-size: 26px; font-weight: 700; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px; font-size: 14px; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.chips button small { opacity: .75; margin-left: 4px; }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 6px 0; }

/* grid table */
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { padding: 8px 6px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.grid th:first-child, .grid td:first-child { text-align: left; }
.grid thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 12px; }
.scrollx { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dot { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; font-size: 12px; font-weight: 700; }
.dot.ok { background: var(--ok-bg); color: var(--ok); } .dot.part { background: var(--warn-bg); color: var(--warn); } .dot.due { background: var(--bad-bg); color: var(--bad); } .dot.na { color: var(--muted); }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.login img { width: 168px; height: 168px; border-radius: 32px; margin-bottom: 14px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.pin { display: flex; gap: 12px; justify-content: center; margin: 0 0 8px; }
.pin i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); }
.pin i.on { background: var(--brand); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; margin-top: 14px; }
.pad button { height: 76px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 28px; font-weight: 500; }
.pad button:active { background: var(--brand-2); }
.pad button.blank { background: none; box-shadow: none; font-size: 15px; color: var(--brand); }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%) translateY(20px); background: #2a1716; color: #fff; padding: 11px 16px;
  border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
.ro-note { font-size: 13px; background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; }
