@font-face {
  font-family: Vera;
  src: url(/assets/Vera.ttf) format('truetype');
  font-display: swap;
}
:root {
  color-scheme: light;
  --navy: #101822;
  --ink: #172433;
  --muted: #526374;
  --blue: #00669a;
  --rule: #d0dbe1;
  --desk: #f3f6f7;
  --focus: #0075b6;
  --cyan: #14c4ee;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--ink);
  background: var(--desk);
  font-size: 16px;
  line-height: 1.4;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea,
a.secondary {
  font: inherit;
}
button,
a.secondary {
  cursor: pointer;
}
button:disabled {
  opacity: 0.56;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
::selection {
  background: #bceafa;
  color: #0a293b;
}
button {
  border: none;
}
input,
textarea {
  caret-color: var(--blue);
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: clamp(2rem, 3vw, 2.8rem);
  letter-spacing: -0.035em;
  line-height: 1.13;
  font-weight: 660;
}
h2 {
  font-size: 1.09rem;
  line-height: 1.35;
  font-weight: 680;
  letter-spacing: -0.015em;
}
[hidden] {
  display: none !important;
}
.skip {
  position: absolute;
  left: 8px;
  top: -100px;
  background: white;
  padding: 10px;
  z-index: 8;
}
.skip:focus {
  top: 8px;
}
.mast {
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid #00acd9;
}
.mast-inner,
main {
  max-width: 1560px;
  margin: auto;
  padding-inline: clamp(18px, 3.3vw, 58px);
}
.mast-inner,
.brand,
nav,
.actions,
.block-heading,
.preview-tools,
.paper-caption,
.paper-caption > div,
.titlebar,
.settings-actions,
#record-tools {
  display: flex;
  align-items: center;
}
.mast-inner {
  min-height: 75px;
  justify-content: space-between;
  gap: 22px;
}
.brand {
  gap: 20px;
  min-width: 0;
}
.brand img {
  display: block;
  width: 200px;
  height: auto;
}
.brand span {
  border-left: 1px solid #495865;
  padding-left: 21px;
  font-size: 0.95rem;
  color: #d5e1e9;
  font-weight: 550;
}
.mast nav {
  align-self: stretch;
  gap: 7px;
}
.mast nav button {
  position: relative;
  background: transparent;
  color: #b5c3d0;
  padding: 0 18px;
  font-weight: 550;
  min-height: 44px;
}
.mast nav button:hover,
.mast nav button[aria-current] {
  color: white;
  background: #1b2835;
}
.mast nav button[aria-current]::after {
  content: '';
  position: absolute;
  inset: auto 17px 0;
  height: 3px;
  background: var(--cyan);
}
main {
  padding-bottom: 55px;
}
main:focus {
  outline: 0;
}
.titlebar {
  justify-content: space-between;
  gap: 16px;
  min-height: 126px;
  padding-block: 23px;
}
.titlebar p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 6px;
}
.titlebar > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.actions,
.settings-actions,
#record-tools {
  gap: 9px;
  flex-wrap: wrap;
}
.primary,
.secondary,
.link-button {
  min-height: 42px;
  border-radius: 5px;
  padding: 9px 15px;
  font-weight: 620;
  line-height: 1.25;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
}
.primary {
  background: var(--blue);
  color: white;
  border: 1px solid var(--blue);
}
.primary:hover {
  background: #00527c;
}
.secondary {
  color: var(--ink);
  background: white;
  border: 1px solid #b5c5d0;
}
.secondary:hover {
  background: #edf5f9;
}
.link-button {
  background: transparent;
  color: var(--blue);
  padding-inline: 6px;
}
.link-button:hover {
  text-decoration: underline;
}
.desk {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(18px, 2.4vw, 40px);
}
@media screen and (min-width: 1560px) {
  main:has(#editor-view:not([hidden])),
  body:has(#editor-view:not([hidden])) .mast-inner { max-width:none; }
  .desk { grid-template-columns:710px minmax(0,1fr); }
}
.form-sheet,
.history-shell {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.block {
  padding: 22px 25px;
  border-bottom: 1px solid var(--rule);
}
.block:last-child {
  border-bottom: 0;
}
.block h2 {
  margin-bottom: 15px;
}
.block-heading {
  justify-content: space-between;
  margin-bottom: 15px;
}
.block-heading h2 {
  margin: 0;
}
.units,
.paper-caption,
.live {
  font-size: 0.77rem;
  color: var(--muted);
}
.units {
  font-weight: 650;
  letter-spacing: 0.05em;
}
.fieldgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.wide {
  grid-column: 1/-1;
}
#invoice-number-field[hidden] + .currency-field {
  grid-column: 1/-1;
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #314454;
  font-size: 0.85rem;
  font-weight: 610;
  min-width: 0;
}
input,
select,
textarea {
  border: 1px solid #b8c6ce;
  border-radius: 4px;
  min-width: 0;
  width: 100%;
  min-height: 42px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.94rem;
  font-weight: 430;
  line-height: 1.35;
}
select {
  padding-right: 20px;
}
textarea {
  resize: vertical;
}
input::placeholder,
textarea::placeholder {
  color: #657681;
  opacity: 1;
}
input:disabled,
select:disabled {
  background: #f2f5f6;
  color: #50616e;
}
summary,
.link-button {
  color: var(--blue);
}
summary {
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
  padding: 5px 0;
}
details[open] summary {
  margin-bottom: 6px;
}
.library {
  margin-bottom: 16px;
}
.service-line {
  padding-block: 15px;
  border-top: 1px solid var(--rule);
}
.row-head,
.line-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.row-head {
  margin-bottom: 5px;
}
.row-head label {
  display: block;
}
.remove {
  font-size: 0.78rem;
  background: transparent;
  color: #526371;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 30px;
}
.line-fields {
  display: grid;
  grid-template-columns: 1.13fr 0.8fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.line-fields.project-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.line-total {
  justify-content: flex-end;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 9px;
  gap: 10px;
}
.line-total b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.included-field {
  margin-top: 15px;
}
.list-format-options {
  margin-top: 6px;
}
.list-format-options[open] summary {
  margin-bottom: 0;
}
.list-format {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.included-field p {
  margin: 3px 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
}
.included-field textarea {
  display: block;
  field-sizing: content;
  min-height: 4.6rem;
  max-height: 23rem;
}
#preview-pane {
  min-width: 0;
  position: sticky;
  top: 14px;
}
.preview-tools {
  justify-content: space-between;
  min-height: 55px;
  padding: 10px 17px;
  background: #e2eaee;
  border: 1px solid #c6d3da;
  border-radius: 7px 7px 0 0;
}
.preview-tools h2 {
  font-size: 0.99rem;
}
.live {
  display: flex;
  gap: 6px;
  align-items: center;
  color: #31555d;
  font-weight: 600;
}
.live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #167660;
}
.paper-bed {
  padding: clamp(13px, 1.7vw, 28px);
  background: #eaf0f2;
  border: 1px solid #c6d3da;
  border-block: 0;
  max-height: calc(100dvh - 200px);
  min-height: 280px;
  overflow: auto;
  scrollbar-color: #a0b1ba transparent;
  scrollbar-width: thin;
}
#pages {
  display: grid;
  gap: 14px;
}
#pages canvas {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: 0 2px 9px #1b384021;
  background: white;
}
.paper-caption {
  background: #f8fafb;
  border: 1px solid #c6d3da;
  border-radius: 0 0 7px 7px;
  padding: 8px 14px;
  justify-content: space-between;
  gap: 8px;
}
.paper-caption > div {
  gap: 8px;
}
.paper-caption .secondary {
  min-height: 36px;
}
#record-tools {
  margin-top: 12px;
}
.mobile-switch {
  display: none;
}
#message:not(:empty) {
  border: 1px solid #a2c4bb;
  background: #e5f2ee;
  color: #194e42;
  border-radius: 5px;
  margin-top: 16px;
  padding: 10px 14px;
  font-size: 0.91rem;
}
#message.error:not(:empty) {
  background: #fff1ec;
  border-color: #ddb4a4;
  color: #872f19;
}
.settings-form {
  max-width: 780px;
}
.settings-actions,
.history-filters {
  padding: 18px 25px;
}
.history-filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(145px, 1fr);
  gap: 15px;
  border-bottom: 1px solid var(--rule);
}
.empty {
  padding: 45px 22px;
  text-align: center;
  color: var(--muted);
}
.history-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(135px, 1fr) minmax(120px, 2fr) 80px minmax(90px, 0.75fr);
  gap: 12px;
  align-items: center;
  padding: 16px 24px;
  text-align: left;
  background: white;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font-size: 0.95rem;
}
.history-row:hover {
  background: #eff7fb;
}
.history-row:last-child {
  border: 0;
  border-radius: 0 0 8px 8px;
}
.history-row b,
.history-row small {
  display: block;
  overflow-wrap: anywhere;
}
.history-row small {
  color: var(--muted);
  margin-top: 3px;
}
.history-row .sum {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.history-status {
  font-size: 0.85rem;
  color: var(--blue);
  font-weight: 620;
}
@media (min-width: 1001px) and (max-height: 650px) {
  #preview-pane {
    position: static;
  }
  .paper-bed {
    max-height: 580px;
  }
}
@media (max-width: 1000px) {
  main,
  .mast-inner {
    max-width: 840px;
  }
  .desk {
    display: block;
  }
  .mobile-switch {
    display: flex;
    gap: 4px;
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 3px;
    width: fit-content;
    background: #e4ebef;
    margin-bottom: 15px;
  }
  .mobile-switch button {
    background: transparent;
    margin: 0;
    min-height: 37px;
    padding: 5px 18px;
    border-radius: 4px;
    color: #415462;
    font-size: 0.9rem;
    font-weight: 600;
  }
  .mobile-switch button[aria-pressed='true'] {
    background: white;
    color: var(--ink);
    box-shadow: 0 1px 3px #10203021;
  }
  #preview-pane {
    display: none;
    position: static;
  }
  .preview-only #preview-pane {
    display: block;
  }
  .preview-only #document-form {
    display: none;
  }
  .paper-bed {
    max-height: none;
  }
  .titlebar {
    min-height: 104px;
  }
}
@media (max-width: 620px) {
  .mast-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    padding-inline: 16px;
  }
  .brand {
    height: 61px;
    gap: 14px;
  }
  .brand img {
    width: 165px;
  }
  .brand span {
    font-size: 0.83rem;
    padding-left: 14px;
  }
  .mast nav {
    gap: 3px;
  }
  .mast nav button {
    padding: 0 16px;
    min-height: 40px;
  }
  .mast nav button[aria-current]::after {
    inset-inline: 10px;
  }
  .mast nav button:first-child {
    margin-left: -6px;
  }
  .titlebar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 21px 0 16px;
  }
  .titlebar h1 {
    font-size: 2rem;
  }
  .titlebar .actions {
    width: 100%;
  }
  .block {
    padding: 18px 16px;
  }
  .fieldgrid {
    gap: 12px;
  }
  .titlebar p {
    margin-top: 4px;
  }
  .history-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 14px 16px;
  }
  .history-row .sum {
    justify-self: end;
  }
  .history-row > span:nth-child(2) {
    text-align: right;
  }
  .history-filters,
  .settings-actions {
    padding: 14px 16px;
  }
  .history-filters {
    grid-template-columns: 1fr;
  }
  .paper-caption {
    padding: 6px 9px;
  }
  .line-fields {
    gap: 7px;
  }
  .mobile-switch {
    width: 100%;
  }
  .mobile-switch button {
    flex: 1;
  }
  .paper-bed {
    padding: 10px;
  }
  .preview-tools {
    min-height: 45px;
  }
}
@media (max-width: 410px) {
  main {
    padding-inline: 12px;
  }
  .fieldgrid {
    grid-template-columns: 1fr;
  }
  .line-fields {
    grid-template-columns: 1fr 1fr;
  }
  .line-fields:not(.project-fields) label:first-child {
    grid-column: 1/-1;
  }
  .block {
    padding: 16px 14px;
  }
  .paper-caption > div {
    gap: 2px;
  }
  .brand {
    gap: 11px;
  }
  .brand img {
    width: 150px;
  }
}
@media print {
  #login-panel, #draft-shelf, .device-actions { display:none !important; }
  @page {
    size: letter;
    margin: 0;
  }
  html,
  body,
  main,
  #editor-view,
  .desk,
  #preview-pane,
  .paper-bed,
  #pages {
    display: block !important;
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    border: 0 !important;
  }
  body > *:not(main),
  #message,
  .titlebar,
  .mobile-switch,
  #document-form,
  .preview-tools,
  .paper-caption,
  #record-tools,
  #history-view,
  #settings-view {
    display: none !important;
  }
  #preview-pane {
    position: static !important;
  }
  #pages canvas {
    width: 8.5in !important;
    height: 11in !important;
    box-shadow: none;
    break-after: page;
  }
  #pages canvas:last-child {
    break-after: auto;
  }
}
.column-heading { margin-bottom: 16px; }
.row-picker { margin:8px 0 12px; }
.settings-tabs { display:flex; gap:5px; border-bottom:1px solid var(--rule); margin:0 0 22px; max-width:780px; }
.settings-tabs button { background:transparent; min-height:44px; color:var(--muted); padding:8px 15px; font-weight:600; border-bottom:3px solid transparent; }
.settings-tabs button[aria-pressed="true"] { color:var(--blue); border-color:var(--blue); }
.section-note, .login-panel p { color:var(--muted); margin-bottom:14px; }
.preset-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(104px,1fr)); gap:10px; }
.preset-card { position:relative; padding:8px; gap:8px; border:1px solid var(--rule); border-radius:5px; cursor:pointer; }
.preset-card input { position:absolute; width:1px; height:1px; min-height:0; opacity:0; }
.preset-card:has(:checked) { border-color:var(--blue); box-shadow:inset 0 0 0 1px var(--blue); color:var(--blue); }
.preset-card:has(:focus-visible) { outline:3px solid var(--focus); outline-offset:2px; }
.stationery { border:1px solid #dbe1e5; display:block; height:68px; background:white; position:relative; overflow:hidden; }
.stationery i { position:absolute; inset:0 0 auto; height:20px; background:var(--head); }
.stationery-ledger i { inset:5px 48% auto 5px; height:13px; }
.stationery-ledger { background:linear-gradient(to bottom,white 19px,var(--accent) 19px 20px,white 20px); }
.stationery-band i { height:25px; border-bottom:5px solid var(--accent); }
.stationery-split i { background:linear-gradient(to right,var(--head) 53%,var(--accent) 53%); }
.stationery-minimal i { inset:5px auto auto 6px; width:3px; height:16px; background:var(--accent); }
.stationery b { position:absolute; inset:30px 8px auto; height:12px; border-block:1px solid #becbd2; }
.stationery em { position:absolute; right:8px; bottom:8px; width:32%; height:6px; background:var(--head); }
.swatches input { max-width:110px; cursor:pointer; padding:4px; }
.size-control { display:flex; align-items:center; gap:14px; max-width:350px; }
.size-control input { accent-color:var(--blue); padding:0; border:0; }
.size-control output { min-width:44px; font-variant-numeric:tabular-nums; }
.upload-hint { margin:5px 0 10px; color:var(--muted); font-size:.85rem; }
#custom-image { display:block; max-width:100%; width:auto; height:auto; max-height:76px; object-fit:contain; }
#design-proof { padding:16px; background:#eaf0f2; }
#design-proof canvas { display:block; max-width:100%; height:auto; margin:auto; }
.device-actions { display:flex; gap:12px; margin-top:20px; }
.login-panel { max-width:440px; margin:clamp(30px,8vh,100px) auto; padding:clamp(22px,4vw,34px); }
.login-panel h1 { font-size:1.9rem; margin-bottom:12px; }
.login-panel form { display:grid; gap:12px; margin-block:18px; }
#draft-shelf { margin-top:20px; }
#draft-shelf h2 { padding:16px 24px; border-bottom:1px solid var(--rule); }
.draft-row { grid-template-columns:1fr 1fr auto; }
@media(max-width:620px) { .draft-row { grid-template-columns:1fr; } .draft-row > span:nth-child(2){text-align:left;} }
