/* ---------- App shell ---------- */
:root {
  --ink: #1a1f2b;
  --grey: #5b6b80;
  --line: #e2e6ee;
  --soft: #eef2f7;
  --bg: #f5f7fa;
  --green: #1d5b38;
  --green-dark: #154a2c;
  --brown: #9c4a3a;
  --danger: #b3261e;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.bar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.bar-brand img { height: 36px; }
.status { font-size: 13px; color: var(--grey); text-align: right; }
.status.bad { color: var(--danger); font-weight: 600; }

.btn {
  font: inherit; font-size: 15px; font-weight: 600;
  border-radius: 12px; padding: 12px 18px;
  border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.green { background: var(--green); color: #fff; }
.btn.green:hover { background: var(--green-dark); }
.btn.green:disabled { opacity: .6; cursor: wait; }
.btn.big { width: 100%; font-size: 18px; padding: 18px; border-radius: 14px; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.link { font: inherit; font-size: 14px; color: var(--green); background: none; border: 0; padding: 6px 0; cursor: pointer; text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  gap: 24px; padding: 20px; align-items: start;
  max-width: 1400px; margin: 0 auto;
}
.preview { position: sticky; top: 80px; }
.preview-title { font-size: 15px; color: var(--grey); font-weight: 600; margin: 0 0 10px; }

.step { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 16px; }
.step h2 { font-size: 18px; margin: 0 0 12px; }
.step h3 { font-size: 16px; margin: 0 0 12px; }
.hint { font-size: 14px; color: var(--grey); margin: -6px 0 12px; line-height: 1.45; }
.muted { color: var(--grey); }

label { display: block; font-size: 13px; font-weight: 500; color: var(--grey); margin-bottom: 12px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 5px;
  font: inherit; font-size: 16px; color: var(--ink);
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Customer chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 16px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.chip.add { border-style: dashed; color: var(--green); }
.panel { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--soft); }

/* Invoice number + date */
.meta { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 16px; font-size: 16px; }
.meta .date { margin: 0; min-width: 170px; }
.past-note { background: #fff6e5; border: 1px solid #f1d9a6; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; margin-bottom: 14px; }

/* Item lines */
.line { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.line-top { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.line-bottom { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: end; }
.line label { margin-bottom: 8px; }
.qty { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.qty input { width: 64px; margin: 0; text-align: center; }
.qty button {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--soft); font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink);
}
.price { position: relative; }
.line-foot { display: flex; justify-content: space-between; align-items: center; font-size: 15px; padding-top: 4px; }
.line-foot .x { font: inherit; font-size: 14px; color: var(--danger); background: none; border: 0; cursor: pointer; padding: 6px 0; }

.grand { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0; font-size: 18px; }
.grand b { font-size: 26px; }
.after { text-align: center; margin-top: 12px; }
.after p { margin: 0 0 10px; font-size: 15px; }

/* History */
.hist { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.hist:last-child { border-bottom: 0; }
.hist .sub { color: var(--grey); font-size: 13px; margin-top: 2px; }
.empty { color: var(--grey); font-size: 14px; margin: 0; }

.settings summary { cursor: pointer; font-weight: 600; font-size: 16px; }
.settings[open] summary { margin-bottom: 14px; }
.upload { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload img { height: 48px; border-radius: 8px; border: 1px solid var(--line); }

/* Preview paper */
.stage { position: relative; }
.paper { width: 794px; background: #fff; transform-origin: top left; box-shadow: 0 8px 30px rgba(26, 31, 43, .12); }

/* Code screen */
.lock { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lock-box { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: center; }
.lock-logo { width: 110px; }
.lock h1 { margin: 6px 0 8px; font-size: 22px; }
.lock p { margin: 0 0 16px; color: var(--grey); font-size: 15px; line-height: 1.45; }
.lock input { text-align: center; font-size: 26px; letter-spacing: 8px; margin-bottom: 8px; }
.lock-error { color: var(--danger); font-size: 14px; min-height: 20px; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--ink); color: #fff; font-size: 15px; padding: 14px 18px; border-radius: 12px;
  max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .layout { display: block; padding: 16px; }
  .preview { position: static; }
}
@media (max-width: 400px) {
  .bar-brand span { display: none; }
  .step { padding: 14px; }
  .line-top { grid-template-columns: 1fr 96px; }
  .meta { flex-direction: column; align-items: stretch; }
  .grid2 { grid-template-columns: 1fr; }
}

/* =========================================================
   The invoice. A4 = 794 x 1123 px. Copied from the PDFs.
   ========================================================= */
.inv {
  width: 794px; min-height: 1120px;
  padding: 14px 14px 22px;
  display: flex; flex-direction: column;
  font-family: Inter, sans-serif; color: #1a1f2b; background: #fff;
  font-size: 13.5px; line-height: 1.35;
}
.inv .top {
  background: #eef2f7; border-radius: 16px;
  padding: 24px 26px 20px;
  display: flex; justify-content: space-between; gap: 20px;
}
.inv .title { font-size: 28px; font-weight: 700; margin: 0 0 24px; letter-spacing: -.2px; }
.inv .lbl { color: #5b6b80; }
.inv .billed .lbl { margin-bottom: 10px; }
.inv .billed .name { font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.inv .billed .addr { white-space: pre-line; line-height: 1.2; }
.inv .nums { text-align: right; }
.inv .nums .no { font-size: 17.5px; font-weight: 700; margin: 6px 0 30px; letter-spacing: .3px; }
.inv .nums .on { margin-top: 6px; }

.inv table { width: calc(100% - 52px); margin: 34px 26px 0; border-collapse: collapse; }
.inv th { text-align: left; font-size: 13px; font-weight: 600; color: #5b6b80; padding: 0 0 18px; }
.inv th:first-child { font-size: 17.5px; color: #1a1f2b; }
.inv td { padding: 9px 0; border-bottom: 1px solid #edf0f4; font-size: 14px; }
.inv tr:last-child td { border-bottom: 0; }
.inv td.g { color: #5b6b80; }
.inv .c-w { width: 119px; }
.inv .c-q { width: 91px; }
.inv .c-p { width: 80px; }
.inv .c-t { width: 72px; text-align: right; }

.inv .spacer { flex: 1; min-height: 30px; }

.inv .sum { display: flex; margin: 0 26px; border-top: 1px solid #edf0f4; }
.inv .sum .fill { flex: 1; }
.inv .sum .box { width: 320px; background: #eef2f7; border-radius: 0 0 16px 16px; border-top-left-radius: 16px; border-top-right-radius: 16px; padding: 24px 26px 22px; margin-top: -1px; }
.inv .sum .r { display: flex; justify-content: space-between; align-items: baseline; }
.inv .sum .r + .r { margin-top: 12px; }
.inv .sum .r span:last-child { font-size: 14.5px; }
.inv .sum .big { font-size: 22px !important; font-weight: 700; }

.inv .foot { display: grid; grid-template-columns: 1.65fr 0.95fr 1.7fr; gap: 18px; margin: 18px 26px 0; }
.inv .foot .logo { width: 66px; display: block; margin-bottom: 10px; }
.inv .foot .biz { font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.inv .foot .addr { white-space: pre-line; line-height: 1.2; margin-bottom: 8px; }
.inv .foot h4 { margin: 0 0 18px; font-size: 13.5px; font-weight: 600; }
.inv .foot .k { color: #5b6b80; font-weight: 600; margin-bottom: 3px; }
.inv .foot .v { font-weight: 700; margin-bottom: 20px; text-transform: uppercase; }
.inv .foot .pay .v:last-child { margin-bottom: 0; }
.inv .foot .terms h4 { margin-bottom: 6px; }
.inv .foot .terms p { margin: 0 0 12px; font-size: 10.5px; color: #5b6b80; line-height: 1.3; }
.inv .foot .terms p:last-child { margin-bottom: 0; }
