:root {
  --primary: #4f3cc9;
  --primary-soft: #eeebfb;
  --ink: #23213a;
  --muted: #7a7891;
  --line: #e7e6ef;
  --bg: #f4f5fa;
  --card: #ffffff;
  --green: #1f9d55;
  --green-soft: #e9f7ef;
  --red: #e5483f;
  --red-soft: #fdeeee;
  --wa: #128c7e;
  --dark: #34324f;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.screen { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: 150px; background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 20; background: #fff; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 60px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 13px; color: var(--muted); font-weight: 400; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 10px; color: var(--primary); cursor: pointer; display: inline-flex; }
.icon-btn:active { background: var(--primary-soft); }
.icon-btn.danger { color: var(--red); }
.icon-btn svg { width: 24px; height: 24px; }
.pad { padding: 16px; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav .inner { display: flex; width: 100%; max-width: 760px; }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--muted); font-size: 12px; }
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }

.fabbar {
  position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; justify-content: center; pointer-events: none;
}
.fabbar .inner { display: flex; gap: 10px; width: 100%; max-width: 760px; padding: 0 14px; }
.fabbar button { pointer-events: auto; }
.fab { flex: 1; border: 0; border-radius: 999px; padding: 15px 10px; font-weight: 600; font-size: 16px; color: #fff; background: var(--primary); box-shadow: 0 6px 18px rgba(79,60,201,.28); cursor: pointer; }
.fab.dark { background: var(--dark); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.fab.green { background: var(--green); }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.stat { padding: 16px; border-radius: var(--radius); border: 1px solid #cfe0f3; background: #f6f9fe; cursor: pointer; position: relative; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 14px; margin-top: 4px; }
.stat.green { background: var(--green-soft); border-color: #a9dcbc; }
.stat.green .l { color: var(--green); font-weight: 600; }
.stat.red { background: var(--red-soft); border-color: #f2b9b5; }
.stat.red .l { color: var(--red); font-weight: 600; }

.section-h { display: flex; justify-content: space-between; align-items: center; padding: 8px 18px; color: var(--muted); font-weight: 600; }
.section-h a, .section-h button { color: var(--primary); font-weight: 600; background: none; border: 0; cursor: pointer; }

.list { padding: 0 14px; display: flex; flex-direction: column; gap: 10px; }
.row-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; display: block; color: inherit; }
.row-card:active { background: #fafaff; }
.row-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.row-name { font-weight: 600; font-size: 16px; }
.row-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.amt { font-weight: 700; white-space: nowrap; }
.amt.collect { color: var(--green); }
.amt.pay { color: var(--red); }
.avatar { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; font-weight: 600; flex: none; color: #555; }
.party-row { display: flex; gap: 14px; align-items: center; }
.party-row .mid { flex: 1; min-width: 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid; }
.badge.paid { color: var(--green); border-color: #a9dcbc; background: var(--green-soft); }
.badge.partial { color: #b7791f; border-color: #f0d49b; background: #fff8e8; }
.badge.unpaid { color: var(--red); border-color: #f2b9b5; background: var(--red-soft); }
.wa-link { color: var(--wa); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px 0; cursor: pointer; }
.wa-link svg { width: 18px; height: 18px; }

.chips { display: flex; gap: 8px; padding: 12px 14px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); }
.chip { border: 1px solid transparent; background: #f0f0f5; border-radius: 999px; padding: 8px 16px; white-space: nowrap; cursor: pointer; font-weight: 500; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.search { margin: 12px 14px 4px; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { border: 0; outline: 0; padding: 12px 0; flex: 1; background: transparent; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---------- menu lists (settings) ---------- */
.menu { background: #fff; margin-bottom: 10px; }
.menu-item { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.menu-item:last-child { border-bottom: 0; }
.menu-item svg.ic { width: 24px; height: 24px; color: var(--primary); flex: none; }
.menu-item .t { flex: 1; }
.menu-item .t small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.menu-item .val { color: var(--muted); font-size: 14px; text-align: right; max-width: 45%; }
.menu-item .chev { color: var(--primary); width: 20px; height: 20px; flex: none; }
.menu-head { padding: 14px 18px 8px; color: var(--muted); font-weight: 600; background: var(--bg); }

/* ---------- forms ---------- */
.form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #d7d6e2; border-radius: 10px; padding: 12px 14px; background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--primary); border: 1.5px solid #d7d6e2; }
.btn.wa { background: var(--wa); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .6; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfcfe0; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }
.seg { display: flex; gap: 10px; flex-wrap: wrap; }
.seg button { border: 1.5px solid transparent; background: #f0f0f5; border-radius: 999px; padding: 9px 20px; cursor: pointer; }
.seg button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.radio-row { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.radio-row .t { flex: 1; font-weight: 500; }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #a7a6b8; display: grid; place-items: center; }
.radio.on { border-color: var(--primary); }
.radio.on::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }
.note-box { margin: 14px; padding: 14px; background: #f6f6f9; border-radius: 12px; color: var(--muted); font-size: 14px; display: flex; gap: 10px; }

/* invoice editor */
.line-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.line-item .li-top { display: flex; justify-content: space-between; gap: 10px; }
.line-item .li-name { font-weight: 600; }
.line-item .li-grid { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 8px; margin-top: 10px; }
.line-item .li-grid input, .line-item .li-grid select { width: 100%; border: 1px solid #d7d6e2; border-radius: 8px; padding: 8px 10px; }
.line-item .li-grid label { font-size: 12px; color: var(--muted); }
.line-item .li-amt { text-align: right; font-weight: 700; margin-top: 8px; }
.add-line { border: 1.5px dashed #b9b4ea; background: #fbfaff; color: var(--primary); border-radius: 12px; padding: 14px; font-weight: 600; cursor: pointer; width: 100%; }
.summary { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; }
.summary .s-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; gap: 10px; }
.summary .s-row input { width: 120px; text-align: right; border: 1px solid #d7d6e2; border-radius: 8px; padding: 8px 10px; }
.summary .s-row.total { font-weight: 700; font-size: 17px; border-top: 1px solid var(--line); }
.summary .s-row.bal { color: var(--red); font-weight: 700; }
.picked-party { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }

/* sheet (bottom modal) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20,18,40,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: #fff; width: 100%; max-width: 760px; border-radius: 22px 22px 0 0; max-height: 88vh; display: flex; flex-direction: column; animation: up .2s ease-out; padding-bottom: env(safe-area-inset-bottom); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 4px 20px 20px; }
.pick-item { padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.pick-item:active { background: #f7f7fb; }
.share-opts { display: flex; gap: 22px; flex-wrap: wrap; padding: 10px 0; }
.share-opt { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; width: 84px; font-size: 14px; }
.share-opt .circ { width: 66px; height: 66px; border-radius: 50%; border: 2px solid #ececf3; display: grid; place-items: center; }
.share-opt .circ svg { width: 30px; height: 30px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

/* invoice view page */
.inv-wrap { padding: 12px; overflow-x: auto; }
.inv-scale { transform-origin: top left; }
.inv-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.inv-actions .inner { max-width: 760px; margin: 0 auto; }
.inv-actions .who { display: flex; justify-content: space-between; padding: 12px 16px 6px; gap: 10px; }
.inv-actions .btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 6px 16px 10px; }
.inv-actions .btns3 { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.inv-actions .btns3 button { background: none; border: 0; padding: 10px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--primary); font-weight: 600; cursor: pointer; font-size: 14px; }
.inv-actions .btns3 svg { width: 24px; height: 24px; }

/* ---------- A4 invoice document ---------- */
.doc { width: 794px; min-height: 1000px; background: #fff; color: #222; padding: 40px 46px; font-family: 'Noto Sans', Arial, sans-serif; font-size: 13px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.doc .tag { display: flex; gap: 10px; align-items: center; font-size: 12px; font-weight: 600; letter-spacing: .3px; }
.doc .tag span.box { border: 1px solid #888; padding: 1px 6px; font-weight: 500; color: #555; }
.doc .head { display: flex; gap: 22px; align-items: center; margin: 26px 0 26px; }
.doc .head img.logo { width: 130px; max-height: 100px; object-fit: contain; }
.doc .head .bn { font-size: 28px; font-weight: 700; }
.doc .head .ba { font-size: 12.5px; margin-top: 4px; color: #333; }
.doc .bar { height: 8px; }
.doc .meta { display: flex; justify-content: space-between; background: #e8e8e8; padding: 12px 18px; font-size: 13px; }
.doc .billto { padding: 14px 0; }
.doc .billto .lbl { font-size: 13px; letter-spacing: .4px; color: #444; }
.doc .billto .nm { font-weight: 700; font-size: 14px; margin-top: 6px; }
.doc table.items { width: 100%; border-collapse: collapse; margin-top: 4px; }
.doc table.items th { text-align: right; font-weight: 600; padding: 10px; font-size: 12.5px; border-top: 2px solid; border-bottom: 2px solid; }
.doc table.items td { text-align: right; padding: 10px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.doc table.items th:first-child, .doc table.items td:first-child { text-align: left; }
.doc table.items td .desc { color: #777; font-size: 11.5px; }
.doc table.items tr.spacer td { height: 120px; border-bottom: 0; }
.doc table.items tr.sub td { font-weight: 700; border-top: 2px solid; border-bottom: 2px solid; }
.doc .totals { display: flex; justify-content: space-between; gap: 30px; margin-top: 14px; }
.doc .totals .left { flex: 1; font-size: 12.5px; }
.doc .totals .right { width: 330px; }
.doc .totals .tr { display: flex; justify-content: space-between; padding: 5px 0; }
.doc .totals .tr.strong { font-weight: 700; border-top: 1px solid #333; border-bottom: 1px solid #333; padding: 8px 0; margin-bottom: 6px; }
.doc .words { text-align: right; margin-top: 14px; }
.doc .words b { display: block; font-weight: 600; }
.doc .sign { text-align: right; margin-top: 30px; }
.doc .sign img { max-width: 170px; max-height: 70px; }
.doc .sign .lbl { font-weight: 700; font-size: 12.5px; margin-top: 8px; }
.doc .qr { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.doc .qr img, .doc .qr canvas { width: 96px; height: 96px; }
.doc .terms { margin-top: 18px; font-size: 12px; white-space: pre-wrap; }

/* ---------- thermal receipt ---------- */
.thermal { background: #fff; color: #000; font-family: 'Courier New', monospace; font-size: 12px; padding: 6px 4px; line-height: 1.3; }
.thermal.w58 { width: 58mm; }
.thermal.w80 { width: 80mm; font-size: 13px; }
.thermal .c { text-align: center; }
.thermal .b { font-weight: 700; }
.thermal .big { font-size: 15px; }
.thermal hr { border: 0; border-top: 1px dashed #000; margin: 5px 0; }
.thermal .r { display: flex; justify-content: space-between; gap: 6px; }
.thermal img.tlogo { width: 60%; max-height: 70px; object-fit: contain; display: block; margin: 0 auto 4px; filter: grayscale(1) contrast(1.4); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #5b47d6, #3a2b9e); }
.login .card { width: 100%; max-width: 380px; padding: 28px 24px; }
.login img { width: 110px; display: block; margin: 0 auto 8px; }
.login h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 22px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; }

.toast { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%) translateY(20px); background: #23213a; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 50px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding: 10px 4px 0; }
.bars .bcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .bv { width: 100%; max-width: 26px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bl { font-size: 10px; color: var(--muted); }
table.rep { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rep th, table.rep td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.rep td.n, table.rep th.n { text-align: right; }

@media (max-width: 380px) {
  .stat .v { font-size: 18px; }
  .fab { font-size: 15px; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .doc { box-shadow: none; width: 100%; padding: 0 6mm; min-height: 0; }
}
#print-root { display: none; }

/* fixes */
.radio-row svg.ic { width: 24px; height: 24px; color: var(--primary); flex: none; }
.summary .s-row.paidrow { flex-wrap: wrap; }
.summary .s-row.paidrow input[type=number] { width: 110px; }
input[type=color] { padding: 0; border-radius: 8px; }
.summary .s-row input[type=checkbox] { width: 20px; height: 20px; padding: 0; }

/* staff */
.datebar { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.datebar .dlabel { position: relative; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.datebar .dlabel span { color: var(--muted); font-size: 13px; }
.datebar .dlabel input[type=date] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.att-seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.att-seg button { border: 1.5px solid; border-radius: 10px; padding: 9px 0; font-weight: 700; cursor: pointer; font-size: 15px; }
.sal-grid { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 4px 10px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.sal-grid b { color: var(--ink); text-align: right; }
.sal-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.cal-head, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.cal-head span { font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal-day { aspect-ratio: 1; border: 1px solid var(--line); background: #fff; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; padding: 0; font-size: 14px; }
.cal-day small { font-size: 10px; font-weight: 700; min-height: 12px; }
.cal-day:disabled { opacity: .35; cursor: default; }
svg.chev { width: 20px; height: 20px; flex: none; color: var(--primary); }
.summary .s-row > span:last-child { white-space: nowrap; }

/* ---------- myBillBook-style create flow ---------- */
.stat.red .l { color: var(--red); font-weight: 600; }
.badge.neutral { color: var(--primary); border-color: #d5cff5; background: var(--primary-soft); }
.fab3 { align-items: center; }
.fab-plus { pointer-events: auto; flex: none; width: 58px; height: 58px; border-radius: 50%; border: 0; background: #7bc47f; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; box-shadow: 0 6px 16px rgba(31,157,85,.3); }
.qa-sheet { max-height: 92vh; }
.qa-h { margin: 4px 0 14px; font-size: 21px; font-weight: 700; }
.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 6px; }
.qa-tile { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: #5d5b72; text-align: center; line-height: 1.25; padding: 0; }
.qa-ic { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; }
.qa-ic svg { width: 28px; height: 28px; }
.qa-ic.g { background: #e9f6ea; color: #2b9a3e; }
.qa-ic.b { background: #edf0fb; color: #3f4fb8; }
.qa-ic.y { background: #fbf4dc; color: #c78b12; }
.qa-ic.r { background: #fde9e9; color: #e0675f; }
.qa-sep { height: 1px; background: var(--line); margin: 22px 0; }
.qa-close { width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); display: grid; place-items: center; cursor: pointer; }
.qa-close svg { width: 24px; height: 24px; }
.sheet.full { height: 94vh; max-height: 94vh; position: relative; }
.search.gray { background: #eceef6; border-color: transparent; margin: 0; border-radius: 14px; padding: 2px 14px; }
.tabs { display: flex; border-bottom: 2px solid #e4e3ec; margin-top: 14px; }
.tabs button { flex: 1; background: none; border: 0; padding: 14px 0; font-weight: 600; font-size: 16px; color: var(--ink); cursor: pointer; margin-bottom: -2px; border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.pp-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pp-row:active { background: #f7f7fb; }
.pp-name { font-size: 16.5px; }
.sheet-fab { position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; }
.sheet-fab .fab { pointer-events: auto; }
.cb-card { background: #fff; margin-top: 10px; padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cb-num { color: var(--primary); font-size: 16px; }
.cb-date { margin-top: 6px; font-size: 15px; }
.cb-edit { border: 1.5px solid #d7d6e2; background: #fff; color: var(--primary); font-weight: 700; border-radius: 999px; padding: 8px 18px; cursor: pointer; letter-spacing: .5px; }
.cb-ref { margin: 8px 16px 0; color: var(--muted); font-size: 13.5px; }
.cb-sec { background: #fff; margin-top: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cb-label { font-weight: 600; letter-spacing: .3px; font-size: 15px; }
.cb-party { width: 100%; display: flex; align-items: center; gap: 12px; border: 1.5px solid #d7d6e2; background: #fff; border-radius: 12px; padding: 14px 16px; cursor: pointer; font-size: 16px; }
.cb-party svg { width: 24px; height: 24px; color: #6b6a80; flex: none; }
.cb-party.picked { border-color: #cfc9f3; }
.cb-pic { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.cb-change { color: var(--primary); font-weight: 600; font-size: 14px; }
.cb-additems { width: 100%; border: 0; background: #eeebfb; color: var(--primary); font-weight: 600; font-size: 16px; padding: 16px; cursor: pointer; border-radius: 4px; }
.cb-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
.cb-foot .inner { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.cp-foot { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); margin: 6px -20px 0; padding: 14px 20px 0; }
.cp-more { background: none; border: 0; text-align: left; cursor: pointer; padding: 0; display: flex; flex-direction: column; }
.cp-more b { color: var(--primary); font-size: 16px; }
.cp-more span { color: var(--muted); font-size: 13px; }
.fab3 .fab { font-size: 15px; padding: 15px 6px; white-space: nowrap; }
@media (max-width: 380px) { .fab3 .fab { font-size: 13.5px; } }
.setup-card { margin: 14px 14px 0; padding: 14px 16px; background: #fff7e6; border: 1px solid #f3d38d; border-radius: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.setup-card b { color: #8a5a00; }
.setup-card span { color: #7a6a4a; font-size: 14px; }

/* invoice settings */
.theme-bar { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: #e3f4e4; color: #4b6b50; font-size: 17px; font-weight: 600; padding: 16px 18px; cursor: pointer; text-align: left; }
.is-preview { background: #ececf1; padding: 0 20px; overflow: hidden; }
.is-preview .inv-scale { box-shadow: 0 1px 6px rgba(0,0,0,.1); }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-pick button { border: 2px solid #e2e1ea; background: #fff; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; }
.theme-pick button.on { border-color: var(--primary); color: var(--primary); }
.th-thumb { width: 100%; height: 70px; border-radius: 6px; background: #fafafa; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid #eee; }
.th-thumb i { display: block; height: 6px; border-radius: 3px; background: #ccc; }
.th-classic i:first-child { background: #0f5f8f; width: 60%; } .th-classic i:nth-child(2) { background: #0f5f8f; height: 4px; }
.th-modern { background: #0f5f8f; } .th-modern i { background: rgba(255,255,255,.7); } .th-modern i:first-child { width: 60%; background: #fff; }
.th-simple i:first-child { background: #333; width: 60%; } .th-simple i { background: #ddd; }
/* invoice themes */
.doc .meta2 { display: flex; gap: 22px; flex-wrap: wrap; padding: 8px 18px; border-bottom: 1px solid #e3e3e3; font-size: 12.5px; }
.doc.theme-modern .head { background: var(--tc); color: #fff; margin: 18px -46px 0; padding: 24px 46px; }
.doc.theme-modern .head .bn { color: #fff !important; }
.doc.theme-modern .head .ba { color: rgba(255,255,255,.9); }
.doc.theme-modern .head img.logo { background: #fff; border-radius: 10px; padding: 6px; }
.doc.theme-modern .bar { display: none; }
.doc.theme-modern .meta { background: #f3f5f8; }
.doc.theme-simple .bn { color: #111 !important; }
.doc.theme-simple .bar { height: 1px; background: #333 !important; }
.doc.theme-simple .meta { background: none; border-bottom: 1px solid #333; }
.doc.theme-simple table.items th, .doc.theme-simple table.items tr.sub td { border-color: #333 !important; border-width: 1px; }

/* =================== PC / tablet layout (wide screens) =================== */
#sidenav { display: none; }
@media (min-width: 1000px) {
  body:not(.public) #app { margin-left: 248px; }
  #sidenav { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: 248px; background: #fff; border-right: 1px solid var(--line); z-index: 40; padding: 16px 12px; gap: 6px; overflow-y: auto; }
  .sn-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 17px; line-height: 1.2; }
  .sn-brand img { width: 44px; height: 36px; object-fit: contain; }
  .sn-new, .sn-create { border: 0; border-radius: 12px; padding: 12px; font-weight: 600; font-size: 15px; cursor: pointer; }
  .sn-new { background: var(--primary); color: #fff; }
  .sn-create { background: #e9f6ea; color: #2b9a3e; margin-bottom: 10px; }
  #sidenav nav { display: flex; flex-direction: column; gap: 2px; }
  #sidenav nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; }
  #sidenav nav a svg { color: var(--muted); flex: none; }
  #sidenav nav a:hover { background: #f4f3fb; }
  #sidenav nav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  #sidenav nav a.on svg { color: var(--primary); }
  .sn-foot { margin-top: auto; padding: 12px 8px 0; color: var(--muted); font-size: 12.5px; word-break: break-all; }

  .bottomnav { display: none; }
  .screen { max-width: 1180px; padding: 0 28px 130px; }
  .screen.narrow { max-width: 900px; }
  .topbar { margin: 0 -28px; padding: 16px 28px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); padding: 20px 0; gap: 16px; }
  .stat { padding: 20px; }
  .stat .v { font-size: 24px; }
  .list { padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .list > .empty, .list > .row-card.full { grid-column: 1 / -1; }
  .section-h { padding: 14px 2px 10px; }
  .search { margin: 14px 0 6px; max-width: 560px; }
  .chips { margin: 0 -28px; padding: 12px 28px; }
  .pad { padding: 16px 0; }
  .grid2.pad { padding: 16px 0 0; }
  .setup-card { margin: 18px 0 0; }
  .datebar { margin: 0 -28px; padding: 8px 28px; }

  /* floating buttons sit at the bottom-right of the content */
  .fabbar, .cb-foot, .inv-actions { left: 248px; }
  .fabbar .inner { max-width: 1180px; padding: 0 28px; justify-content: flex-end; }
  .fab { flex: none !important; padding: 14px 28px; }
  .fabbar { bottom: 24px !important; }
  .cb-foot .inner { max-width: 900px; display: flex; justify-content: flex-end; }
  .cb-foot .btn { min-width: 160px; }
  .inv-actions .inner { max-width: 1180px; display: grid; grid-template-columns: 1.2fr 1.4fr 1.6fr; align-items: center; gap: 10px; padding: 6px 28px; }
  .inv-actions .who { padding: 8px 0; }
  .inv-actions .btns2 { padding: 0; }
  .inv-actions .btns3 { border-top: 0; }
  .screen[style*="padding-bottom:240px"] { padding-bottom: 140px !important; }
  .inv-wrap { padding: 24px 0; display: flex; justify-content: center; }
  .cb-card, .cb-sec { border-radius: 14px; border: 1px solid var(--line); }
  .form { padding: 16px 0; }

  /* bottom sheets become centred dialogs */
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; max-width: 560px; max-height: 86vh; }
  .sheet.full { height: 80vh; max-height: 80vh; }
  .qa-sheet { max-width: 640px; }
  .toast { bottom: 40px; }
  .menu { border-radius: 14px; border: 1px solid var(--line); overflow: hidden; }
  .menu-head { padding: 18px 4px 8px; background: none; }
  .theme-bar { border-radius: 14px 14px 0 0; margin-top: 16px; }
  .is-preview { border-radius: 0 0 14px 14px; margin-bottom: 14px; }
  .radio-row:first-of-type { margin-top: 12px; }
  .note-box { margin: 14px 0; }
}
@media (min-width: 1400px) {
  .stat-grid { grid-template-columns: repeat(6, 1fr); }
  .stat .v { font-size: 21px; }
}
@media (min-width: 1000px) { .list > .row-card:only-child { grid-column: 1 / -1; } }
