/* INFILITH Books — web edition stylesheet
 *
 * The palette is shared with the INFILITH Books desktop app
 * (ui/theme/Theme.kt): same indigo/teal/violet/amber/rose brand colours,
 * same light surface stack, and the same dark scheme. Light is the default;
 * <html data-theme="dark"> (set from localStorage before first paint) swaps
 * every token below to the desktop app's dark colours. Printing always uses
 * the light values — paper stays black on white whatever the screen shows. */
:root {
  /* brand */
  --indigo: #4655D6; --violet: #7C5CE0; --teal: #00A88F; --amber: #F59E0B; --red: #E5484D;
  /* light surfaces (desktop LightColors) */
  --bg: #F6F7FB; --card: #FFFFFF; --surface2: #EFF1F8; --field: #FFFFFF;
  --ink: #1B1D2A; --ink2: #5C6079;
  --line: #E7E9F4; --line-soft: #F0F1F8; --outline: #C9CDDF;
  --th-bg: #FAFBFF; --hover: #F1F2FA;
  /* material-style containers */
  --on-primary: #FFFFFF;
  --primary-c: #E7E9FB; --on-primary-c: #2A3399;
  --teal-c: #E3F8F3; --on-teal-c: #00786A;
  --violet-c: #EFE9FD; --on-violet-c: #4B2FA8;
  --red-c: #FDECEC; --on-red-c: #8A1C22;
  --amber-c: #FFF4E0; --on-amber-c: #9A6200;
  /* misc */
  --sel: #D9DDFB; --focus-glow: #C9CDF3; --red-line: #F3C9CB;
  --warn-line: #F6DFB4; --warn-bg: #FFFCF5;
  /* the INFILITH brand gradient — desktop brandBrush() */
  --brand-grad: linear-gradient(120deg, #4655D6 0%, #7C5CE0 55%, #00A88F 100%);
}
/* desktop DarkColors, token for token */
[data-theme="dark"] {
  --indigo: #9BA6F4; --violet: #C4A9F5; --teal: #59D6C0; --amber: #F59E0B; --red: #FF8A90;
  --bg: #12141F; --card: #1B1D2A; --surface2: #262A3B; --field: #262A3B;
  --ink: #EEF0FA; --ink2: #A6ABC4;
  --line: #333950; --line-soft: #262A3B; --outline: #444B66;
  --th-bg: #262A3B; --hover: #262A3B;
  --on-primary: #1A2270;
  --primary-c: #2E3A8C; --on-primary-c: #E3E6FF;
  --teal-c: #00574A; --on-teal-c: #B6F2E5;
  --violet-c: #4B2FA8; --on-violet-c: #EFE9FD;
  --red-c: #7A1F24; --on-red-c: #FFDAD6;
  --amber-c: #42330D; --on-amber-c: #FCD34D;
  --sel: #2E3A8C; --focus-glow: #2E3A8C; --red-line: #5F1418;
  --warn-line: #5A4A1F; --warn-bg: #241F12;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
::selection { background: var(--sel); }
body { margin: 0; font: 14px/1.5 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
.rail nav a:hover, .tabs a:hover, .btn:hover { text-decoration: none; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.rail { width: 248px; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
/* the desktop app's brand panel: 96dp tall, indigo→violet→teal brush */
.brand { display: flex; align-items: center; gap: 12px; min-height: 96px; padding: 14px 18px; background: var(--brand-grad); }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.brand strong { display: block; font-size: 15px; letter-spacing: .3px; color: #fff; }
.brand span { font-size: 12.5px; color: rgba(255, 255, 255, .85); }
/* the nav scrolls inside the rail when the window is short, so the last
   links and the footer (company, theme, sign out) never fall off-screen */
.rail nav { display: flex; flex-direction: column; padding: 6px 0; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* section labels — desktop nav groups (HOME / MASTERS / …) */
.rail-sec { display: block; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ink2); padding: 14px 20px 4px; }
.rail nav a { margin: 0 10px; padding: 11px 10px; border-radius: 10px; color: var(--ink); font-weight: 600; font-size: 14px; }
.rail nav a:hover { background: var(--hover); text-decoration: none; }
.rail nav a.on { background: var(--primary-c); color: var(--on-primary-c); }
.rail-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }
.rail-foot .co { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rail-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rail-foot b { font-size: 13px; display: block; }
.rail-foot small { color: var(--ink2); font-size: 11.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); flex: none; }
.logout { font-size: 12.5px; color: var(--red); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; padding: 18px 24px 12px; background: var(--bg); }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; }
.topbar p { margin: 2px 0 0; color: var(--ink2); font-size: 12.5px; }
.top-left { display: flex; align-items: center; min-width: 0; }
.top-right { display: flex; gap: 10px; align-items: center; }
/* drawer controls — shut by default; only the mobile media query turns them on */
.burger, .rail-x, .scrim { display: none; }
.who { color: var(--ink2); font-size: 12.5px; }
.content { padding: 8px 24px 40px; display: flex; flex-direction: column; gap: 16px; }

/* theme toggle (desktop: light/dark button in the rail) */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink2); cursor: pointer; padding: 0; }
.theme-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.theme-btn .ico-sun { display: none; }
[data-theme="dark"] .theme-btn .ico-moon { display: none; }
[data-theme="dark"] .theme-btn .ico-sun { display: inline; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; overflow-x: auto; box-shadow: 0 1px 2px rgba(27, 29, 42, .04); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); align-items: start; }
.stat .k { display: block; font-size: 11px; letter-spacing: .7px; text-transform: uppercase; color: var(--ink2); }
.stat strong { display: block; font-size: 22px; margin: 6px 0 2px; }
.stat small { color: var(--ink2); font-size: 11.5px; }
.big-num { font-size: 30px; font-weight: 700; color: var(--indigo); }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin-bottom: 10px; }
input, select, textarea { width: 100%; font: inherit; color: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
input:disabled { background: var(--surface2); color: var(--ink2); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus-glow); border-color: var(--indigo); }
.r { text-align: right; }
.c { text-align: center; }
.row { display: flex; gap: 10px; }
.row > label { flex: 1; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.form button, .actions button { margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.inline { display: inline; }
.btn { display: inline-block; background: var(--indigo); color: var(--on-primary); border: 1px solid var(--indigo); border-radius: 10px; padding: 9px 15px; font: 600 13px/1.2 inherit; cursor: pointer; transition: filter .12s ease, background .12s ease, box-shadow .12s ease; }
.btn:hover { filter: brightness(1.06); }
.btn:active { filter: brightness(.96); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.btn.ghost { background: var(--card); color: var(--indigo); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.pads { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.page-form { display: flex; flex-direction: column; gap: 16px; }
.filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.filters label { margin-bottom: 0; min-width: 130px; }

/* ---------- period quick ranges, and the bundle picker ----------------
   The ranges sit in a filter card as one group; the range the page is
   already showing wears the active colour, exactly as the portal's
   toolbar does. The picker's bar carries the count and the two actions
   a ticked selection unlocks — both disabled until something is ticked. */
.ranges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ranges .btn.on { background: var(--indigo); color: var(--on-primary); border-color: var(--indigo); }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.btn[disabled]:hover { filter: none; }
.pick-col { width: 34px; text-align: center; }
.pick-col input { width: auto; }
.pick-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); }
.pick-count { font: 600 13px/1.2 inherit; color: var(--ink2); font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.2px; min-width: 520px; }
.tbl .r, .stat strong, .big-num { font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--ink2); padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--th-bg); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--th-bg); }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: none; padding-top: 10px; }
.tbl.flat td:first-child { color: var(--ink2); width: 42%; }
.muted { color: var(--ink2); }
.empty { text-align: center; color: var(--ink2); padding: 28px 0; }
.note { color: var(--ink2); font-size: 12px; margin: 8px 0 0; }
.err { background: var(--red-c); color: var(--on-red-c); padding: 10px 13px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; }
.ok { background: var(--teal-c); color: var(--on-teal-c); padding: 10px 13px; border-radius: 10px; margin-bottom: 12px; }

/* ---------- tabs / pills ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 13px; font-size: 13px; font-weight: 600; color: var(--ink2); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--indigo); border-bottom-color: var(--indigo); }
.pill { background: var(--teal-c); color: var(--on-teal-c); border-radius: 99px; padding: 3px 11px; font-size: 11.5px; font-weight: 700; }

/* ---------- status badges (admin panel) ---------- */
.badge { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.ok      { background: var(--teal-c); color: var(--on-teal-c); }
.badge.admin   { background: var(--primary-c); color: var(--on-primary-c); }
.badge.trial   { background: var(--amber-c); color: var(--on-amber-c); }
.badge.pending { background: var(--amber-c); color: var(--on-amber-c); }
.badge.expired { background: var(--surface2); color: var(--ink2); }
.badge.blocked { background: var(--red-c); color: var(--on-red-c); }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.btn.danger:hover { background: var(--red-c); }

/* ---------- charts (SVG colours follow the theme) ---------- */
.ch-grid { stroke: var(--line); }
.ch-axis { fill: var(--ink2); }
.ch-ink { fill: var(--ink); }
.ch-a { fill: var(--indigo); }
.ch-b { fill: var(--red); }
.ch-line { fill: none; stroke: var(--teal); }
.ch-dot-pos { fill: var(--teal); }
.ch-dot-neg { fill: var(--red); }
.ch-zero { stroke: var(--ink2); }

/* ---------- auth / install ---------- */
.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px; text-align: center; }
.auth-card .logo { width: 62px; margin-bottom: 10px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card form { text-align: left; margin-top: 18px; }
.auth-card button { width: 100%; margin-top: 6px; }
.small { font-size: 12px; }
code { background: var(--surface2); padding: 1px 5px; border-radius: 5px; }

/* ---------- invoice sheet ---------- */
/* paper: always white, always black ink — in both themes */
.sheet { background: #fff; max-width: 1080px; margin: 20px auto; padding: 26px 30px; border: 1.5px solid #000; font-family: "Times New Roman", Times, serif; font-size: 13px; color: #000; }
.sheet table { width: 100%; border-collapse: collapse; }
.head { table-layout: fixed; }
.head td { vertical-align: top; padding-bottom: 10px; }
.head .co { width: 68%; }
.head .ttl { width: 32%; }
.head .name { font-size: 19px; }
.co-logo { float: left; max-height: 64px; max-width: 180px; margin: 0 12px 6px 0; }
.head .ttl { text-align: right; }
.head .ttl b { display: block; font-size: 17px; }
.head .ttl span { font-size: 11px; color: #555; }
.head .ttl .docmeta { font-size: 12.5px; color: #000; margin-top: 3px; }
.blocks { margin: 6px 0 10px; }
.blocks td { border: 1px solid #000; padding: 8px 10px; vertical-align: top; width: 50%; height: 74px; }
.blocks .pn { font-weight: 700; }
.vou div { display: flex; gap: 6px; }
.vou span { color: #333; min-width: 96px; }
.items th, .items td { border: 1px solid #000; padding: 5px 7px; font-variant-numeric: tabular-nums; }
.items th { background: #fff; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; }
/* fixed proportional columns so preview and paper match exactly */
.sheet table.items { table-layout: fixed; }
/* Only the description column may break a word. Everything else on the line
   is a figure, a code or a rate — quantity, taxable value and the per-line
   tax never split across lines. A long number in a narrow column used to
   wrap mid-digit and push the quantity out of its cell on paper. Written as
   "every column except the description" so it holds whatever the sheet's
   column count happens to be — the intrastate layout has one more tax
   column than the interstate one. */
.sheet table.items td { white-space: nowrap; overflow-wrap: normal; }
.sheet table.items td:nth-child(2) { white-space: normal; overflow-wrap: anywhere; }
/* The HSN/SAC code is the one figure that can outgrow its fixed column —
   eight digits in nine percent of a narrowed sheet used to spill straight
   over the cell border. While it fits, it stays on one line like every
   other figure (no change at any normal width); only when it truly cannot
   fit does it fold inside its own cell. Nothing else on the sheet moves. */
.sheet table.items th:nth-child(3),
.sheet table.items td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; }
/* Header words get the same treatment: QUANTITY is one long word with no
   space to break at, so once the sheet narrows (A4 paper, a share link on a
   phone) it painted straight over the Rate cell's border. It folds inside
   its own cell only when it truly cannot fit — while it fits, every header
   stays exactly as it was. */
.sheet table.items th { overflow-wrap: anywhere; }
/* .cols9: taxable value + the CGST and SGST halves (place of supply = ours).
   The quantity column takes 11%, not 10%: at A4's 718px sheet the 10% column
   could not hold the word Quantity on one line. The one percent comes off
   the description, which is wrapping text and simply rewraps — no figure,
   no code, no border moves anywhere else. */
.cols9 th:nth-child(1) { width: 6%; } .cols9 th:nth-child(2) { width: 25%; }
.cols9 th:nth-child(3) { width: 9%; } .cols9 th:nth-child(4) { width: 11%; }
.cols9 th:nth-child(5) { width: 11%; } .cols9 th:nth-child(6) { width: 5%; }
.cols9 th:nth-child(7) { width: 12%; } .cols9 th:nth-child(8) { width: 10.5%; }
.cols9 th:nth-child(9) { width: 10.5%; }
/* .cols8: taxable value + IGST in one column (interstate supply) */
.cols8 th:nth-child(1) { width: 6%; } .cols8 th:nth-child(2) { width: 32%; }
.cols8 th:nth-child(3) { width: 10%; } .cols8 th:nth-child(4) { width: 11%; }
.cols8 th:nth-child(5) { width: 12%; } .cols8 th:nth-child(6) { width: 5%; }
.cols8 th:nth-child(7) { width: 13%; } .cols8 th:nth-child(8) { width: 11%; }
/* On a phone the sheet cannot hold nine columns: instead of crushing each
   one until the figures touch their borders, the items table keeps its paper
   proportions (740px — every header word and figure measured whole there)
   and the reader swipes the table sideways inside the sheet's frame. Screen
   only — on paper the page is always wider than 720px, so print never hits
   this rule. */
@media screen and (max-width: 720px) {
  .sheet { overflow-x: auto; }
  .sheet table.items { min-width: 740px; }
}
/* .totals here is the voucher form's own running-total panel — the printed
   sheets no longer have a second table of their own. The summary is now the
   closing rows of the items table: the label spans the leading columns so
   every amount lands exactly under Taxable Value, whichever layout is in use. */
.totals { margin: 0; break-inside: avoid; page-break-inside: avoid; }
.sheet table.items tfoot td { border-top: 1.5px solid #000; }
.sheet table.items tfoot .lbl { text-align: right; }
.sheet table.items tfoot tr.g td { font-weight: 700; }
/* the amount in words, then the bank/declaration block, carry straight on
   beneath the table so they still read as part of one sheet */
.words { border: 1px solid #000; border-top: none; padding: 4px 7px; font-size: 10.5px; break-inside: avoid; page-break-inside: avoid; }
.sect { text-align: center; font-weight: 700; text-transform: uppercase; margin: 9px 0 3px; font-size: 11px; }
.brk { margin-bottom: 8px; }
.nar { font-size: 10.5px; margin: 5px 0; }
/* invoice footer: bank details | declaration, then terms */
.inv-foot-grid { display: flex; gap: 0; margin: 8px 0 0; border: 1px solid #000; break-inside: avoid; page-break-inside: avoid; }
.inv-foot-grid > div { padding: 5px 8px; font-size: 10px; line-height: 1.38; }
.inv-foot-grid .bank { width: 50%; border-right: 1px solid #000; }
.inv-foot-grid .decl { width: 50%; }
.inv-foot-grid b { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
/* scan-to-pay: the UPI QR sits under the bank/declaration block as one
   more bordered band, so it prints with the rest of the sheet */
.upi-pay { display: flex; gap: 12px; align-items: center; margin: 8px 0 0; border: 1px solid #000; padding: 6px 8px; break-inside: avoid; page-break-inside: avoid; }
.upi-pay-qr svg { display: block; width: 108px; height: 108px; }
.upi-pay-txt { font-size: 10px; line-height: 1.5; }
.upi-pay-txt b { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
/* terms run in two columns: a long set of conditions takes half the height,
   which is what keeps the whole invoice on one page */
.terms { margin: 6px 0 0; font-size: 10px; line-height: 1.38; columns: 2; column-gap: 18px; orphans: 2; widows: 2; }
.terms b { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 1px; column-span: all; }
.sign { margin-top: 18px; font-size: 11.5px; break-inside: avoid; page-break-inside: avoid; }
.sign td { vertical-align: bottom; }
.sign .r { text-align: right; border: 1px solid #000; padding: 6px 10px; width: 38%; }
.pfoot { text-align: center; font-size: 10px; color: #444; margin-top: 10px; }
.actions-bar { max-width: 1080px; margin: 0 auto 30px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* ---------- invoice settings section headings ---------- */
.sect-note { font-size: 11px; letter-spacing: .7px; text-transform: uppercase; color: var(--ink2); margin: 14px 0 8px; font-weight: 700; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 14px; margin-bottom: 6px; }
.check-grid label { margin-bottom: 0; }
.print-head { display: none; }

@media print {
  /* paper ignores the screen theme entirely: force the light tokens back so a
     dark-mode print is still black ink on white */
  :root, [data-theme] {
    --bg: #fff; --card: #fff; --surface2: #f2f2f2; --field: #fff;
    --ink: #000; --ink2: #333; --line: #999; --line-soft: #dcdcdc; --outline: #999;
    --th-bg: #fff; --hover: #fff; --indigo: #000; --on-primary: #fff;
    --primary-c: #fff; --on-primary-c: #000; --focus-glow: transparent;
  }
  @page { size: A4; margin: 12mm 10mm; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rail, .noprint, .actions-bar, .tabs, .filters, .burger, .scrim { display: none !important; }
  .shell, .main { display: block; }
  .content { padding: 0; display: block; }
  body { background: #fff; }
  .topbar { padding: 0 0 8px; border-bottom: 2px solid #1B1D2A; margin-bottom: 10px; }
  .topbar h1 { font-size: 17px; }
  .topbar p { display: none; }
  .top-right { display: none !important; }
  .card { border: 1px solid #d5d5d5; border-radius: 0; padding: 8px 10px; margin: 0 0 10px; page-break-inside: avoid; }
  .card-head { margin-bottom: 6px; }
  .card-head h3 { font-size: 13px; }
  .card-head .btn { display: none !important; }
  .grid { display: block; }
  .grid.two > .card { margin-bottom: 10px; }
  .tbl { font-size: 11px; }
  .tbl th { background: #fff; border-bottom: 1.5px solid #000; }
  .tbl td, .tbl th { padding: 4px 6px; border-bottom: 1px solid #dcdcdc; }
  .tbl tfoot td { border-top: 1.5px solid #000; }
  a { color: #000; text-decoration: none; }
  a[href]:after { content: ""; }
  .print-head {
    display: block; font-size: 11px; color: #333; margin-bottom: 8px;
    border-bottom: 1px solid #999; padding-bottom: 5px;
  }
  .print-head b { font-size: 13px; color: #000; }

  /* the invoice sheet prints exactly as previewed: same frame, same type.
     On paper the sheet uses the page, not the screen — and it must use ONE
     page: a five-line invoice with its bank block, declaration and terms
     still has to land on a single A4, so every margin below is trimmed to
     the bone. Measured against the 1032px an A4 page holds at 12mm
     margins: the five-line intrastate sheet with full terms comes to
     ~955px after this, leaving room for a couple of description lines to
     wrap before page two is ever a risk. The page title above the sheet is
     dropped — the sheet carries its own TAX INVOICE head, number and date;
     printing the title twice is noise, and those 46px are what tipped long
     invoices onto page two. */
  body:has(.sheet) .topbar { display: none; }
  .sheet { margin: 0; max-width: none; padding: 6px 8px; }
  .sheet .head { line-height: 1.28; }
  .sheet .head td { padding-bottom: 6px; }
  .sheet .head .name { font-size: 16px; }
  .sheet .blocks { line-height: 1.25; }
  .sheet .blocks td { height: 56px; padding: 6px 8px; }
  .sheet table.items th, .sheet table.items td { padding: 1px 4px; }
  .sheet .words { padding: 3px 6px; }
  .sheet .inv-foot-grid > div { padding: 3px 6px; font-size: 9.5px; }
  .sheet .upi-pay { padding: 4px 6px; margin-top: 6px; }
  .sheet .upi-pay-qr svg { width: 96px; height: 96px; }
  .sheet .sign { margin-top: 8px; }
  .sheet .terms { font-size: 9.3px; line-height: 1.3; }
  .sheet .pfoot { margin-top: 6px; }
  .sheet thead { display: table-header-group; }
  .sheet tfoot { display: table-footer-group; }
  .sheet tr { page-break-inside: avoid; }
}
@media (max-width: 900px) {
  .shell { flex-direction: column; }

  /* The rail leaves the flow and becomes a drawer: shut until the burger
     opens it. `visibility` — not the transform on its own — is what keeps
     its links out of the tab order while it is shut. */
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 82vw; max-width: 300px; height: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease, visibility .22s ease;
    z-index: 60; overflow-y: auto;
    box-shadow: 0 0 42px rgba(16, 18, 30, .22);
  }
  .rail.open { transform: none; visibility: visible; }
  .rail nav { flex: 1 0 auto; }

  .scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(16, 18, 30, .5);
    opacity: 0; visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
  }
  .scrim.open { opacity: 1; visibility: visible; }

  .burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; margin-right: 10px; flex: none;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); color: var(--ink); cursor: pointer;
  }
  .rail-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; margin-left: auto; flex: none;
    border: 1px solid rgba(255, 255, 255, .35); border-radius: 10px;
    background: rgba(255, 255, 255, .12); color: #fff;
    font-size: 20px; line-height: 1; cursor: pointer;
  }

  body.rail-open { overflow: hidden; }

  .topbar { padding: 14px 16px 10px; flex-wrap: wrap; gap: 8px; }
  .content { padding: 4px 12px 32px; }
  .auth-card { width: calc(100% - 32px); max-width: 380px; padding: 24px 20px; }
  .row { flex-direction: column; gap: 0; }
}

/* ---------- public product page (landing) ---------- */
body.lp { background: linear-gradient(180deg, #F2F3FD 0%, var(--bg) 340px); }
[data-theme="dark"] body.lp { background: linear-gradient(180deg, #191C2B 0%, var(--bg) 340px); }
.lp-top { display: flex; align-items: center; justify-content: space-between; gap: 20px;
  max-width: 1120px; margin: 0 auto; padding: 20px 24px; }
.lp-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; }
.lp-brand:hover { text-decoration: none; }
.lp-brand img { width: 34px; height: 34px; border-radius: 9px; }
.lp-top nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
/* plain links are muted; .btn in here must keep the button's own colours
   (otherwise the nav's "Start free trial" prints grey on indigo) */
.lp-top nav a:not(.btn) { color: var(--ink2); font-size: 13.5px; }

.lp-hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center;
  max-width: 1120px; margin: 0 auto; padding: 46px 24px 30px; }
.lp-eyebrow { display: inline-block; background: var(--primary-c); color: var(--on-primary-c); border-radius: 99px;
  padding: 4px 12px; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; }
.lp-hero h1 { font-size: 40px; line-height: 1.15; margin: 16px 0 12px; letter-spacing: -.5px; }
.lp-hero p { color: var(--ink2); font-size: 15px; margin: 0 0 20px; max-width: 46ch; }
.lp-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.lp-shot { display: grid; gap: 14px; }
.lp-shot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lp-shot-table { padding: 12px 14px; }
.lp-shot-table .tbl { margin: 0; }
.lp-shot-foot { display: flex; gap: 8px; margin-top: 10px; }

.lp-sect { max-width: 1120px; margin: 0 auto; padding: 46px 24px; }
.lp-sect h2 { font-size: 27px; margin: 0 0 8px; letter-spacing: -.3px; }
.lp-lede { color: var(--ink2); font-size: 14.5px; max-width: 62ch; margin: 0 0 24px; }
.lp-feats { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.lp-feats h3 { margin: 0 0 6px; font-size: 15px; }
.lp-feats p { margin: 0; color: var(--ink2); font-size: 13px; }

.lp-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; align-items: start; }
.lp-plan { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 20px; }
.lp-plan.featured { border-color: var(--indigo); box-shadow: 0 10px 26px rgba(70,85,214,.10); }
.lp-plan.current { border-color: var(--teal); }
.lp-flag { position: absolute; top: -10px; left: 20px; background: var(--indigo); color: var(--on-primary);
  border-radius: 99px; padding: 3px 10px; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; }
.lp-plan.current .lp-flag { background: var(--teal); color: var(--on-primary); }
.lp-plan h3 { margin: 0 0 4px; font-size: 17px; }
.lp-blurb { color: var(--ink2); font-size: 12.5px; margin: 0 0 14px; min-height: 34px; }
.lp-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.lp-price strong { font-size: 27px; letter-spacing: -.5px; }
.lp-price span { color: var(--ink2); font-size: 12.5px; }
.lp-price em { width: 100%; font-style: normal; color: var(--ink2); font-size: 12px; }
.lp-ticks { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 7px; }
.lp-ticks li { position: relative; padding-left: 22px; font-size: 13px; color: var(--ink); }
.lp-ticks li::before { content: "\2713"; position: absolute; left: 0; top: 0; color: var(--teal); font-weight: 700; }
.lp-plan .btn { width: 100%; }
.lp-fineprint { color: var(--ink2); font-size: 12.5px; margin: 20px 0 0; }
.lp-faq { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.lp-faq h3 { margin: 0 0 6px; font-size: 14.5px; }
.lp-faq p { margin: 0; color: var(--ink2); font-size: 13px; }
.lp-foot { border-top: 1px solid var(--line); margin-top: 30px; padding: 22px 24px 34px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: var(--ink2); font-size: 12.5px; }

/* ---------- billing ---------- */
.usage-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.usage-row:last-of-type { border-bottom: none; }
.usage-row b { font-size: 12.5px; }
.meter { display: block; height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--indigo), var(--violet)); }
.meter.infinite i { width: 100%; background: linear-gradient(90deg, var(--teal), #4FCBB0); }
.pending-pay { border-color: var(--warn-line); background: var(--warn-bg); }
.pending-pay .note { margin-top: 0; }
.pads { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .lp-hero { grid-template-columns: 1fr; gap: 24px; padding-top: 30px; }
  .lp-hero h1 { font-size: 29px; }
  .lp-top nav { gap: 12px; }
  .usage-row { grid-template-columns: 1fr; gap: 6px; }
}

/* item type-ahead on voucher lines */
.itemcell { position: relative; }
.itemcell .itemq { width: 100%; }
.itempop { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 2px); background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 26px rgba(16, 24, 40, .14); max-height: 230px; overflow: auto; }
.itempop button { display: block; width: 100%; padding: 8px 12px; border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink); text-align: left; cursor: pointer; }
.itempop button.hi, .itempop button:hover { background: var(--hover); }
.itempop .none { padding: 8px 12px; font-size: 13px; color: var(--ink2); }

/* ---------- user guide ---------- */
.guide-hero { background: var(--brand-grad); color: #fff; border: none; }
.guide-hero h2 { margin: 0 0 6px; font-size: 22px; color: #fff; letter-spacing: -.3px; }
.guide-hero p { margin: 0; color: rgba(255, 255, 255, .92); font-size: 14px; max-width: 74ch; }
.guide-hero .btn { background: #fff; color: var(--indigo); border-color: #fff; }
.guide-hero .btn.ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); }
.guide-layout { display: grid; grid-template-columns: 232px 1fr; gap: 20px; align-items: start; }
.guide-toc { position: sticky; top: 16px; }
.guide-toc .card { padding: 12px 12px; }
.guide-toc b { display: block; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--ink2); margin: 2px 6px 8px; }
.guide-toc a { display: block; padding: 5px 8px; border-radius: 8px; font-size: 13px; color: var(--ink); }
.guide-toc a:hover { background: var(--hover); text-decoration: none; }
.guide-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.guide-body h2 { font-size: 18px; margin: 4px 0 10px; scroll-margin-top: 16px; }
.guide-body h3 { font-size: 14.5px; margin: 14px 0 6px; }
.guide-body p { margin: 0 0 8px; }
.guide-body ul, .guide-body ol { margin: 0 0 10px; padding-left: 20px; }
.guide-body li { margin-bottom: 5px; }
.guide-body .pill-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
/* numbered "how to" steps */
.steps { counter-reset: step; list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 9px; }
.steps li { counter-increment: step; position: relative; padding: 10px 12px 10px 46px; background: var(--surface2); border-radius: 10px; margin: 0; }
.steps li::before { content: counter(step); position: absolute; left: 12px; top: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--indigo); color: var(--on-primary); font-weight: 700; font-size: 12.5px; display: flex; align-items: center; justify-content: center; }
.steps li b { display: block; margin-bottom: 2px; }
.steps li span { color: var(--ink2); font-size: 13px; }
.guide-body table.role-tbl td:first-child { font-weight: 600; white-space: nowrap; }
.kbd { display: inline-block; background: var(--card); border: 1px solid var(--outline); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-size: 12px; font-family: ui-monospace, monospace; }
@media (max-width: 900px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc { position: static; }
}

/* ---------- payroll attendance grid ---------- */
.tbl-wrap { overflow-x: auto; }
.att-tbl td, .att-tbl th { padding: 4px 3px; text-align: center; }
.att-tbl td:first-child, .att-tbl th:first-child { text-align: left; padding-left: 10px; position: sticky; left: 0; background: var(--card); min-width: 120px; }
.att-day { font-size: 10.5px; color: var(--ink2); font-weight: 600; min-width: 22px; }
.att-cell { min-width: 22px; }
.att-sel { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--field); font-size: 11px; font-weight: 700; text-align: center; cursor: pointer; appearance: none; -webkit-appearance: none; }
.att-sel.a-p { background: var(--teal-c); color: var(--on-teal-c); border-color: transparent; }
.att-sel.a-a { background: var(--red-c); color: var(--on-red-c); border-color: transparent; }
.att-sel.a-l { background: var(--violet-c); color: var(--on-violet-c); border-color: transparent; }
.att-sel.a-x { background: var(--surface2); color: var(--ink2); }
.att-swatch { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.att-swatch.a-p { background: var(--teal-c); color: var(--on-teal-c); }
.att-swatch.a-a { background: var(--red-c); color: var(--on-red-c); }
.att-swatch.a-l { background: var(--violet-c); color: var(--on-violet-c); }
.att-swatch.a-x { background: var(--surface2); }

/* ---------- sharing & client portal ---------- */
.hint { font-size: 12.5px; color: var(--ink2); margin: 8px 0 0; }
.share-card .share-url { display: flex; gap: 8px; align-items: center; }
.share-card .share-url code { flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap;
  font-size: 12.5px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.share-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.share-actions label { display: flex; gap: 6px; align-items: center; margin: 0; white-space: nowrap; }
.share-actions select { width: auto; }
.share-revoke { display: inline; margin-left: auto; }
.portal-url { font-size: 12px; word-break: break-all; }
.portal-create { margin-top: 12px; align-items: end; }
.portal-create label { margin: 0; min-width: 220px; }
/* the customer's public pages (share.php): paper-warm frame, no chrome */
.share-page .pv-sheet .card { box-shadow: none; }
.share-page .share-foot { text-align: center; font-size: 11.5px; color: #8A8FA6; margin: 14px 0 2px; }
