/* Invoice Generator — navy + amber. The paper is always white, like the PDF it produces. */
@font-face { font-family: "InterInv"; font-weight: 400; font-display: swap; src: url("/vendor/inter-400.woff2") format("woff2"); }
@font-face { font-family: "InterInv"; font-weight: 600; font-display: swap; src: url("/vendor/inter-600.woff2") format("woff2"); }

/* ---------- Toolbar ---------- */
.iv-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.iv-opts { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.iv-opts .field { margin: 0; }
.iv-opts select { min-width: 0; width: auto; padding-right: 34px; }
#ivCur { max-width: 196px; }
.iv-colors { border: 0; padding: 0; margin: 0; min-width: 0; }
.iv-colors legend { font-weight: 650; font-size: 14px; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
#ivSwatches { display: flex; gap: 5px; align-items: center; min-height: 44px; }
.iv-sw { position: relative; width: 24px; height: 24px; border-radius: 50%; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .12s; }
.iv-sw:hover { transform: scale(1.1); }
.iv-sw input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; margin: 0; }
.iv-sw:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.iv-sw:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; }
.iv-sw-custom { background: conic-gradient(#f43f5e, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #f43f5e); }
.iv-actions { display: flex; gap: 8px; margin-left: auto; }
.iv-actions .btn { min-height: 44px; }
.iv-actions .btn.primary { padding: 0 18px; }
.iv-actions .btn[disabled] { opacity: .7; cursor: progress; }

/* ---------- Paper ---------- */
.iv-paper {
  --iv: #1e3a8a;
  --p-ink: #18181b; --p-ink2: #3f3f46; --p-muted: #71717a; --p-rule: #e4e4e7; --p-ph: #a1a1aa;
  --p-tint: color-mix(in oklab, var(--iv) 9%, white);
  font-family: "InterInv", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--p-ink); background: #fff; color-scheme: light;
  border-radius: 6px; padding: 52px 56px 56px;
  box-shadow: 0 0 0 1px rgba(24,24,27,.07), 0 2px 4px rgba(24,24,27,.04), 0 24px 56px -28px rgba(24,24,27,.35);
  font-size: 14px; line-height: 1.5;
  max-width: 880px; margin: 0 auto;
}
/* Arabic: letter-spacing would break the joined letters */
.iv-paper[dir=rtl] .iv-lbl, .iv-paper[dir=rtl] .iv-meta dt, .iv-paper[dir=rtl] .iv-thead .iv-in, .iv-paper[dir=rtl] .iv-title { letter-spacing: 0; }
.iv-paper ::selection { background: color-mix(in oklab, var(--iv) 22%, white); color: var(--p-ink); }

/* Editable fields that read like plain text until you hover or focus them */
.iv-paper .iv-in {
  font: inherit; color: inherit; background: transparent; width: 100%; min-height: 0;
  border: 1px dashed transparent; border-radius: 6px; padding: 3px 7px; margin: 0;
  box-shadow: none; transition: border-color .12s, background .12s, box-shadow .12s;
}
.iv-paper textarea.iv-in { resize: none; overflow: hidden; min-height: 0; line-height: 1.5; display: block; }
.iv-paper .iv-in::placeholder { color: var(--p-ph); opacity: 1; }
.iv-paper .iv-in:hover { border-color: #d4d4d8; background: #fafafa; }
.iv-paper .iv-in:focus { outline: none; border: 1px solid var(--iv); background: #fff; box-shadow: 0 0 0 3px color-mix(in oklab, var(--iv) 18%, transparent); }
.iv-paper select.iv-in { appearance: none; background-image: none; padding-inline-end: 7px; cursor: pointer; }
.iv-paper input[type=date].iv-in { min-height: 0; }
/* Each line follows its own text direction (an English address on an Arabic invoice), aligned to the document's side */
.iv-paper textarea.iv-in, .iv-paper .iv-name { unicode-bidi: plaintext; text-align: left; }
.iv-paper[dir=rtl] textarea.iv-in, .iv-paper[dir=rtl] .iv-name { text-align: right; }
.iv-paper input[type=date].iv-in::-webkit-calendar-picker-indicator { opacity: .35; cursor: pointer; }
.iv-r, .iv-paper .iv-r { text-align: end; }

/* Header */
.iv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 28px; }
.iv-logo { position: relative; min-height: 64px; display: flex; align-items: center; }
.iv-logo-add {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--p-muted); cursor: pointer;
  height: 64px; padding: 0 18px; border: 1.5px dashed #d4d4d8; border-radius: 10px; background: #fafafa;
  display: inline-flex; align-items: center; gap: 8px; transition: border-color .12s, color .12s;
}
.iv-logo-add span { font-size: 18px; line-height: 1; }
.iv-logo-add:hover { border-color: var(--iv); color: var(--iv); }
#ivLogo { display: block; max-width: 220px; max-height: 84px; width: auto; height: auto; cursor: pointer; border-radius: 4px; }
.iv-logo-del { position: absolute; top: -10px; inset-inline-end: -10px; opacity: 0; }
.iv-logo:hover .iv-logo-del, .iv-logo-del:focus-visible { opacity: 1; }
.iv-titles { text-align: end; min-width: 0; flex: 0 1 340px; }
.iv-paper .iv-title { font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; color: var(--iv); text-align: end; padding: 0 7px; }
.iv-num { display: flex; align-items: center; justify-content: flex-end; color: var(--p-muted); }
.iv-num span { margin-inline-end: -2px; }
.iv-paper .iv-num .iv-in { width: 15ch; text-align: end; color: var(--p-ink2); }

/* Parties & meta */
.iv-parties { display: grid; grid-template-columns: 1fr 1fr minmax(210px, .95fr); gap: 20px 28px; padding: 22px 0 26px; border-top: 1px solid var(--p-rule); }
.iv-lbl, .iv-meta dt { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--p-muted); padding: 0 8px; margin-bottom: 4px; }
.iv-paper .iv-name { font-weight: 600; font-size: 15px; }
.iv-party textarea { color: var(--p-ink2); font-size: 13.5px; }
.iv-meta { margin: 0; display: grid; gap: 2px; align-content: start; }
.iv-meta > div { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 6px; }
.iv-meta dt { margin: 0; padding: 0; padding-inline-start: 8px; }
.iv-meta dt label { font: inherit; color: inherit; }
.iv-meta dd { margin: 0; }
.iv-paper .iv-meta .iv-in { text-align: end; font-weight: 600; font-size: 13.5px; }
.iv-meta select.iv-in { text-align-last: end; }

/* Items */
.iv-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 112px 118px 26px; gap: 6px; align-items: start; }
.iv-thead { background: var(--p-tint); border-radius: 6px; padding: 5px 4px; align-items: center; }
.iv-paper .iv-thead .iv-in { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--iv); }
.iv-item { padding: 7px 4px; border-bottom: 1px solid var(--p-rule); }
.iv-paper .iv-item .iv-in { font-size: 14px; }
.iv-line { display: block; padding: 4px 8px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.iv-paper .iv-item input { font-variant-numeric: tabular-nums; }
.iv-x {
  width: 24px; height: 24px; margin-top: 3px; border-radius: 50%; border: 0; cursor: pointer;
  font: 600 16px/1 system-ui, sans-serif; color: var(--p-muted); background: transparent;
  display: inline-flex; align-items: center; justify-content: center; transition: background .12s, color .12s, opacity .12s;
}
.iv-x:hover { background: #fee2e2; color: #b91c1c; }
.iv-item .iv-x { opacity: 0; }
.iv-item:hover .iv-x, .iv-item:focus-within .iv-x, .iv-x:focus-visible { opacity: 1; }
@media (hover: none) {
  .iv-item .iv-x { opacity: 1; }
  .iv-paper .iv-in { background: #f7f7f8; border-color: #ececef; }
  .iv-paper .iv-thead .iv-in { background: transparent; border-color: transparent; }
}
.iv-add {
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--iv); cursor: pointer;
  margin: 12px 0 0; padding: 8px 14px; border-radius: 8px; border: 1px dashed color-mix(in oklab, var(--iv) 45%, white); background: #fff;
}
.iv-add:hover { background: var(--p-tint); }

/* Totals & notes */
.iv-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 36px; margin-top: 26px; align-items: start; }
.iv-notes .iv-lbl { margin-top: 2px; }
.iv-notes textarea { color: var(--p-ink2); font-size: 13.5px; margin-bottom: 14px; }
.iv-t { display: grid; grid-template-columns: 1fr auto 26px; align-items: center; gap: 6px; min-height: 34px; padding: 0; padding-inline-start: 8px; color: var(--p-ink2); }
.iv-t > b { font-weight: 600; color: var(--p-ink); font-variant-numeric: tabular-nums; text-align: end; padding-inline-end: 8px; white-space: nowrap; }
.iv-t > b:last-child { grid-column: 2; }
.iv-t-edit { display: flex; align-items: center; gap: 2px; min-width: 0; }
.iv-paper .iv-mini { width: 62px; text-align: end; padding: 2px 6px; }
.iv-paper select.iv-mini { width: auto; text-align: center; }
.iv-paper .iv-tax-lbl { width: 9ch; flex: 1 1 auto; padding-inline-start: 0; margin-inline-start: -1px; }
.iv-paper .iv-amt { width: 120px; text-align: end; font-weight: 600; color: var(--p-ink); font-variant-numeric: tabular-nums; }
.iv-total { border-top: 1px solid var(--p-rule); margin-top: 4px; }
.iv-due {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 8px; padding: 13px 16px; border-radius: 8px; background: var(--iv); color: #fff;
}
.iv-due span { font-weight: 600; font-size: 14px; }
.iv-due b { font-size: 21px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.iv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; justify-content: flex-end; }
.iv-chips button {
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--p-muted); cursor: pointer;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--p-rule); background: #fff; transition: color .12s, border-color .12s;
}
.iv-chips button:hover { color: var(--iv); border-color: var(--iv); }

/* ---------- Below the paper ---------- */
.iv-foot { font-size: 13.5px; text-align: center; margin: 18px auto 0; max-width: 60ch; }
.iv-saved { max-width: 880px; margin: 14px auto 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); padding: 0 16px; }
.iv-saved summary { cursor: pointer; font-weight: 650; padding: 13px 0; }
.iv-saved ul { list-style: none; margin: 0 0 12px; padding: 0; }
.iv-saved li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center; padding: 9px 10px; border-top: 1px solid var(--line); font-size: 14.5px; }
.iv-saved li.on { background: var(--tint); border-radius: 8px; }
.iv-saved li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-saved-btns { display: flex; gap: 4px; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .iv-paper { padding: 26px 18px 28px; border-radius: 4px; font-size: 13.5px; }
  .iv-head { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
  .iv-titles { text-align: start; flex: none; }
  .iv-paper .iv-title { text-align: start; font-size: 28px; }
  .iv-num { justify-content: flex-start; }
  .iv-paper .iv-num .iv-in { text-align: start; }
  .iv-parties { grid-template-columns: 1fr; gap: 16px; }
  .iv-meta > div { grid-template-columns: 110px 1fr; }
  /* Each item: description on its own line, then qty · rate · amount */
  .iv-row { grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr) 26px; gap: 4px 6px; }
  .iv-thead > :first-child { display: none; }
  .iv-thead > :nth-child(2) { grid-column: 1; }
  .iv-item .iv-desc { grid-column: 1 / 4; grid-row: 1; font-weight: 600; }
  .iv-item .iv-x { grid-column: 4; grid-row: 1; opacity: 1; }
  .iv-item > [data-item="qty"] { grid-column: 1; grid-row: 2; }
  .iv-item > [data-item="rate"] { grid-column: 2; grid-row: 2; }
  .iv-line { grid-column: 3; grid-row: 2; padding-top: 4px; }
  .iv-bottom { grid-template-columns: 1fr; gap: 18px; }
  .iv-totals { order: -1; }
  .iv-saved li { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .iv-actions { width: 100%; }
  .iv-actions .btn.primary { flex: 1; }
}
