/**
 * blue-invoice.com — public stylesheet
 *
 * Three rules hold throughout:
 *
 * 1. Logical properties (inline-start / inline-end) rather than left/right, so
 *    the Arabic RTL layout falls out of dir="rtl" with no second stylesheet and
 *    no mirroring build step.
 * 2. Form controls are at least 16px. Anything smaller makes iOS Safari zoom the
 *    whole viewport on focus, which cannot be undone once it happens.
 * 3. In the editor, an input is styled as the text it produces. Chrome appears
 *    on hover and focus only, so the canvas reads as a document at rest and as a
 *    form the moment you touch it.
 */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e3e8f2;
  --line-soft: #edf0f6;
  --txt: #161b26;
  --txt-2: #59616f;
  --txt-3: #8b93a4;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eef4ff;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 10px 34px -14px rgba(16, 24, 40, .2);
  --shadow-lg: 0 -6px 24px -8px rgba(16, 24, 40, .16);
  --tap: 44px;
  --ui-font: 'Inter';
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--ui-font), ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1340px; margin: 0 auto; padding-inline: 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; inset-block-start: -60px; inset-inline-start: 12px;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: 0 0 8px 8px; z-index: 100;
}
.skip:focus { inset-block-start: 0; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- header ---------- */

.site-head {
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
}

.head-inner { display: flex; align-items: center; gap: 24px; min-height: 62px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--txt); }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .15);
}

.brand-name { font-size: 16.5px; letter-spacing: -.02em; }

.site-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-inline-end: auto; }

.site-nav a {
  color: var(--txt-2);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
}
.site-nav a:hover { background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; }

.lang-switch select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--txt-2);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  min-height: 40px;
  cursor: pointer;
}

/* ---------- hero ---------- */

.hero { padding-block: 30px 20px; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(25px, 4.2vw, 38px);
  line-height: 1.14;
  letter-spacing: -.03em;
  font-weight: 800;
  max-width: 24ch;
}
.hero .lede { margin: 0; color: var(--txt-2); font-size: 16.5px; max-width: 62ch; }

.trust { list-style: none; display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 0; padding: 0; }
.trust li {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid #d5e3ff;
  padding: 4px 11px;
  border-radius: 999px;
}
.trust li::before { content: "✓"; margin-inline-end: 5px; }

/* ============================================================
   EDITOR SHELL
   ============================================================ */

.editor-wrap { padding-block-end: 56px; }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ---------- the document canvas ---------- */

.canvas {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

/*
 * The shared input look.
 *
 * These were transparent at rest so the canvas would read as a finished
 * document. That was the wrong trade: a first-time visitor saw the word "Email"
 * and had no way to know it was a field rather than printed text. Affordance
 * beats elegance here, so every input carries a visible border and a tinted
 * fill at rest, and earns a white background as you engage with it.
 *
 * Font size is deliberately document-scale rather than form-scale, which is the
 * whole point of editing in place.
 */
.in, .in-md, .in-lg, .in-num {
  width: 100%;
  font: inherit;
  color: var(--txt);
  background: #fbfcfe;
  /* Deliberately darker than --line, which is tuned for dividers between white
     panels. At that value a field border on a white canvas is invisible, which
     defeats the whole point of showing one. */
  border: 1px solid #ccd5e4;
  border-radius: 8px;
  padding: 7px 10px;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}

.in { font-size: 16px; }
.in-md { font-size: 18px; font-weight: 600; }
.in-lg { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }

/*
 * A date field is 2px taller than a text field because of the native picker
 * icon, which was enough to break the vertical rhythm of the header rows. An
 * explicit height normalises them and doubles as the touch target.
 */
input.in, input.in-md { height: 44px; }
input.in-lg { height: 50px; }

.in:hover, .in-md:hover, .in-lg:hover, .in-num:hover {
  background: var(--surface);
  border-color: #9cb0d4;
}

.in:focus, .in-md:focus, .in-lg:focus, .in-num:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}

.in::placeholder, .in-md::placeholder, .in-lg::placeholder { color: #9aa3b5; }

input[type="date"].in::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
input[type="date"].in:hover::-webkit-calendar-picker-indicator { opacity: 1; }

textarea.in { resize: vertical; line-height: 1.5; min-height: 58px; }

/* ---------- document header ---------- */

.doc-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding-block-end: 18px;
}

.doc-issuer { min-width: 0; }
.doc-meta { min-width: 0; }

.doc-title {
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1;
  color: var(--txt);
  margin-block-end: 14px;
}

/*
 * A single grid for the whole header block: the label column is sized to the
 * widest label, so every label starts on the same edge and none of them wrap,
 * and every field is the same width. Right-aligning the labels instead left
 * their leading edges ragged, which reads as broken alignment even when the
 * fields themselves line up.
 */
.doc-fields {
  display: grid;
  /* The floor has to clear a formatted date plus the native picker icon, or the
     icon overlaps the year. */
  grid-template-columns: max-content minmax(148px, 176px);
  justify-content: end;
  align-items: center;
  gap: 8px 14px;
}
.doc-fields > label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--txt-2);
  text-align: start;
  white-space: nowrap;
}
/* .doc-meta is end-aligned to place the title; fields must not inherit that or
   their values sit against the far edge of the box. */
.doc-fields .in { text-align: start; }

/* ---------- client block ---------- */

.doc-client {
  border-block-start: 1px solid var(--line-soft);
  padding-block: 16px;
}

.doc-eyebrow {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
  color: var(--txt-3);
  margin-block-end: 5px;
  padding-inline-start: 11px;
}

.doc-client-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }

/* ---------- items table ---------- */

.items { width: 100%; border-collapse: collapse; }

.items thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 800;
  color: var(--txt-3);
  text-align: start;
  padding: 9px 13px;
  border-block-end: 1px solid var(--line);
  white-space: nowrap;
}

.items .c-qty, .items .c-price, .items .c-tax, .items .c-amt { text-align: end; }
/*
 * Tight on purpose. These were wide enough that on a 1024-1200px window the
 * description column collapsed to about 150px and truncated mid-word, which is
 * the one column that actually needs room.
 */
.items .c-qty { width: 68px; }
.items .c-price { width: 104px; }
.items .c-tax { width: 74px; }
.items .c-amt { width: 112px; }
.items .c-del { width: 34px; }

.items tbody td { padding: 2px; vertical-align: middle; border-block-end: 1px solid var(--line-soft); }

.items tbody .num input { text-align: end; }

.items .amt {
  padding-inline: 13px;
  text-align: end;
  font-size: 16px;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
}

.row-del {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  color: #c3c9d6;
  border-radius: 7px;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.row-del:hover { background: #fef2f2; color: #dc2626; }

.add-row {
  display: block;
  width: 100%;
  margin-block-start: 10px;
  padding: 11px;
  min-height: var(--tap);
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--brand-dark);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.add-row:hover { background: var(--brand-soft); border-color: #c7dbff; border-style: solid; }

/* ---------- notes + totals ---------- */

.doc-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  margin-block-start: 22px;
}

.nfield { display: block; margin-block-end: 10px; }
.nfield > span {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 800;
  color: var(--txt-3);
  margin-block-end: 3px;
  padding-inline-start: 11px;
}

.doc-totals { min-width: 0; }

.t-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 7px;
  font-size: 15.5px;
  border-block-end: 1px solid var(--line-soft);
}
/* An author `display` declaration beats the UA rule for [hidden] no matter the
   specificity, so hiding has to be restated for anything given a display here. */
.t-row[hidden] { display: none; }
.t-row > span { color: var(--txt-2); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.t-row > b { font-weight: 600; white-space: nowrap; }

.in-num {
  width: 76px;
  font-size: 16px;
  text-align: end;
  padding: 5px 8px;
}

.t-grand { font-size: 19px; font-weight: 700; border-block-end: 2px solid var(--txt); }
.t-grand > span { color: var(--txt); font-weight: 700; }
.t-grand > b { font-size: 21px; }

.t-due { font-size: 17px; border-block-end: none; }
.t-due > span { color: var(--txt); font-weight: 700; }
.t-due > b { font-weight: 800; color: var(--brand-dark); }

.t-adders { display: flex; gap: 14px; padding-block: 8px; flex-wrap: wrap; }

.linkish {
  border: none;
  background: none;
  padding: 4px 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }
.linkish[hidden] { display: none; }

/* ---------- side panel ---------- */

.side { min-width: 0; display: grid; gap: 14px; }

.side-actions { display: grid; gap: 9px; }

.side-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-sm);
}

.side-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  color: var(--txt-3);
  margin: 0 0 12px;
}

.sfield { display: block; margin-block-end: 13px; }
.sfield:last-child { margin-block-end: 0; }
.sfield > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt-2);
  margin-block-end: 5px;
}
.sfield select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  min-height: var(--tap);
  background: var(--surface);
  color: var(--txt);
  cursor: pointer;
}
.sfield select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}

.acc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acc-dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--dot);
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, .12) inset;
  cursor: pointer;
  padding: 0;
}
.acc-dot[aria-pressed="true"] { border-color: var(--txt); box-shadow: 0 0 0 2px #fff inset; }
.acc-row input[type="color"] {
  width: 44px; height: 32px; padding: 2px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer;
}

/* ---------- logo zone ----------
 *
 * Dashed rather than solid: it reads as an empty slot to fill, not as a field
 * that already holds something. Sized to a real logo's footprint so the
 * document does not jump when one lands in it.
 */

.logo-zone { margin-block-end: 12px; }

.logo-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  max-width: 220px;
  min-height: 74px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--txt-3);
  text-align: center;
  background: #fbfcfe;
  border: 1.5px dashed #c3cfe3;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s, background-color .12s, color .12s;
}
.logo-drop:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: #f4f8ff;
}
.logo-drop:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.logo-drop.is-dragover { color: var(--brand); border-color: var(--brand); background: #eaf1ff; }

.logo-plus {
  position: relative;
  flex: 0 0 auto;
  width: 15px; height: 15px;
}
.logo-plus::before,
.logo-plus::after {
  content: '';
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  border-radius: 1px;
}
.logo-plus::before { width: 15px; height: 2px; }
.logo-plus::after { width: 2px; height: 15px; }

.logo-text { min-width: 0; }

/* Locked: the padlock is borrowed from the template gallery so the two gates
   read as the same mechanism. */
.logo-drop.is-locked { padding-inline-end: 34px; }
.logo-drop.is-locked .tpl-lock { top: 7px; inset-inline-end: 7px; }

/* ---------- template gallery ----------
 *
 * A native <select> can only offer names, and "Ledger" or "Onyx" means nothing
 * to someone who has never seen them. This is a listbox of schematic previews
 * grouped by what it costs to use them.
 *
 * --accent is set on the document element by the accent picker, so every
 * thumbnail re-tints live without asking the server for anything.
 */

:root { --accent: #2563eb; }

.sfield { position: relative; }

.tpl-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 7px 10px;
  font: inherit;
  text-align: start;
  color: var(--txt);
  background: var(--surface);
  border: 1px solid #ccd5e4;
  border-radius: 9px;
  cursor: pointer;
}
.tpl-trigger:hover { border-color: #9cb0d4; }
.tpl-trigger[aria-expanded="true"],
.tpl-trigger:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.tpl-trigger .thumb { flex: 0 0 30px; width: 30px; }
.tpl-trigger-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-caret {
  flex: 0 0 auto;
  width: 7px; height: 7px;
  border-right: 2px solid var(--txt-3);
  border-bottom: 2px solid var(--txt-3);
  transform: rotate(45deg) translateY(-2px);
}

/* Anchored to the field's inline end and wider than the sidebar, so it opens
   back over the canvas instead of off the edge of the window. */
.tpl-pop {
  position: absolute;
  z-index: 40;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  width: min(432px, calc(100vw - 32px));
  max-height: min(62vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 22px 48px -18px rgba(16, 24, 40, .34);
}
.tpl-pop[hidden] { display: none; }

.tpl-group { padding: 8px; }
.tpl-group + .tpl-group { border-top: 1px solid var(--line); }
.tpl-group-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block-end: 8px;
}
.tpl-group-h > span:first-child {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 800;
  color: var(--txt-3);
}
.tpl-group-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2fb;
  color: var(--brand);
  white-space: nowrap;
}

.tpl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }

.tpl-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px;
  font: inherit;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}
.tpl-card:hover { background: #f2f5fa; }
.tpl-card:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.tpl-card[aria-selected="true"] { border-color: var(--brand); background: #eef4ff; }
.tpl-card-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt-2);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-card[aria-selected="true"] .tpl-card-name { color: var(--brand); }

/* Locked designs stay fully legible — the point is to make them desirable —
   but are visibly muted so the padlock is not the only signal. */
.tpl-card.is-locked .thumb { opacity: .62; }
.tpl-card.is-locked:hover .thumb { opacity: .8; }

.tpl-lock {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: rgba(16, 24, 40, .74);
}
.tpl-lock::before {
  content: '';
  position: absolute;
  top: 3.5px; left: 50%;
  transform: translateX(-50%);
  width: 7px; height: 5px;
  border: 1.5px solid #fff;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
}
.tpl-lock::after {
  content: '';
  position: absolute;
  bottom: 3.5px; left: 50%;
  transform: translateX(-50%);
  width: 11px; height: 7px;
  background: #fff;
  border-radius: 2px;
}

/* ---------- template thumbnail ----------
 * Built from the same style values the PDF uses, so it cannot advertise a
 * design the document will not produce.
 */

.thumb {
  display: flex;
  flex-direction: column;
  gap: 3px;
  aspect-ratio: 3 / 4;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.thumb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding: 2px;
  border-radius: 2px;
}
.thumb-head.is-band { background: var(--th-head); padding: 4px 3px 5px; }

.thumb-lines { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.thumb-lines > i { height: 2px; border-radius: 1px; background: var(--th-ink); }

.thumb-title {
  flex: 0 0 auto;
  width: 24%;
  height: 6px;
  border-radius: 1px;
  background: var(--th-title);
}
.thumb.is-serif .thumb-title { height: 8px; width: 28%; }

.thumb-th { height: 5px; border-radius: 1px; background: var(--th-bar); }
.thumb-th.is-rule {
  height: 4px;
  background: transparent;
  border-bottom: 1.5px solid var(--th-rule);
}

.thumb-rows { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.thumb-rows > i { position: relative; height: 6px; border-radius: 1px; }

/* Compact templates fit more lines on the page; the thumbnail says so. */
.thumb.is-dense { gap: 2px; padding: 3px; }
.thumb.is-dense .thumb-rows { gap: 1px; }
.thumb.is-dense .thumb-rows > i { height: 4px; }
/* The band is the row stripe; the inner bar is the row's content. A template
   with no striping therefore shows a blank band, which is accurate. */
.thumb-rows > i.alt { background: var(--th-stripe); }
.thumb-rows > i::before {
  content: '';
  position: absolute;
  inset-block: 1.5px;
  inset-inline: 1px 34%;
  background: #dde3ee;
  border-radius: 1px;
}

.thumb-total {
  align-self: flex-end;
  width: 46%;
  height: 3px;
  border-radius: 1px;
  background: var(--th-rule);
}

/* ---------- locked template dialog ---------- */

.lock-panel {
  position: relative;
  margin: auto;
  width: min(408px, calc(100% - 32px));
  padding: 26px 24px 22px;
  text-align: center;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(16, 24, 40, .5);
}
.lock-badge {
  display: block;
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #eef2fb;
  position: relative;
}
.lock-badge::before {
  content: '';
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 13px; height: 9px;
  border: 2px solid var(--brand);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}
.lock-badge::after {
  content: '';
  position: absolute;
  bottom: 11px; left: 50%;
  transform: translateX(-50%);
  width: 20px; height: 13px;
  background: var(--brand);
  border-radius: 3px;
}
.lock-title { font-size: 19px; font-weight: 750; letter-spacing: -.01em; margin: 0 0 7px; }
.lock-copy { font-size: 14.5px; color: var(--txt-2); line-height: 1.5; margin: 0 0 18px; }
.lock-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  border-radius: 9px;
  padding: 11px 18px;
  min-height: var(--tap);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; display: block; }
.btn.sm { padding: 8px 14px; min-height: 38px; font-size: 14px; }

.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }

.btn.soft { background: var(--surface); border-color: var(--line); color: var(--brand-dark); }
.btn.soft:hover { background: var(--brand-soft); border-color: #c7dbff; }

.btn.icon { padding: 8px 12px; background: transparent; color: var(--txt-2); font-size: 20px; }
.btn.icon:hover { background: var(--line-soft); }

.btn.zoom {
  background: var(--surface);
  border-color: var(--line);
  color: var(--txt-2);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  min-height: 36px;
}
.btn.zoom[aria-pressed="true"] { background: var(--brand-soft); border-color: #c7dbff; color: var(--brand-dark); }

/* ---------- mobile action bar ---------- */

.mobile-bar {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-block-start: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

/* ---------- view modal ---------- */

.modal { position: fixed; inset: 0; z-index: 60; display: flex; }
.modal[hidden] { display: none; }

.modal-back { position: absolute; inset: 0; background: rgba(16, 24, 40, .55); }

.modal-panel {
  position: relative;
  margin: auto;
  width: min(900px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px -20px rgba(16, 24, 40, .5);
}

.modal-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}
.modal-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  color: var(--txt-3);
  margin-inline-end: auto;
}

.modal-body { padding: 14px; overflow-y: auto; overscroll-behavior: contain; }

.preview-paper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
/* Panning at actual size. Fit-to-width never overflows, so this only applies
   once the user asks for 100%. */
.preview-paper.zoomed {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* A4 at 96dpi, scaled by JS to fit the space available, so the modal shows a
   true rendition of the PDF rather than a reflowed approximation of it. */
.preview-stage { width: 794px; transform-origin: top left; }
[dir="rtl"] .preview-stage { transform-origin: top right; }

#preview[aria-busy="true"] { opacity: .5; }

body.modal-open { overflow: hidden; }

/* ---------- faq ---------- */

.faq { background: var(--surface); border-block-start: 1px solid var(--line); padding-block: 44px 52px; }
.faq h2 { margin: 0 0 20px; font-size: 24px; letter-spacing: -.02em; }
.faq dl { margin: 0; max-width: 78ch; }
.faq dt { font-weight: 700; margin-block-start: 18px; }
.faq dd { margin: 5px 0 0; color: var(--txt-2); }

/* ---------- footer ---------- */

.site-foot {
  border-block-start: 1px solid var(--line);
  background: var(--surface);
  padding-block: 22px;
}
.foot-inner {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  color: var(--txt-3); font-size: 13.5px;
}
.foot-inner p { margin: 0; }
.foot-langs { list-style: none; display: flex; gap: 14px; margin: 0; padding: 0; flex-wrap: wrap; }

/* ============================================================
   Tablet and up: the canvas becomes a real document layout
   ============================================================ */

@media (min-width: 760px) {
  .canvas { padding: 34px 38px; }
  /* Even halves: the header block needs enough room for its label column plus a
     date field, and the issuer block has nothing that needs the extra width. */
  .doc-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; }
  .doc-meta { text-align: end; }
  .doc-bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 34px; }
  .doc-client-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
}

@media (min-width: 1024px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr) 264px; gap: 22px; }
  .side { position: sticky; inset-block-start: 84px; }
  .mobile-bar { display: none; }
  .editor-wrap { padding-block-end: 60px; }
}

/* ============================================================
   Phone: the canvas reflows instead of shrinking
   ============================================================ */

@media (max-width: 1023px) {
  /* Room for the fixed action bar. */
  .editor-wrap { padding-block-end: 84px; }
  /* Duplicated by the fixed bar at the bottom of the screen. */
  .side-actions { display: none; }

  /* An absolutely positioned popover anchored to a full-width field would run
     off both edges here, so it becomes a bottom sheet instead. */
  .tpl-pop {
    position: fixed;
    inset: auto 0 0 0;
    top: auto;
    z-index: 80;
    width: auto;
    max-height: 78vh;
    padding-block-end: max(10px, env(safe-area-inset-bottom));
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -18px 44px -14px rgba(16, 24, 40, .38);
  }
  /* Dims the page behind the sheet without needing an extra element. */
  .tpl-open::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 79;
    background: rgba(16, 24, 40, .45);
  }
}

@media (max-width: 759px) {
  .head-inner { min-height: 56px; gap: 12px; flex-wrap: wrap; padding-block-end: 6px; }
  /* One scrollable row rather than a wrapping block: nav wrapping to two lines
     pushes the document below the fold. */
  .site-nav {
    order: 3;
    width: 100%;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { padding: 6px 10px; font-size: 14px; white-space: nowrap; flex: none; }
  .brand-name { font-size: 16px; }

  .hero { padding-block: 22px 16px; }
  .hero .lede { font-size: 15.5px; }
  .trust li { font-size: 12px; padding: 3px 9px; }

  .tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tpl-card-name { font-size: 12px; }

  .wrap { padding-inline: 12px; }
  .canvas { padding: 14px 12px; border-radius: 10px; }

  .doc-title { margin-block-end: 10px; }
  .doc-fields { justify-content: start; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 10px; }
  .doc-fields > label { font-size: 12.5px; }

  /*
   * Card-per-row instead of a five-column table. Scaling an A4 table down to
   * 360px is exactly the unreadable-input problem this layout exists to solve,
   * so the table reflows and every field keeps its full size and its label.
   */
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: auto; }

  .items tbody tr {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 42px 10px 10px;
    margin-block-end: 9px;
    background: #fcfdff;
  }
  [dir="rtl"] .items tbody tr { padding: 10px 10px 10px 42px; }

  .items tbody td { border: none; padding: 0; }

  /* Label each field from the header text carried on the cell. */
  .items tbody td.num::before,
  .items tbody td.amt::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    color: var(--txt-3);
    margin-block-end: 2px;
    padding-inline-start: 11px;
  }

  .items tbody td.num { display: inline-block; width: 32%; vertical-align: top; }
  .items tbody .num input { text-align: start; }

  .items .amt {
    display: block;
    text-align: start;
    padding-inline: 0;
    margin-block-start: 8px;
    padding-block-start: 8px;
    border-block-start: 1px solid var(--line-soft);
  }
  .items .amt span { padding-inline-start: 11px; display: inline-block; }

  .items tbody td.c-del-cell {
    position: absolute;
    inset-block-start: 8px;
    inset-inline-end: 8px;
  }

  .modal-panel { border-radius: 0; width: 100%; height: 100%; }
  .modal-body { padding: 10px; }
}

/* Secondary link under the editor's action buttons: signing in to save, or
   jumping to the saved list. Quiet on purpose — the download button is the
   primary action for an anonymous visitor and must stay the loudest thing. */
.side-link {
  display: block;
  margin-block-start: 2px;
  padding: 6px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-3);
  text-align: center;
  text-decoration: none;
}
.side-link:hover { color: var(--brand); text-decoration: underline; }

/* The saved account logo, shown in the editor where the mark will print.
   A link, not an upload target: the logo is set on the branding screen. */
.logo-set {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 10px 6px 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
}
.logo-set img {
  max-width: 190px;
  max-height: 54px;
  width: auto;
  height: auto;
  display: block;
}
.logo-swap {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  opacity: 0;
  transition: opacity .12s;
  white-space: nowrap;
}
.logo-set:hover,
.logo-set:focus-visible {
  border-color: #d7dfec;
  background: #fbfcfe;
}
.logo-set:hover .logo-swap,
.logo-set:focus-visible .logo-swap { opacity: 1; }

/* Touch has no hover, so the affordance must always be legible there. */
@media (hover: none) {
  .logo-swap { opacity: 1; }
}
