/* ==========================================================================
   Change Order — single directly-editable document (block: co-doc), restyled
   to the owner's shipped design ("Invoice app redesign/Invoice Template.dc.html"):
   #FDFCFA sheet on #EDEAE4 page, Newsreader serif display type, 10px
   small-caps eyebrow labels (13px floor below 1024px), #EEEAE2 dividers,
   #9A4A28 accent, tabular numerals, meta Total highlight box, footer strip.

   Tokens: consumes the shared main.css redesign tokens (self-hosted
   Newsreader @font-face lives there too — zero external font requests;
   page bg #EDEAE4 comes from main.css's body { background: var(--color-paper) }).
   The --doc-* names below are thin aliases of those shared tokens so the
   rest of this file reads consistently; this inherits the WCAG-darkened
   muted (#756E62) and faint (#7A7368) grays.
   ========================================================================== */

.co-doc-wrap {
  margin-bottom: var(--space-5);
  --doc-sheet: var(--color-sheet);
  --doc-ink: var(--color-ink);
  --doc-ink-soft: var(--color-ink-soft);
  --doc-ink-muted: var(--color-ink-muted);
  --doc-divider: var(--color-divider);
  --doc-divider-soft: var(--color-border);
  --doc-accent: var(--color-accent);
  --doc-highlight: var(--color-paper-alt);
  --doc-footer-ink: var(--color-ink-faint);
  --doc-serif: var(--font-doc-serif);
}

/* ---- The sheet ----
   Width parity: fills the same content column as the page copy (mirrors
   the invoice worker's mechanism). Mockup look: no border/radius, soft
   double shadow, generous side padding at desktop; the footer strip
   supplies the bottom padding. ---- */
.co-doc {
  width: 100%;
  background: var(--doc-sheet);
  color: var(--doc-ink);
  box-shadow: 0 1px 2px rgba(28, 26, 23, 0.06), 0 24px 64px rgba(28, 26, 23, 0.12);
  padding: var(--space-5) var(--space-4) 0;
}
@media (min-width: 1024px) {
  .co-doc { padding: 48px 64px 0; }
}

/* ---- Eyebrow labels: small-caps, letter-spaced, muted. 13px floor on
   small screens (owner: >=13px below 1024px), mockup 10px from 1024px up. */
.co-doc__party-label,
.co-doc__reference-label,
.co-doc__notes-label,
.co-doc__meta-label,
.co-doc__meta-total-label,
.co-doc__th {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--doc-ink-muted);
}
@media (min-width: 1024px) {
  .co-doc__party-label,
  .co-doc__reference-label,
  .co-doc__notes-label,
  .co-doc__meta-label,
  .co-doc__meta-total-label,
  .co-doc__th { font-size: 10px; }
}

/* ---- Editable-field baseline: reads as document text until interacted
   with (transparent -> faint outline on hover -> accent ring on focus). ---- */
.co-doc__input {
  display: block;
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-1) var(--space-2);
  margin: 0;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--doc-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color var(--motion-fast) var(--ease-out),
              background-color var(--motion-fast) var(--ease-out);
}
@media (min-width: 1024px) {
  .co-doc__input { font-size: 14px; }
}
/* --color-placeholder (#99907F) on sheet: 3.02:1 — deliberately lighter
   than entered text (owner 2026-07-13), placeholder floor-compliant. */
.co-doc__input::placeholder { color: var(--color-placeholder); opacity: 1; }
.co-doc__input:hover { border-color: var(--doc-divider); background: var(--doc-highlight); }
.co-doc__input:focus-visible {
  outline: none;
  border-color: var(--doc-accent);
  background: var(--doc-sheet);
  box-shadow: 0 0 0 3px rgba(154, 74, 40, 0.18);
}
.co-doc__input[readonly] { color: var(--doc-ink); cursor: default; }
.co-doc__input[readonly]:hover { border-color: transparent; background: transparent; }
.co-doc__input--textarea { resize: vertical; min-height: 3.5em; }
.co-doc__input--num { text-align: right; -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
.co-doc__input--num::-webkit-inner-spin-button,
.co-doc__input--num::-webkit-outer-spin-button { margin-left: var(--space-1); }
.co-doc__input--meta {
  display: inline-block;
  width: auto;
  min-width: 8em;
  text-align: right;
  font-size: 0.9rem;
}
@media (min-width: 1024px) {
  .co-doc__input--meta { font-size: 14px; }
}
.co-doc__co-number { font-weight: 500; letter-spacing: 0.04em; }

/* ---- Masthead: circular accent monogram/logo above the centered
   Newsreader title, 1px ink rule underneath. ---- */
.co-doc__masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--doc-ink);
}
.co-doc__logo-cell { position: relative; }
.co-doc__logo-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--doc-accent);
  color: var(--doc-sheet);
  cursor: pointer;
}
.co-doc__logo-slot:hover { background: var(--color-accent-dark); }
.co-doc__logo-slot:focus-visible { outline: 3px solid var(--doc-accent); outline-offset: 2px; }
.co-doc__monogram {
  font-family: var(--doc-serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1;
}
.co-doc__logo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 4px;
  background: var(--doc-sheet);
  border: 1px solid var(--doc-divider);
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
}
.co-doc__logo-btn:hover { border-color: var(--doc-accent); }
.co-doc__logo-btn:focus-visible { outline: 3px solid var(--doc-accent); outline-offset: 2px; }
.co-doc__logo-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 50%; }
.co-doc__logo-remove {
  position: absolute;
  top: -8px;
  right: -12px;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--doc-sheet);
  border: 1px solid var(--doc-divider);
  border-radius: 999px;
  color: var(--color-error);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.co-doc__logo-remove:hover { background: var(--color-error-bg); }
.co-doc__logo-remove:focus-visible { outline: 3px solid var(--doc-accent); outline-offset: 1px; }
.co-doc__wordmark {
  font-family: var(--doc-serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--doc-ink);
}
@media (min-width: 1024px) {
  .co-doc__wordmark { font-size: 44px; }
}

/* ---- Head row: parties (From above Bill To) left, meta column right. ---- */
.co-doc__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-bottom: 36px;
}
@media (min-width: 768px) {
  .co-doc__head { flex-direction: row; justify-content: space-between; gap: 56px; }
}
.co-doc__parties {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  flex: 1 1 auto;
}
@media (min-width: 768px) {
  /* Owner: From/Bill To block caps at half the sheet's content width. */
  .co-doc__parties { max-width: 50%; }
}
.co-doc__party-label { margin-bottom: 8px; }
.co-doc__party-name { font-weight: 500; }

.co-doc__meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .co-doc__meta { width: 280px; }
}
.co-doc__meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
/* Mockup's Balance-due highlight box, mirroring the live grand total. */
.co-doc__meta-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--doc-highlight);
}
.co-doc__meta-total-label { color: var(--doc-ink-soft); }
.co-doc__meta-total-amount {
  font-weight: 500;
  font-size: 16px;
  color: var(--doc-accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Project / original scope reference ---- */
.co-doc__reference {
  margin-bottom: 28px;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--doc-divider);
}
.co-doc__reference-label { display: block; margin-bottom: 8px; }
.co-doc__reference-name { font-weight: 500; }
.co-doc__reference-scope { font-size: 0.9rem; color: var(--doc-ink-soft); }

/* ---- Line-item table: small-caps header over a 1px ink rule, #EEEAE2 row
   dividers, tabular right-aligned numbers, medium-weight amounts. ---- */
.co-doc__table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}
.co-doc__th {
  text-align: left;
  padding: 0 var(--space-2) 10px;
  border-bottom: 1px solid var(--doc-ink);
}
.co-doc__th--num { text-align: right; }
.co-doc__th--remove { width: var(--touch-min); }
.co-doc__th--hours, .co-doc__td--hours { width: 8ch; }
.co-doc__th--rate, .co-doc__td--rate { width: 11ch; }
.co-doc__td {
  padding: var(--space-2);
  vertical-align: top;
  border-bottom: 1px solid var(--doc-divider);
}
.co-doc__td--num { text-align: right; }
.co-doc__td--desc .co-doc__input { font-weight: 500; }
.co-doc__td--amount {
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.co-doc__td--remove { text-align: center; vertical-align: middle; }
.co-doc__cell-stack { display: flex; flex-direction: column; align-items: flex-end; }
.co-doc__hours-hint {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--doc-ink-muted);
  font-weight: 500;
}
.co-doc__remove-btn {
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--doc-ink-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.co-doc__remove-btn:hover { background: var(--color-error-bg); color: var(--color-error); }
.co-doc__remove-btn:focus-visible { outline: 3px solid var(--doc-accent); outline-offset: 1px; }
.co-doc__add-row-cell { padding: var(--space-2) 0 0; }
.co-doc__add-row {
  min-height: var(--touch-min);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px dashed var(--doc-divider);
  border-radius: var(--radius-sm);
  color: var(--doc-accent);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}
.co-doc__add-row:hover { background: var(--doc-highlight); border-color: var(--doc-accent); }
.co-doc__add-row:focus-visible { outline: 3px solid var(--doc-accent); outline-offset: 2px; }

/* ---- Mobile: line-item table becomes a stacked card list. ---- */
@media (max-width: 639px) {
  .co-doc__table, .co-doc__table thead, .co-doc__table tbody, .co-doc__table tfoot { display: block; width: 100%; }
  .co-doc__table thead { display: none; }
  .co-doc__row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    grid-template-areas: "desc desc remove" "hours rate rate" "amount amount amount";
    gap: var(--space-2);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--doc-divider);
  }
  .co-doc__td { padding: 0; border-bottom: none; width: auto; }
  .co-doc__td--desc { grid-area: desc; }
  .co-doc__td--remove { grid-area: remove; text-align: right; }
  .co-doc__row .co-doc__td:nth-of-type(2) { grid-area: hours; }
  .co-doc__row .co-doc__td:nth-of-type(3) { grid-area: rate; }
  .co-doc__td--amount { grid-area: amount; text-align: right; border-bottom: none; }
  .co-doc__cell-stack, .co-doc__td--num { align-items: stretch; text-align: left; }
  .co-doc__input--num { text-align: left; }
}

/* ---- Totals: right column, label left / amount right, single line always.
   Total row: 1px ink rule above, Newsreader 22px accent amount. ---- */
.co-doc__totals-wrap { display: flex; justify-content: flex-end; margin-bottom: var(--space-4); }
.co-doc__totals {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  min-width: 0;
}
@media (min-width: 768px) {
  .co-doc__totals { width: 280px; }
}
.co-doc__totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: nowrap;
  min-width: 0;
}
.co-doc__totals-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--doc-ink-soft);
  flex-wrap: nowrap;
  white-space: nowrap;
  min-width: 0;
}
.co-doc__totals-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 6em;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.co-doc__totals-value--static { padding: var(--space-1) var(--space-2); }
.co-doc__totals-row--total {
  align-items: baseline;
  border-top: 1px solid var(--doc-ink);
  padding-top: 12px;
  margin-top: 2px;
}
.co-doc__totals-row--total .co-doc__totals-label { color: var(--doc-ink); font-weight: 500; }
.co-doc__totals-row--total .co-doc__totals-value {
  font-family: var(--doc-serif);
  font-weight: 400;
  font-size: 22px;
  color: var(--doc-accent);
}
.co-doc__input--buffer {
  display: inline-block;
  width: 4.5em;
  min-width: 0;
  min-height: 36px;
}

/* ---- Empty-state tone: computed €0,00 renders muted while its numeric
   source inputs (hours/rate) are empty (all rows', for totals + meta box) —
   an untouched change order reads as a template, not filled data. Toggled
   by change-order-doc.js / change-order-events.js. Muted = AA on sheet.
   The two-class selectors below deliberately out-cascade the accent rules
   for the serif Total and the meta-box amount. ---- */
.co-doc__td--amount-empty,
.co-doc__totals-value--empty,
.co-doc__meta-total-amount--empty,
.co-doc__meta-total .co-doc__meta-total-amount--empty,
.co-doc__totals-row--total .co-doc__totals-value--empty { color: var(--color-ink-muted); }

/* ---- Notes ---- */
.co-doc__notes {
  margin-top: var(--space-4);
  padding: 22px 0 0;
  border-top: 1px solid var(--doc-divider-soft);
}
.co-doc__notes-label { display: block; margin-bottom: 8px; }
.co-doc__notes-text { font-size: 13px; line-height: 1.7; color: var(--doc-ink-soft); }

/* ---- Signatures ---- */
.co-doc__signatures {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin-top: var(--space-6);
}
@media (min-width: 640px) {
  .co-doc__signatures { grid-template-columns: 1fr 1fr; }
}
.co-doc__sig-line {
  border-top: 1px solid var(--doc-ink);
  padding-top: var(--space-2);
  font-size: 0.8rem;
  color: var(--doc-ink-muted);
}

/* ---- Footer strip: name left, italic serif brand line right. ---- */
.co-doc__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-6);
  padding: 14px 0 20px;
  border-top: 1px solid var(--doc-divider);
  font-size: 11px;
  color: var(--doc-footer-ink);
  letter-spacing: 0.03em;
}
.co-doc__footer-brand {
  font-family: var(--doc-serif);
  font-style: italic;
  font-size: 12px;
}

/* ---- Below-sheet toolbar: currency + clear all ---- */
.co-doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}
.co-doc-toolbar__currency {
  margin-bottom: 0;
  max-width: 220px;
  flex: 1 1 200px;
}
