/* DailyCRM — shared styles for the free invoice and estimate generators. Builds on /style.css and /tools/tools.css. */
.inv-section { background: var(--sand); padding: 28px 0 88px; }

.inv-privacy { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; padding: 18px 20px; border-radius: 14px; background: #ecf8f2; border: 1px solid #bfe5d2; color: #14513a; }
.inv-privacy .i { width: 24px; height: 24px; color: #1f9d6b; margin-top: 2px; }
.inv-privacy h2 { font-size: 21px; line-height: 1.3; color: #0f3d2c; }
.inv-privacy p { margin-top: 4px; font-size: 15px; line-height: 1.55; }

.inv-app { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; align-items: start; }
.inv-edit { grid-column: 1; grid-row: 1; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 8px 28px 28px; }
.inv-side { grid-column: 2; grid-row: 1; position: sticky; top: 92px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 108px); }
.inv-toolbar { padding: 12px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); }
.inv-tabs { display: none; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inv-actions .btn { height: 40px; padding: 0 14px; font-size: 14px; }
.inv-actions .btn-primary { flex: 1 1 auto; }
.inv-actions .btn[aria-busy='true'] { opacity: 0.7; cursor: progress; }
.inv-status { font-size: 14px; color: #177a53; margin-top: 8px; }
.inv-status:empty { display: none; }
.inv-status.is-error { color: #c2410c; }

.inv-preview { display: flex; flex-direction: column; min-height: 0; }
.inv-preview-head { display: flex; justify-content: space-between; padding: 0 4px 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.inv-preview-meta { font-weight: 500; letter-spacing: 0; text-transform: none; }
.inv-paper-wrap { container-type: inline-size; overflow: auto; min-height: 0; border-radius: 6px; }
.inv-fine { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* Editor */
.inv-edit .field textarea { width: 100%; min-height: 70px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--paper); font: inherit; font-size: 16px; line-height: 1.45; color: var(--ink); resize: vertical; transition: border-color 0.15s, box-shadow 0.15s; }
.inv-edit .field textarea:hover { border-color: var(--muted); }
.inv-edit .field textarea:focus, .inv-edit .input input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62, 99, 221, 0.18); }
.inv-edit .input input[readonly] { background: var(--sand); color: var(--ink-2); }
.inv-edit [data-when][hidden] { display: none; }
.inv-pair { display: flex; gap: 8px; align-items: stretch; }
.inv-pair select { flex: 0 0 132px; width: 132px; }
.inv-pair .input { flex: 1 1 auto; min-width: 0; }
.inv-pair .input--suf { flex: 0 0 104px; }
.inv-pair .input--suf input { padding-right: 32px; }
.inv-pair .inv-pair-name { flex: 1 1 auto; }
.seg--sm { flex: none; padding: 3px; }
.seg--sm span { min-height: 38px; padding: 0 12px; }
.inv-check-cell { align-content: end; padding-bottom: 12px; }
.field-check small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

.inv-logo { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; padding: 14px; border: 1px dashed var(--line-2); border-radius: 12px; transition: border-color 0.15s, background-color 0.15s; }
.inv-logo.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.inv-logo-box { flex: none; display: flex; align-items: center; justify-content: center; width: 104px; height: 72px; border-radius: 8px; background: var(--sand); overflow: hidden; }
.inv-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.inv-logo-box img[hidden], .inv-logo-box .is-hidden { display: none; }
.inv-logo-box .i { width: 28px; height: 28px; color: var(--muted); }
.inv-logo-body { display: grid; gap: 4px; min-width: 0; }
.inv-logo-body .field-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.inv-logo-body small { font-size: 13px; color: var(--muted); }
.inv-logo-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.inv-logo-btns .btn { height: 38px; padding: 0 14px; font-size: 14px; }
.inv-logo-btns .btn[hidden] { display: none; }
.inv-file { position: relative; cursor: pointer; }
.inv-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.inv-file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.inv-err { font-size: 13px; color: #c2410c; }
.inv-err:empty { display: none; }

.inv-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.inv-presets[hidden] { display: none; }
.inv-presets ul { display: contents; }
.inv-presets-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.inv-chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--paper); font-size: 13px; font-weight: 600; color: var(--ink-2); transition: border-color 0.15s, color 0.15s; }
.inv-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.inv-link { padding: 4px 0; font-size: 13px; font-weight: 600; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.inv-link[hidden] { display: none; }
#presets-show { margin-bottom: 12px; }

.inv-rows { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.inv-row { padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fcfcfa; }
.inv-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.inv-row-num { font-size: 13px; font-weight: 600; color: var(--muted); }
.inv-row-tools { display: flex; gap: 6px; }
.inv-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2); }
.inv-icon-btn:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.inv-icon-btn:disabled { opacity: 0.35; cursor: default; }
.inv-icon-btn--del:hover:not(:disabled) { border-color: #c2410c; color: #c2410c; }
.inv-row .field textarea { min-height: 52px; }
.inv-row-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.inv-row-grid .field { flex: 1 1 84px; min-width: 0; }
.inv-row-grid .field label, .inv-row-grid .field-label, .inv-row .field label { font-size: 13px; }
.inv-row-grid .field select { padding-left: 10px; }
.inv-f-disc { display: none !important; }
.inv-line-disc .inv-f-disc { display: grid !important; }
.inv-f-amt { flex: 1.3 1 110px !important; }
.inv-f-amt output { display: flex; align-items: center; justify-content: flex-end; height: 46px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.inv-row-checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.inv-row-checks:empty { display: none; }
.inv-f-tax { display: none; margin-top: 10px; font-size: 14px; }
.inv-taxed .inv-f-tax { display: flex; }
.inv-f-opt { display: flex; margin-top: 10px; font-size: 14px; }
.inv-row.is-optional { border-style: dashed; background: #fbfaf5; }
.inv-row.is-optional .inv-row-num::after { content: ' · optional add-on'; color: #a16207; }
.inv-sum-note { margin-top: 8px; font-size: 13px; color: var(--muted); }
.inv-sum-note:empty { display: none; }
.inv-convert { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; margin-top: 4px; border-radius: 12px; background: var(--accent-soft); border: 1px solid #c9d5fa; font-size: 14px; color: var(--ink-2); }
.inv-convert .btn { height: 40px; padding: 0 14px; font-size: 14px; background: var(--sun); color: var(--night); border-color: transparent; }
.inv-convert .btn:hover { filter: brightness(0.96); }
.inv-rows-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.inv-rows-foot .btn { height: 40px; font-size: 14px; }

.inv-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.inv-sum div { padding: 10px 12px; border-radius: 10px; background: var(--sand); border: 1px solid var(--line); min-width: 0; }
.inv-sum div.is-main { background: var(--accent-soft); border-color: #c9d5fa; }
.inv-sum dt { font-size: 12px; font-weight: 600; color: var(--muted); }
.inv-sum dd { margin: 2px 0 0; font-family: var(--display); font-size: 19px; line-height: 1.2; color: var(--ink); overflow-wrap: anywhere; }

.inv-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inv-swatches label { position: relative; cursor: pointer; }
.inv-swatches input[type='radio'] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { display: block; width: 32px; height: 32px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); transition: box-shadow 0.15s; }
.inv-swatches input:checked + .sw { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.inv-swatches input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 4px; }
.sw-1 { background: #3e63dd; }
.sw-2 { background: #0f766e; }
.sw-3 { background: #15803d; }
.sw-4 { background: #7c3aed; }
.sw-5 { background: #be123c; }
.sw-6 { background: #c2410c; }
.sw-7 { background: #12141c; }
.inv-color input { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--paper); cursor: pointer; }
.inv-save { display: grid; gap: 14px; justify-items: start; }
.inv-save .btn { height: 40px; font-size: 14px; }
.inv-save .field-check input:disabled + span { opacity: 0.5; }
.inv-example-btn { margin: 16px 0 0; }

.inv-mini { display: none; }

/* Invoice sheet — sized in em, where 1em equals 10pt on the printed page */
.inv-sheet { --inv-accent: #3e63dd; --inv-on-accent: #fff; position: relative; background: #fff; color: #12141c; font-family: Helvetica, Arial, 'Liberation Sans', 'Nimbus Sans', sans-serif; font-size: 10.5px; font-size: calc(100cqw * 10 / 612); line-height: 1.3; padding: 5.4em; aspect-ratio: 612 / 792; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-md); overflow-wrap: anywhere; }
.inv-sheet.inv-paper--a4 { font-size: calc(100cqw * 10 / 595.28); aspect-ratio: 595.28 / 841.89; }
.inv-sheet dl, .inv-sheet dd { margin: 0; }
.inv-pre { white-space: pre-line; }
.inv-ph { color: #b4b7c2; }
.inv-muted { color: #6b7080; }
.inv-band { display: flex; align-items: center; justify-content: space-between; gap: 2em; height: 9.6em; margin: -5.4em -5.4em 3em; padding: 0 5.4em; background: var(--inv-accent); color: var(--inv-on-accent); border-radius: 5px 5px 0 0; }
.inv-band-title { font-size: 2.6em; font-weight: 700; letter-spacing: 0.04em; }
.inv-band-meta { text-align: right; font-size: 1em; }
.inv-band-no { font-size: 1.1em; font-weight: 700; }
.inv-head { display: flex; justify-content: space-between; gap: 2em; }
.inv-from { width: 52%; min-width: 0; }
.inv-logo-img { display: block; max-width: 15em; max-height: 5em; object-fit: contain; object-position: left top; margin-bottom: 1.2em; }
.inv-from-name { font-size: 1.2em; font-weight: 700; line-height: 1.33; margin-bottom: 0.2em; }
.inv-from .inv-muted { font-size: 0.9em; line-height: 1.39; }
.inv-meta { flex: none; width: 21em; }
.inv-title { text-align: right; font-size: 2.6em; font-weight: 700; line-height: 1.23; letter-spacing: 0.02em; color: var(--inv-accent); margin-bottom: 0.3em; }
.inv--minimal .inv-title { font-size: 2em; font-weight: 400; letter-spacing: 0.2em; color: #12141c; margin-bottom: 0.4em; }
.inv-meta-list div { display: flex; justify-content: space-between; gap: 1em; font-size: 0.9em; line-height: 1.67; }
.inv-meta-list dt { color: #6b7080; white-space: nowrap; }
.inv-meta-list dd { text-align: right; min-width: 0; }
.inv-meta-list .is-strong { margin-top: 0.4em; padding-top: 0.3em; border-top: 1px solid #e4e4e0; font-weight: 700; }
.inv-meta-list .is-strong dd { font-size: 1.11em; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2.4em; margin-top: 2em; }
.inv-party > div { font-size: 0.95em; line-height: 1.37; color: #3b3f4c; }
.inv-party > .inv-party-name { font-size: 1em; font-weight: 700; color: #12141c; }
.inv-sheet .inv-label { font-size: 0.75em; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--inv-accent); margin-bottom: 0.5em; }
.inv--minimal .inv-label { color: #6b7080; }
.inv-items { width: 100%; margin-top: 1.6em; border-collapse: collapse; }
.inv-items th { padding: 0.9em 0; font-size: 0.75em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; color: #12141c; border-bottom: 2px solid var(--inv-accent); }
.inv-items td { padding: 0.5em 0; font-size: 0.95em; line-height: 1.37; vertical-align: top; border-bottom: 1px solid #e4e4e0; }
.inv-items .num { text-align: right; white-space: nowrap; padding-left: 1.2em; }
.inv-items .desc { width: 100%; }
.inv-note { font-size: 0.8em; color: #6b7080; }
.inv--modern .inv-items th { background: var(--inv-accent); color: var(--inv-on-accent); border: 0; }
.inv--modern .inv-items th:first-child, .inv--modern .inv-items td:first-child { padding-left: 0.85em; }
.inv--modern .inv-items th:last-child, .inv--modern .inv-items td:last-child { padding-right: 0.85em; }
.inv--minimal .inv-items th { font-weight: 400; color: #6b7080; border-bottom: 1px solid #12141c; }
.inv-totals { display: flex; justify-content: flex-end; margin-top: 1.6em; }
.inv-totals dl { width: 23em; }
.inv-totals dl > div { display: flex; justify-content: space-between; gap: 1em; padding: 0 1em; font-size: 0.95em; line-height: 1.9; }
.inv-totals dt { color: #6b7080; }
.inv-totals dd { text-align: right; white-space: nowrap; }
.inv-totals .is-total { margin-top: 0.4em; padding-top: 0.3em; border-top: 1px solid #e4e4e0; font-weight: 700; }
.inv-totals .is-total dt { color: #12141c; }
.inv-totals .is-balance { align-items: center; margin-top: 0.8em; padding: 0.55em 1em; font-size: 1.05em; font-weight: 700; background: var(--inv-accent); color: var(--inv-on-accent); }
.inv-totals .is-balance dt { color: inherit; }
.inv-totals .is-balance dd { font-size: 1.24em; }
.inv--minimal .inv-totals .is-balance { background: none; color: #12141c; border-top: 1.5px solid #12141c; }
.inv--minimal .inv-totals .is-balance dd { color: var(--inv-accent); font-size: 1.33em; }
.inv-block { margin-top: 1.6em; }
.inv-tail { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 2.4em; margin-top: 1.4em; }
.inv-tail > .inv-totals { grid-column: 2; grid-row: 1; margin-top: 0; }
.inv-tail > .inv-blocks { grid-column: 1; grid-row: 1; padding-top: 0.4em; }
.inv-blocks .inv-block { margin-top: 1.4em; }
.inv-blocks .inv-block:first-child { margin-top: 0; }
.inv-body { font-size: 0.9em; line-height: 1.39; color: #3b3f4c; }
.inv-block--pre { margin-top: 1.6em; }
.inv-block--pre .inv-body { font-size: 0.95em; line-height: 1.37; }
.inv-opt { margin-top: 1.4em; }
.inv-opt .inv-items { margin-top: 0.4em; border-top: 1px solid #e4e4e0; }
.inv-opt-hint { font-weight: 400; letter-spacing: 0; text-transform: none; color: #6b7080; font-size: 1.07em; }
.inv-totals .is-after { padding: 0 1em; }
.inv-totals .is-balance + .is-after { margin-top: 0.5em; }
.inv-totals .is-after--strong { font-weight: 700; }
.inv-totals .is-after--strong dt { color: #12141c; }
.inv-accept { margin-top: 1.6em; break-inside: avoid; }
.inv-signs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.4em; margin-top: 2em; }
.inv-sign { display: grid; gap: 0.3em; font-size: 0.8em; color: #6b7080; }
.inv-sign-line { display: block; border-top: 1px solid #12141c; }

@media (max-width: 1024px) {
  .inv-app { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .inv-side { grid-column: 1; grid-row: 1; position: static; max-height: none; }
  .inv-edit { grid-column: 1; grid-row: 2; }
  .inv-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: 10px; background: var(--sand-2); border: 1px solid var(--line); }
  .inv-tabs [role='tab'] { flex: 1; min-height: 42px; border-radius: 7px; font-size: 15px; font-weight: 600; color: var(--muted); }
  .inv-tabs [role='tab'][aria-selected='true'] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(18, 20, 28, 0.08); }
  .inv-app:not(.is-preview) .inv-preview { display: none; }
  .inv-app.is-preview .inv-edit { display: none; }
  .inv-paper-wrap { overflow: visible; }
  .inv-mini:not([hidden]) { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--night); color: #d9dbe6; font-size: 14px; box-shadow: var(--shadow-lg); }
  .inv-mini b { font-family: var(--display); font-weight: 400; font-size: 20px; color: #fff; margin-right: auto; white-space: nowrap; }
  .inv-mini .btn { height: 38px; padding: 0 14px; font-size: 14px; }
  .btn-sun { background: var(--sun); color: var(--night); }
}
@media (max-width: 640px) {
  .inv-privacy { padding: 14px 16px; }
  .inv-privacy h2 { font-size: 18px; }
  .inv-edit { padding: 4px 16px 20px; }
  .inv-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .inv-actions .btn-primary { grid-column: 1 / -1; height: 46px; font-size: 15px; }
  .inv-actions .btn { padding: 0 8px; font-size: 13px; }
  #act-print { order: 1; }
  #act-new { order: 2; }
  #act-dup { order: 3; grid-column: 1 / -1; }
  .inv-pair select { flex-basis: 112px; width: 112px; }
  .inv-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inv-row { padding: 10px 12px 12px; }
  .inv-row-grid .field { flex-basis: 30%; }
  .inv-f-amt { flex-basis: 100% !important; }
  .inv-f-amt output { justify-content: flex-start; height: auto; font-size: 17px; }
  .inv-logo { flex-direction: column; }
}

/* Print: only the invoice */
@page inv-letter { size: letter; margin: 0.75in; }
@page inv-a4 { size: A4; margin: 0.75in; }
@media print {
  body > :not(main), main > :not(.inv-section), .inv-privacy, .inv-edit, .inv-toolbar, .inv-preview-head, .inv-fine, .inv-mini, .inv-sr, .sr-only { display: none !important; }
  html { page: inv-letter; }
  html.inv-print-a4 { page: inv-a4; }
  html, body, main, .inv-section { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  .inv-section .wrap { max-width: none; padding: 0; }
  .inv-app { display: block; }
  .inv-side { position: static; max-height: none; display: block; }
  .inv-preview { display: block !important; }
  .inv-paper-wrap { overflow: visible; container-type: normal; border-radius: 0; }
  .inv-sheet, .inv-sheet.inv-paper--a4 { font-size: 10pt; padding: 0; aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-band { margin: 0 0 3em; padding: 0 1.6em; border-radius: 0; }
  .inv-ph { display: none; }
  .inv-items thead { display: table-header-group; }
  .inv-items tr, .inv-totals, .inv-block { break-inside: avoid; }
}
