/* PrimeBug Billing v1.1 (last changed 2026-10-04), created by Jayakanthan@primebug.com */
:root {
  --ink: #1B2735; --muted: #5B6878; --line: #DCE2E8; --paper: #F2F4F7; --card: #fff;
  --navy: #1E3350; --primary: #24476B; --danger: #B3261E;
  --RFQ: #2F5AA8; --DO: #B26B12; --INV: #0E7466; --REC: #3B7A34; --PO: #6A4C9C; --SR: #A23B5B; --ARC: #3E5468;
  --font: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); }
a { color: var(--primary); }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
:focus-visible { outline: 3px solid #7BA7D9; outline-offset: 2px; }

/* Shell */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--navy) 228px, transparent 228px); }
.side { background: var(--navy); color: #C9D4E2; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.side::-webkit-scrollbar { width: 6px; } .side::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 3px; }
.side nav { flex-shrink: 0; } .side .me { flex-shrink: 0; margin-top: auto; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; padding: 0 10px; }
.brand span { display: block; font-weight: 400; font-size: 13px; color: #9FB0C6; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #C9D4E2; text-decoration: none; padding: 7px 10px; border-radius: 6px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.side nav a.dt-RFQ { border-left-color: var(--RFQ); } .side nav a.dt-DO { border-left-color: var(--DO); }
.side nav a.dt-INV { border-left-color: var(--INV); } .side nav a.dt-REC { border-left-color: var(--REC); }
.side nav a.dt-PO { border-left-color: var(--PO); } .side nav a.dt-SR { border-left-color: var(--SR); }
.side nav hr { border: 0; border-top: 1px solid rgba(255,255,255,.12); margin: 8px 10px; width: auto; }
.side nav .count { background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; margin-left: 4px; }
.me { margin-top: auto; font-size: 13px; padding: 0 10px; } .me a { color: #9FB0C6; }
.navtoggle { display: none; }
.main { padding: 28px 32px 16px; min-width: 0; }
.appfoot { margin-top: 48px; font-size: 12px; color: var(--muted); }

/* Page head */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Buttons & forms */
.btn { display: inline-block; font: 600 14px var(--font); padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #AEB9C5; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1B3A5A; }
.btn.danger { color: var(--danger); } .btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.t-RFQ { background: var(--RFQ); border-color: var(--RFQ); color: #fff; } .btn.t-DO { background: var(--DO); border-color: var(--DO); color: #fff; }
.btn.t-INV { background: var(--INV); border-color: var(--INV); color: #fff; } .btn.t-REC { background: var(--REC); border-color: var(--REC); color: #fff; }
.btn.t-PO { background: var(--PO); border-color: var(--PO); color: #fff; } .btn.t-SR { background: var(--SR); border-color: var(--SR); color: #fff; }
.btn[class*=" t-"]:hover { filter: brightness(.92); }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #33414F; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; font: 15px var(--font); padding: 8px 10px; border: 1px solid #C8D0D9; border-radius: 6px; background: #fff; color: var(--ink); }
textarea { min-height: 72px; resize: vertical; }
.grid { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; background: #E5F2E6; border: 1px solid #B9DABC; }
.flash.err { background: #FBE9E7; border-color: #F0B7B1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid #EDF0F3; vertical-align: top; }
table.list tr:hover td { background: #FAFBFC; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.docno-l { font-family: var(--mono); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #E8ECF0; color: #3E4B59; white-space: nowrap; }
.st-sent { background: #E1EAF7; color: #234A86; } .st-accepted, .st-paid, .st-delivered { background: #DDF0DF; color: #245C27; }
.st-rejected, .st-void, .st-cancelled, .st-obsolete { background: #F8E0DD; color: #8A231B; } .st-partial { background: #FCEFD6; color: #7A4D05; }
.st-acknowledged, .st-received, .st-released { background: #DDF0DF; color: #245C27; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--c, var(--primary)); border-radius: 8px; padding: 14px 16px; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 24px; } .stat span { font-size: 13px; color: var(--muted); }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.flow i { font-style: normal; padding: 3px 10px; border-radius: 4px; color: #fff; font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Line-item editor */
table.items { width: 100%; border-collapse: collapse; }
table.items th { font-size: 12px; text-align: left; color: var(--muted); padding: 6px; }
table.items td { padding: 4px; vertical-align: top; }
table.items textarea { min-height: 40px; }
table.items .c-qty { width: 90px; } table.items .c-unit { width: 90px; } table.items .c-price { width: 130px; } table.items .c-amt { width: 120px; padding-top: 12px; } table.items .c-x { width: 36px; }
.sumbox { margin-left: auto; max-width: 340px; margin-top: 14px; }
.sumbox div { display: flex; justify-content: space-between; padding: 4px 0; gap: 12px; align-items: center; }
.sumbox .g { font-weight: 700; font-size: 17px; border-top: 2px solid var(--ink); padding-top: 8px; }
.sumbox input { width: 120px; text-align: right; }

/* Document view layout */
.docview { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.side-panel .card { padding: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-bottom: 1px solid #EDF0F3; }
.timeline time { display: block; color: var(--muted); font-size: 12px; }
.linkbox { display: flex; gap: 6px; } .linkbox input { font-size: 12px; }

/* The document sheet: table layout shared with the PDF engine */
.sheet { background: #fff; border: 1px solid var(--line); border-left: 8px solid var(--doc); border-radius: 4px; padding: 36px 40px; max-width: 900px; position: relative; }
table.layout { width: 100%; border-collapse: collapse; }
table.layout > tbody > tr > td, table.layout > tr > td { vertical-align: top; padding: 0; }
.sheet-head .doc-id { text-align: right; width: 45%; }
.sheet .logo { max-height: 56px; max-width: 220px; display: block; margin-bottom: 8px; }
.sheet .co { font-size: 18px; font-weight: 700; }
.doc-title { font-size: 26px; font-weight: 700; letter-spacing: .04em; line-height: 1.1; }
.docno { font-family: var(--mono); font-size: 17px; margin-top: 4px; }
.rule { height: 2px; margin: 18px 0 22px; }
.void-stamp, .draft-stamp { color: var(--danger); border: 3px solid var(--danger); font-weight: 700; font-size: 18px; padding: 1px 12px; display: inline-block; margin-top: 8px; transform: rotate(-4deg); }
.draft-stamp { color: #8793A1; border-color: #8793A1; font-size: 14px; }
.parties .party { width: 52%; padding-right: 24px !important; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
table.meta { border-collapse: collapse; font-size: 14px; margin-left: auto; }
table.meta th { text-align: left; color: var(--muted); font-weight: 400; padding: 2px 16px 2px 0; vertical-align: top; }
table.meta td { font-weight: 600; padding: 2px 0; }
.subject { margin: 18px 0 14px; }
.arc-title { font-size: 19px; font-weight: 700; }
table.lines { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.lines th { background: #F3F5F8; text-align: left; padding: 8px 10px; font-size: 12px; color: #3E4B59; border-bottom: 1px solid var(--line); }
table.lines td { padding: 9px 10px; border-bottom: 1px solid #EDF0F3; vertical-align: top; }
table.lines .n { width: 44px; color: var(--muted); }
table.lines th.num { text-align: right; }
table.lines.receipt th { width: 40%; background: none; font-size: 14px; font-weight: 500; color: var(--muted); }
table.lines .big { font-size: 22px; font-weight: 700; }
table.totals { margin: 12px 0 0 auto; min-width: 300px; border-collapse: collapse; font-size: 14px; }
table.totals td { padding: 5px 10px; }
table.totals .grand td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--ink); }
.block { margin-top: 18px; font-size: 14px; } .terms { color: var(--muted); font-size: 13px; }
.richtext { margin-top: 14px; line-height: 1.6; }
.richtext h2 { font-size: 19px; margin: 18px 0 6px; } .richtext h3 { font-size: 16px; margin: 16px 0 6px; } .richtext h4 { font-size: 15px; margin: 12px 0 4px; }
.richtext table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.richtext td, .richtext th { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.richtext th { background: #F3F5F8; }
.richtext img { max-width: 100%; height: auto; }
.richtext figure { margin: 10px 0; } .richtext figure.table { margin: 0; } .richtext figcaption { font-size: 13px; color: var(--muted); }
.richtext figure.image-style-side { float: right; max-width: 45%; margin-left: 14px; }
.richtext blockquote { border-left: 4px solid var(--line); margin: 10px 0; padding-left: 14px; color: #3E4B59; }
.photos { margin-top: 22px; break-inside: avoid; }
table.photo-grid td { width: 33.33%; padding: 4px !important; }
table.photo-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
table.photo-grid .cap { font-size: 12px; color: var(--muted); margin-top: 3px; }
.filebox { display: flex; flex-direction: column; justify-content: center; align-items: center; aspect-ratio: 4/3; border: 1px dashed #AEB9C5; border-radius: 4px; text-decoration: none; font-weight: 700; text-align: center; padding: 6px; word-break: break-all; }
table.signoff { margin-top: 48px; font-size: 13px; color: var(--muted); }
table.signoff td { width: 50%; padding-right: 40px !important; }
.sigline { border-bottom: 1px solid var(--ink); height: 48px; margin-bottom: 6px; }
.signed { color: var(--REC); font-weight: 600; min-height: 48px; margin-bottom: 6px; border-bottom: 1px solid var(--ink); }
.sheet-foot { margin-top: 30px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

/* Modals: PDF pop-up and link picker */
dialog.modal { border: 0; border-radius: 10px; padding: 0; box-shadow: 0 20px 60px rgba(15,25,40,.35); max-width: calc(100vw - 24px); }
dialog.modal::backdrop { background: rgba(20,30,45,.55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #F6F8FA; }
.modal-body { padding: 16px; }
.pdfmodal { width: 1000px; height: calc(100vh - 40px); }
.pdfmodal[open] { display: flex; flex-direction: column; }
.pdfmodal iframe { flex: 1; width: 100%; border: 0; background: #525659; }
.linkmodal { width: 640px; }
ul.pick { list-style: none; margin: 12px 0 0; padding: 0; max-height: 55vh; overflow: auto; }
ul.pick li { border-bottom: 1px solid #EDF0F3; }
.pickrow { width: 100%; text-align: left; background: none; border: 0; padding: 10px 6px; font: 14px var(--font); cursor: pointer; color: var(--ink); }
.pickrow:hover, .pickrow:focus { background: #F3F6FA; }
.edtools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ck-editor__editable { min-height: 320px; }
.ck.ck-editor { max-width: 100%; }
table.items .c-stock { width: 170px; }

/* Customer portal */
.portal { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.portal .respond { margin-top: 18px; }

/* Login */
.auth { max-width: 380px; margin: 10vh auto; }
.auth .card { padding: 28px; } .auth h1 { margin-bottom: 16px; }

@media (max-width: 1100px) { .docview { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 14px; }
  .side nav, .me { display: none; width: 100%; }
  body.navopen .side nav, body.navopen .me { display: flex; }
  .navtoggle { display: block; background: none; border: 1px solid #52667F; color: #fff; border-radius: 6px; padding: 6px 12px; font: 14px var(--font); }
  .main { padding: 18px 14px; }
  .two { grid-template-columns: 1fr; }
  .sheet { padding: 20px 16px; border-left-width: 5px; }
  table.sheet-head td, table.parties td, table.signoff td { display: block; width: 100% !important; padding-right: 0 !important; }
  .sheet-head .doc-id { text-align: left; margin-top: 12px; } table.meta { margin: 14px 0 0; }
  table.signoff td { margin-bottom: 18px; }
  .pdfmodal { height: calc(100vh - 16px); }
  table.items, table.items tbody, table.items tr, table.items td { display: block; width: 100% !important; }
  table.items thead { display: none; }
  table.items tr { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
}
@media print {
  body { background: #fff; }
  .side, .noprint, .appfoot, .side-panel, .flash, .pagehead, .respond, dialog { display: none !important; }
  .shell { display: block; } .main, .portal { padding: 0; } .docview { display: block; }
  .sheet { border: 0; border-left: 6px solid var(--doc); max-width: none; padding: 0 0 0 18px; }
  @page { size: A4; margin: 14mm; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== v1.0: branding ===== */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.brand svg.brandlogo { display: block; max-width: 100%; height: auto; margin: -4px 0 4px -6px; }
.brand .brandname { font-size: 15px; }
.loginpage { background: radial-gradient(ellipse at top, #2B3E57 0%, #15202E 70%); min-height: 100vh; }
.loginpage .auth .muted { color: #AEB9C5; }
.loginlogo { text-align: center; margin: 24px 0 6px; }
.loginlogo svg { max-width: 100%; height: auto; }
.portal-brand { text-align: center; margin-bottom: 8px; }
.portal-brand svg { height: auto; max-width: 100%; }
.imgbox { min-height: 120px; display: flex; align-items: center; justify-content: flex-start; background: repeating-conic-gradient(#F1F3F6 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
h3.sub { font-size: 14px; margin: 16px 0 6px; color: #3E4B59; }

/* ===== signatures and stamp on documents ===== */
.sig-area { position: relative; height: 74px; }
.sig-area .sig-img { position: absolute; left: 0; bottom: -4px; max-height: 70px; max-width: 220px; z-index: 2; }
.sig-area .stamp-img { position: absolute; left: 150px; bottom: -18px; max-height: 96px; max-width: 150px; opacity: .88; z-index: 1; }
table.signoff .sigline { height: 1px; margin: 0 0 6px; }
.signed { color: var(--REC); font-weight: 600; border: 0 !important; min-height: 0 !important; margin: 0 !important; }
canvas.sigpad { width: 100%; max-width: 520px; height: 170px; border: 1px dashed #AEB9C5; border-radius: 6px; background: #fff; touch-action: none; display: block; margin: 4px 0 8px; cursor: crosshair; }
.sigpreview { background: repeating-conic-gradient(#F1F3F6 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.sigpreview img { max-height: 90px; max-width: 100%; display: block; }

/* ===== mailbox ===== */
.mailgrid { display: grid; grid-template-columns: 210px 1fr; gap: 18px; align-items: start; }
.mailfolders { padding: 8px; }
.mailfolders a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--ink); font-size: 14px; }
.mailfolders a.on { background: #E8EEF6; font-weight: 600; }
.mailfolders a:hover { background: #F1F4F8; }
.mailfolders .count { background: var(--primary, #24476B); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
table.maillist tr.unread td { font-weight: 700; }
table.maillist td a { color: inherit; text-decoration: none; display: block; }
table.maillist tr:hover td { background: #F6F8FB; }
.mailsubject { font-size: 20px; margin: 14px 0 8px; }
table.mailmeta { margin-left: 0; margin-bottom: 10px; }
.mailframe { width: 100%; height: 620px; border: 1px solid var(--line); border-radius: 6px; background: #fff; resize: vertical; }
.mailtext { white-space: pre-wrap; font-family: var(--font); font-size: 14px; background: #FAFBFC; border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.mailatts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.mailatts .att { background: #F3F5F8; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 13px; }

/* ===== templates ===== */
.phs code { display: inline-block; background: #F3F5F8; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; margin: 2px 2px 2px 0; font-size: 12px; cursor: help; }
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.sig-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; color: var(--ink); }
.sig-card .lbl { display: flex; justify-content: space-between; align-items: center; }

/* ===== wiki ===== */
.crumbs { margin-bottom: 6px; } .crumbs a { color: var(--muted); }
.wikigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
ul.wikilist { list-style: none; padding: 0; margin: 0; }
ul.wikilist li { padding: 8px 0; border-bottom: 1px solid #EDF0F3; }
ul.wikilist li a { font-weight: 600; }
.wiki-title { font-size: 26px; margin: 4px 0 2px; }

@media (max-width: 860px) {
  .mailgrid { grid-template-columns: 1fr; }
  .mailfolders { display: flex; flex-wrap: wrap; gap: 4px; }
  .sig-area .stamp-img { left: 120px; }
}
