/* GST billing UI. Mobile first. Separate from the ERP's styles.css. */
:root {
  --navy: #10294a; --navy2: #1b3d6b; --maroon: #8b3a30; --gold: #b8892b;
  --bg: #f2f4f8; --card: #fff; --line: #dde2ea; --text: #14202f; --muted: #667487;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --okbg: #e8f6ee; --warnbg: #fff4e0; --badbg: #fdecec;
  --tap: 48px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
.hi { font-size: .82em; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 8px; }
a { color: var(--navy2); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--navy), #0b1c34); }
.login-card { background: #fff; border-radius: 16px; padding: 24px 20px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-logo { width: 100%; max-width: 280px; display: block; margin: 0 auto 8px; }
.login-card h1 { font-size: 20px; text-align: center; margin: 4px 0; }
.login-card p { text-align: center; margin-bottom: 12px; }
.login-card label { display: block; font-size: 13px; margin: 10px 0 4px; color: var(--muted); }

/* shell */
.top { position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; }
.top-in { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.top-seal { width: 34px; height: 34px; border-radius: 50%; background: #fff; padding: 2px; }
.top-title { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.top-title span { font-size: 11px; opacity: .8; letter-spacing: .08em; }
main { max-width: 980px; margin: 0 auto; padding: 12px 12px 96px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: 12px; line-height: 1.15; }
.tabs a i { font-style: normal; font-size: 20px; line-height: 1; }
.tabs a small { font-size: 10px; }
.tabs a.on { color: var(--navy); font-weight: 700; box-shadow: inset 0 3px 0 var(--maroon); }
.tabs a[data-tab="new"] i { background: var(--maroon); color: #fff; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; }

/* basics */
h2 { font-size: 18px; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--navy); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 160px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
label.f { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; font: inherit; font-size: 16px; border: 1px solid #c3cbd8; border-radius: 10px; background: #fff; color: var(--text); }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy2); outline-offset: 0; border-color: var(--navy2); }
input[type=checkbox] { width: 24px; height: 24px; min-height: 0; }
.btn { flex-direction: column; gap: 0; line-height: 1.2; text-align: center; min-height: var(--tap); padding: 10px 16px; border-radius: 10px; border: 1px solid #b6c0cf; background: #fff; color: var(--navy); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.maroon { background: var(--maroon); color: #fff; border-color: var(--maroon); }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
.btn .hi { font-size: .72em; opacity: .85; }
.btn.primary .hi, .btn.maroon .hi { color: rgba(255,255,255,.85); }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; margin-top: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip.ok { background: var(--okbg); color: var(--ok); } .chip.warn { background: var(--warnbg); color: var(--warn); }
.chip.bad { background: var(--badbg); color: var(--bad); } .chip.gray { background: #e8ecf2; color: #475569; } .chip.blue { background: #e3edfb; color: var(--navy2); }
.banner { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.banner.warn { background: var(--warnbg); color: #7a4106; border: 1px solid #f3cf92; }
.banner.bad { background: var(--badbg); color: #8f1212; border: 1px solid #f0b4b4; }
.banner.ok { background: var(--okbg); color: #0f5d2d; border: 1px solid #b5e2c7; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.sticky-actions { position: sticky; bottom: 62px; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 6px; display: flex; gap: 8px; z-index: 10; }
.sticky-actions .btn { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag-b2b { background: #e3edfb; color: var(--navy2); } .tag-b2c { background: #f1e9fb; color: #5b2a8f; }

/* invoice list */
.sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.sum div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.sum b { display: block; font-size: 16px; } .sum span { font-size: 11px; color: var(--muted); }
.inv { display: block; text-decoration: none; color: inherit; }
.inv .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.inv .l2 { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.inv.cancelled { opacity: .6; } .inv.cancelled .l1 b:first-child { text-decoration: line-through; }

/* invoice editor lines */
.line { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; background: #fff; position: relative; }
.line.freight { background: #fbf8ef; border-color: #e6d6a8; }
.line .lt { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; color: var(--navy); }
.line .amt { text-align: right; font-weight: 700; margin-top: 6px; }
.totals { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.totals .tr { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .tr.g { border-top: 2px solid var(--navy); margin-top: 4px; padding-top: 6px; font-size: 18px; font-weight: 800; }
.words { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 16, 30, .55); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 14px 14px 20px; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; } }
.modal h2 { margin-top: 0; }
.pick { display: flex; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.pick .t { flex: 1; min-width: 0; font-size: 14px; } .pick .t small { color: var(--muted); display: block; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 80; background: #111c2e; color: #fff; padding: 12px 14px; border-radius: 10px; text-align: center; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 14px; } .kv dt { color: var(--muted); }

/* tables (reports) */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t td.r, table.t th.r { text-align: right; }

/* ---------- A4 invoice sheet ---------- */
.sheet-wrap { background: #cfd6e2; border-radius: 10px; padding: 8px; overflow: hidden; margin: 8px 0; }
.sheet-scale { transform-origin: top left; width: 794px; }
.sheet {
  position: relative; width: 794px; min-height: 1116px; background: #fff; color: #111; padding: 28px 30px 22px;
  font: 11.5px/1.35 Arial, 'Noto Sans', 'Noto Sans Devanagari', sans-serif; margin: 0 auto 10px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 1px 6px rgba(0,0,0,.2);
}
.sheet .sh-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--navy); padding-bottom: 6px; }
.sheet .sh-logo { height: 62px; width: auto; }
.sheet .sh-title { text-align: right; }
.sheet .sh-title .t { font-size: 22px; font-weight: 800; letter-spacing: .06em; color: var(--navy); }
.sheet .sh-title .copy { font-size: 10px; font-weight: 700; color: var(--maroon); letter-spacing: .04em; margin-top: 2px; }
.sheet .sh-firm { padding: 5px 0 7px; font-size: 11px; border-bottom: 1px solid #999; }
.sheet .sh-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 0; border: 1px solid #555; border-top: 0; }
.sheet .meta { width: 100%; border-collapse: collapse; }
.sheet .meta td { padding: 3px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
.sheet .meta td.k { width: 38%; color: #444; }
.sheet .buyer { padding: 5px 8px; border-left: 1px solid #555; font-size: 11.5px; }
.sheet .bh { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--maroon); font-weight: 700; }
.sheet table.items { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sheet table.items th { background: #e9edf4; border: 1px solid #555; padding: 4px 3px; font-size: 10px; }
.sheet table.items td { border-left: 1px solid #555; border-right: 1px solid #555; padding: 4px 4px; vertical-align: top; }
.sheet table.items tbody { border-bottom: 1px solid #555; }
.sheet .c { text-align: center; } .sheet .r { text-align: right; font-variant-numeric: tabular-nums; }
.sheet .sh-sum { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; margin-top: 8px; align-items: start; }
.sheet .words { padding: 4px 0; color: #111; font-size: 11.5px; margin: 0; }
.sheet table.tots { width: 100%; border-collapse: collapse; }
.sheet table.tots td { padding: 3px 6px; border-bottom: 1px solid #ccc; }
.sheet table.tots tr.grand td { font-size: 14px; font-weight: 800; border-top: 2px solid var(--navy); border-bottom: 2px solid var(--navy); background: #f1f4f9; }
.sheet table.hsn { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 10.5px; }
.sheet table.hsn th, .sheet table.hsn td { border: 1px solid #777; padding: 3px 5px; }
.sheet table.hsn th { background: #eef1f6; text-align: center; }
.sheet table.hsn tr.tot td { font-weight: 700; background: #f6f7fa; }
.sheet .sh-foot { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; margin-top: 10px; border-top: 1px solid #555; padding-top: 6px; flex: 1; }
.sheet .terms { font-size: 10px; color: #333; }
.sheet .sign { text-align: center; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet .sign .decl { font-size: 9.5px; color: #444; text-align: left; margin-bottom: 4px; }
.sheet .sign .for { font-size: 12px; }
.sheet .stamps { position: relative; height: 92px; }
.sheet .stamps .seal { position: absolute; left: 50%; top: 2px; width: 84px; height: 84px; margin-left: -86px; object-fit: contain; opacity: .95; }
.sheet .stamps .sig { position: absolute; left: 50%; top: 14px; width: 130px; margin-left: -20px; object-fit: contain; }
.sheet .sign .auth { border-top: 1px solid #333; padding-top: 3px; font-weight: 700; font-size: 11px; }
.sheet .sh-end { margin-top: 6px; text-align: center; font-size: 9.5px; color: #555; }
.sheet .wm { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) rotate(-28deg); font-size: 110px; font-weight: 900; letter-spacing: .08em; pointer-events: none; z-index: 5; text-align: center; line-height: 1; white-space: nowrap; }
.sheet .wm-cancel { color: rgba(200, 20, 20, .22); border: 10px solid rgba(200, 20, 20, .22); padding: 6px 30px; border-radius: 12px; }
.sheet .wm-prev { color: rgba(16, 41, 74, .12); font-size: 96px; } .sheet .wm-prev small { font-size: 30px; letter-spacing: .1em; }
.sheet.nomargin { margin: 0; box-shadow: none; }
.pdf-host { position: fixed; left: -10000px; top: 0; width: 794px; background: #fff; z-index: -1; }
#print-root { display: none; }

@media print {
  @page { size: A4; margin: 0; }
  body.printing { background: #fff; }
  body.printing #app, body.printing #login, body.printing #modal-root, body.printing #toast { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing .sheet { box-shadow: none; margin: 0; page-break-after: always; break-after: page; width: 210mm; min-height: 296mm; height: auto; padding: 9mm 10mm 8mm; transform: none; zoom: 1; }
  body.printing .sheet:last-child { page-break-after: auto; break-after: auto; }
  body.printing .sheet tr { page-break-inside: avoid; }
  body.printing * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
