/* PrimeBug Billing v0.1, 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;
  --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: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.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: 8px 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); }
.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; }
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 { background: #F8E0DD; color: #8A231B; } .st-partial { background: #FCEFD6; color: #7A4D05; }

/* 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 printed sheet */
.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; }
.sheet-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--doc); }
.sheet .logo { max-height: 56px; max-width: 220px; display: block; margin-bottom: 8px; }
.sheet .co { font-size: 18px; }
.doc-id { text-align: right; }
.doc-id h2 { color: var(--doc); font-size: 26px; letter-spacing: .04em; margin: 0; }
.docno { font-family: var(--mono); font-size: 17px; margin-top: 4px; }
.void-stamp { color: var(--danger); border: 3px solid var(--danger); font-weight: 700; font-size: 22px; padding: 2px 14px; display: inline-block; margin-top: 8px; transform: rotate(-6deg); }
.sheet-parties { display: flex; justify-content: space-between; gap: 24px; margin: 22px 0; flex-wrap: wrap; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.meta { display: grid; grid-template-columns: auto auto; gap: 3px 16px; margin: 0; font-size: 14px; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; font-weight: 600; }
.subject { margin: 0 0 14px; }
table.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
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.receipt th { width: 40%; background: none; font-size: 14px; font-weight: 500; color: var(--muted); }
table.lines .big { font-size: 22px; font-weight: 700; text-align: left; }
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; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photos { margin-top: 22px; break-inside: avoid; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.photo-grid figcaption { font-size: 12px; color: var(--muted); margin-top: 3px; }
.photo-grid .pdf { 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; }
.signoff { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; font-size: 13px; color: var(--muted); }
.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; }

/* 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; 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; }
  .sheet-head { flex-direction: column; } .doc-id { text-align: left; }
  .signoff { grid-template-columns: 1fr; gap: 20px; }
  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 { 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; } }
