/* The composer pane. Application chrome, so it follows the viewer's theme — unlike the document
 * below it, which is paper and stays on white. */

.cmp {
  width: 100%; max-width: 820px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(20, 32, 43, .04);
  overflow: hidden;
}

/* ---- toolbar --------------------------------------------------------------------------------- */
.cmp-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--sunk);
  border-bottom: 1px solid var(--rule);
}
.cmp-bar__title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cmp-bar__title strong { font-size: 14px; }
.cmp-bar__plan { font-size: 12px; color: var(--muted); }
.cmp-bar__spacer { flex: 1 1 auto; }

.cmp-btn {
  font: inherit; font-size: 13px; font-weight: 550;
  padding: 5px 11px; min-height: 29px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  transition: border-color var(--speed), background var(--speed), color var(--speed), transform var(--speed);
}
.cmp-btn:active:not(:disabled) { transform: translateY(1px); }
.cmp-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.cmp-btn:disabled { opacity: .45; cursor: not-allowed; }
.cmp-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cmp-btn--primary:hover:not(:disabled) { color: var(--accent-ink); filter: brightness(1.08); }
.cmp-btn--ghost { border-color: transparent; background: transparent; padding: 3px 6px; color: var(--muted); }
.cmp-btn--ghost:hover:not(:disabled) { background: var(--sunk); }
.cmp-btn__icon { font-size: 13px; line-height: 1; }
.cmp-btn:focus-visible, .cmp-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- sections -------------------------------------------------------------------------------- */
.cmp-section { padding: 14px; border-bottom: 1px solid var(--rule); }
.cmp-section:last-child { border-bottom: 0; }
.cmp-section__title {
  margin: 0 0 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
.cmp-section__body.is-grid {
  display: grid; gap: 10px 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.cmp-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cmp-field__label { font-size: 12px; font-weight: 550; color: var(--ink-2); }
.cmp-field__hint { font-size: 11.5px; color: var(--muted); }

.cmp-input {
  font: inherit; font-size: 13.5px;
  padding: 6px 9px; width: 100%; min-width: 0;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  transition: border-color var(--speed), box-shadow var(--speed);
}
.cmp-input:hover:not(:focus) { border-color: var(--muted); }
.cmp-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.cmp-input--num { text-align: right; font-variant-numeric: tabular-nums; }
.cmp-input--area { resize: vertical; font-family: inherit; }
.cmp-input--code { font-family: var(--font-mono); font-size: 12.5px; }
.cmp-input--picker { font-size: 12px; padding: 4px 6px; color: var(--muted); }

/* ---- the line grid ---------------------------------------------------------------------------- */
.cmp-grid { display: flex; flex-direction: column; gap: 6px; }
.cmp-grid__head, .cmp-grid__row {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: minmax(0, 1fr) 78px 100px 96px 88px;
}
.cmp-grid__head.has-hsn, .cmp-grid__row.has-hsn {
  grid-template-columns: minmax(0, 1fr) 92px 78px 100px 96px 88px;
}
.cmp-grid__head {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding-bottom: 2px;
}
.cmp-grid__head .is-num { text-align: right; }
.cmp-grid__desc { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cmp-grid__amount {
  text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px;
  color: var(--ink-2); padding-right: 2px;
}
.cmp-grid__gutter { display: flex; gap: 1px; justify-content: flex-end; }
.cmp-grid__foot { padding-top: 4px; }

/* ---- money + totals ---------------------------------------------------------------------------- */
.cmp-moneyrow {
  display: grid; gap: 0;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  border-bottom: 1px solid var(--rule);
}
.cmp-moneyrow .cmp-section { border-bottom: 0; }
.cmp-totals {
  display: flex; flex-direction: column; gap: 5px;
  padding: 14px; border-left: 1px solid var(--rule); background: var(--sunk);
}
.cmp-totals__row { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; color: var(--muted); }
.cmp-totals__row .is-num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.cmp-totals__row.is-grand {
  border-top: 1px solid var(--rule-2); margin-top: 3px; padding-top: 7px;
  font-size: 14.5px; font-weight: 650; color: var(--ink);
}
.cmp-totals__row.is-grand .is-num { color: var(--ink); }
.cmp-totals__note { font-size: 11.5px; color: var(--warn); line-height: 1.35; }

/* ---- notices ----------------------------------------------------------------------------------- */
.cmp-notice {
  margin: 0; padding: 10px 14px;
  background: var(--warn-soft); color: var(--ink);
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.cmp-notice p { margin: 3px 0 0; color: var(--ink-2); }
/* An issued document: the notice carries the actions, and the form beneath it is greyed rather
 * than hidden — a person can still read what they are not editing. */
.cmp-notice--lock { background: var(--accent-soft); }
/* Two lines billing the same thing, and the one press that folds them together. */
.cmp-dupes {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 8px 11px;
  background: var(--warn-soft); color: var(--ink); border-radius: var(--radius); font-size: 12.5px;
}
.cmp-notice__row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.cmp-form.is-locked { opacity: .62; }
.cmp-form.is-locked .cmp-totals { opacity: 1; }

/* ---- a client or a catalogue item ------------------------------------------------------------ */
.rec-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 320px); gap: 0; align-items: start; }
.rec-fields { min-width: 0; }
.rec-fields .cmp-section { border-bottom: 1px solid var(--rule); }
.rec-fields .cmp-section:last-child { border-bottom: 0; }
/* Wider columns than the composer's: an address line or a product name needs room to be read
 * back, and three cramped columns of half-width boxes is what made this look unfinished. */
.cmp-section--rec .cmp-section__body.is-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.cmp-field--wide { grid-column: 1 / -1; }
.cmp-suggest { display: block; }
.rec-missing { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-missing .cmp-input { flex: 1 1 120px; }
.rec-check { width: 18px; height: 18px; accent-color: var(--accent); }
.rec-side {
  position: sticky; top: 0;
  padding: 14px 16px; border-left: 1px solid var(--rule); background: var(--paper);
  display: flex; flex-direction: column; gap: 10px;
}
.rec-preview {
  background: var(--doc-paper); color: var(--doc-ink); font-family: var(--font-doc);
  border: 1px solid var(--rule); border-radius: 6px; padding: 14px 16px; min-height: 96px;
}
.rec-preview .inv-party__label { color: var(--doc-muted); }
.rec-preview__note { margin-top: 8px; font-family: var(--font); font-size: 12px; color: var(--doc-muted); }
.rec-preview__product { display: flex; align-items: center; gap: 12px; }
.rec-preview__meta { min-width: 0; }
.rec-preview__meta .inv-party__name { overflow-wrap: anywhere; }
.rec-preview__img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; border: 1px solid var(--doc-rule); background: #fff; flex: none; }
.rec-preview__img.is-empty { display: flex; align-items: center; justify-content: center; font-family: var(--font); font-size: 10px; color: var(--doc-muted); background: #f4f6f8; }
.rec-preview__price { font-size: 17px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.rec-actions { display: flex; gap: 8px; justify-content: flex-end; }
.rec-drop {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px dashed var(--rule-2); border-radius: 6px; background: var(--surface);
}
.rec-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.rec-drop__hint { font-size: 12.5px; color: var(--muted); }
.rec-thumb { width: 44px; height: 44px; border-radius: 5px; object-fit: cover; border: 1px solid var(--rule); }
.rec--compact { margin: 0 14px 14px; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.cmp-inline:empty { display: none; }
@media (max-width: 900px) {
  .rec-body { grid-template-columns: 1fr; }
  .rec-side { position: static; border-left: 0; border-top: 1px solid var(--rule); }
}

.cmp-skipped {
  padding: 9px 14px; font-size: 12.5px;
  background: var(--warn-soft); border-bottom: 1px solid var(--rule);
}
.cmp-skipped summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.cmp-skipped ul { margin: 7px 0 0; padding-left: 18px; }
.cmp-skipped li { margin: 2px 0; color: var(--ink-2); }
.cmp-skipped strong { font-family: var(--font-mono); font-size: 12px; color: var(--ink); }
.cmp-skipped p { margin: 6px 0 0; color: var(--muted); }

@media (max-width: 720px) {
  .cmp-grid__head { display: none; }
  .cmp-grid__row, .cmp-grid__row.has-hsn { grid-template-columns: 1fr 1fr; gap: 6px; }
  .cmp-grid__row > *:first-child { grid-column: 1 / -1; }
  .cmp-grid__gutter { grid-column: 1 / -1; justify-content: flex-start; }
  .cmp-moneyrow { grid-template-columns: 1fr; }
  .cmp-totals { border-left: 0; border-top: 1px solid var(--rule); }
}

@media (prefers-reduced-motion: reduce) {
  .cmp-btn, .cmp-input { transition: none; }
  .cmp-btn:active:not(:disabled) { transform: none; }
}

.cmp-repeat { display: inline-flex; align-items: center; gap: 6px; }
.cmp-repeat .cmp-input--select { width: auto; padding-top: 6px; padding-bottom: 6px; }

@media print { .cmp { display: none !important; } }
