:root {
  --navy: #254e8c; --navy-d: #1b3c6e; --ink: #1d2733; --muted: #6b7684; --line: #e4e9f0;
  --tab: #fffbd1; --tab-line: #f1e8a0; --panel: #f1f4f8; --green: #2eb872; --red: #dc3545; --blue: #1e9be0; --orange: #f0801c; --grey: #6c757d;
  --ok: #198754;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: #fff; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.pre { white-space: pre-line; }
.muted { color: var(--muted); }
.r { text-align: right; }

/* header */
.topbar { background: #f4f5f6; border-bottom: 1px solid #eceff2; }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: grid; grid-template-columns: 1fr minmax(220px, 440px) 1fr; align-items: center; gap: 12px; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -.3px; color: #111; display: inline-flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .mark { background: #ffd83b; border-radius: 5px; padding: 0 7px; }
.search { display: flex; }
.search input { flex: 1; min-width: 0; border: 1px solid #d5dbe3; border-right: 0; border-radius: 4px 0 0 4px; padding: 8px 10px 8px 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 10px center no-repeat; }
.search button { background: var(--navy); color: #fff; border: 0; padding: 0 14px; border-radius: 0 4px 4px 0; cursor: pointer; font-weight: 600; }
.acct { justify-self: end; position: relative; }
.acct > button { background: none; border: 0; cursor: pointer; padding: 6px 4px; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.acct .who { text-decoration: underline; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(20, 30, 50, .14); min-width: 190px; padding: 6px; z-index: 30; }
.menu a, .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.menu a:hover, .menu button:hover { background: var(--panel); text-decoration: none; }

/* quick create row */
.quick { text-align: center; margin: 22px 16px 6px; display: flex; justify-content: center; gap: 8px 18px; flex-wrap: wrap; align-items: center; }
.quick .plus { width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; font-weight: 700; }
.quick a { font-size: 16px; }

/* page frame + tabs */
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 12px 60px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 20px 0 0; padding: 0 4px; }
.tab { background: var(--tab); border: 1px solid var(--tab-line); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 9px 16px; color: var(--ink); display: inline-flex; gap: 7px; align-items: center; font-size: 15px; }
.tab:hover { text-decoration: none; background: #fff6a8; }
.tab.on { background: #fff; font-weight: 600; border-color: #d8dfe8; position: relative; top: 1px; z-index: 1; }
.tab .ic { width: 15px; height: 15px; opacity: .75; }
.panel { background: var(--panel); border: 1px solid #e2e8f0; border-radius: 0 12px 12px 12px; padding: 18px 16px 22px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 0; padding: 0 2px; }
.subtab { background: var(--tab); border: 1px solid var(--tab-line); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 8px 14px; color: var(--ink); display: inline-flex; gap: 8px; align-items: center; font-size: 14.5px; }
.subtab:hover { text-decoration: none; background: #fff6a8; }
.subtab.on { background: #fff; font-weight: 600; border-color: var(--line); position: relative; top: 1px; z-index: 1; }
.badge { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 1.5; }
.b-all { background: var(--navy); } .b-overdue { background: var(--red); } .b-partial { background: var(--blue); } .b-unpaid { background: var(--orange); } .b-paid { background: var(--ok); } .b-grey { background: var(--grey); } .b-new { background: var(--red); }
.inner { background: #fff; border: 1px solid var(--line); border-radius: 0 10px 10px 10px; padding: 14px 14px 18px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-transform: uppercase; font-size: 12.5px; letter-spacing: .02em; text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th a { color: var(--ink); }
.tbl th .arr { opacity: .45; font-size: 11px; margin-left: 3px; }
.tbl th.on .arr { opacity: 1; color: var(--navy); }
.tbl td { padding: 13px 10px; border-bottom: 1px solid #eef1f5; }
.tbl tr.row { cursor: pointer; }
.tbl tr.row:hover td { background: #f8fafc; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.c, .tbl th.c { text-align: center; }
.tbl td a { color: inherit; }
.neg { color: var(--red); }
.pos { color: var(--ok); }
.chk { width: 16px; height: 16px; }
.totals { display: flex; justify-content: flex-end; gap: 28px; flex-wrap: wrap; padding: 16px 10px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
.totals b { display: block; font-size: 17px; text-transform: none; letter-spacing: 0; margin-top: 2px; }
.pager { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; padding: 18px 0 2px; }
.pager a, .pager span { padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.pager a:hover { background: var(--panel); text-decoration: none; }
.pager .on { background: var(--navy); color: #fff; border-color: var(--navy); }
.pager .off { opacity: .45; }
.empty { text-align: center; color: var(--muted); padding: 38px 10px; }
.bulk { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: #eef4ff; border-radius: 8px; margin-bottom: 10px; }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; gap: 7px; background: var(--navy); color: #fff; border: 1px solid var(--navy); padding: 9px 16px; border-radius: 7px; cursor: pointer; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--navy-d); text-decoration: none; }
.btn.alt { background: #fff; color: var(--navy); }
.btn.alt:hover { background: var(--panel); }
.btn.green { background: var(--green); border-color: var(--green); }
.btn.green:hover { background: #26a263; }
.btn.red { background: #fff; color: var(--red); border-color: #f0b8be; }
.btn.red:hover { background: #fdf0f1; }
.btn.small { padding: 5px 11px; font-size: 13.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: block; margin: 0 0 14px; }
.field > span, .lab { display: block; font-weight: 600; font-size: 13.5px; margin: 0 0 5px; }
.field small { color: var(--muted); display: block; margin-top: 4px; font-size: 12.5px; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; border: 1px solid #cdd5df; border-radius: 6px; padding: 9px 10px; background: #fff; }
textarea { resize: vertical; min-height: 78px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ec0f0; outline-offset: 0; border-color: #7aa6e6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.err { color: var(--red); font-weight: 600; margin: 8px 0; }
.note { background: #fff8d6; border: 1px solid #efe29a; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.okbox { background: #e9f8ef; border: 1px solid #b5e3c7; border-radius: 8px; padding: 10px 12px; }
h1.t { font-size: 20px; margin: 0 0 14px; }
h2.t { font-size: 16px; margin: 22px 0 10px; }

/* action tabs on an invoice */
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 0; padding: 0 2px; }
.act { background: var(--tab); border: 1px solid var(--tab-line); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 8px 13px; color: var(--ink); cursor: pointer; font-size: 14.5px; display: inline-flex; gap: 6px; align-items: center; }
.act:hover { text-decoration: none; background: #fff6a8; }
.act.on { background: #fff; font-weight: 600; border-color: var(--line); position: relative; top: 1px; }
.act.danger { color: var(--red); }

/* invoice form */
.ibox { background: #e3f0fd; border: 1px solid #cfe2f7; border-radius: 10px; padding: 16px; }
.items-h, .item { display: grid; grid-template-columns: 80px 1fr 120px 120px 36px; gap: 10px; align-items: start; }
.items-h { font-weight: 700; font-size: 13.5px; margin: 14px 0 6px; }
.item { margin-bottom: 8px; }
.item textarea { min-height: 40px; height: 40px; }
.item .amt { padding: 9px 10px; background: #fff; border: 1px solid #cdd5df; border-radius: 6px; text-align: right; }
.x { width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; border: 0; cursor: pointer; font-weight: 700; margin-top: 6px; }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 16px; }
.add-row button { background: #fdf0b8; border: 1px solid #ecd77a; border-radius: 6px; padding: 9px; cursor: pointer; }
.sum { margin-left: auto; width: min(360px, 100%); }
.sum div { display: flex; justify-content: space-between; padding: 5px 0; }
.sum .tot { font-weight: 800; font-size: 20px; color: var(--navy); border-top: 2px solid #b9d2ee; margin-top: 6px; padding-top: 10px; }
.sugg { position: absolute; z-index: 20; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 22px rgba(20, 30, 50, .13); max-height: 260px; overflow: auto; }
.sugg button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; }
.sugg button:hover { background: var(--panel); }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 40, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px 14px; z-index: 100; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: min(540px, 100%); padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d2733; color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 200; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); max-width: 92vw; }
.toast.bad { background: #b02a37; }
.pick { max-height: 55vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #eef1f5; cursor: pointer; }
.pick label:hover { background: var(--panel); }
.pick .p { margin-left: auto; font-variant-numeric: tabular-nums; }

/* cards in orders etc. */
.ocard { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.ocard h3 { margin: 0; font-size: 16px; }
.ocard ul { margin: 8px 0; padding-left: 18px; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; color: #fff; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 22px; margin-top: 2px; }
.bar { height: 10px; border-radius: 5px; background: #dfe8f5; overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--navy); }

/* login */
.login { max-width: 400px; margin: 12vh auto; padding: 0 16px; }
.login .card { padding: 24px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }

/* invoice paper */
.paper { background: #fff; border: 1px solid #d9e0ea; box-shadow: 0 2px 14px rgba(30, 50, 80, .08); position: relative; max-width: 820px; margin: 0 auto; }
.paper-bar { height: 10px; background: #3b6cb7; }
.paper-body { padding: 28px 34px 26px; }
.paper-from { font-size: 18px; margin-bottom: 18px; }
.paper-from .pre { font-size: 13px; color: #444; margin-top: 4px; }
.paper-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 18px; }
.paper .lbl { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; color: #333; display: inline-block; min-width: 96px; }
.paper-head > div:first-child .lbl { display: block; margin-bottom: 4px; }
.paper-meta div { display: flex; gap: 14px; justify-content: space-between; margin-bottom: 4px; font-size: 14px; }
.paper-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid #111; border-bottom: 1px solid #ccd; padding: 12px 0; margin-bottom: 14px; font-size: 20px; font-weight: 800; }
.paper-items { width: 100%; border-collapse: collapse; font-size: 14px; }
.paper-items th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; padding: 8px 6px; border-bottom: 1px solid #222; }
.paper-items th.r, .paper-items td.r { text-align: right; }
.paper-items td { padding: 9px 6px; border-bottom: 1px solid #eceff3; vertical-align: top; }
.paper-items .c-qty { width: 52px; }
.paper-sums { margin: 14px 0 0 auto; width: min(300px, 100%); font-size: 14px; }
.paper-sums div { display: flex; justify-content: space-between; padding: 4px 0; }
.paper-sums .big { font-size: 18px; font-weight: 800; border-top: 2px solid #111; margin-top: 4px; padding-top: 8px; }
.paper-foot { margin-top: 24px; font-size: 13px; color: #333; }
.paper-stamp { position: absolute; right: 38px; top: 70px; transform: rotate(-12deg); border: 3px solid #2e9e5b; color: #2e9e5b; font-weight: 900; letter-spacing: .15em; font-size: 26px; padding: 2px 14px; border-radius: 6px; opacity: .8; pointer-events: none; }

/* responsive */
@media (max-width: 720px) {
  .topbar-in { grid-template-columns: 1fr auto; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .acct .who { display: none; }
  .panel { padding: 12px 8px 16px; border-radius: 0 10px 10px 10px; }
  .inner { padding: 8px 6px 14px; }
  .tbl th, .tbl td { padding: 11px 6px; font-size: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .items-h { display: none; }
  .item { grid-template-columns: 70px 1fr 36px; }
  .item .price, .item .amt { grid-column: 2 / 3; }
  .item .x { grid-row: 1; grid-column: 3; }
  .paper-body { padding: 18px 16px; }
  .tab { padding: 8px 11px; font-size: 14px; }
  .hide-sm { display: none; }
}

/* print: only the invoice */
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .topbar, .quick, .tabs, .acts, .subtabs, .no-print, .toast { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .panel, .inner, .card { background: none; border: 0; padding: 0; box-shadow: none; }
  .paper { border: 0; box-shadow: none; max-width: none; }
  .paper-bar, .paper-stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ======================================================================
   APP MODE (phones, <= 720px): native-style top bar, bottom tab bar,
   grouped lists, full-screen menu and bottom sheets. Scoped to body.app
   so the desktop layout and the public invoice page are unchanged.
   ====================================================================== */
.mbar, .tabbar, .ihint { display: none; }
.m-only { display: none; }
/* manual order form */
.orow { display: grid; grid-template-columns: 1fr 70px 90px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.orow input { width: 100%; box-sizing: border-box; border: 1px solid #cdd5df; border-radius: 8px; padding: 10px 12px; font: inherit; background: #fff; min-width: 0; }
.orow .ox { padding: 8px 0; justify-content: center; }
@media (max-width: 720px) { .orow { grid-template-columns: 76px 1fr 40px; } .orow .od { grid-column: 1 / -1; } }
/* stock + shopping list */
.stk { margin: 6px 0; font-size: 14px; }
.stk.ok { color: #1f8a4c; }
.stk.short { color: #b45309; background: #fff7e0; border: 1px solid #f3dd9a; border-radius: 8px; padding: 7px 10px; }
.shp-sec { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 4px 6px; }
.shlist { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.shrow { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.shrow:last-child { border-bottom: 0; }
.shrow.have { cursor: default; }
.shrow input[type=checkbox] { width: 26px; height: 26px; flex: none; accent-color: var(--navy); }
.shrow .grow { flex: 1; min-width: 0; }
.shrow .mt { font-weight: 600; }
.shrow .ms { color: var(--muted); font-size: 13.5px; }
.shrow .qty { font-weight: 700; font-size: 18px; white-space: nowrap; }
.shrow.done .mt, .shrow.done .qty { text-decoration: line-through; color: var(--muted); }
.urow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow .grow { flex: 1; min-width: 0; }
@media (max-width: 720px) {
  body.app { --ios: #0a7aff; --sep: #c6c6c8; --grp: #f2f2f7; --bar: rgba(247, 247, 247, .94);
    background: var(--grp); overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(66px + env(safe-area-inset-bottom)); font-size: 16px; -webkit-user-select: none; user-select: none; }
  body.app input, body.app textarea, body.app select { font-size: 16px; -webkit-user-select: text; user-select: text; }
  body.app .pre, body.app .paper { -webkit-user-select: text; user-select: text; }
  html { background: #f2f2f7; }
  .app .topbar, .app .quick, .app .tabs { display: none !important; }
  .app .wrap { max-width: none; padding: 0 0 20px; }
  .app .m-hide { display: none !important; }
  .app .m-only { display: block; }
  .app .flush .inner { padding: 0 12px; }
  .app .flush .pager { padding: 14px 12px; justify-content: center; }
  .app .dot.grey { background: #8e8e93; }
  .app .drawer .ic { width: 22px; height: 22px; flex: none; stroke: var(--ios); }
  .app .drawer button.mlink { font: inherit; }
  .app .neg { color: #ff3b30; }
  .app .mr .dt.neg, .app .mr .amt.neg { color: #ff3b30; }
  .app .shp-head { padding: 12px 16px 0; }
  .app .shp-sec { margin: 18px 16px 6px; }
  .app .shlist { border-left: 0; border-right: 0; border-radius: 0; }
  .app .shrow { padding: 14px 16px; }
  .app .ihint { display: flex; gap: 10px; align-items: flex-start; background: #fff8d6; border-bottom: .5px solid #e6d98f; padding: 10px 14px; font-size: 13.5px; line-height: 1.4; }
  .app .ihint .ihow { margin-top: 4px; color: #5c5320; }
  .app .ihint button { flex: none; background: #fff; border: 1px solid #d9cc80; border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--ink); }
  .app .ioshint { margin: 0 16px 16px; padding: 12px 14px; background: #fff8d6; border-radius: 12px; font-size: 14px; line-height: 1.4; }
  .app .flush > .empty { background: #fff; margin: 12px 0; }
  .app textarea { resize: none; }

  /* top bar */
  .app .mbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; position: sticky; top: 0; z-index: 40;
    background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
    border-bottom: .5px solid var(--sep); padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; min-height: 48px; }
  .app .mb-t { font-weight: 600; font-size: 17px; text-align: center; max-width: 54vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app .mb-l, .app .mb-r { background: none; border: 0; color: var(--ios); font-size: 17px; padding: 8px 6px; cursor: pointer; min-width: 44px; min-height: 40px; display: flex; align-items: center; }
  .app .mb-l { justify-self: start; } .app .mb-r { justify-self: end; justify-content: flex-end; font-weight: 500; }
  .app .mb-l svg { width: 26px; height: 26px; stroke: var(--ios); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  .app .mb-l:active, .app .mb-r:active { opacity: .45; }
  .app .mb-r:empty, .app .mb-l:empty { visibility: hidden; }

  /* bottom tab bar */
  .app .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--bar);
    -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-top: .5px solid var(--sep);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
  .app .tabbar a, .app .tabbar button { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10.5px; color: #8e8e93; text-decoration: none; position: relative; cursor: pointer; padding: 3px 0; }
  .app .tabbar .on { color: var(--ios); }
  .app .tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .app .tabbar .on svg { stroke-width: 2.3; }
  .app .tabbar .badge { position: absolute; top: -1px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; font-size: 11px; }

  /* flat pages */
  .app .panel { background: none; border: 0; border-radius: 0; padding: 12px 12px 16px; }
  .app .panel.flush { padding: 0; }
  .app .card { border: 0; border-radius: 12px; }
  .app .inner { background: none; border: 0; padding: 0; }
  .app #view > * { animation: pg .2s ease-out; }
  @keyframes pg { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
  .app .btn { border-radius: 10px; padding: 11px 16px; }
  .app .btn:active { opacity: .7; }

  /* iOS-style segmented control (orders tabs, etc.) */
  .app .subtabs { background: #e3e3e8; border-radius: 9px; padding: 2px; margin: 0 0 12px; gap: 2px; flex-wrap: nowrap; }
  .app .subtab { flex: 1; justify-content: center; background: none; border: 0; border-radius: 7px; padding: 7px 4px; font-size: 14px; top: 0; }
  .app .subtab.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .16); top: 0; }

  /* search + lists */
  .app .msearch { padding: 8px 12px; background: var(--grp); }
  .app .msearch input { width: 100%; background: #e3e3e8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 10px center no-repeat; border: 0; border-radius: 10px; padding: 9px 10px 9px 34px; }
  .app .msearch input:focus { outline: 0; }
  .app .mlist { background: #fff; border-top: .5px solid var(--sep); }
  .app .mtotal, .app .mrow, .app .mlink { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: .5px solid var(--sep); color: var(--ink); text-decoration: none; width: 100%; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
  .app .mrow:active, .app .mlink:active { background: #e5e5ea; }
  .app .mtotal { cursor: default; }
  .app .sigma { width: 20px; font-size: 22px; font-weight: 700; text-align: center; flex: none; }
  .app .grow { flex: 1; }
  .app .dot { width: 20px; height: 20px; border-radius: 50%; flex: none; border: 2px solid transparent; }
  .app .dot.paid { background: #34c759; } .app .dot.overdue { background: #ff3b30; } .app .dot.partial { background: #0aa5f5; } .app .dot.unpaid { background: #ff9500; }
  .app .dot.all { border-color: var(--ios); background: none; }
  .app .mid { flex: 1; min-width: 0; }
  .app .mt { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app .ms { color: #8e8e93; font-size: 15px; }
  .app .mr { text-align: right; flex: none; }
  .app .mr .amt { font-size: 17px; }
  .app .mr .dt { color: #8e8e93; font-size: 15px; }
  .app .chev { width: 10px; flex: none; color: #c7c7cc; }
  .app .chev::before { content: "\203A"; font-size: 28px; line-height: 1; }
  .app .cnt { color: #8e8e93; font-size: 17px; }
  .app .mmore { display: block; width: 100%; background: #fff; border: 0; border-bottom: .5px solid var(--sep); color: var(--ios); padding: 14px; font-size: 17px; cursor: pointer; }
  .app .mmore:active { background: #e5e5ea; }
  .app .mempty { text-align: center; color: #8e8e93; padding: 40px 16px; background: #fff; }
  .app .mchip { margin: 0 12px 8px; }

  /* full-screen menu (filters) */
  .app .drawer { position: fixed; inset: 0; z-index: 90; background: var(--grp); overflow: auto; animation: up .25s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .app .drawer .dhead { position: sticky; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: var(--bar); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; border-bottom: .5px solid var(--sep); }
  .app .drawer .dhead button { background: none; border: 0; color: var(--ios); font-size: 17px; justify-self: start; padding: 8px 0; cursor: pointer; }
  .app .drawer .dhead b { font-size: 17px; }
  .app .drawer .logo { width: 118px; height: 118px; border-radius: 50%; margin: 14px auto; background: linear-gradient(#fff 50%, #ffd83b 50%); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; line-height: 1.15; text-align: center; padding: 0 12px; overflow: hidden; border: 1px solid #e5e5ea; }
  .app .drawer .logo span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app .drawer .dgroup { margin: 0 0 22px; border-top: .5px solid var(--sep); }
  .app .drawer .mlink.on { background: #eaf2ff; }
  .app .drawer .ico { width: 22px; height: 22px; flex: none; stroke: var(--ios); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .app .vlabel { text-align: center; color: #8e8e93; font-size: 13px; padding: 4px 0 22px; }

  /* bottom sheets + modals */
  .app .modal-bg { align-items: flex-end; padding: 0; }
  .app .modal { width: 100%; max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; overflow: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
  .app .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .app .sheet-list { margin: 0 -16px; border-top: .5px solid var(--sep); }

  /* invoice page: pill actions + full-width paper */
  .app .acts { overflow-x: auto; flex-wrap: nowrap; gap: 8px; padding: 2px 0 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .app .acts::-webkit-scrollbar { display: none; }
  .app .act { border: 0; border-radius: 999px; background: #e3e3e8; white-space: nowrap; top: 0; padding: 8px 14px; }
  .app .act.on { background: var(--ios); color: #fff; top: 0; }
  .app .act.danger { color: #ff3b30; }
  .app .paper { max-width: none; border-radius: 4px; }
  .app .paper-body { padding: 18px 16px; }
  .app .acts + .inner { margin: 0 -12px; }
  .app .acts + .inner > .paper { border-left: 0; border-right: 0; }
  .app .acts + .inner > :not(.paper) { margin: 0 12px; }

  /* invoice form as grouped inline rows */
  .app .ibox { background: none; border: 0; padding: 0; margin: 0 -12px; }
  .app .ibox .grid2 { display: block; }
  .app .ibox .grid2 .grid2 { display: block; }
  .app .ibox .lab { padding: 14px 16px 6px; color: #6d6d72; text-transform: uppercase; font-size: 13px; font-weight: 500; }
  .app .ibox .card { border-radius: 0; border-left: 0; border-right: 0; margin-bottom: 0 !important; }
  .app .ibox .field { display: flex; align-items: center; gap: 12px; background: #fff; margin: 0; padding: 0 16px; border-bottom: .5px solid var(--sep); }
  .app .ibox .field > span { flex: 0 0 36%; margin: 0; font-weight: 500; font-size: 16px; }
  .app .ibox .field input, .app .ibox .field select { border: 0; background: transparent; text-align: right; padding: 13px 0; border-radius: 0; }
  .app .ibox .field textarea { border: 0; background: transparent; padding: 12px 0; min-height: 66px; border-radius: 0; }
  .app .ibox .field:has(textarea) { align-items: flex-start; }
  .app .ibox .field:has(textarea) > span { padding-top: 13px; }
  .app .ibox .field input:focus, .app .ibox .field textarea:focus, .app .ibox .field select:focus { outline: 0; }
  .app .ibox .field small { display: none; }
  .app .ibox .sugg { top: 100%; left: 0; right: 0; }
  .app .ibox .grid2 > div { border-top: .5px solid var(--sep); margin-bottom: 18px; }
  .app .ibox .items-h { display: none; }
  .app #items { border-top: .5px solid var(--sep); margin-top: 16px; }
  .app .ibox .item { background: #fff; margin: 0; padding: 10px 16px; border-bottom: .5px solid var(--sep); grid-template-columns: 70px 1fr 34px; }
  .app .ibox .item input, .app .ibox .item textarea { background: #f2f2f7; border: 0; border-radius: 8px; padding: 9px 10px; }
  .app .ibox .item .amt { background: none; border: 0; text-align: right; font-weight: 600; padding: 9px 0; }
  .app .ibox .add-row { display: block; margin: 0 0 18px; }
  .app .ibox .add-row button { display: block; width: 100%; background: #fff; border: 0; border-bottom: .5px solid var(--sep); border-radius: 0; color: var(--ios); text-align: left; padding: 14px 16px; font-size: 16px; }
  .app .ibox .sum { background: #fff; padding: 6px 16px 10px; width: auto; margin: 0 0 18px; border-top: .5px solid var(--sep); border-bottom: .5px solid var(--sep); }
  .app .ibox .sum .tot { border-top: 0; margin-top: 0; padding-top: 4px; }
  .app .ibox > .field { }
  .app #ferr { margin: 0 16px; }
  .app #iform .actions { padding: 0 16px 6px; }
  .app #iform .actions .btn.alt { display: none; }
  .app #iform #save { width: 100%; justify-content: center; }

  /* login */
  .app .login { margin: 14vh auto; }
  .app .drawer .logo span { white-space: normal !important; text-overflow: clip !important; font-size: 18px; display: -webkit-box !important; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
  .app .paper-stamp { top: auto !important; left: 14px !important; right: auto !important; bottom: 175px; transform: rotate(-12deg) scale(.6); transform-origin: left bottom; opacity: .6; }
}
