:root{--navy:#0A2342;--navy2:#163F69;--accent:#245B8F;--bg:#F4F6F9;--card:#fff;--border:#E2E7ED;--text:#243447;--muted:#748195;--sidebar-w:230px}
*{box-sizing:border-box}
html,body{min-height:100%}
body{background:var(--bg);color:var(--text);font-family:"Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;font-size:14px;line-height:1.45}
a{color:var(--accent)}
h1,h2,h3,h4,h5,h6{color:var(--navy)}
.form-label{font-size:12.5px;font-weight:600;color:var(--text);margin-bottom:3px}
.form-control,.form-select{font-size:14px;border-color:#cfd8e3}
.form-control:focus,.form-select:focus{border-color:var(--accent);box-shadow:0 0 0 .18rem rgba(36,91,143,.18)}
.form-control[readonly]{background:#f6f8fb}

/* ---------- Top bar ---------- */
.topbar{background:var(--navy);color:#fff;height:58px;position:fixed;top:0;left:0;right:0;z-index:1030;display:flex;align-items:center;padding:0 16px;border-bottom:3px solid var(--accent)}
.topbar .brand{display:flex;align-items:center;gap:11px;color:#fff;text-decoration:none;min-width:0}
.topbar .brand img{height:38px;width:auto;max-width:72px;object-fit:contain;background:#fff;border-radius:6px;padding:3px 5px;flex:none}
.topbar .brand .t1{font-weight:700;font-size:15px;letter-spacing:.3px;white-space:nowrap;line-height:1.15}
.topbar .brand .t2{font-size:11px;opacity:.75;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:46vw}
.topbar .user{margin-left:auto;display:flex;align-items:center;gap:14px;font-size:13px;white-space:nowrap}
.topbar .user .role{background:var(--accent);padding:1px 9px;border-radius:10px;font-size:11px;letter-spacing:.4px}
.topbar a.tlink{color:#dbe6f3;text-decoration:none}.topbar a.tlink:hover{color:#fff}

/* ---------- Sidebar ---------- */
#sidebar{position:fixed;top:58px;bottom:0;left:0;width:var(--sidebar-w);background:var(--navy2);overflow-y:auto;z-index:1020;padding:6px 0 20px}
#sidebar .grp{font-size:10.5px;letter-spacing:1.2px;text-transform:uppercase;color:#8fa6c2;padding:14px 20px 5px;font-weight:600}
#sidebar .grp:not(:first-child){margin-top:8px;border-top:1px solid rgba(255,255,255,.1)}
#sidebar a{display:flex;align-items:center;gap:11px;color:#d6e2f0;text-decoration:none;padding:9px 20px;font-size:13.5px;border-left:3px solid transparent}
#sidebar a i{font-size:15px;width:18px;text-align:center;opacity:.9}
#sidebar a:hover{background:rgba(255,255,255,.07);color:#fff}
#sidebar a.active{background:rgba(255,255,255,.13);color:#fff;border-left-color:#8fb8e6;font-weight:600}
main{margin-left:var(--sidebar-w);padding:76px 22px 20px;min-height:calc(100vh - 40px)}
.app-footer{margin-left:var(--sidebar-w);padding:10px 22px 16px;font-size:11.5px;color:var(--muted)}
@media(max-width:991px){
  #sidebar{transform:translateX(-100%);transition:transform .2s;box-shadow:2px 0 10px rgba(0,0,0,.25)}
  #sidebar.open{transform:none}
  main,.app-footer{margin-left:0}main{padding:72px 10px 20px}
  .topbar .brand .t2{display:none}.topbar .brand .t1{font-size:13.5px}
}

/* ---------- Cards & headings ---------- */
.card{border:1px solid var(--border);border-radius:5px;box-shadow:0 1px 2px rgba(10,35,66,.04)}
.card-header{background:#fff;border-bottom:1px solid var(--border);font-weight:600;color:var(--navy);padding:10px 16px}
.card-header .step{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:var(--navy);color:#fff;font-size:12px;margin-right:8px}
.page-title{font-size:20px;font-weight:600;color:var(--navy);margin:0 0 2px}
.breadcrumb{font-size:12.5px;margin-bottom:6px}
.btn-navy{background:var(--navy);color:#fff;border-color:var(--navy)}.btn-navy:hover,.btn-navy:focus{background:var(--navy2);border-color:var(--navy2);color:#fff}
.btn-sm{font-size:12.5px}
.badge{font-weight:500}
.small-muted{font-size:12px;color:var(--muted)}
.alert{font-size:13.5px}
.nav-tabs{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;white-space:nowrap;border-bottom:1px solid var(--border)}
.nav-tabs .nav-link{color:var(--accent);font-size:13.5px;border-radius:4px 4px 0 0}
.nav-tabs .nav-link.active{color:var(--navy);font-weight:600}
.modal-header{background:var(--navy);color:#fff}
.modal-header .btn-close{filter:invert(1)}

/* ---------- Dashboard stat cards ---------- */
.stat{background:#fff;border:1px solid var(--border);border-left:4px solid var(--accent);padding:10px 14px;border-radius:5px;height:100%}
.stat .n{font-size:22px;font-weight:700;color:var(--navy);line-height:1.2;word-break:break-word}.stat .l{font-size:12px;color:var(--muted)}
.stat.warn{border-left-color:#d98a00}.stat.bad{border-left-color:#c0392b}.stat.ok{border-left-color:#2e8b57}

/* ---------- Data tables ---------- */
.dt-wrap{max-height:68vh;overflow:auto;border:1px solid var(--border);background:#fff;border-radius:4px}
table.dt{width:100%;border-collapse:separate;border-spacing:0;font-size:12.8px;margin-bottom:0}
table.dt thead th{position:sticky;top:0;z-index:2;background:#EAF0F7;color:var(--navy);font-weight:600;border-bottom:1px solid #cfd8e3;border-right:1px solid var(--border);padding:0 8px;height:32px;white-space:nowrap;vertical-align:middle}
table.dt thead tr.filters th{top:32px;background:#f6f9fc;padding:3px 4px;height:auto;z-index:2}
table.dt thead tr.filters input,table.dt thead tr.filters select{width:100%;font-size:12px;padding:1px 4px;border:1px solid var(--border);border-radius:2px;min-width:70px;height:24px;background:#fff}
table.dt tbody td{padding:4px 8px;border-bottom:1px solid var(--border);border-right:1px solid #f0f3f7;vertical-align:middle}
table.dt tbody tr:hover{background:#eef5fc}
table.dt tbody tr:nth-child(even){background:#fbfcfe}
table.dt tbody tr:nth-child(even):hover{background:#eef5fc}
table.dt .num,table.dt th.num{text-align:right;font-variant-numeric:tabular-nums}
table.dt .mono,.mono{font-family:Consolas,"Courier New",monospace}
table.dt th a{color:inherit;text-decoration:none;display:block;line-height:32px}
.card > .table-responsive{border-radius:0 0 5px 5px}
.card .table.dt thead th{position:static}

/* ---------- Detail lists & timeline ---------- */
dl.row dt{font-weight:600;color:var(--muted);font-size:12.5px}
dl.row dd{margin-bottom:6px;word-break:break-word}
.timeline{list-style:none;padding-left:0;margin:0}
.timeline li{position:relative;padding:0 0 14px 26px;border-left:2px solid var(--border);margin-left:8px}
.timeline li:before{content:"";position:absolute;left:-7px;top:2px;width:12px;height:12px;border-radius:50%;background:#b8c6d6;border:2px solid #fff}
.timeline li.done:before{background:#2e8b57}.timeline li.fail:before{background:#c0392b}.timeline li.todo{opacity:.55}
.warn-email{background:#fff4e0;border:1px solid #f0c36d;color:#7a5200;padding:6px 10px;border-radius:4px;font-size:12.5px}

/* ---------- Add Bill: source buttons & party panel ---------- */
.src-btns .btn .badge{margin-left:4px}
#partyList{border-radius:0 0 5px 5px}
#partyList .list-group-item{font-size:13.5px}
.party-panel .empty{padding:26px 10px;text-align:center;color:var(--muted)}
.party-panel .empty i{font-size:34px;display:block;margin-bottom:6px;opacity:.5}
.party-panel .pname{font-size:16px;font-weight:700;color:var(--navy);line-height:1.25}
.party-panel .kv{display:flex;gap:8px;padding:5px 0;border-bottom:1px dashed var(--border);font-size:13px}
.party-panel .kv:last-child{border-bottom:0}
.party-panel .kv .k{flex:0 0 92px;color:var(--muted);font-size:12px}
.party-panel .kv .v{flex:1;word-break:break-word}
.party-panel .acc{background:#f6f9fc;border:1px solid var(--border);border-radius:4px;padding:6px 8px;margin-top:4px;font-size:12.5px}
.party-panel .mini{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:10px 0}
.party-panel .mini div{background:#f6f9fc;border:1px solid var(--border);border-radius:4px;padding:6px 8px;text-align:center}
.party-panel .mini b{display:block;font-size:16px;color:var(--navy)}
.party-panel .mini span{font-size:11.5px;color:var(--muted)}
.amount-preview{font-size:12.5px;color:var(--accent);font-weight:600;min-height:18px}

/* ---------- Login / install ---------- */
body.auth-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px;background:var(--bg)}
.auth-wrap{width:100%;max-width:430px}
.auth-card{background:#fff;border:1px solid var(--border);border-radius:8px;box-shadow:0 8px 28px rgba(10,35,66,.10);overflow:hidden}
.auth-head{background:var(--navy);color:#fff;text-align:center;padding:20px 22px 16px;border-bottom:4px solid var(--accent)}
.auth-head img{height:52px;width:auto;max-width:110px;object-fit:contain;background:#fff;border-radius:10px;padding:5px 8px;margin-bottom:10px}
.auth-head .sw{font-size:17px;font-weight:700;letter-spacing:.4px;line-height:1.25}
.auth-head .org{font-size:12px;opacity:.82;margin-top:4px}
.auth-body{padding:26px 28px 22px}
.auth-body .tag{font-size:12px;color:var(--muted);text-align:center;margin-bottom:18px}
.auth-body .input-group-text{background:#f6f8fb;color:var(--muted);border-color:#cfd8e3}
.auth-foot{text-align:center;font-size:11.5px;color:var(--muted);margin-top:14px}
.auth-wide{max-width:680px}

@media print{
  .topbar,#sidebar,.no-print,.pagination,.app-footer{display:none!important}
  main{margin:0;padding:0}.dt-wrap{max-height:none;overflow:visible;border:0}
  body{background:#fff}.card{border:0;box-shadow:none}
}

/* ---------- Bulk select bar (Bills list) ---------- */
.sel-cell{width:34px;text-align:center}
.sel-cell input{cursor:pointer;width:16px;height:16px}
#bulkBar{position:fixed;left:var(--sidebar-w);right:0;bottom:0;z-index:1025;background:var(--navy);color:#fff;padding:12px 24px;display:none;align-items:center;gap:14px;box-shadow:0 -4px 16px rgba(10,35,66,.25);border-top:3px solid var(--accent)}
#bulkBar.show{display:flex}
#bulkBar .cnt{font-weight:600}
#bulkBar .hint{font-size:12px;opacity:.75}
@media (max-width:991px){#bulkBar{left:0;padding:10px 14px;flex-wrap:wrap}#bulkBar .hint{display:none}}
body:has(#bulkBar.show) .app-footer{padding-bottom:70px}
@media print{#bulkBar{display:none!important}}

/* top-right user circle + sidebar logout */
.topbar a.user{color:#fff;text-decoration:none;gap:0}
.topbar a.user i{font-size:30px;line-height:1;opacity:.95}.topbar a.user:hover i{opacity:1}
#sidebar a.logout-link{margin-top:10px;border-top:1px solid rgba(255,255,255,.1);padding-top:12px}