/* Invoice workspaces use the same reading geometry and action language as project sheets.
   This stylesheet is deliberately scoped: it does not restyle the invoice register or documents. */

body:is([data-page="invoice-new"],[data-page="invoice"]) :is(.page-header,#app) {
  padding-inline: var(--work-inset-inline);
  container: invoice-frame / inline-size;
}

body:is([data-page="invoice-new"],[data-page="invoice"]) .page-header {
  padding-block: var(--work-inset-top) 0;
  border: 0;
}

body:is([data-page="invoice-new"],[data-page="invoice"]) #app {
  display: flex;
  max-width: none;
  padding-block: 24px calc(var(--work-inset-bottom) + var(--work-action-lift));
}

body[data-page="invoice"] .page-header:empty { display: none; }
body[data-page="invoice"]:has(.invoice-workspace--issued) #app { padding-block-start: var(--work-inset-top); }
.invoice-project-action.home-action-pair { justify-content: flex-start; }
[data-issued-project-form] fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
[data-issued-project-form] fieldset[hidden] { display: none; }

.invoice-workspace {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1120px;
  margin-inline: 0;
  min-width: 0;
  font: 400 var(--text-body, 14px)/1.5 var(--ui-font);
}

@container invoice-frame (width > 880px) {
  body:is([data-page="invoice-new"],[data-page="invoice"]) .page-header > div:first-child,
  .invoice-workspace {
    margin-inline-start: var(--work-content-offset);
  }
  .invoice-workspace {
    width: min(1120px, calc(100% - var(--work-content-offset)));
  }
}

.invoice-workspace :is(h2, summary) {
  font: 550 var(--work-section-size, 18px)/1.35 var(--ui-font);
  letter-spacing: -.018em;
}

.invoice-workspace .sheet-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--title-rule, #8d8b86);
}

.invoice-workspace .sheet-title h1 {
  margin: 0;
}

/* The editor is a work surface, not a collection of boxed forms. */
.invoice-editor > .note {
  margin: 0 0 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 400 var(--text-body, 14px)/1.5 var(--ui-font);
}

.invoice-editor > .stack {
  gap: 0;
}

.invoice-editor .grid {
  gap: var(--work-column-gap);
}

.invoice-editor .panel {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.invoice-editor > .stack > :not(:first-child),
.invoice-editor > .stack > .grid + .panel,
.invoice-editor > .stack > .panel + .grid {
  border-top: 1px solid var(--line);
}

.invoice-editor .panel-header {
  min-height: 0;
  padding: 26px 0 16px;
  border: 0;
}

.invoice-editor .panel-body {
  padding: 0 0 28px;
}

.invoice-editor .panel-header h2 {
  font: 550 var(--work-section-size, 18px)/1.35 var(--ui-font);
}

.invoice-editor .field-grid {
  gap: 18px 28px;
}

.invoice-editor .field,
.invoice-editor .entity-field {
  gap: 7px;
  color: var(--muted);
  font: 400 var(--text-body, 14px)/1.4 var(--ui-font);
}

.invoice-editor .field :is(input, select, textarea),
.invoice-editor .entity-field select {
  min-height: 40px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 var(--text-body, 14px)/1.4 var(--ui-font);
}

.invoice-editor .field textarea {min-height: 88px;}
.invoice-editor .field :is(input, select, textarea):focus,
.invoice-editor .entity-field select:focus {border-bottom-color: var(--ink);outline: 0;}
.invoice-editor .field input[readonly] {background: transparent;}

.invoice-editor .source,
.invoice-editor .small,
.invoice-editor .definition,
.invoice-editor .sums,
.invoice-editor .invoice-summary,
.invoice-editor .invoice-lines :is(input, select) {
  font-size: var(--text-body, 14px);
}

.invoice-editor .source {
  margin-top: 16px;
  color: var(--muted);
}

.invoice-editor .definition {gap: 10px 24px;}
.invoice-editor .sums {margin-top: 20px;}

.invoice-editor .invoice-lines :is(input, select) {
  min-height: 38px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.invoice-editor .invoice-lines th,
.invoice-editor .invoice-lines td {font-size: var(--text-body, 14px);}
.invoice-editor .invoice-lines th {background: transparent;}

.invoice-editor .actions,
.invoice-workspace .workspace-actions {
  gap: var(--work-action-gap, 12px);
}

.invoice-editor .actions > :is(button, a.button),
.invoice-workspace--issued .issued-document-actions > :is(button, a.button) {
  min-height: 42px;
  padding: 9px 13px;
  border-radius: 0;
  font-size: var(--text-body, 14px);
}

.invoice-summary {
  align-items: center;
  min-height: var(--work-action-size, 112px);
}

.invoice-editor .invoice-summary {
  justify-content: flex-end;
}

.invoice-editor .invoice-summary > span {
  margin-inline-end: auto;
}

.invoice-primary-action {
  flex: 0 0 var(--work-action-size, 112px);
  width: var(--work-action-size, 112px);
  min-height: var(--work-action-size, 112px);
  padding: 14px;
  border: 0;
  border-radius: 50%;
  background: #171514;
  color: #fff;
  font: 400 var(--work-action-size-text, 14px)/1.25 var(--ui-font);
  text-align: center;
}

.invoice-primary-action:hover {background: #30302d;}

/* An issued invoice is a compact reference sheet, not a customer-profile variation. */
.invoice-workspace--issued .sheet-content {
  width: min(100%, 960px);
  max-height: none;
  overflow: visible;
}

.invoice-workspace--issued .sheet-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--work-column-gap);
  align-items: start;
  --sheet-rule: transparent;
  --sheet-section-gap: 0;
}

.invoice-workspace--issued .sheet-columns > div {gap: 0;}
.invoice-workspace--issued .sheet-columns > div > * + *::before {content: none;}

.invoice-workspace--issued .sheet-section {
  padding: 22px 0 26px;
  border-top: 1px solid var(--line);
}

.invoice-workspace--issued .sheet-columns > div > :first-child {padding-top: 0;border-top: 0;}

.invoice-workspace--issued .sheet-section :is(h2, summary) {
  margin-bottom: 14px;
  font-size: var(--work-section-size, 18px);
}

.invoice-workspace--issued .sheet-facts,
.invoice-workspace--issued .sheet-totals {gap: 9px;}

.invoice-workspace--issued .issued-document-actions {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.invoice-workspace--issued .issued-document-actions .text-link {
  padding: 0;
  color: var(--ink);
  text-align: start;
}

.invoice-original-page {
  display: block;
  width: min(100%, 58vh);
  margin: 0 auto;
}

.invoice-original-page img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
}

.invoice-review-hours-option,
.invoice-review-hours-note,
.invoice-review-manifest,
.invoice-issued-handoff {
  font:400 var(--text-body)/1.45 var(--work-body-font);
}

.invoice-review-hours-option {display:flex;align-items:baseline;gap:var(--work-action-gap);}
.invoice-review-hours-option input {flex:none;margin:0;accent-color:var(--ink);}
.invoice-review-hours-note,.invoice-issued-handoff > p {
  margin:var(--work-action-gap) 0 0;color:var(--muted);
}

.invoice-review-manifest,.invoice-issued-handoff .issued-document-actions {margin-block-start:var(--work-heading-gap);}
.invoice-issued-handoff .issued-document-actions {justify-items:stretch;gap:0;}
.invoice-review-manifest ul {
  margin:var(--work-action-gap) 0 0;padding:0;list-style:none;
}
.invoice-review-manifest li,.invoice-issued-handoff .issued-document-actions > a {
  display:block;padding-block:var(--work-action-gap);border-block-end:1px solid var(--line);
}
.invoice-issued-handoff .text-link,.invoice-review-manifest .text-link {color:var(--ink);font:inherit;}
.invoice-workspace--issued [data-issued-package] {font-weight:600;}

@media (max-width: 1050px) {
  .invoice-editor .grid,
  .invoice-workspace--issued .sheet-columns {grid-template-columns: minmax(0, 1fr);}
}

@media (max-width: 760px) {
  .invoice-editor .field-grid {grid-template-columns: minmax(0, 1fr);}
  .invoice-editor .field.wide {grid-column: auto;}
  .invoice-summary {align-items: flex-end;flex-direction: column;}
  .invoice-editor .invoice-summary > span {margin-inline-end: 0;align-self: flex-start;}
}

/* The project selection reads like the hours sheet. The right column follows the current selection. */
.invoice-workspace.billing-selection {
  display:flex;flex-direction:column;
  max-width:none;width:auto;min-width:0;
}
.billing-context {
  display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 20px;
  padding-bottom:18px;border-bottom:1px solid var(--work-title-rule);
}
.billing-context strong,.billing-selection h2 {
  font:550 var(--work-section-size,18px)/1.35 var(--ui-font);
  letter-spacing:-.018em;margin:0;
}
.billing-context span,.billing-muted,.billing-check dt,.billing-dates label,.billing-manual-line label {color:var(--muted);}
.billing-selection :is(.billing-context span, p, .billing-work-section summary > span, .billing-entry > :not(input), .billing-check dd, .billing-check li) {
  font:400 var(--text-body)/1.45 var(--work-body-font);
}
.billing-layout {display:grid;grid-template-columns:minmax(0,2fr) minmax(210px,1fr);gap:var(--work-column-gap);align-items:start;padding-top:26px;}
.billing-layout > *,.billing-manual-line > * {min-width:0;}
.billing-selection h2 {margin-bottom:18px;}
.billing-dates {display:flex;flex-wrap:wrap;gap:18px;margin-bottom:18px;}
.billing-selection :is(.billing-dates label,.billing-manual-line label,.billing-rate-input) {display:grid;gap:4px;min-width:0;}
.billing-selection input:not([type="checkbox"]) {
  display:block;width:100%;max-width:100%;min-width:0;min-height:34px;padding:4px 0;
  border:0;border-bottom:1px solid var(--line);border-radius:0;
  color:var(--ink);background:transparent;font:400 var(--text-body)/1.45 var(--work-body-font);
}
.billing-selection input:not([type="checkbox"]):focus {outline:none;border-bottom-color:var(--ink);}
.billing-work-section > .field,
.billing-selection .billing-dates label {
  font:400 var(--text-body)/1.45 var(--work-body-font);
}
.billing-work-section > .field {margin-block-end:var(--work-heading-gap);}
.billing-dates label {flex:0 1 9.2em;}
.billing-work-section details {border-bottom:1px solid var(--line);}
.billing-group-head {
  display:grid;grid-template-columns:minmax(0,1fr) minmax(8ch,auto) minmax(10ch,auto) 16px;
  align-items:baseline;gap:14px;padding:8px 0;color:var(--muted);border-bottom:1px solid var(--line);
}
.billing-group-head > :not(:first-child) {text-align:end;}
.billing-work-section summary {
  display:grid;grid-template-columns:minmax(0,1fr) minmax(8ch,auto) minmax(10ch,auto) 16px;
  align-items:baseline;gap:14px;cursor:pointer;padding:15px 0;
  font:400 var(--text-body,14px)/1.4 var(--ui-font);letter-spacing:normal;list-style:none;
}
.billing-work-section summary::-webkit-details-marker {display:none;}
.billing-work-section summary > :first-child {font-weight:550;overflow-wrap:anywhere;}
.billing-work-section summary > :nth-child(2),.billing-work-section summary > :nth-child(3) {text-align:end;font-variant-numeric:tabular-nums;white-space:nowrap;}
.billing-work-section summary > :nth-child(2) {color:var(--muted);}
.billing-work-section summary .ui-icon {color:var(--icon-muted);width:16px;height:16px;align-self:center;}
.billing-work-section details[open] > summary .ui-icon {transform:rotate(180deg);}
.billing-entries {padding:0 0 10px;}
.billing-entry {
  display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:start;
  padding:10px 0;
}
.billing-entry > input {margin:4px 0;width:16px;height:16px;accent-color:var(--ink);}
.billing-entry > label:not(.billing-rate-input) {cursor:pointer;overflow-wrap:anywhere;}
.billing-entry label strong {display:block;font-weight:500;}
.billing-entry label span,.billing-entry > span,.billing-rate-input {color:var(--muted);}
.billing-rate-input {max-width:10em;}
.billing-check dl {display:grid;gap:8px;margin:0;}
.billing-check dl > div {display:flex;align-items:baseline;justify-content:space-between;gap:12px;}
.billing-check .billing-breakdown {margin-top:16px;}
.billing-check dd {margin:0;text-align:end;font-variant-numeric:tabular-nums;}
.billing-net {margin-top:22px;padding-top:18px;border-top:1px solid var(--line);}
.billing-net strong {display:block;font:550 var(--work-title-size,32px)/1.25 var(--ui-font);letter-spacing:-.035em;overflow-wrap:anywhere;}
.billing-muted {margin:14px 0;text-wrap:pretty;}
.billing-selection [hidden] {display:none;}
.billing-manual {padding-top:18px;}
.billing-selection :is(.billing-add,.billing-icon) {display:inline-flex;align-items:center;gap:8px;border:0;border-radius:0;background:transparent;color:var(--ink);padding:6px 0;font:inherit;}
.billing-selection :is(.billing-add,.billing-icon) .ui-icon {width:17px;height:17px;}
.billing-selection .billing-add {font-family:var(--work-body-font);}
.billing-add:hover {text-decoration:underline;text-underline-offset:3px;}
.billing-manual-line {display:grid;grid-template-columns:minmax(12ch,2fr) minmax(5ch,.6fr) minmax(7ch,.8fr) minmax(11ch,1fr) 24px;gap:12px;align-items:end;padding:14px 0;}
.billing-selection .billing-icon {align-self:end;justify-content:center;min-height:34px;}
.billing-actions.home-action-row {align-self:stretch;justify-content:flex-end;margin-top:auto;padding:30px 0 0;gap:0;}
.billing-actions.home-action-row .home-tile {--tile-size:var(--work-action-size);font-size:var(--text-body);}
@container invoice-frame (width <= 680px) {
  .billing-layout {grid-template-columns:minmax(0,1fr);gap:26px;}
  .billing-check {padding-top:20px;border-top:1px solid var(--line);}
  .billing-net {display:flex;align-items:baseline;justify-content:space-between;}
  .billing-work-section summary,.billing-group-head {gap:6px;grid-template-columns:minmax(0,1fr) minmax(6ch,auto) minmax(8ch,auto) 14px;}
  .billing-manual-line {grid-template-columns:repeat(3,minmax(0,1fr)) 24px;gap:8px;}
  .billing-manual-line > label:first-child {grid-column:1 / -1;}
  .billing-entry {grid-template-columns:18px minmax(0,1fr);}
  .billing-entry > :last-child {grid-column:2;}
}
