:root {
  --bg:#f6f4ef; --card:#ffffff; --ink:#1d2a2a; --muted:#566666; --line:#e3ded3;
  --brand:#0f6b5e; --brand-d:#0a4f45; --brand-l:#e2f1ee; --accent:#f2b134;
  --ok:#1b7a3e; --ok-bg:#e3f4e8; --warn:#9a4a05; --warn-bg:#fdf0d5; --bad:#b42318; --bad-bg:#fde8e6;
  --r:16px; --shadow:0 2px 10px rgba(29,42,42,.08);
}
* { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html { font-size:16px; }
body { font-family:'Noto Sans Lao','Noto Sans Lao Looped',system-ui,sans-serif; background:var(--bg); color:var(--ink);
  line-height:1.55; padding-bottom:96px; -webkit-font-smoothing:antialiased; }
button, input, select, textarea { font:inherit; color:inherit; }
.wrap { max-width:760px; margin:0 auto; padding:0 16px; }

/* header */
.top { background:var(--brand); color:#fff; padding:14px 0; position:sticky; top:0; z-index:30; box-shadow:0 2px 8px rgba(0,0,0,.15); }
.top .wrap { display:flex; align-items:center; gap:12px; }
.logo { width:44px; height:44px; border-radius:12px; background:var(--accent); display:grid; place-items:center; font-size:1.5rem; flex:none; }
.top h1 { font-size:1.15rem; font-weight:800; line-height:1.2; }
.top small { opacity:.85; font-size:.8rem; }

/* pages */
.page { display:none; padding-top:18px; }
.page.on { display:block; animation:up .25s ease; }
@keyframes up { from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:none} }
h2.t { font-size:1.35rem; font-weight:800; margin:4px 0 14px; color:var(--brand-d); }
.sub { color:var(--muted); font-size:.9rem; }

/* cards */
.card { background:var(--card); border-radius:var(--r); box-shadow:var(--shadow); padding:18px; margin-bottom:14px; border:1px solid var(--line); }
.card h3 { font-size:1.05rem; font-weight:800; margin-bottom:10px; }
.hero { background:linear-gradient(135deg,var(--brand),var(--brand-d)); color:#fff; border:none; }
.hero h2 { font-size:1.5rem; font-weight:800; margin-bottom:6px; }
.hero p { opacity:.95; white-space:pre-line; }

/* buttons */
.btn { display:flex; align-items:center; justify-content:center; gap:10px; width:100%; min-height:50px; padding:12px 18px;
  border:2px solid transparent; border-radius:14px; font-weight:800; font-size:1.05rem; cursor:pointer; text-align:center; }
.btn:active { transform:scale(.98); }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn-pri { background:var(--accent); color:#2a1d00; }
.btn-brand { background:var(--brand); color:#fff; }
.btn-line { background:#fff; border-color:var(--brand); color:var(--brand-d); }
.btn-ghost { background:transparent; border-color:rgba(255,255,255,.7); color:#fff; }
.btn-bad { background:var(--bad); color:#fff; }
.btn-sm { min-height:44px; width:auto; padding:8px 14px; font-size:.9rem; border-radius:12px; }
.stack > * + * { margin-top:10px; }
.row { display:flex; gap:10px; flex-wrap:wrap; }
.row > * { flex:1; }

/* forms */
label.l { display:block; font-weight:800; margin:16px 0 8px; }
label.l .n { display:inline-grid; place-items:center; width:28px; height:28px; border-radius:50%; background:var(--brand); color:#fff; font-size:.85rem; margin-right:8px; }
.inp { width:100%; min-height:50px; padding:12px 14px; border:2px solid var(--line); border-radius:14px; background:#fff; }
.inp:focus { outline:3px solid rgba(15,107,94,.3); border-color:var(--brand); }
.chips { display:flex; flex-wrap:wrap; gap:8px; }
.chip { min-height:52px; padding:10px 16px; border-radius:14px; border:2px solid var(--line); background:#fff; font-weight:700; cursor:pointer; }
.chip.on { background:var(--brand); border-color:var(--brand); color:#fff; }
.choice { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.choice .chip { min-height:64px; font-size:1.1rem; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; }
.pick { width:100%; text-align:left; min-height:64px; padding:12px 16px; border:2px dashed var(--brand); border-radius:14px; background:var(--brand-l); font-weight:800; cursor:pointer; }
.pick.has { border-style:solid; background:#fff; }
.shot { width:100%; max-height:260px; object-fit:contain; border-radius:12px; border:1px solid var(--line); margin-top:10px; background:#f3f3f3; }
.big-amt { font-size:2rem; font-weight:900; color:var(--brand-d); text-align:center; padding:6px 0; }

/* badges / status */
.badge { display:inline-flex; align-items:center; gap:6px; padding:4px 12px; border-radius:999px; font-weight:800; font-size:.85rem; white-space:nowrap; }
.b-paid { background:var(--ok-bg); color:var(--ok); }
.b-partial { background:var(--warn-bg); color:var(--warn); }
.b-unpaid { background:var(--bad-bg); color:var(--bad); }
.b-inactive { background:#eee; color:#555; }
.note { padding:12px 14px; border-radius:12px; font-size:.92rem; }
.note.warn { background:var(--warn-bg); color:var(--warn); }
.note.bad { background:var(--bad-bg); color:var(--bad); }
.note.ok { background:var(--ok-bg); color:var(--ok); }

/* progress + stats */
.bar { height:16px; background:#e6e2d8; border-radius:999px; overflow:hidden; margin:10px 0 6px; }
.bar > i { display:block; height:100%; background:var(--ok); border-radius:999px; transition:width .6s; }
.big { font-size:2.2rem; font-weight:900; line-height:1.1; }
.stats { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; margin-bottom:14px; }
.stat { background:#fff; border:1px solid var(--line); border-radius:var(--r); padding:14px; text-align:center; box-shadow:var(--shadow); }
.stat b { display:block; font-size:1.6rem; font-weight:900; }
.stat span { font-size:.82rem; color:var(--muted); }
.stat.ok b { color:var(--ok); } .stat.bad b { color:var(--bad); } .stat.warn b { color:var(--warn); }

/* month switcher */
.msw { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.msw button { width:56px; height:56px; flex:none; border-radius:14px; border:2px solid var(--line); background:#fff; font-size:1.4rem; font-weight:900; cursor:pointer; }
.msw div { flex:1; text-align:center; font-size:1.25rem; font-weight:900; }

/* tabs inside page */
.seg { display:flex; gap:6px; overflow-x:auto; margin-bottom:12px; padding-bottom:4px; }
.seg button { flex:none; min-height:46px; padding:8px 14px; border-radius:999px; border:2px solid var(--line); background:#fff; font-weight:700; cursor:pointer; }
.seg button.on { background:var(--brand); color:#fff; border-color:var(--brand); }

/* list rows */
.li { display:flex; align-items:center; gap:12px; padding:14px 4px; border-bottom:1px solid var(--line); }
.li:last-child { border-bottom:none; }
.li .main { flex:1; min-width:0; }
.li .main b { display:block; font-weight:800; overflow-wrap:anywhere; }
.li .main small { color:var(--muted); display:block; }
.li .amt { font-weight:900; text-align:right; white-space:nowrap; }
.li.btnrow { cursor:pointer; }
.empty { text-align:center; color:var(--muted); padding:28px 8px; }

/* QR */
.qr { display:block; width:min(280px,80%); margin:6px auto 12px; border-radius:12px; border:1px solid var(--line); background:#fff; }
.acct { text-align:center; }
.acct .no { font-size:1.6rem; font-weight:900; letter-spacing:1px; color:var(--brand-d); margin:4px 0 10px; }

/* policy */
.pol { white-space:pre-line; overflow-wrap:anywhere; }

/* bottom nav */
.tabs { position:fixed; left:0; right:0; bottom:0; z-index:40; background:#fff; border-top:1px solid var(--line); box-shadow:0 -2px 10px rgba(0,0,0,.06); padding-bottom:env(safe-area-inset-bottom); }
.tabs .in { max-width:760px; margin:0 auto; display:flex; }
.tabs button { flex:1; min-height:68px; border:none; background:none; font-weight:700; font-size:.78rem; color:var(--muted); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; cursor:pointer; }
.tabs button span { font-size:1.5rem; line-height:1; }
.tabs button.on { color:var(--brand-d); background:var(--brand-l); }
.tabs button.pay span { background:var(--accent); border-radius:50%; width:40px; height:40px; display:grid; place-items:center; font-size:1.3rem; margin-top:-14px; box-shadow:0 2px 8px rgba(0,0,0,.2); }

/* modal */
.ov { position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:100; display:flex; align-items:flex-end; justify-content:center; }
.sheet { background:#fff; width:100%; max-width:760px; max-height:92vh; overflow:auto; border-radius:22px 22px 0 0; padding:20px 18px 28px; animation:up .2s ease; }
.sheet h3 { font-size:1.2rem; font-weight:800; margin-bottom:12px; }
.sheet .x { float:right; width:44px; height:44px; border-radius:50%; border:none; background:#eee; font-size:1.2rem; cursor:pointer; }
.proof { width:100%; border-radius:12px; margin-top:8px; }

/* toast */
#toast { position:fixed; left:50%; bottom:100px; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; width:min(92vw,520px); pointer-events:none; }
.toast { background:#1d2a2a; color:#fff; padding:14px 16px; border-radius:14px; font-weight:700; box-shadow:0 6px 20px rgba(0,0,0,.3); }
.toast.err { background:var(--bad); } .toast.ok { background:var(--ok); }

.spin { width:40px; height:40px; border:5px solid var(--line); border-top-color:var(--brand); border-radius:50%; animation:sp .8s linear infinite; margin:30px auto; }
@keyframes sp { to { transform:rotate(360deg); } }
.foot { text-align:center; color:var(--muted); font-size:.85rem; padding:10px 0 20px; }
.foot a { color:var(--muted); }
.ok-big { text-align:center; padding:10px 0; }
.ok-big .ic { width:92px; height:92px; border-radius:50%; background:var(--ok-bg); color:var(--ok); display:grid; place-items:center; font-size:3rem; margin:0 auto 12px; }
canvas { max-width:100%; }
.scroll-x { overflow-x:auto; }
@media (min-width:700px) { html { font-size:17px; } .stats { grid-template-columns:repeat(4,1fr); } }
@media (prefers-reduced-motion:reduce) { * { animation:none !important; transition:none !important; } }

/* ===== VPS app polish ===== */
.top { background:linear-gradient(135deg,var(--brand),var(--brand-d)); border-radius:0 0 22px 22px; padding-top:calc(14px + env(safe-area-inset-top)); padding-bottom:16px; }
.logo { box-shadow:0 2px 8px rgba(0,0,0,.25); }
.hero { position:relative; overflow:hidden; }
.hero::after { content:''; position:absolute; right:-46px; top:-46px; width:170px; height:170px; border-radius:50%; background:rgba(242,177,52,.22); }
.hero::before { content:''; position:absolute; right:30px; bottom:-60px; width:130px; height:130px; border-radius:50%; background:rgba(255,255,255,.07); }
.hero > * { position:relative; z-index:1; }
.card { transition:box-shadow .2s; }
.av { width:42px; height:42px; border-radius:50%; background:var(--brand-l); color:var(--brand-d); display:grid; place-items:center; font-weight:900; flex:none; }
.tabs { padding-bottom:env(safe-area-inset-bottom); }
.tabs button { position:relative; }
.tabs button.on::before { content:''; position:absolute; top:0; left:25%; right:25%; height:3px; border-radius:0 0 4px 4px; background:var(--brand); }
body { padding-bottom:calc(92px + env(safe-area-inset-bottom)); }
textarea.inp { min-height:90px; resize:vertical; }
input[type=checkbox] { width:22px; height:22px; vertical-align:middle; margin-right:8px; accent-color:var(--brand); }
/* timeline (activity log) */
.tl { position:relative; }
.tl::before { content:''; position:absolute; left:19px; top:6px; bottom:6px; width:2px; background:var(--line); }
.tl-i { display:flex; gap:12px; padding:9px 0; position:relative; }
.tl-dot { width:40px; height:40px; border-radius:50%; background:var(--brand-l); display:grid; place-items:center; flex:none; z-index:1; font-size:1.1rem; border:2px solid #fff; }
.tl-dot.bad { background:var(--bad-bg); }
.tl-b { min-width:0; overflow-wrap:anywhere; font-size:.92rem; }
.tl-b small { color:var(--muted); }
.seg { scrollbar-width:none; }
.seg::-webkit-scrollbar { display:none; }
@media (min-width:900px) { .wrap { max-width:820px; } .tabs .in { max-width:820px; } }

.top-rank { width:34px; height:34px; border-radius:50%; display:grid; place-items:center; font-weight:900; color:#fff; flex:none; background:#7a8a8a; }
.top-rank.r1 { background:linear-gradient(135deg,#f59e0b,#d97706); } .top-rank.r2 { background:linear-gradient(135deg,#94a3b8,#64748b); } .top-rank.r3 { background:linear-gradient(135deg,#cd7f32,#a0522d); }

/* ===== ສີສະຖານະ (ໃຊ້ຄືກັນທຸກໜ້າ): ຂຽວ=ຊຳລະ/ລາຍຮັບ · ແດງ=ຍັງບໍ່ຊຳລະ/ລາຍຈ່າຍ · ເຫຼືອງສົ້ມ=ຄ້າງ/ບາງສ່ວນ · ຟ້າ=ຍອດເງິນ/ຄາດການ ===== */
:root { --info:#1d4ed8; --info-bg:#e4ecfd; }
.b-info { background:var(--info-bg); color:var(--info); }
.note.info { background:var(--info-bg); color:var(--info); }
.stat { position:relative; overflow:hidden; text-align:left; padding:12px 14px 12px 18px; }
.stat::before { content:''; position:absolute; left:0; top:0; bottom:0; width:5px; background:var(--line); }
.stat.ok::before { background:var(--ok); } .stat.bad::before { background:var(--bad); }
.stat.warn::before { background:#e08a00; } .stat.info::before { background:var(--info); }
.stat.warn b { color:var(--warn); } .stat.info b { color:var(--info); }
.stat span { display:block; }
.stats.s3 { grid-template-columns:repeat(3,1fr); }
.stats.s3 .stat b { font-size:1.15rem; }
.stats.s3 .stat { padding:10px 10px 10px 14px; }

/* ແຖບສີຊ້າຍຂອງແຖວຕາມສະຖານະ */
.li.acc { border-left:5px solid var(--line); padding-left:12px; margin-left:-4px; }
.li.acc-paid { border-left-color:var(--ok); }
.li.acc-partial { border-left-color:#e08a00; }
.li.acc-unpaid { border-left-color:var(--bad); }
.li.acc-inactive { border-left-color:#b5b5b5; }
.li.acc-income { border-left-color:var(--ok); }
.li.acc-spent { border-left-color:var(--bad); }
.amt.pos { color:var(--ok); } .amt.neg { color:var(--bad); }

/* ສະຫຼຸບຕົວເລກເປັນແຖວສີ */
.sumrows { display:flex; flex-direction:column; gap:8px; margin-top:12px; }
.sumrow { display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:12px; font-size:.95rem; }
.sumrow b { margin-left:auto; font-size:1.02rem; white-space:nowrap; }
.sumrow.ok { background:var(--ok-bg); color:var(--ok); }
.sumrow.bad { background:var(--bad-bg); color:var(--bad); }
.sumrow.warn { background:var(--warn-bg); color:var(--warn); }
.sumrow.info { background:var(--info-bg); color:var(--info); }
.dot { width:11px; height:11px; border-radius:50%; flex:none; background:currentColor; }
.legend { display:flex; flex-wrap:wrap; gap:6px 14px; font-size:.82rem; color:var(--muted); margin:-4px 0 12px; }
.legend span { display:inline-flex; align-items:center; gap:6px; }
.legend i { width:10px; height:10px; border-radius:50%; display:inline-block; }

/* ===== ປັບຂະໜາດ/ໄລຍະຫ່າງ: ບໍ່ໃຫຍ່ ບໍ່ແໜ້ນເກີນ ===== */
.btn { min-height:46px; padding:10px 16px; font-size:1rem; }
.btn-sm { min-height:40px; padding:7px 12px; font-size:.88rem; }
.chip { min-height:46px; padding:8px 14px; }
.choice .chip { min-height:62px; }
.inp, .pick { min-height:46px; }
.card { padding:16px; margin-bottom:14px; }
.card h3 { font-size:1rem; margin-bottom:10px; }
.hero h2 { font-size:1.35rem; }
.big { font-size:1.85rem; }
.big-amt { font-size:1.7rem; padding:4px 0 10px; }
h2.t { font-size:1.25rem; margin:2px 0 14px; }
label.l { margin:16px 0 8px; }
.li { padding:13px 4px; gap:12px; }
.stats { gap:10px; margin-bottom:14px; }
.stat b { font-size:1.4rem; }
.seg { gap:8px; margin-bottom:14px; }
.seg button { min-height:42px; padding:6px 14px; }
.msw button { width:46px; height:46px; }
.msw div { font-size:1.15rem; }
.tabs button { min-height:62px; }
.badge { padding:3px 11px; font-size:.82rem; }
.page { padding-top:16px; }
.sheet { padding:20px 18px 26px; }
