.returns-page {
  .action-buttons { display: flex; gap: 0.1rem; }
  .amount { font-family: 'Courier New', monospace; font-weight: 600; text-align: end; }
  .mono { font-family: 'Courier New', monospace; font-weight: 600; font-size: 0.8rem; color: var(--color-text-secondary); }
}

// ── ng-deep overrides for header-add-btn (white button in dark header) ──
:host ::ng-deep {
  .header-add-btn {
    border-color: rgba(255,255,255,0.4) !important;
    color: #fff !important;
    font-size: 0.72rem !important;
    padding: 0.2rem 0.5rem !important;
    &:hover {
      background: rgba(255,255,255,0.15) !important;
      border-color: rgba(255,255,255,0.6) !important;
    }
  }
}

.return-form {
  overflow-x: hidden;

  // ── Global compact overrides for PrimeNG inside the form ──
  :host ::ng-deep {
    .p-select .p-select-label { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
    .p-inputtext { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
    .p-inputnumber-input { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
    .p-datepicker .p-inputtext { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
  }

  // ── Primary form strip — the "header band" ──
  .form-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--color-surface-muted);
    border-radius: 8px;
    border: 1px solid var(--color-surface-border);
    border-inline-start: 3px solid var(--color-accent, #f5a623);

    &.secondary {
      background: transparent;
      border: none;
      border-inline-start: none;
      padding: 0.35rem 0.75rem;
      margin-bottom: 0.25rem;
    }
  }

  .form-strip-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    min-width: 120px;
    max-width: 240px;

    &.grow-2 { flex: 2; min-width: 180px; max-width: 360px; }

    label {
      font-weight: 700;
      font-size: 0.65rem;
      color: var(--color-text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.03em;
      white-space: nowrap;
    }

    input, textarea { width: 100%; }
  }

  // ── Keep backward compat for old .form-grid (used by notes area) ──
  .form-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem;
    .form-field {
      display: flex; flex-direction: column; gap: 0.2rem;
      max-width: 240px;
      label {
        font-weight: 700;
        font-size: 0.65rem;
        color: var(--color-text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.03em;
      }
      input, textarea { width: 100%; }
      &.span-2 { grid-column: span 2; max-width: 360px; }
      &.span-4 { grid-column: span 4; max-width: none; }
    }
  }

  .standalone-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    .standalone-hint {
      font-size: 0.75rem;
      color: var(--color-text-muted);
      font-style: italic;
    }
  }

  .field-settings-panel {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--color-surface-hover);
    border: 1px dashed var(--color-surface-border);
    border-radius: 8px;

    .field-settings-grid {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      flex: 1;
    }

    .field-toggle-item {
      display: flex;
      align-items: center;
      gap: 0.35rem;
      font-size: 0.8rem;
      white-space: nowrap;
    }
  }

  // ── Line Items Section ──
  .lines-section {
    margin-top: 0.25rem;
    border: 1px solid var(--color-surface-border);
    border-radius: 8px;
    overflow: hidden;

    .lines-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.4rem 0.6rem;
      background: var(--module-color, var(--color-brand));

      h3 {
        margin: 0;
        font-size: 0.8rem;
        font-weight: 700;
        color: #ffffff;
        letter-spacing: 0.02em;
      }
    }

    .loading-spinner { text-align: center; padding: 1rem; color: var(--color-text-muted); }
    .fully-returned-banner {
      display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-radius: 0;
      background: rgba(234, 179, 8, 0.12); color: #b45309; font-size: 0.875rem; font-weight: 600;
      i { font-size: 1.1rem; }
    }

    .lines-table {
      width: 100%; border-collapse: collapse; font-size: 0.75rem; table-layout: fixed;

      thead th {
        background: var(--color-surface-hover);
        padding: 0.4rem 0.3rem;
        text-align: start;
        font-weight: 700;
        font-size: 0.68rem;
        color: var(--color-text-secondary);
        border-bottom: 2px solid var(--color-surface-border);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        white-space: nowrap;
      }

      tbody td {
        padding: 0.2rem 0.2rem;
        border-bottom: 1px solid var(--color-surface-hover);
        vertical-align: middle;
        overflow: hidden;
        input { width: 100%; }
      }

      tbody tr:hover td {
        background: rgba(245, 166, 35, 0.04);
      }

      :host ::ng-deep {
        .p-select { font-size: 0.75rem; }
        .p-select .p-select-label { padding: 0.25rem 0.35rem; font-size: 0.75rem; }
        .p-inputnumber-input { padding: 0.25rem 0.3rem; font-size: 0.75rem; }
      }

      .col-num { width: 12%; }
      .amount { font-family: 'Courier New', monospace; font-weight: 600; text-align: end; }
      .line-total { color: var(--module-color, var(--color-brand)); font-weight: 700; padding-inline-end: 0.75rem; }

      .row-fully-returned {
        opacity: 0.55;
        td { background: var(--color-surface-hover); }
      }
      .returned-tag { margin-inline-start: 0.5rem; vertical-align: middle; }
      .returned-zero { display: block; text-align: center; color: var(--color-text-muted); }
    }

    tfoot {
      .grand-total-row td {
        border-top: 2px solid var(--module-color, var(--color-brand));
        background: var(--color-surface-muted);
        padding: 0.5rem;
      }
    }

    .no-items {
      text-align: center;
      padding: 1.5rem;
      color: var(--color-text-muted);
      font-size: 0.875rem;
    }
  }
}

.dialog-custom-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--color-surface-border); }

.view-return {
  .view-header-info {
    display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--color-surface-border);
    .info-item { display: flex; flex-direction: column; gap: 0.25rem;
      label { font-size: 0.75rem; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; }
      span { font-size: 0.8125rem; }
      .mono { font-family: 'Courier New', monospace; font-weight: 600; }
    }
  }
  .view-description { margin-bottom: 1rem;
    label { font-size: 0.75rem; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; display: block; margin-bottom: 0.25rem; }
    p { margin: 0 0 0.5rem; color: var(--color-text-primary); }
  }
  .je-section {
    display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem;
    .je-loading { text-align: center; padding: 1rem; color: var(--text-color-secondary); }
    .je-block {
      background: var(--surface-ground); border-radius: 8px; padding: 0.75rem;
      .je-block-header {
        display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
        i { color: var(--primary-color); font-size: 1.1rem; }
        .je-block-title { font-weight: 600; font-size: 0.85rem; }
        .je-number { font-family: monospace; font-weight: 700; font-size: 0.85rem; }
      }
      .je-lines-table {
        width: 100%; border-collapse: collapse; font-size: 0.85rem;
        th, td { padding: 0.35rem 0.5rem; text-align: start; }
        th { background: var(--surface-hover); font-weight: 600; }
        td { border-bottom: 1px solid var(--surface-border); }
        .text-end { text-align: end; }
      }
    }
  }
  .view-lines-table {
    width: 100%; border-collapse: collapse; font-size: 0.8125rem;
    thead th { background: var(--color-surface-muted); padding: 0.5rem; text-align: start; font-weight: 600; font-size: 0.8rem; color: var(--color-text-secondary); border-bottom: 1px solid var(--color-surface-border); }
    tbody td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--color-surface-hover); }
    tfoot td { padding: 0.4rem 0.5rem; }
    .grand-total-row td { border-top: 2px solid var(--module-color, var(--color-brand)); background: var(--color-surface-muted); padding: 0.5rem; }
    .amount { text-align: end; font-family: 'Courier New', monospace; }
  }
}
