.invoices-page,
.ivm-modal,
.ivm-delete-modal {
  --inv-blue: #2563a8;
  --inv-blue-bg: rgba(37, 99, 168, 0.08);
  --inv-amber: #c49510;
  --inv-amber-bg: rgba(196, 149, 16, 0.08);
  --inv-green: #1e7a45;
  --inv-green-bg: rgba(30, 122, 69, 0.08);
  --inv-red: #b03030;
  --inv-red-bg: rgba(176, 48, 48, 0.08);
  --inv-border: rgba(26, 24, 21, 0.1);
  --inv-surface: #ffffff;
  --inv-surface-soft: #fcfaf4;
  --inv-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.invoices-page.page-section {
  padding-top: 0;
  padding-bottom: 0;
}

.invoices-proto {
  margin-inline: calc(var(--ipi-page-gutter) * -1);
}

.invoices-page .ipi-stats-strip {
  padding-bottom: 18px;
}

.invoices-page .ipi-result-meta {
  margin-top: 2px;
}

.invoices-page .inv-filter-bar {
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto auto;
}

.invoices-page .inv-filter-date {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid var(--ipi-rule-h);
  border-radius: 7px;
  background: var(--ipi-bg);
}

.invoices-page .inv-filter-date span {
  flex-shrink: 0;
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.invoices-page .inv-filter-date input {
  min-width: 0;
  width: 100%;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--ipi-ink);
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 18px;
  outline: none;
}

.invoices-page .inv-filter-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.invoices-page .inv-row-primary,
.invoices-page .inv-row-secondary,
.invoices-page .inv-date-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.invoices-page .inv-number {
  color: var(--ipi-ink);
}

.invoices-page .inv-row-secondary,
.invoices-page .inv-date-cell {
  font-size: 12.5px;
  color: var(--ipi-ink-2);
}

.invoices-page .inv-history-table td:last-child,
.invoices-page .inv-history-table th:last-child {
  text-align: right;
}

.invoices-page .inv-action-btn--primary {
  min-width: 72px;
  justify-content: center;
}

.invoices-page .inv-delete-btn {
  margin-left: 2px;
  color: var(--ipi-ink-4);
}

.invoices-page .inv-delete-btn:hover {
  color: var(--ipi-ink);
}

.invoices-page .inv-empty-state {
  background: var(--ipi-bg-card);
  border-radius: 12px;
  box-shadow: var(--ipi-shadow-card);
}

.invoices-page .inv-empty-state__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 26px 24px;
}

.invoices-page .inv-empty-state__body h3,
.invoices-page .invd-card__header h3 {
  margin: 0;
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 18px;
}

.invoice-detail-page .invd-header {
  align-items: flex-start;
}

.invoice-detail-page .invd-header__form {
  margin: 0;
}

.invoice-detail-page .invd-stat-status {
  font-size: 1.35rem;
}

.invoice-detail-page .invd-overdue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-inline: var(--ipi-page-gutter);
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(176, 48, 48, 0.18);
  border-radius: 12px;
  background: rgba(176, 48, 48, 0.07);
  color: #7f1d1d;
}

.invoice-detail-page .invd-overdue strong {
  margin-right: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.invoice-detail-page .invd-overdue__actions {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.invoice-detail-page .invd-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-inline: var(--ipi-page-gutter);
  margin-bottom: 16px;
}

.invoice-detail-page .invd-card {
  border: 1px solid var(--ipi-rule);
  border-radius: 12px;
  padding: 18px;
  background: var(--ipi-bg-card);
  box-shadow: var(--ipi-shadow-card);
}

.invoice-detail-page .invd-card__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ipi-rule);
}

.invoice-detail-page .invd-card__subcopy {
  margin: 0;
  color: var(--ipi-ink-4);
  font-size: 12px;
  line-height: 1.5;
}

.invoice-detail-page .invd-definition-list {
  display: grid;
  grid-template-columns: minmax(0, 148px) minmax(0, 1fr);
  gap: 0 18px;
  margin: 0;
}

.invoice-detail-page .invd-definition-list dt {
  padding: 14px 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ipi-ink-4);
  border-top: 1px solid var(--ipi-rule);
}

.invoice-detail-page .invd-definition-list dd {
  margin: 0;
  padding: 14px 0;
  color: var(--ipi-ink);
  border-top: 1px solid var(--ipi-rule);
}

.invoice-detail-page .invd-definition-list dt:first-child,
.invoice-detail-page .invd-definition-list dd:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.invoice-detail-page .invd-definition-list__value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  text-align: right;
}

.invoice-detail-page .invd-definition-list__value--stack {
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.invoice-detail-page .invd-primary-value {
  color: var(--ipi-ink);
  font-weight: 600;
}

.invoice-detail-page .invd-secondary-value {
  color: var(--ipi-ink-4);
  font-size: 12px;
}

.invoice-detail-page .invd-definition-list__key--total,
.invoice-detail-page .invd-definition-list__value--total {
  padding-top: 16px;
}

.invoice-detail-page .invd-primary-value--total {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.invoice-detail-page .invd-footnote {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--ipi-rule);
}

.invoice-detail-page .invd-list-area {
  margin-top: 0;
}

.ivm-eyebrow {
  margin: 0;
  color: var(--inv-amber);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ivm-modal .modal__title {
  font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #1a1815;
}

.ivm-subcopy {
  margin: 6px 0 0;
  max-width: 54ch;
  color: #6b6458;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
}

.ivm-modal .ivm-modal__dialog,
.ivm-delete-modal .ivm-delete-modal__dialog {
  width: min(1180px, calc(100vw - 32px));
  max-height: min(90vh, 960px);
  border-radius: 16px;
  border: 1px solid var(--inv-border);
  background: var(--inv-surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Mobile: full-screen dialog (override desktop width constraint).
   !important mirrors canonical so no page CSS can narrow the dialog. */
@media (max-width: 900px) {
  .modal.modal--sheet.ivm-modal .ivm-modal__dialog,
  .modal.modal--sheet.ivm-delete-modal .ivm-delete-modal__dialog {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
}

/* Step 1: single-column workflow picker (align with quote create modal width). */
.ivm-modal:has(.ivm-stage--source:not([hidden])) .ivm-modal__dialog {
  width: min(720px, 100%);
}

.ivm-delete-modal .ivm-delete-modal__dialog {
  width: min(560px, 100%);
}

.ivm-modal .ivm-modal__header,
.ivm-delete-modal .ivm-delete-modal__header {
  position: relative;
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(26, 24, 21, 0.07);
  flex-shrink: 0;
  background: var(--inv-surface);
}

.ivm-modal .ivm-modal__close,
.ivm-delete-modal .ivm-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: #edeae3;
  color: #9a9188;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ivm-modal .ivm-modal__close:hover,
.ivm-delete-modal .ivm-modal__close:hover {
  background: #e5e1d8;
  color: #6b6458;
}

.ivm-modal .ivm-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 18px 24px 0;
}

.ivm-modal .ivm-progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ipi-ink-4);
}

.ivm-modal .ivm-progress-step.is-active {
  color: var(--ipi-ink);
}

.ivm-modal .ivm-progress-step.is-complete {
  color: var(--ipi-ink-2);
}

.ivm-modal .ivm-progress-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(26, 24, 21, 0.12);
  background: #fff;
  color: #6b6458;
  font-size: 12px;
  font-weight: 700;
}

.ivm-modal .ivm-progress-step.is-active .ivm-progress-dot {
  border-color: rgba(196, 149, 16, 0.3);
  background: rgba(196, 149, 16, 0.12);
  color: var(--inv-amber);
}

.ivm-modal .ivm-progress-step.is-complete .ivm-progress-dot {
  border-color: rgba(196, 149, 16, 0.24);
  background: rgba(196, 149, 16, 0.08);
  color: #8a6610;
}

.ivm-modal .ivm-progress-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ivm-modal .ivm-progress-label {
  font-size: 13px;
  font-weight: 700;
}

.ivm-modal .ivm-progress-meta {
  font-size: 11.5px;
  color: var(--ipi-ink-4);
}

.ivm-modal .ivm-progress-divider {
  display: block;
  width: 100%;
  max-width: 52px;
  height: 1px;
  background: rgba(26, 24, 21, 0.08);
}

.ivm-modal .ivm-modal__body,
.ivm-delete-modal .ivm-delete-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 20px 22px 22px;
  background: #f7f5f0;
}

.ivm-modal .ivm-form,
.ivm-delete-modal .ivm-delete-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ivm-modal .ivm-stage-flow {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  min-width: 0;
}

.ivm-modal .ivm-card--workflow-pick .ivm-card__header {
  margin-bottom: 8px;
}

/* Workflow-pick is a flat section card — matches Create Quote
   (.qcm-modal__section) and RAMs (.rams-create-picker__section) which
   both set box-shadow: none. The base .ivm-card rule applies shadow
   on all cards, but the Step-1 picker card should read as a flat
   section, not a floating card. */
.ivm-modal .ivm-card--workflow-pick {
  box-shadow: none;
}

.ivm-modal .ivm-details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 22px;
  align-items: start;
}

.ivm-modal .ivm-details-grid > * {
  min-width: 0;
}

.ivm-modal .ivm-preview,
.ivm-modal .ivm-card,
.ivm-delete-modal .ivm-card {
  border: 1px solid var(--inv-border);
  border-radius: 10px;
  padding: 16px 18px;
  background: var(--inv-surface);
  box-shadow: var(--inv-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Collapsible card (details/summary) ── */
.ivm-modal details.ivm-card--collapsible {
  display: block;
  padding: 0;
}

.ivm-modal summary.ivm-card__toggle {
  cursor: pointer;
  list-style: none;
  padding: 12px 18px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  user-select: none;
  -webkit-user-select: none;
}

.ivm-modal summary.ivm-card__toggle::-webkit-details-marker {
  display: none;
}

.ivm-modal summary.ivm-card__toggle::marker {
  content: '';
}

/* Collapsed: single-line — hide description, compact eyebrow + title */
.ivm-modal .ivm-card__toggle > div {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ivm-modal .ivm-card__toggle > div > p:last-child {
  display: none;
}

.ivm-modal .ivm-card__toggle > div > .ivm-eyebrow {
  margin: 0;
  white-space: nowrap;
}

.ivm-modal .ivm-card__toggle > div > h4 {
  margin: 0;
  white-space: nowrap;
}

/* Separator dot between eyebrow and title when inline */
.ivm-modal .ivm-card__toggle > div > .ivm-eyebrow::after {
  content: '\00b7';
  margin-left: 8px;
  color: var(--ink-4, #9a9188);
}

/* Open: restore stacked layout with description */
.ivm-modal details[open] .ivm-card__toggle {
  padding: 16px 18px 12px;
}

.ivm-modal details[open] .ivm-card__toggle > div {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.ivm-modal details[open] .ivm-card__toggle > div > p:last-child {
  display: block;
}

.ivm-modal details[open] .ivm-card__toggle > div > .ivm-eyebrow::after {
  content: none;
}

/* Toggle icon (+/–) */
.ivm-modal .ivm-toggle-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  position: relative;
}

.ivm-modal .ivm-toggle-icon::before,
.ivm-modal .ivm-toggle-icon::after {
  content: '';
  position: absolute;
  background: var(--ink-3, #6b6458);
  border-radius: 1px;
  top: 50%;
  left: 50%;
}

.ivm-modal .ivm-toggle-icon::before {
  width: 12px;
  height: 2px;
  transform: translate(-50%, -50%);
}

.ivm-modal .ivm-toggle-icon::after {
  width: 2px;
  height: 12px;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.ivm-modal details[open] .ivm-toggle-icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
  opacity: 0;
}

.ivm-modal .ivm-card__collapsible-body {
  padding: 0 18px 18px;
}

.ivm-modal summary.ivm-card__toggle:hover {
  background: rgba(26, 24, 21, 0.02);
}

.ivm-modal details:not([open]) summary.ivm-card__toggle:hover {
  border-radius: 10px;
}

.ivm-modal details[open] summary.ivm-card__toggle:hover {
  border-radius: 10px 10px 0 0;
}

/* Dark mode */
html[data-theme="dark"] .ivm-modal .ivm-toggle-icon::before,
html[data-theme="dark"] .ivm-modal .ivm-toggle-icon::after {
  background: var(--ink-3, #94a3b8);
}

html[data-theme="dark"] .ivm-modal summary.ivm-card__toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ivm-modal .ivm-card__header h4,
.ivm-modal .ivm-preview__header h4,
.ivm-delete-modal .ivm-card h4 {
  margin: 0;
  font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #1a1815;
}

.ivm-modal .ivm-card__header p,
.ivm-modal .ivm-card__header p.text-muted,
.ivm-modal .ivm-card__header p.small-text {
  margin: 0;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  color: #6b6458;
  max-width: 52ch;
}

.ivm-modal .ivm-stage-kicker {
  margin: 0;
  color: #6b6458;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ivm-modal .ivm-source-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ivm-modal .ivm-source-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--inv-border);
  border-radius: 10px;
  background: var(--inv-surface);
  color: #1a1815;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ivm-modal .ivm-source-choice:hover {
  border-color: rgba(196, 149, 16, 0.3);
  box-shadow: 0 6px 18px rgba(26, 24, 21, 0.05);
}

.ivm-modal .ivm-source-choice.is-active {
  border-color: rgba(196, 149, 16, 0.42);
  background: #fbf8ef;
  box-shadow: 0 6px 18px rgba(26, 24, 21, 0.05);
}

.ivm-modal .ivm-source-choice__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(196, 149, 16, 0.1);
  color: var(--inv-amber);
  flex-shrink: 0;
}

.ivm-modal .ivm-source-choice__icon svg {
  width: 18px;
  height: 18px;
}

.ivm-modal .ivm-source-choice__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.ivm-modal .ivm-source-choice__title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.ivm-modal .ivm-source-choice__meta {
  color: #9a9188;
  font-size: 12px;
  line-height: 1.45;
  max-width: none;
}

.ivm-modal .ivm-source-panel__note,
.ivm-modal .ivm-preview__header p {
  color: #6b6458;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.45;
}

.ivm-modal .ivm-source-panel-wrap,
.ivm-modal .ivm-details-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ivm-modal .ivm-source-panel,
.ivm-modal .ivm-card__header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
}

.ivm-modal .ivm-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.ivm-modal .ivm-form-grid label,
.ivm-delete-modal .ivm-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a9188;
}

.ivm-modal .ivm-form-grid label small,
.ivm-modal .ivm-form-grid label .form-hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  font-size: 12px;
  color: #9a9188;
}

/* Override global .text-muted / .small-text inside invoice modal */
.ivm-modal .ivm-card .text-muted.small-text,
.ivm-modal .ivm-card p.text-muted {
  font-size: 12.5px;
  line-height: 1.45;
  color: #6b6458;
}

.ivm-modal .ivm-field-span {
  grid-column: 1 / -1;
}

.ivm-modal .ivm-lines-table,
.invoice-detail-page .invd-line-items-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

.ivm-modal .ivm-lines-table th {
  text-align: left;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: #9a9188;
  padding: 10px 10px;
  border-bottom: 2px solid rgba(26, 24, 21, 0.08);
  background: transparent;
}

.ivm-modal .ivm-lines-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(26, 24, 21, 0.05);
  color: #1a1815;
  font-size: 13px;
}

.ivm-modal .ivm-lines-table tbody tr:last-child td {
  border-bottom: none;
}

.ivm-modal .table-wrapper {
  max-width: 100%;
  overflow-x: auto;
}

.ivm-modal .ivm-inline-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(26, 24, 21, 0.06);
}

.ivm-modal .ivm-extra-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ivm-modal .ivm-preview {
  position: sticky;
  top: 0;
  align-self: start;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 1px solid rgba(26, 24, 21, 0.1);
  border-radius: 10px;
  background: var(--inv-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.ivm-modal .ivm-preview__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  margin-bottom: 0;
  background: #f7f5f0;
  border-bottom: 1px solid var(--inv-border);
}

.ivm-modal .ivm-preview__header h4 {
  font-size: 13px;
  letter-spacing: -0.01em;
}

.ivm-modal .ivm-preview__header .ivm-eyebrow {
  font-size: 9px;
}

.ivm-modal .ivm-preview__totals {
  margin: 0;
  display: grid;
  gap: 0;
  padding: 4px 0;
}

.ivm-modal .ivm-preview__totals > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(26, 24, 21, 0.06);
}

.ivm-modal .ivm-preview__totals dt {
  font-size: 12.5px;
  color: #6b6458;
}

.ivm-modal .ivm-preview__totals dd {
  margin: 0;
  font-weight: 700;
  color: #1a1815;
}

.ivm-modal .ivm-modal__footer,
.ivm-delete-modal .ivm-delete-modal__body .ivm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ivm-modal .ivm-modal__footer {
  flex-shrink: 0;
  padding: 14px 22px 16px;
  background: var(--inv-surface);
  border-top: 1px solid rgba(26, 24, 21, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.ivm-modal .ivm-actions .btn,
.ivm-delete-modal .ivm-actions .btn {
  min-height: 38px;
  min-width: 112px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid rgba(26, 24, 21, 0.14);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ivm-modal .ivm-actions .btn:hover,
.ivm-delete-modal .ivm-actions .btn:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ivm-modal .ivm-actions .btn-primary,
.ivm-delete-modal .ivm-actions .btn-primary {
  background: #1a1815;
  color: #fff;
  border-color: transparent;
  font-weight: 700;
}

.ivm-modal .ivm-actions .btn-primary:hover,
.ivm-delete-modal .ivm-actions .btn-primary:hover {
  background: #3d3a34;
}

.ivm-modal .ivm-actions .btn-ghost,
.ivm-delete-modal .ivm-actions .btn-ghost {
  border-color: transparent;
  box-shadow: none;
  min-width: auto;
}

.ivm-modal .ivm-actions .btn-ghost:hover,
.ivm-delete-modal .ivm-actions .btn-ghost:hover {
  background: rgba(26, 24, 21, 0.06);
  box-shadow: none;
}

/* --- Form control styling (matches quotes pattern) --- */
.ivm-modal :where(input, select, textarea),
.ivm-delete-modal :where(input, select, textarea) {
  width: 100%;
  min-height: 40px;
  padding: 10px 13px;
  border: 1px solid rgba(26, 24, 21, 0.14);
  border-radius: 9px;
  background: var(--inv-surface);
  font-family: var(--font-sans, inherit);
  font-size: 13.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: #1a1815;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ivm-modal :where(input, select, textarea):focus,
.ivm-delete-modal :where(input, select, textarea):focus {
  outline: none;
  border-color: rgba(196, 149, 16, 0.34);
  box-shadow: 0 0 0 3px rgba(196, 149, 16, 0.1);
}

.ivm-modal :where(input, select, textarea)::placeholder,
.ivm-delete-modal :where(input, select, textarea)::placeholder {
  color: #9a9188;
}

.ivm-modal select,
.ivm-delete-modal select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239a9188' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

.ivm-modal textarea,
.ivm-delete-modal textarea {
  min-height: 72px;
  resize: vertical;
}

.ivm-modal input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.ivm-modal .ivm-preview__totals > div:last-child {
  border-bottom: none;
}

.ivm-modal [data-preview-balance-hint] {
  margin: 0;
  padding: 10px 18px 14px;
  font-size: 12px;
}

html[data-theme="dark"] .invoice-detail-page .invd-overdue {
  background: rgba(127, 29, 29, 0.2);
  border-color: rgba(248, 113, 113, 0.35);
  color: rgba(254, 226, 226, 0.94);
}

html[data-theme="dark"] .ivm-modal .ivm-modal__dialog,
html[data-theme="dark"] .ivm-delete-modal .ivm-delete-modal__dialog {
  background: var(--card);
  border-color: var(--border);
  box-shadow: var(--panel-shadow);
}

html[data-theme="dark"] .ivm-modal .ivm-modal__header,
html[data-theme="dark"] .ivm-delete-modal .ivm-delete-modal__header {
  background: var(--card);
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .ivm-modal .ivm-modal__body,
html[data-theme="dark"] .ivm-delete-modal .ivm-delete-modal__body {
  background: rgba(15, 23, 42, 0.65);
}

html[data-theme="dark"] .ivm-modal .ivm-modal__footer {
  background: var(--card);
  border-top-color: var(--border);
  box-shadow: none;
}

html[data-theme="dark"] .invoice-detail-page .invd-card,
html[data-theme="dark"] .ivm-modal .ivm-card,
html[data-theme="dark"] .ivm-delete-modal .ivm-card {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: none;
}

html[data-theme="dark"] .ivm-modal .ivm-preview {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: none;
}

html[data-theme="dark"] .invoice-detail-page .invd-card__header,
html[data-theme="dark"] .invoice-detail-page .invd-footnote,
html[data-theme="dark"] .invoice-detail-page .invd-definition-list dt,
html[data-theme="dark"] .invoice-detail-page .invd-definition-list dd {
  border-color: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .invoice-detail-page .invd-definition-list dd,
html[data-theme="dark"] .ivm-modal .ivm-card__header h4,
html[data-theme="dark"] .ivm-modal .ivm-preview__header h4,
html[data-theme="dark"] .ivm-modal .ivm-form-grid label,
html[data-theme="dark"] .ivm-delete-modal .ivm-card label {
  color: var(--text);
}

html[data-theme="dark"] .ivm-modal .modal__title {
  color: var(--text);
}

html[data-theme="dark"] .ivm-eyebrow {
  color: #e3b008;
}

html[data-theme="dark"] .invoice-detail-page .invd-definition-list dt,
html[data-theme="dark"] .ivm-modal .ivm-stage-kicker,
html[data-theme="dark"] .ivm-modal .ivm-source-choice__meta,
html[data-theme="dark"] .ivm-modal .ivm-source-panel__note,
html[data-theme="dark"] .ivm-modal .ivm-preview__header p,
html[data-theme="dark"] .ivm-modal .ivm-progress-meta,
html[data-theme="dark"] .ivm-modal .ivm-preview__totals dt,
html[data-theme="dark"] .ivm-subcopy {
  color: var(--text-muted);
}

html[data-theme="dark"] .invoice-detail-page .invd-secondary-value {
  color: rgba(148, 163, 184, 0.9);
}

html[data-theme="dark"] .ivm-modal .ivm-source-choice {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: none;
  color: var(--text);
}

html[data-theme="dark"] .ivm-modal .ivm-source-choice:hover {
  border-color: rgba(196, 149, 16, 0.3);
  box-shadow: none;
}

html[data-theme="dark"] .ivm-modal .ivm-source-choice.is-active {
  border-color: rgba(196, 149, 16, 0.42);
  background: rgba(196, 149, 16, 0.08);
}

html[data-theme="dark"] .ivm-modal .ivm-source-choice__icon {
  background: rgba(196, 149, 16, 0.16);
  color: #f4d98b;
}

html[data-theme="dark"] .ivm-modal .ivm-source-choice__meta {
  color: var(--text-muted);
}

html[data-theme="dark"] .ivm-modal .ivm-preview__header {
  background: rgba(15, 23, 42, 0.4);
  border-bottom-color: rgba(71, 85, 105, 0.58);
}

html[data-theme="dark"] .ivm-modal .ivm-preview__totals > div {
  background: transparent;
  border-bottom-color: rgba(71, 85, 105, 0.4);
}

html[data-theme="dark"] .ivm-modal .ivm-preview__totals dd {
  color: var(--text);
}

html[data-theme="dark"] .ivm-modal .ivm-actions .btn-primary,
html[data-theme="dark"] .ivm-delete-modal .ivm-actions .btn-primary {
  background: rgba(226, 232, 240, 0.92);
  color: #0f172a;
}

html[data-theme="dark"] .ivm-modal .ivm-actions .btn-primary:hover,
html[data-theme="dark"] .ivm-delete-modal .ivm-actions .btn-primary:hover {
  background: rgba(226, 232, 240, 0.82);
}

html[data-theme="dark"] .ivm-modal .ivm-actions .btn,
html[data-theme="dark"] .ivm-delete-modal .ivm-actions .btn {
  box-shadow: none;
}

html[data-theme="dark"] .ivm-modal .ivm-lines-table th {
  color: var(--text-muted);
  background: transparent;
  border-bottom-color: rgba(71, 85, 105, 0.58);
}

html[data-theme="dark"] .ivm-modal .ivm-lines-table td {
  color: var(--text);
  border-bottom-color: rgba(71, 85, 105, 0.4);
}

html[data-theme="dark"] .ivm-modal .ivm-card .text-muted.small-text,
html[data-theme="dark"] .ivm-modal .ivm-card p.text-muted {
  color: var(--text-muted);
}

html[data-theme="dark"] .ivm-modal .ivm-card__header p {
  color: var(--text-muted);
}

html[data-theme="dark"] .ivm-modal :where(input, select, textarea),
html[data-theme="dark"] .ivm-delete-modal :where(input, select, textarea) {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.36);
  color: var(--text);
}

html[data-theme="dark"] .ivm-modal :where(input, select, textarea):focus,
html[data-theme="dark"] .ivm-delete-modal :where(input, select, textarea):focus {
  border-color: rgba(196, 149, 16, 0.45);
  box-shadow: 0 0 0 3px rgba(196, 149, 16, 0.12);
}

html[data-theme="dark"] .ivm-modal :where(input, select, textarea)::placeholder,
html[data-theme="dark"] .ivm-delete-modal :where(input, select, textarea)::placeholder {
  color: rgba(148, 163, 184, 0.92);
}

html[data-theme="dark"] .ivm-modal select,
html[data-theme="dark"] .ivm-delete-modal select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
}

/* --- Dark mode: table cards on mobile --- */
@media (max-width: 900px) {
  html[data-theme="dark"] .invoices-page .inv-history-table tr {
    background: var(--card);
    border-color: var(--border);
    box-shadow: none;
  }

  html[data-theme="dark"] .invoices-page .inv-history-table td {
    border-bottom-color: rgba(71, 85, 105, 0.4);
    color: var(--text);
  }

  html[data-theme="dark"] .invoices-page .inv-history-table td::before {
    color: var(--text-muted);
  }
}

@media (max-width: 900px) {
  /* Bottom-sheet container, overlay, dialog sizing, and slide-up animation
     are now handled by the canonical .modal.modal--sheet rule in style.css.
     Delete-modal shares the same .modal.modal--sheet shell. */

  /* --- Grid collapse (from 980px) --- */
  .invoices-page .inv-filter-bar {
    grid-template-columns: 1fr;
  }

  .invoice-detail-page .invd-grid,
  .ivm-modal .ivm-details-grid {
    grid-template-columns: 1fr;
  }

  .ivm-modal .ivm-preview {
    position: static;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 4px;
  }

  /* --- Invoice detail page (from 768px) --- */
  .invoice-detail-page .invd-definition-list {
    grid-template-columns: 1fr;
  }

  .invoice-detail-page .invd-definition-list__value,
  .invoice-detail-page .invd-definition-list__value--stack {
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
  }

  .invoice-detail-page .invd-overdue {
    align-items: flex-start;
    flex-direction: column;
  }

  /* --- Progress indicator: compact horizontal bar on mobile --- */
  .ivm-modal .ivm-progress {
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    padding: 12px 16px 14px;
    border-bottom: 1px solid var(--ipi-rule-h, rgba(0, 0, 0, 0.11));
  }

  .ivm-modal .ivm-progress-dot {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }

  .ivm-modal .ivm-progress-label {
    font-size: 12px;
  }

  .ivm-modal .ivm-progress-meta {
    display: none;
  }

  .ivm-modal .ivm-progress-divider {
    width: 24px;
    height: 1px;
    align-self: center;
  }

  .ivm-modal .ivm-form-grid {
    grid-template-columns: 1fr;
  }

  .modal.modal--sheet.ivm-modal .ivm-modal__body,
  .modal.modal--sheet .ivm-delete-modal__body {
    padding: 14px 16px calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Header + footer padding owned by canonical + gold-spec in style.css.
     justify-content is family-specific so kept. */
  .ivm-modal .ivm-modal__footer {
    justify-content: stretch;
  }

  /* --- Footer buttons: 2-col grid; last-child spans full width when alone on its row --- */
  .ivm-modal .ivm-actions,
  .ivm-delete-modal .ivm-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    flex: 1 1 auto;
  }

  .ivm-modal .ivm-actions > *:last-child:nth-child(odd),
  .ivm-delete-modal .ivm-actions > *:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .ivm-modal .ivm-actions .btn,
  .ivm-delete-modal .ivm-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    min-width: 0;
    font-size: 13px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .ivm-modal .ivm-card {
    border-radius: 8px;
    padding: 12px 14px;
  }

  /* Keep the outer workflow-pick card chrome on mobile so the heading and
     6 source-choice buttons are visually grouped inside a single card. The
     inner source-choice buttons drop their always-on border on mobile so we
     don't get a card-inside-card look — they become flat list items that
     pick up border/background only on :hover and .is-active.
     Padding matches Create Quote canonical (.qcm-modal__section: 12px 14px,
     border-radius 8px) so invoice/quotes/rams Step-1 cards are identical. */
  .ivm-modal .ivm-card--workflow-pick {
    padding: 12px 14px !important;
    border-radius: 8px;
    gap: 8px !important;
  }

  .ivm-modal .ivm-card--workflow-pick .ivm-source-choice {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    padding: 10px 8px;
  }

  .ivm-modal .ivm-card--workflow-pick .ivm-source-choice:hover {
    border-color: rgba(196, 149, 16, 0.2);
    background: rgba(196, 149, 16, 0.04);
    box-shadow: none;
  }

  .ivm-modal .ivm-card--workflow-pick .ivm-source-choice.is-active {
    border-color: rgba(196, 149, 16, 0.42);
    background: #fbf8ef;
    box-shadow: none;
  }

  /* Guaranteed scroll-past padding on the form itself (independent of the
     body's padding-bottom), so the last element never touches the footer.
     Higher specificity + !important so page overrides can't accidentally
     flatten this below a visible margin. */
  .modal.modal--sheet.ivm-modal .ivm-form {
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Extra margin below the preview aside on mobile (it's the last card when
     the details grid collapses to single column) to guarantee it never sits
     flush with the footer. */
  .modal.modal--sheet.ivm-modal .ivm-preview {
    margin-bottom: 24px !important;
  }

  .ivm-modal .ivm-source-choice {
    padding: 10px 12px;
  }

  .ivm-modal .ivm-source-choice__icon {
    width: 32px;
    height: 32px;
  }

  .ivm-modal .ivm-source-choice__icon svg {
    width: 16px;
    height: 16px;
  }

  .ivm-modal .ivm-source-choice__title {
    font-size: 13px;
  }

  .ivm-modal .ivm-source-choice__meta {
    font-size: 11px;
  }

  .ivm-modal .modal__title {
    font-size: 1.1rem;
  }

  .ivm-modal .ivm-preview__header {
    padding: 10px 14px;
  }

  .ivm-modal .ivm-preview__totals > div {
    padding: 8px 14px;
  }

  /* --- Line items table: card-ify rows on mobile --- */
  .ivm-modal .ivm-lines-table,
  .ivm-modal .ivm-lines-table thead,
  .ivm-modal .ivm-lines-table tbody,
  .ivm-modal .ivm-lines-table tr,
  .ivm-modal .ivm-lines-table th,
  .ivm-modal .ivm-lines-table td {
    display: block;
    width: 100%;
  }

  .ivm-modal .ivm-lines-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .ivm-modal .ivm-lines-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .ivm-modal .ivm-lines-table tr {
    border: 1px solid var(--inv-border);
    border-radius: 8px;
    background: var(--inv-surface);
    padding: 4px 0;
  }

  .ivm-modal .ivm-lines-table td {
    position: relative;
    padding: 7px 12px 7px 110px;
    border-bottom: 1px solid var(--inv-border);
    text-align: left !important;
    white-space: normal;
  }

  .ivm-modal .ivm-lines-table td:last-child {
    border-bottom: none;
  }

  .ivm-modal .ivm-lines-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    top: 7px;
    width: 86px;
    color: #9a9188;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* --- Tab overflow fix: horizontal scroll on mobile --- */
  .invoices-page .ipi-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
    scroll-padding-left: 4px;
    scroll-padding-right: 4px;
    width: 100%;
  }

  .invoices-page .ipi-tabs::-webkit-scrollbar {
    display: none;
  }

  .invoices-page .ipi-tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  /* --- Filter drawer: bottom-sheet (matching quotes page) --- */
  body.invoices-mobile-filters-open {
    overflow: hidden;
  }

  body.invoices-mobile-filters-open .invoices-page .ipi-list-area {
    pointer-events: none;
  }

  body.invoices-mobile-filters-open .invoices-page .ipi-filter-shell {
    pointer-events: auto;
  }

  body.invoices-mobile-filters-open .support-fab,
  body.invoices-mobile-filters-open button[data-support-open] {
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }

  .invoices-page .inv-filter-bar {
    grid-template-columns: 1fr;
  }

  .invoices-page .inv-filter-date {
    min-height: 38px;
  }

  /* --- Invoice history table: card-ify rows on mobile --- */
  .invoices-page .inv-history-table,
  .invoices-page .inv-history-table thead,
  .invoices-page .inv-history-table tbody,
  .invoices-page .inv-history-table tr,
  .invoices-page .inv-history-table th,
  .invoices-page .inv-history-table td {
    display: block;
    width: 100%;
  }

  .invoices-page .inv-history-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .invoices-page .inv-history-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .invoices-page .inv-history-table tr {
    border: 1px solid var(--inv-border, rgba(26, 24, 21, 0.1));
    border-radius: 10px;
    background: var(--inv-surface, #ffffff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    padding: 6px 0;
  }

  .invoices-page .inv-history-table td {
    position: relative;
    padding: 7px 14px 7px 110px;
    border-bottom: 1px solid rgba(26, 24, 21, 0.06);
    text-align: left !important;
    white-space: normal;
  }

  .invoices-page .inv-history-table td:last-child {
    border-bottom: none;
  }

  .invoices-page .inv-history-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 14px;
    top: 7px;
    width: 82px;
    color: #9a9188;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* Actions cell: right-align buttons */
  .invoices-page .inv-history-table td.ipi-actions {
    padding-left: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .invoices-page .inv-history-table td.ipi-actions::before {
    display: none;
  }

  .invoices-page .inv-history-table .inv-action-group {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  /* Override ipi-table-wrap min-width for card layout */
  .invoices-page .ipi-table-wrap {
    overflow-x: visible;
  }

  .invoices-page .ipi-table.inv-history-table {
    min-width: 0;
  }
}

.invoice-modal__dialog {
  width: min(980px, 100%);
  max-height: 90vh;
}

.invoice-modal-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: stretch;
}

.invoice-modal__primary {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}

.invoice-modal__primary .invoice-card {
  max-width: 520px;
  width: 100%;
}

.invoice-modal__secondary {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.invoice-modal__secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: flex-start;
}

.invoice-card {
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  padding: 18px 18px 16px;
  background: #f8fafc;
}

.invoice-card legend {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.invoice-modal__actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.invoice-step-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.invoice-step-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(248, 250, 252, 0.95);
  color: #475569;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.invoice-step-pill.is-active {
  background: rgba(0, 82, 204, 0.12);
  border-color: rgba(0, 82, 204, 0.25);
  color: #0052cc;
}

.invoice-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.invoice-source-tile {
  appearance: none;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #0f172a;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.invoice-source-tile:hover {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.invoice-source-tile--active {
  border-color: rgba(0, 82, 204, 0.35);
  background: linear-gradient(135deg, rgba(0, 82, 204, 0.08), rgba(248, 250, 252, 0.95));
  box-shadow: 0 20px 40px rgba(0, 82, 204, 0.12);
}

.invoice-source-tile__icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(0, 82, 204, 0.12);
  color: #0052cc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.invoice-source-tile__icon svg {
  width: 22px;
  height: 22px;
}

.invoice-source-tile__label {
  font-weight: 700;
  line-height: 1.25;
}

.invoice-source-detail {
  margin-top: 12px;
}

.invoice-modal__secondary-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.invoice-preview-card h4 {
  margin: 0 0 8px 0;
}

.invoice-preview-details {
  margin: 0;
}

.invoice-preview-details > summary {
  display: none;
}

.invoice-preview-totals {
  margin: 12px 0 0 0;
  display: grid;
  gap: 10px;
}

.invoice-preview-totals > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(226, 232, 240, 0.85);
}

.invoice-preview-totals dt {
  font-size: 0.82rem;
  color: #64748b;
}

.invoice-preview-totals dd {
  margin: 0;
  font-weight: 800;
  color: #0f172a;
}

html[data-theme="dark"] .invoice-card {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .invoice-card legend {
  color: rgba(226, 232, 240, 0.92);
}

@media (max-width: 1024px) {
  .invoice-page .invoice-filter-actions {
    align-items: stretch;
    width: 100%;
  }

  .invoice-page .invoice-filter-pills {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .invoice-page .invoice-filter-pills::-webkit-scrollbar {
    display: none;
  }

  .invoice-page .invoice-filter-pill {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .invoice-page .invoice-filter-search {
    width: 100%;
    justify-content: flex-start;
  }

  .invoice-page .invoice-filter-search input[type="date"] {
    flex: 1 1 160px;
    min-width: 0;
  }

  .invoice-page .invoice-filter-search input[type="search"] {
    flex: 2 1 260px;
    min-width: 0;
  }

  .invoice-page .invoice-filter-search button {
    flex: 0 0 auto;
  }

  .invoice-page .table-stack-mobile td[data-label="Number"] {
    padding-left: 46px;
  }

  .invoice-page .table-stack-mobile td[data-label="Number"] .table-delete-btn {
    position: absolute;
    top: 10px;
    left: 12px;
  }

  .invoice-modal__secondary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .invoice-preview-card {
    position: static;
    top: auto;
  }
}

@media (max-width: 900px) {
  .modal.modal--sheet .invoice-modal__secondary-grid {
    grid-template-columns: 1fr;
  }

  .modal.modal--sheet :where(.invoice-modal__primary, .invoice-modal__secondary-main) {
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
  }

  .modal.modal--sheet :where(.invoice-modal__primary, .invoice-modal__secondary-main) .invoice-card {
    max-width: none;
  }

  .modal.modal--sheet .modal__footer .invoice-modal__actions {
    width: 100%;
    margin-top: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: center;
  }

  .modal.modal--sheet .modal__footer .invoice-modal__actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .modal.modal--sheet .modal__footer .invoice-modal__actions[data-invoice-footer-step="2"] .btn.btn-primary {
    grid-column: 1 / -1;
    order: 10;
  }

  .invoice-preview-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
    font-weight: 800;
    cursor: pointer;
  }

  .invoice-preview-details > summary::-webkit-details-marker {
    display: none;
  }

  .invoice-preview-details > summary::marker {
    content: '';
  }

  .invoice-preview-details > summary::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid color-mix(in srgb, var(--text) 65%, transparent);
    border-bottom: 2px solid color-mix(in srgb, var(--text) 65%, transparent);
    transform: rotate(45deg);
    transition: transform 0.16s ease;
    flex: 0 0 auto;
  }

  .invoice-preview-details[open] > summary::after {
    transform: rotate(-135deg);
  }

  .invoice-preview-details > .invoice-preview-card {
    margin-top: 10px;
  }

  .invoice-modal__secondary-grid {
    grid-template-columns: 1fr;
  }

  .invoice-modal__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .invoice-modal__actions .btn {
    width: 100%;
  }
}
