:root {
  --ink: #152b2a;
  --muted: #677873;
  --green: #17644f;
  --line: #dfe7e1;
  --paper: #f5f7f3;
  --white: #fff;
  --lime: #dceca5;
  --red: #a3322d;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  font:
    15px/1.55 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--paper);
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: -1.3px;
  margin-bottom: 10px;
}
h2 {
  font-size: 23px;
  letter-spacing: -0.5px;
}
h3 {
  font-size: 17px;
}
a {
  color: var(--green);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  background: #edf3e9;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
button.primary:hover {
  background: #104c3c;
}
button.danger {
  color: var(--red);
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd7cf;
  border-radius: 7px;
  padding: 11px;
  background: white;
  color: var(--ink);
  min-width: 0;
}
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #bad990;
  outline-offset: 2px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 18px;
}
small,
.muted {
  color: var(--muted);
  font-weight: 400;
}
.muted {
  font-size: 13px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 1.7px;
  color: var(--muted);
  margin-bottom: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 38px;
  font-weight: 850;
  letter-spacing: -3px;
  color: inherit;
  text-decoration: none;
}
.brand span {
  font-weight: 500;
}
.brand small {
  font-size: 10px;
  letter-spacing: 2px;
  border-left: 1px solid currentColor;
  padding-left: 12px;
  margin-left: 18px;
  color: inherit;
}
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.welcome {
  background: #173e33;
  color: #fafcf4;
  padding: 45px 10%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 60px;
  background-image: radial-gradient(
    ellipse at bottom right,
    #326646,
    transparent 65%
  );
}
.welcome .eyebrow {
  color: #c7ddab;
}
.welcome h1 {
  font-size: clamp(36px, 4vw, 59px);
  line-height: 1.08;
  letter-spacing: -2px;
}
.welcome p:not(.eyebrow) {
  color: #c4d3c4;
  max-width: 420px;
}
.benefits {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 45px;
  color: #e3edcc;
}
.welcome-foot {
  font-size: 12px;
}
.auth-panel {
  display: grid;
  place-items: center;
  padding: 48px 30px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.segmented {
  display: flex;
  background: #e9eee6;
  padding: 4px;
  gap: 3px;
  border-radius: 9px;
  margin: 25px 0;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 12px;
  padding: 10px 5px;
}
.segmented button.selected {
  background: white;
  box-shadow: 0 1px 4px #183a2414;
}
.wide {
  width: 100%;
}
#auth-message {
  margin: 20px 0;
  color: var(--red);
}
.workspace {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: 100vh;
}
.sidebar {
  padding: 27px 23px;
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.company-name {
  margin-top: 35px;
  font-weight: 700;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 20px;
}
.sidebar nav button {
  text-align: left;
  background: none;
  border: 0;
  font-size: 13px;
  padding: 12px;
}
.sidebar nav button.active {
  background: #eaf1df;
  color: #235440;
}
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 12px;
  padding-top: 25px;
}
.sidebar-bottom button {
  text-align: left;
}
.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  min-height: 85px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  background: #ffffffb3;
  font-size: 12px;
  color: var(--muted);
  gap: 20px;
}
.environment-label {
  margin: 0;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.environment-label select {
  font-size: 12px;
  width: auto;
}
#main {
  padding: 30px 40px;
  max-width: 1450px;
  width: 100%;
  margin: auto;
  flex: 1;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 28px;
}
.banner {
  padding: 12px 16px;
  background: #eaf0df;
  border: 1px solid #d4dfc1;
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 13px;
}
.banner.live {
  background: #fff0df;
  border-color: #ebc8a0;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 26px;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 22px;
}
.cards .card {
  margin: 0;
}
.metric {
  display: block;
  font-size: 38px;
  letter-spacing: -1.5px;
  font-weight: 650;
}
.card-label {
  font-size: 12px;
  color: var(--muted);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}
.card-head h2 {
  margin: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}
.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.span-all {
  grid-column: 1/-1;
}
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.table-scroll {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 15px 12px;
  border-bottom: 1px solid #eef1ec;
}
td button {
  font-size: 12px;
  padding: 6px 10px;
}
.badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.6px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 20px;
  background: #f6edcf;
  color: #6a5824;
}
.badge.good {
  background: #e4efdd;
  color: #34632d;
}
.badge.bad {
  background: #fae2dd;
  color: #923c2f;
}
.empty {
  text-align: center;
  padding: 35px 15px;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  margin-bottom: 9px;
}
.invoice-line {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 100px 100px 50px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.invoice-line button {
  padding: 8px;
}
.invoice-total {
  font-size: 28px;
  font-weight: 650;
  text-align: right;
  margin: 24px 0;
}
.notice {
  padding: 14px;
  background: #f5f7f1;
  border-radius: 8px;
  font-size: 13px;
}
.key-output {
  font-family: monospace;
  overflow-wrap: anywhere;
  background: #eef4e8;
  padding: 20px;
  border-radius: 8px;
}
#toast {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: var(--ink);
  color: white;
  border-radius: 10px;
  padding: 16px 22px;
  max-width: min(520px, 90vw);
  box-shadow: 0 5px 25px #0002;
  z-index: 10;
}
footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  padding: 20px 40px;
  border-top: 1px solid var(--line);
}
dialog {
  max-width: 750px;
  width: 90%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
}
dialog::backdrop {
  background: #102c2877;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}
.receipt-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}
.signature {
  overflow-wrap: anywhere;
  font: 12px/1.7 monospace;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.reference-results {
  max-height: 450px;
  overflow: auto;
}
@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 200px 1fr;
  }
  .sidebar {
    padding: 22px 12px;
  }
  #main {
    padding: 25px;
  }
  .topbar {
    padding: 18px 25px;
  }
  .grid.three {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 700px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }
  .welcome {
    padding: 24px;
    gap: 25px;
  }
  .welcome h1 {
    font-size: 35px;
  }
  .welcome .benefits,
  .welcome-foot {
    display: none;
  }
  .auth-panel {
    padding: 30px 22px;
  }
  .workspace {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 15px;
  }
  .sidebar .brand {
    font-size: 28px;
  }
  .company-name {
    margin-top: 12px;
  }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
    margin-top: 5px;
  }
  .sidebar nav button {
    white-space: nowrap;
  }
  .sidebar-bottom {
    flex-direction: row;
    margin: 0;
    padding-top: 10px;
  }
  .topbar {
    padding: 15px;
    flex-wrap: wrap;
  }
  #main {
    padding: 20px 15px;
  }
  .cards {
    gap: 8px;
  }
  .cards .card {
    padding: 15px 10px;
  }
  .metric {
    font-size: 29px;
  }
  .card {
    padding: 18px;
  }
  .grid,
  .grid.three {
    grid-template-columns: 1fr;
  }
  .invoice-line {
    grid-template-columns: 1fr 65px 65px 35px;
    gap: 6px;
  }
  h1 {
    font-size: 29px;
  }
  footer {
    padding: 18px;
    font-size: 10px;
  }
  .environment-label {
    gap: 8px;
  }
}
@media print {
  body > * {
    display: none !important;
  }
  #receipt-dialog {
    display: block !important;
    position: static;
    border: 0;
    width: 100%;
    max-width: none;
    overflow: visible;
  }
  .dialog-actions {
    display: none;
  }
  body {
    background: white;
  }
  th,
  td {
    padding: 8px;
  }
  a {
    color: inherit;
  }
}
.receipt-logo{width:105px;height:auto;display:block;margin:0 auto 12px}
#receipt-qr{margin:18px auto;width:180px;break-inside:avoid}
#receipt-qr img{display:block}
#print-area table{width:100%;font-size:12px}
#print-area .signature{overflow-wrap:anywhere}
#print-area pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:10px}
.invoice-line{flex-wrap:wrap}
@media print{#print-area{color:#000}#print-area h3,#print-area tr{break-inside:avoid}#print-area button{display:none!important}}
@media print and (max-width: 85mm) {
  #receipt-dialog { padding: 0; margin: 0; }
  #print-area { font-size: 10px; overflow-wrap: anywhere; }
  #print-area table { table-layout: fixed; font-size: 8px; }
  #print-area th, #print-area td { padding: 3px 1px; overflow-wrap: anywhere; }
  #print-area h2 { font-size: 16px; }
  #print-area h3, #print-area .invoice-total { font-size: 13px; }
  #receipt-qr { width: 150px; }
}
/* 58 mm POS paper: stack item details within a 48 mm printable area. */
@media print and (max-width: 62mm) {
  body { margin: 0; }
  #receipt-dialog { padding: 0; margin: 0; }
  #print-area:has(#receipt-qr) table:first-of-type thead { display: none; }
  #print-area:has(#receipt-qr) table:first-of-type,
  #print-area:has(#receipt-qr) table:first-of-type tbody { display: block; }
  #print-area:has(#receipt-qr) table:first-of-type tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px;
    border-bottom: 1px solid #000; padding: 6px 0;
  }
  #print-area:has(#receipt-qr) table:first-of-type td {
    display: block; border: 0; padding: 0; font-size: 10px; color: #000;
  }
  #print-area:has(#receipt-qr) table:first-of-type td:first-child { grid-column: 1 / -1; font-weight: 600; }
  #print-area:has(#receipt-qr) table:first-of-type td::before { display: block; font-size: 9px; font-weight: 400; }
  #print-area:has(#receipt-qr) table:first-of-type td:nth-child(2)::before { content: 'Quantity'; }
  #print-area:has(#receipt-qr) table:first-of-type td:nth-child(3)::before { content: 'Unit price'; }
  #print-area:has(#receipt-qr) table:first-of-type td:nth-child(4)::before { content: 'Discount'; }
  #print-area:has(#receipt-qr) table:first-of-type td:nth-child(5)::before { content: 'Total RWF'; }
  #print-area th { font-size: 9px; letter-spacing: 0; color: #000; }
  #print-area .invoice-total { margin: 12px 0; }
  #print-area .signature { font-size: 10px; }
  #receipt-qr { width: 150px; max-width: 100%; }
}
@media print {
  #receipt-dialog { border-radius: 0; box-shadow: none; max-height: none; height: auto; }
  #receipt-dialog::backdrop { display: none !important; background: transparent !important; }
}
@media print and (max-width: 62mm) {
  /* Keep large currency values together instead of splitting their decimals. */
  #print-area:has(#receipt-qr) table:first-of-type tr { grid-template-columns: 1fr; }
  #print-area:has(#receipt-qr) table:first-of-type td {
    display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 4px;
  }
  #print-area:has(#receipt-qr) table:first-of-type td:first-child { display: block; }
  #print-area:has(#receipt-qr) table:nth-of-type(2),
  #print-area:has(#receipt-qr) table:nth-of-type(2) tbody { display: block; }
  #print-area:has(#receipt-qr) table:nth-of-type(2) thead { display: none; }
  #print-area:has(#receipt-qr) table:nth-of-type(2) tr { display: block; border-bottom: 1px solid #000; padding: 4px 0; }
  #print-area:has(#receipt-qr) table:nth-of-type(2) td {
    display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 4px;
    border: 0; padding: 1px 0; font-size: 10px;
  }
  #print-area:has(#receipt-qr) table:nth-of-type(2) td::before { font-size: 9px; }
  #print-area:has(#receipt-qr) table:nth-of-type(2) td:nth-child(1)::before { content: 'Group / rate'; }
  #print-area:has(#receipt-qr) table:nth-of-type(2) td:nth-child(2)::before { content: 'Taxable RWF'; }
  #print-area:has(#receipt-qr) table:nth-of-type(2) td:nth-child(3)::before { content: 'Tax RWF'; }
}
