:root{--red:#c02626;--ink:#111827;--mut:#6b7280;--bd:#d1d5db}
*{box-sizing:border-box}body{font-family:Arial,Helvetica,sans-serif;color:var(--ink);background:#f3f4f6;margin:0}
.topbar{background:var(--red);color:#fff;display:flex;align-items:center;gap:10px;padding:8px 14px;position:sticky;top:0;z-index:50}
.topbar img{width:34px;height:34px}.topbar b{font-size:1.05rem;letter-spacing:.3px}.topbar .sp{flex:1}.topbar small{opacity:.9}
.tabs{display:flex;gap:4px;background:#fff;border-bottom:2px solid var(--bd);padding:6px 10px;overflow-x:auto;position:sticky;top:50px;z-index:40}
.tabs button{border:0;background:#f3f4f6;padding:10px 16px;border-radius:8px;font-weight:700;white-space:nowrap;display:flex;align-items:center;gap:8px}.tabs button.on{background:var(--red);color:#fff}
.bar .btn{min-height:40px}.bar .btn-group .btn{min-width:44px}.dropdown-item{padding:10px 18px;font-size:1rem}.dropdown-menu{min-width:220px}
main{padding:12px}.panel{background:#fff;border:1px solid var(--bd);border-radius:10px;padding:12px;margin-bottom:12px}
.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:end}.bar label{font-size:.78rem;font-weight:700;color:var(--mut);display:block}
.chips{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}.chip{background:#eef2ff;border-radius:20px;padding:3px 10px;font-size:.85rem}.chip-warn{background:#fef08a;font-weight:700}.chip-info{background:#dbeafe}
.banner{padding:8px 12px;border-radius:8px;margin-bottom:10px;font-weight:700}.banner.warn{background:#fee2e2;color:#991b1b}.banner.ok{background:#dcfce7;color:#166534}
.scroll{overflow:auto;max-width:100%;border:1px solid var(--bd);border-radius:8px;background:#fff}
table.stmt{border-collapse:collapse;table-layout:fixed;width:max-content;min-width:100%}
table.stmt th{background:#f9fafb;border:1px solid var(--bd);padding:6px;font-size:.8rem;position:sticky;top:0;z-index:2;text-align:left;user-select:none}
table.stmt td{border:1px solid var(--bd);padding:0;height:34px}
.cell{width:100%;height:100%;border:0;padding:6px;background:transparent;font-size:.95rem;font-weight:700}.cell:focus{outline:2px solid #2563eb;background:#eff6ff}
.c-bad{background:#fef08a}.c-let{box-shadow:inset 3px 0 #2563eb}.lk{position:absolute;right:4px;top:10px;font-size:.7rem;color:#6b7280}
td{position:relative}.calc{text-align:right;padding:6px!important;font-weight:700;background:#f9fafb}.c-idx{text-align:center;color:var(--mut);width:38px}
.rz{position:absolute;right:0;top:0;bottom:0;width:7px;cursor:col-resize;background:rgba(37,99,235,.25)}
body.editmode table.stmt th{outline:1px dashed #2563eb}
.empty-note{padding:28px;text-align:center;font-weight:700;color:var(--mut)}
.login{max-width:340px;margin:12vh auto;background:#fff;padding:24px;border-radius:12px;border:1px solid var(--bd);text-align:center}.login img{width:90px}
.modal-bg{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:100;display:flex;align-items:center;justify-content:center;padding:12px}
.modal-c{background:#fff;border-radius:12px;padding:16px;max-width:720px;width:100%;max-height:85vh;overflow:auto}
.modal-c table{width:100%;font-size:.85rem}.modal-c td,.modal-c th{border-bottom:1px solid #eee;padding:3px 6px}
/* ledger */
table.ledger{border-collapse:collapse;width:100%;background:#fff}.ledger th,.ledger td{border:1px solid #111;padding:6px 8px}.ledger th{background:#f3f4f6}
.n{text-align:right}.b{font-weight:900}.ledger .bf td,.ledger .tot td,.ledger .close td{background:#f3f4f6;font-weight:800}.ledger-head h2{margin:0 0 4px}.chk-warn{color:#991b1b;font-weight:700;margin-top:8px}
/* chicken */
.chkwrap{max-height:70vh}table.chk{border-collapse:collapse;font-size:.85rem;table-layout:fixed;width:max-content}table.chk th{background:#f9fafb;border:1px solid var(--bd);padding:6px;position:sticky;top:0;z-index:3;white-space:nowrap}
table.chk td{border:1px solid var(--bd);padding:0;height:32px;overflow:hidden}table.chk td.n,table.chk td.calc{padding:4px 6px}.stk1{position:sticky;left:0;background:#fff;z-index:2;padding:4px 6px!important;font-weight:700;white-space:nowrap}
.daysum td{background:#fff7ed;font-weight:700}.grand td{background:#e5e7eb;font-weight:900}.neg{color:#b91c1c}.waiting{color:#92400e;font-style:italic;padding:4px}.cell.linked{background:#ecfdf5}.cell.manual{background:#fef3c7}
/* 6-up bills: same design, smaller type so six fit on one A4 page */
.six .bill{padding:7px 9px;border-width:2px}.six .bill-head{padding-bottom:4px;border-bottom-width:2px}.six .bill-title{font-size:16px}.six .bill-ph{font-size:11px;margin-top:2px}
.six .bill-info{font-size:13px;line-height:1.2}.six .bill-t th{border-width:2px;padding:3px 4px;font-size:10px}.six .bill-t td{border-width:2px;padding:3px 4px;font-size:15px}.six .bill-t td.lb{font-size:12px}
.six .bill-t tr.rec td{height:22px}.six .bill-t tr.tp td{border-width:3px}.six .bill-t td.big{font-size:17px}.six .bill-t tr.gap td{height:7px}.six .bill-foot{font-size:9px;padding-top:3px;border-top-width:1px}
/* one bill = one picture (shared on WhatsApp): full-size type, no empty writing space */
.bill-solo{width:420px;background:#fff;margin:0 auto}.bill-solo .bill{min-height:0}.bill-solo tr.gap{display:none}.bill-solo .bill-foot,.bill-solo .bill-info{margin-top:10px}
/* bills (screen preview + print) */
#printArea{display:none}.bill-prev{overflow:auto;background:#e5e7eb;padding:10px;border-radius:8px}.bill-prev .bill-page{margin:0 auto 12px;box-shadow:0 0 6px rgba(0,0,0,.3)}
.bill-page{width:210mm;height:297mm;padding:6mm;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:repeat(3,1fr);gap:4mm;background:#fff;position:relative;page-break-after:always;break-after:page;overflow:hidden}
.bill-page:last-child{page-break-after:auto;break-after:auto}.cut-v{position:absolute;left:50%;top:0;bottom:0;border-left:1px dashed #777}.cut-h{position:absolute;top:100.33mm;left:0;right:0;border-top:1px dashed #777}.cut-h2{position:absolute;top:196.67mm;left:0;right:0;border-top:1px dashed #777}
.bill{border:3px solid #000;padding:14px 16px;display:flex;flex-direction:column;justify-content:space-between;background:#fff;color:#000;font-family:Arial,sans-serif;min-width:0}
.bill *{color:#000}.bill-head{text-align:center;border-bottom:3px solid #000;padding-bottom:8px}.bill-title{font-family:'Arial Black',Arial,sans-serif;font-size:20px;font-weight:900}
.bill-ph{font-size:16px;font-weight:900;-webkit-text-stroke:.5px #000;margin-top:4px;white-space:nowrap}.bill-info{font-size:18px;font-weight:900;-webkit-text-stroke:.4px #000;line-height:1.3}
table.bill-t{width:100%;border-collapse:collapse;table-layout:fixed}.bill-t th{border:3px solid #000;padding:6px;font-size:15px;font-weight:900;text-transform:uppercase;text-align:left;background:#fff}
.bill-t td{border:3px solid #000;padding:6px;font-size:22px;font-weight:900;-webkit-text-stroke:.5px #000}.bill-t td.lb{font-size:18px}.bill-t td.n,.bill-t th.n{text-align:right}
.bill-t tr.rec td{height:34px}.bill-t tr.tp td{border:4px solid #000}.bill-t td.big{font-size:24px}.bill-t tr.gap td{border:none;height:26px;padding:0}
.bill-foot{border-top:2px dashed #000;padding-top:6px;text-align:center;font-size:13px;font-weight:900;-webkit-text-stroke:.5px #000}
@media print{body>*:not(#printArea){display:none!important}#printArea{display:block!important;margin:0}body{background:#fff}
 body.pr-ledger .ledger{font-size:15pt}body.pr-ledger .ledger-head h2{font-size:22pt}body.pr-ledger .ledger-head div{font-size:13pt}
 .pr-h{font-size:11pt;margin:0 0 3px}body.pr-stmt table.stmt{font-size:var(--prf,8pt);width:100%;min-width:0;table-layout:fixed;border-collapse:collapse}body.pr-stmt table.stmt tr{break-inside:avoid;page-break-inside:avoid}
 body.pr-stmt table.stmt td{height:var(--prh,20px);padding:0}body.pr-stmt table.stmt th{font-size:var(--prf,8pt);padding:1px 2px;overflow-wrap:anywhere;line-height:1.1;position:static}
 body.pr-stmt .cell{font-size:var(--prf,8pt);height:var(--prh,20px);padding:0 3px;line-height:1;box-sizing:border-box;border:0;background:transparent}body.pr-stmt .calc{padding:0 3px!important}body.pr-stmt .c-del,body.pr-stmt .lk,body.pr-stmt .rz{display:none}
 body.pr-chk table.chk{width:100%;min-width:0;font-size:7pt}body.pr-chk table.chk td{height:18px}body.pr-chk table.chk th{font-size:6.5pt;padding:2px 1px;white-space:normal;overflow-wrap:anywhere;position:static}body.pr-chk .cell{font-size:7pt;padding:1px 2px}body.pr-chk table.chk td.calc,body.pr-chk table.chk td.n{padding:1px 2px}body.pr-chk .stk1{position:static}body.pr-chk button{display:none}}
/* phones: statement rows become cards */
@media screen and (max-width:767px){main{padding:6px}.topbar small{display:none}
 .tabs{gap:3px;padding:4px 6px}.tabs button{flex:1;flex-direction:column;gap:2px;padding:6px 2px;font-size:.72rem}.tabs button i{font-size:1.15rem}.bar .btn{min-height:44px}
 table.stmt{width:100%;display:block}table.stmt colgroup,table.stmt thead{display:none}table.stmt tbody,table.stmt tfoot{display:block}
 table.stmt tr{display:block;border:1px solid var(--bd);border-radius:10px;margin:8px 0;background:#fff;padding:4px}
 table.stmt td{display:flex;justify-content:space-between;align-items:center;border:0;border-bottom:1px solid #f1f1f1;height:auto;min-height:38px}
 table.stmt td::before{content:attr(data-label);font-size:.75rem;color:var(--mut);font-weight:700;padding-left:6px;flex:0 0 38%}
 table.stmt td.c-idx,table.stmt tfoot td:first-child{display:none}.cell{text-align:right;font-size:1.05rem}.calc{background:#f9fafb}
 table.stmt tfoot td{justify-content:space-between}table.stmt tfoot td::before{content:attr(data-tot)}}

/* incoming sub-tabs */
.subtabs{display:flex;gap:6px;margin-bottom:10px;overflow-x:auto}.subtabs button{border:1px solid var(--bd);background:#fff;padding:8px 14px;border-radius:20px;font-weight:700;white-space:nowrap}.subtabs button.on{background:var(--red);color:#fff;border-color:var(--red)}
body.editmode table.chk th{outline:1px dashed #2563eb}table.chk th .rz{position:absolute;right:0;top:0;bottom:0;width:7px;cursor:col-resize;background:rgba(37,99,235,.25)}
table.chk td.calc[style]{font-weight:600}

/* Windows computers only: text on the Statement, Chicken and Expenses sheets is centred (also when printed from Windows) */
@media screen and (min-width:768px), print{
html.win table.stmt th,html.win table.stmt td,html.win table.chk th,html.win table.chk td,html.win table.stmt .cell,html.win table.chk .cell,html.win table.stmt td.calc,html.win table.chk td.calc,html.win table.stmt td.n,html.win table.chk td.n{text-align:center}
}
/* bills: starred list + corner credit */
.brow{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #eef0f6}.brow label{flex:1;cursor:pointer}
.star{border:0;background:transparent;font-size:1.35rem;line-height:1;color:#b8bfd6;padding:2px 10px;cursor:pointer}.star.on{color:#f5a400}.star:hover{color:#f5a400}
.bl-h{font-size:.78rem;font-weight:800;color:var(--mut);background:#f3f4f6;padding:4px 8px;margin-top:4px;border-radius:4px}
.bill-pw{text-align:right;font-size:14px;font-weight:700;margin-top:5px}.bill-pw b{font-weight:900}
.six .bill-pw{font-size:12px;margin-top:3px}.bill-solo .bill-pw{font-size:16px;margin-top:8px}

/* chicken / expenses: no day-summary rows, so each day starts with a heavier line */
table.chk tr.day-first td{border-top:2px solid #6b7280}
/* "new version available" bar */
#updBar{position:fixed;top:0;left:0;right:0;z-index:3000;display:flex;gap:12px;align-items:center;justify-content:center;padding:10px 12px;background:#0A1450;color:#fff;font-weight:700;box-shadow:0 2px 10px rgba(0,0,0,.3)}
#updBar button{border:0;border-radius:8px;background:#FFE14D;color:#0A1450;font-weight:800;padding:8px 14px}
@media print{#updBar{display:none!important}
 .pr-top{display:flex;justify-content:space-between;align-items:baseline;gap:12px;margin:0 0 3px}.pr-top .pr-h{margin:0;white-space:nowrap}}
