/* New/edit invoice composition recovered from the selected Stitch editor.
   All inputs and mutations remain owned by the existing invoice controller. */
.tv-stitch-invoice-editor {
  --invoice-editor-ink: var(--tv-text, #15221f);
  --invoice-editor-muted: var(--tv-text-muted, #5d6b67);
  --invoice-editor-line: var(--tv-border, #d5e0da);
  --invoice-editor-paper: var(--tv-surface, #fff);
  --invoice-editor-canvas: var(--tv-bg, #f4f7f5);
  --invoice-editor-brand: var(--tv-brand, #073b37);
  --invoice-editor-accent: var(--tv-accent, #f45b17);
  display: block;
  min-width: 0;
  color: var(--invoice-editor-ink);
}
.tv-stitch-invoice-editor-frame[data-route-id="invoice-editor"] > .workspace-hero {padding:0 0 18px;border:0;border-bottom:1px solid var(--tv-border,#d5e0da);border-radius:0;background:transparent;box-shadow:none;}
.tv-stitch-invoice-editor-frame[data-route-id="invoice-editor"] > .workspace-hero h2 {font-size:24px;line-height:1.3;letter-spacing:-.025em;}
.tv-stitch-invoice-editor-frame[data-route-id="invoice-editor"] > .workspace-hero p {font-size:14px;line-height:1.5;}

.tv-stitch-invoice-editor .tv-document-strip {
  display: flex;
  flex-wrap:wrap;
  gap: 12px 28px;
  margin-bottom: 16px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--invoice-editor-line);
}
.tv-stitch-invoice-editor .tv-document-strip > div { min-width: 0; display: flex; align-items:baseline;gap: 8px; }
.tv-stitch-invoice-editor .tv-document-strip span {
  color: var(--invoice-editor-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.tv-stitch-invoice-editor .tv-document-strip strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.tv-invoice-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  align-items: start;
  gap: 20px;
  min-width: 0;
}
.tv-invoice-editor-primary { display: grid; align-content: start; gap: 16px; min-width: 0; }
.tv-stitch-invoice-editor .field {display:grid;align-content:start;gap:6px;min-width:0;font-size:13px;line-height:1.45;}
.tv-stitch-invoice-editor .field > :is(input,select,textarea),
.tv-stitch-invoice-editor .combo-field > :is(input,select,textarea) {width:100%;min-width:0;min-height:40px;}
.tv-stitch-invoice-editor .customer-picker,
.tv-stitch-invoice-editor .combo-field {min-width:0;position:relative;}
.tv-stitch-invoice-editor .customer-picker-fieldset {display:grid;align-items:start;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;}
.tv-stitch-invoice-editor .selected-customer {display:grid;gap:3px;margin-top:6px;font-size:12px;line-height:1.4;}
.tv-stitch-invoice-editor .selected-customer > span {color:var(--invoice-editor-muted);}
.tv-stitch-invoice-editor .field-help {display:block;font-size:11px;line-height:1.5;color:var(--invoice-editor-muted);margin-top:5px;}
.tv-stitch-invoice-editor .invoice-meta-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:18px;}
.tv-stitch-invoice-editor .invoice-meta-grid > .field:last-child {grid-column:1/-1;}
.tv-stitch-invoice-editor .tv-primary-grid > .editor-card {padding:0;border:0;background:transparent;box-shadow:none;}
.tv-stitch-invoice-editor .tv-primary-grid h2 {margin:0 0 18px;font-size:19px;line-height:1.3;}
.tv-stitch-invoice-editor .helper-copy {font-size:12px;line-height:1.5;}
.tv-invoice-editor-primary > [data-invoice-step="customer"],
.tv-invoice-editor-primary > [data-invoice-step="items"],
.tv-invoice-editor-primary > .advanced-invoice-fields {
  min-width: 0;
  border: 1px solid var(--invoice-editor-line);
  border-radius: 10px;
  background: var(--invoice-editor-paper);
  box-shadow: none;
}
.tv-invoice-editor-primary > [data-invoice-step="customer"],
.tv-invoice-editor-primary > [data-invoice-step="items"] { padding: 18px; }
.tv-invoice-editor-primary :is(h2, h3) { color: var(--invoice-editor-ink); }
.tv-invoice-editor-primary .helper-copy { color: var(--invoice-editor-muted); }
.tv-invoice-editor-primary .table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--invoice-editor-line);
  border-radius: 8px;
}
.tv-invoice-editor-primary table.edit-lines { min-width: 880px;width:100%;table-layout:fixed;border-collapse:collapse;font-size:13px; }
.tv-invoice-editor-primary table.edit-lines :is(th,td) {vertical-align:top;padding:10px;}
.tv-invoice-editor-primary table.edit-lines th {font-size:11px;letter-spacing:.02em;}
.tv-invoice-editor-primary table.edit-lines :is(th,td):nth-child(1) {width:160px;}
.tv-invoice-editor-primary table.edit-lines :is(th,td):nth-child(3) {width:64px;}
.tv-invoice-editor-primary table.edit-lines :is(th,td):nth-child(4) {width:120px;}
.tv-invoice-editor-primary table.edit-lines :is(th,td):nth-child(5) {width:152px;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums;}
.tv-invoice-editor-primary table.edit-lines :is(th,td):nth-child(6) {width:112px;}
.tv-invoice-editor-primary table.edit-lines :is(input,textarea,select) {width:100%;min-width:0;max-width:100%;font-size:13px;}
.tv-invoice-editor-primary table.edit-lines .line-action-group {display:flex;gap:4px;}
.tv-invoice-editor-primary table.edit-lines .icon-btn {width:28px;min-width:28px;min-height:36px;padding:4px;}
.tv-invoice-editor-primary .invoice-line-extra {margin-top:6px;font-size:11px;}
.tv-invoice-editor-primary .invoice-line-extra > summary {cursor:pointer;color:var(--invoice-editor-muted);}
.tv-invoice-editor-primary .invoice-line-extra-fields {display:grid;gap:10px;margin-top:10px;}
.tv-invoice-editor-primary .invoice-line-extra-fields .field {font-size:11px;}
.tv-invoice-editor-primary .section-head {display:flex;align-items:start;justify-content:space-between;gap:16px;margin-bottom:12px;}
.tv-invoice-editor-primary .section-head h2 {margin:4px 0 8px;font-size:19px;}
.tv-invoice-editor-primary .tv-invoice-step-kicker {font-size:11px;color:var(--invoice-editor-muted);}
.tv-invoice-editor-primary .invoice-line-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tv-invoice-editor-review { position: sticky; top: 16px; display: grid; gap: 16px; min-width: 0; }
.tv-invoice-editor-checks {padding:16px 18px;border:1px solid var(--invoice-editor-line);border-radius:10px;background:var(--invoice-editor-canvas);}
.tv-invoice-editor-checks h2 {margin:0 0 12px;font-size:15px;line-height:1.3;}
.tv-invoice-editor-checks .health-line {display:flex;justify-content:space-between;gap:12px;padding:6px 0;font-size:12px;}
.tv-invoice-editor-checks .health-line > span {color:var(--invoice-editor-muted);}
.tv-invoice-editor-checks p {margin:12px 0 0;font-size:12px;line-height:1.5;}
.tv-invoice-editor-review .invoice-totals-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--invoice-editor-line);
  border-top: 3px solid var(--invoice-editor-brand);
  border-radius: 10px;
  background: var(--invoice-editor-paper);
  box-shadow: 0 8px 24px rgb(21 34 31 / 6%);
}
.tv-invoice-editor-review .invoice-totals-head { display: grid; gap: 12px; }
.tv-invoice-editor-review .invoice-totals-head h2 { margin: 2px 0 4px; font-size: 19px; line-height: 1.25; }
.tv-invoice-editor-review .invoice-totals-head p { margin: 0; font-size: 13px; }
.tv-invoice-editor-review .invoice-review-actions { display: grid; gap: 10px; }
.tv-invoice-editor-review .invoice-review-actions > .btn { width: 100%; }
.tv-invoice-editor-review :is(.invoice-discount-compact,.invoice-internal-totals) {border-top:1px solid var(--invoice-editor-line);padding-top:12px;}
.tv-invoice-editor-review :is(.invoice-discount-compact,.invoice-internal-totals) > summary {cursor:pointer;color:var(--invoice-editor-muted);font-size:12px;font-weight:600;}
.tv-invoice-editor-review .invoice-discount-compact[open] > :not(summary) {margin-top:10px;}
.tv-invoice-editor-review .total-line {display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:7px 0;font-size:13px;}
.tv-invoice-editor-review .total-line > strong {text-align:right;white-space:nowrap;font-size:13px;}
.tv-invoice-editor-review .total-line.major {margin-top:10px;padding-top:14px;border-top:1px solid var(--invoice-editor-line);font-weight:700;}
.tv-invoice-editor-review .total-line.major > strong {font-size:18px;}
.tv-invoice-editor-review .invoice-total-metrics { display: grid; gap: 0; }
.tv-invoice-editor-review .invoice-total-metrics > * { min-width: 0; }
.tv-invoice-editor-review .invoice-total-metrics :is(strong, b) { font-variant-numeric: tabular-nums; }
.tv-invoice-editor-review [data-invoice-total="grand"],
.tv-invoice-editor-review [data-invoice-total="outstanding"] { color: var(--invoice-editor-brand); font-weight: 750; }
.tv-invoice-editor-review .invoice-total-metrics [data-invoice-total="outstanding"] {
  margin-top: 8px;
  padding: 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--invoice-editor-brand) 8%, white);
}
.tv-stitch-invoice-editor .sticky-save {
  display: grid;
  gap: 8px;
  margin:0;
  padding:12px 0 0;
  border-top:1px solid var(--invoice-editor-line);
}
.tv-stitch-invoice-editor .sticky-save .sticky-save-copy {display:grid;gap:6px;font-size:11px;line-height:1.5;color:var(--invoice-editor-muted);}
.tv-stitch-invoice-editor .sticky-save .btn {width:100%;}

@media (max-width: 1080px) {
  .tv-invoice-editor-layout { grid-template-columns: minmax(0, 1fr) 290px; gap: 14px; }
  .tv-invoice-editor-primary > [data-invoice-step="customer"],
  .tv-invoice-editor-primary > [data-invoice-step="items"] { padding: 14px; }
}
@media (max-width: 820px) {
  .tv-invoice-editor-layout { grid-template-columns: minmax(0, 1fr); }
  .tv-invoice-editor-review { position: static; grid-row: 2; }
  .tv-invoice-editor-review .invoice-totals-panel { box-shadow: none; }
}
@media (max-width: 560px) {
  .tv-stitch-invoice-editor .tv-document-strip {gap:8px 16px;}
  .tv-stitch-invoice-editor .customer-picker-fieldset,
  .tv-stitch-invoice-editor .invoice-meta-grid {grid-template-columns:minmax(0,1fr);gap:12px;}
  .tv-invoice-editor-primary > [data-invoice-step="customer"],
  .tv-invoice-editor-primary > [data-invoice-step="items"],
  .tv-invoice-editor-review .invoice-totals-panel { padding: 12px; }
}
@media (max-width: 820px) {
  .tv-invoice-editor-primary table.edit-lines .icon-btn {min-width:36px;min-height:44px;}
  .tv-invoice-editor-primary .section-head {flex-direction:column;}
}
